Commit Graph

18014 Commits

Author SHA1 Message Date
Javi Martín
be059f1437 Remove obsolete resource loading in direct uploads
The `create` action is the only one in this controller since commit
930bb753c.
2021-10-19 02:33:32 +02:00
Javi Martín
f4b338b65f Merge pull request #4712 from consul/within_components
Use page.find instead of within in component tests
2021-10-18 16:28:37 +02:00
Javi Martín
174f765074 Make component tests fail when using within
This way we avoid writing useless tests which always pass.
2021-10-18 13:51:32 +02:00
Javi Martín
7154228fbb Move budget map icon tests back to system specs
These tests don't work without JavaScript. They were passing because the
`within` method always passes in component tests.

This reverts most of commit 822140a14.
2021-10-18 13:51:32 +02:00
Javi Martín
d7f26f012d Fix test checking link in budget header
The test was passing because we were using `within`, but actually the
`have_css` method doesn't support the `href:` argument.
2021-10-18 13:51:32 +02:00
Javi Martín
57fcdc402d Use page.find instead of within in component tests
In component tests, the `within` method is actually an alias to RSpec's
`be_within` matcher, which is used to test numeric ranges. That meant
the tests always passed, even when there were bugs on the page.

In order to use `within` in component tests, we have to use
`page.within`. However, that also fails, since there's no such method
for `Capybara::Node::Simple'` objects, which are used in component
tests.

So we're using `page.find` instead.

See also pull request 945 in https://github.com/github/view_component
2021-10-18 13:51:32 +02:00
Javi Martín
973e9acf11 Merge pull request #4642 from consul/poll_questions
Order polls by user geozone and questions by creation
2021-10-18 13:50:49 +02:00
decabeza
9709b267a2 Always show order poll questions by created at
PostgreSQL doesn't guarantee the order of the records, so we have to
specify it if we want the questions to be displayed in a consistent
order.
2021-10-18 13:31:34 +02:00
decabeza
25aa77c4c3 Show polls with the user's geozone first 2021-10-18 13:07:16 +02:00
Javi Martín
1664ebe8eb Refactor code comparing polls 2021-10-18 12:18:55 +02:00
Javi Martín
0d6b0afc2d Merge pull request #4707 from consul/information_texts_performance
Improve performance when editing custom texts
2021-10-18 11:58:53 +02:00
Javi Martín
0c24dd4450 Merge pull request #4710 from consul/dependabot/bundler/puma-4.3.9
Bump puma from 4.3.8 to 4.3.10
2021-10-14 17:09:52 +02:00
dependabot[bot]
d141880a6a Bump puma from 4.3.8 to 4.3.10
Bumps [puma](https://github.com/puma/puma) from 4.3.8 to 4.3.10.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v4.3.8...v4.3.10)

---
updated-dependencies:
- dependency-name: puma
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-14 16:02:29 +02:00
Senén Rodero Rodríguez
9dae396323 Fix some source strings typos
A translator warned some typos through Crowdin. Thanks `chkoun`.
2021-10-14 13:20:41 +02:00
Javi Martín
7243ace903 Improve performance when editing custom texts
We were executing SQL queries searching for translations even for
records which were not persisted in the database and therefore had no
translations.

So we're now only looking for translations when the record is persisted.

Note that, when the record isn't persisted, we're using `I18n.translate`
instead of the `t` method. That's because the `t` method would also
perform database queries since we overwrite the `t` method in the
`i18n_translation` initializer.

On tabs with many records, like the proposals tab, requests are now up
to three times faster on production environments.

Tests related to this part of the application were failing sometimes
because requests took longer than `Capybara.default_max_wait_time`.
After these changes, the custom information texts pages load about 30%
faster when running the tests.
2021-10-11 20:03:07 +02:00
Javi Martín
c7230e668f Refactor method to get custom texts translations
It was a bit confusing to return `false` in the method and then handle
this case in the view.
2021-10-11 20:03:07 +02:00
Javi Martín
b35c8bda4b Move form field partial to a component
This way it's easier to test; changing it will also be easier.

During my experiments I made a mistake which wasn't covered by the test
suite. We're adding a test for this case.

Note we're using `i18n_content` in the component instead of `content`
because there's already a `content` method provided by ViewComponent.
2021-10-11 20:03:07 +02:00
Sebastia
ced55a58f8 Merge pull request #4708 from consul/confirmation-instructions
Fix sending OAuth confirmation instructions
2021-10-11 13:57:07 +02:00
Javi Martín
1a54659dd7 Merge pull request #4693 from consul/delayed_errbit
Include DelayedJob errors in Errbit exceptions
2021-10-11 13:33:29 +02:00
taitus
0493893ab8 Fix send confirmation instructions on do_finish_signup action
When we try to register with omniauth and the email or username already exists,
we use the finish_signup and do_finish_signup actions to allow the user to choose
another email or username.

The do_finish_signup action of the registration controller calls the
send_oauth_confirmation_instructions method which is responsible for sending the
confirmation email.

In this method we were only validating the case that the email is duplicated. Now
we add one more condition that allows us to send the instructions for the case in
which we have had to change our username.
2021-10-11 12:28:51 +02:00
taitus
ba4595f6ce Use the label text in the specs
Using the label text in the specs is superior to using the name because it tests the label is correctly associated to its form control.
2021-10-11 12:27:18 +02:00
Javi Martín
9f21c27bf1 Include DelayedJob errors in Errbit exceptions
The integration between Airbrake/Errbit and DelayedJob wasn't working
because we require our dependencies in alphabetic order, and so by the
time `airbrake` was required, `delayed_job` wasn't loaded.

So we're manually requiring the integration.
2021-10-08 23:09:27 +02:00
Javi Martín
16fdb94255 Merge pull request #4649 from consul/dependabot/bundler/master/omniauth-google-oauth2-and-omniauth-rails_csrf_protection-and-omniauth-1.0.0
Bump omniauth-google-oauth2, omniauth-rails_csrf_protection and omniauth
2021-10-08 16:44:23 +02:00
dependabot[bot]
376fa684d9 Bump omniauth-google-oauth2, omniauth-rails_csrf_protection and omniauth
Bumps [omniauth-google-oauth2](https://github.com/zquestz/omniauth-google-oauth2), [omniauth-rails_csrf_protection](https://github.com/cookpad/omniauth-rails_csrf_protection) and [omniauth](https://github.com/omniauth/omniauth). These dependencies needed to be updated together.

Updates `omniauth-google-oauth2` from 0.8.2 to 1.0.0
- [Release notes](https://github.com/zquestz/omniauth-google-oauth2/releases)
- [Changelog](https://github.com/zquestz/omniauth-google-oauth2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zquestz/omniauth-google-oauth2/compare/v0.8.2...v1.0.0)

Updates `omniauth-rails_csrf_protection` from 0.1.2 to 1.0.0
- [Release notes](https://github.com/cookpad/omniauth-rails_csrf_protection/releases)
- [Commits](https://github.com/cookpad/omniauth-rails_csrf_protection/compare/v0.1.2...v1.0.0)

Updates `omniauth` from 1.9.1 to 2.0.4
- [Release notes](https://github.com/omniauth/omniauth/releases)
- [Commits](https://github.com/omniauth/omniauth/compare/v1.9.1...v2.0.4)

---
updated-dependencies:
- dependency-name: omniauth-google-oauth2
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: omniauth-rails_csrf_protection
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: omniauth
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-08 01:10:47 +02:00
Javi Martín
a0c7856d33 Merge pull request #4657 from consul/dependabot/bundler/master/airbrake-11.0.3
Bump airbrake from 7.4.0 to 11.0.3
2021-10-08 01:10:04 +02:00
dependabot[bot]
838e5a50be Bump airbrake from 7.4.0 to 11.0.3
Note we're using `config.performance_stats = false` because enabling it
was causing a huge performance hit; pages were about 2-4 times slower
and some tests failed since requests took longer than Capybara's default
max wait time. Errbit also recommends disabling this option since
Errbit doesn't handle performance stats.

Bumps [airbrake](https://github.com/airbrake/airbrake) from 7.4.0 to 11.0.3.
- [Release notes](https://github.com/airbrake/airbrake/releases)
- [Changelog](https://github.com/airbrake/airbrake/blob/master/CHANGELOG.md)
- [Commits](https://github.com/airbrake/airbrake/compare/v7.4.0...v11.0.3)

---
updated-dependencies:
- dependency-name: airbrake
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-07 04:12:23 +02:00
Javi Martín
4e3f24faf4 Merge pull request #4694 from consul/question_image
Show answers with attachments in additional info
2021-10-06 17:16:45 +02:00
Javi Martín
6d26ce57cb Show answers with attachments in additional info
We weren't showing the details of answers without a description, even if
they had images, videos or documents. Some users found that behavior
unexpected since the description isn't a mandatory field and so they
left it blank, but they added images to that answer and they didn't
appear on the poll page.

Note we had a condition not to show the title of an answer when it had
no description. I think that condition was redundant because answers
without a description weren't loaded in the first place. Anyway, that
condition doesn't make sense anymore because we're displaying answers
with images but no description.
2021-10-06 16:52:23 +02:00
Javi Martín
25465e71ea Merge pull request #4692 from consul/globalize_length
Simplify displaying debate length validation error
2021-10-06 16:49:09 +02:00
Javi Martín
b1c07862b4 Merge pull request #4689 from consul/ie_heading_mode
Fix budget mode selection in Internet Explorer 11
2021-10-06 15:59:16 +02:00
Javi Martín
24d1bd33fb Merge pull request #4671 from consul/gitkeep
Fix .keep file in custom stylesheets.
2021-10-06 15:38:58 +02:00
Javi Martín
4631633adf Simplify displaying debate length validation error
Adding the error to the translation means Rails will automatically show
the error message in the view.

We're also adding a test to make sure the error message is correctly
displayed.

We now have duplication in the validation rules, however. Validating
translatable attributes is still a bit of mess.
2021-10-06 14:46:30 +02:00
Javi Martín
0652d3f52d Fix budget mode selection in Internet Explorer 11
As mentioned in commit b7f6c4c43:

> [In Internet Explorer] the `flex: 1` property doesn't work so well
> when `flex-direction` is set to `column`. We're replacing it with
> `flex-grow: 1`. No need to set other `flex-basis` nor `flex-shrink`
> since in this case the default values will work just fine.
2021-10-06 14:46:08 +02:00
Javi Martín
081b524e03 Fix .keep file in custom stylesheets.
It was accidentally named `.gitkeep` in commit b549eb444. We use `.keep`
everywhere else.
2021-10-06 14:45:51 +02:00
Javi Martín
e11dcf3868 Merge pull request #4670 from consul/remove_simulation_task
Remove unused dashboard tasks
2021-10-06 14:39:56 +02:00
Javi Martín
480bb8cd55 Remove link column in dashboard actions
This column wasn't used in any released Consul version since it was only
used during development. For the same reason, the task to migrate the
information in the `link` column to the `links` table isn't needed
either.
2021-10-06 14:13:44 +02:00
Javi Martín
af8b01c7dc Remove unused dashboard task
It was never used and its data is based on Madrid's requirements for
successful proposals. It was written during the development of the
dashboard, probably for testing purposes.
2021-10-06 14:12:06 +02:00
Javi Martín
67a4ecfdac Merge pull request #4678 from consul/remove_1.3_tasks
Remove tasks to upgrade to version 1.3.0
2021-10-06 14:11:31 +02:00
Javi Martín
a187641f79 Merge pull request #4677 from consul/officing_js_specs
Make officing specs detect bugs in the menu links
2021-10-06 14:08:33 +02:00
Javi Martín
b97da02f98 Remove code to rename already renamed setting
It was already renamed in version 1.1.0.
2021-10-06 13:51:56 +02:00
Javi Martín
1b2256e084 Remove tasks to upgrade to version 1.3.0
These tasks are not needed for new installations, and in existing
installations they've already been executed when upgrading to version
1.3.0.
2021-10-06 13:51:56 +02:00
Javi Martín
d041d06809 Make officing specs detect bugs in the menu links
In commit baaec3a29 we started using the JavaScript driver in tests
dealing with the user menu, and made all tests pass.

However, we didn't update some officing tests that were also passing
when there was a bug in the code. That's because now that these tests
use a JavaScript driver, the link to "Polling officers" is never present
before pressing the "Menu" item. So tests checking the link isn't
present when loading the page always pass.
2021-10-06 13:48:03 +02:00
Javi Martín
0cdddc3647 Merge pull request #4691 from consul/private_following
Hide what users are following unless they allow it
2021-10-05 15:02:56 +02:00
Javi Martín
5c1a7044cd Hide comments when features are disabled
We were already doing so for debates and investments.

We probably never noticed because this is an edge case that requires
enabling a feature, people adding comments, and then disabling the
feature.
2021-10-05 14:43:47 +02:00
Javi Martín
af53b2159c Refactor code getting a user's comments
This way it's more readable and easier to change.
2021-10-05 14:43:47 +02:00
Javi Martín
3cd4f3827e Hide what users are following unless they allow it
It could be argued that seeing which proposals a user follows is a good
indicator of which proposals a user has supported, since we're
automatically creating follows for supported proposals since commit
74fbde09f. So now, we're extending the `public_interests` funcionality,
so it only shows elements users are following if they've enabled it.

This is an improvement over using the `public_activity` attribute in two
ways:

* The `public_interests` attribute is disabled by default, so by default
  other users won't be able to see what a user is following
* Who has created proposals/debates/investments/comments is public
  information, while who is following which elements is not; so enabling
  `public_activity` shouldn't imply potentially private information should
  be displayed as well

We've considered removing the `public_interests` attribute completely
and just hiding the "following" page for everyone except its owner, but
keeping it provides more compatibility with existing installations.
2021-10-05 14:43:09 +02:00
Javi Martín
0875c214ba Make following tab tests easier to understand
The `click_link` part did nothing other than scrolling to the element,
since in these cases we've got a same-page link and the element it links
to is already on the page. Programmers reading the test would expect the
link to load the page or change to a different tab and would think the
element it links to wasn't there before clicking the link (at least I
did).
2021-10-05 14:40:47 +02:00
Javi Martín
9bc529dce1 Group almost identical public interests tests 2021-10-05 14:40:47 +02:00
Javi Martín
64258baf97 Refactor getting the public activity information
We had similar conditions many times and some duplication, particularly
between the code getting records and the code counting records. We can
remove it by returning a generic scope and calling the `count` method to
count the records and the `order` and `page` methods when we want to
pass the records to the view. And, since we only display one partial per
request, we can simplify the code to render all the partials. There's
one minor disadvantage to this approach: searching the code for the
place where these partials are rendered is now a bit harder since
searching the code for something like "render (.+) budget_investments"
won't return any results.

We're also writing conditions about a certain filter just once, by
setting `valid_filters`. This greatly simplifies the logic, although
again there's one minor disadvantage: we have to implement the
`current_filter` method, duplicating the logic already defined in the
`HasFilters` concern.
2021-10-05 14:40:36 +02:00
Javi Martín
62b23f1e56 Extract component to show a user's public activity 2021-10-05 13:26:30 +02:00