8 Commits

Author SHA1 Message Date
Javi Martín
a1439d0790 Apply Layout/LineLength rubocop rule
Note we're excluding a few files:

* Configuration files that weren't generated by us
* Migration files that weren't generated by us
* The Gemfile, since it includes an important comment that must be on
  the same line as the gem declaration
* The Budget::Stats class, since the heading statistics are a mess and
  having shorter lines would require a lot of refactoring
2023-08-30 14:46:35 +02:00
Javi Martín
76555495f6 Hide legislation proposals when blocking a user
We're also updating the notice messages to specify all contents have
been hidden (not just debates).
2021-12-30 15:50:03 +01:00
Javi Martín
021fef07b6 Make action names to block and hide more clear
The `hide` action was calling the `block` method while the `soft_block`
action was calling the `hide` method.

Combined with the fact that we also have a `block` permission which is
used in `ModerateActions` the logic was hard to follow.
2021-12-30 15:50:03 +01:00
Carlos Iniesta
49edd6a9b1 Add soft block button in moderation user view 2021-12-30 15:50:03 +01:00
Javi Martín
4c8dfb6695 Use just one action to hide users
Other than removing a redundant action, we're fixing two bugs when
blocking an author using the links in the public views:

* We were always redirecting to the debates index, even if we blocked
  the author of a proposal or an investment
* We weren't showing any kind of success message
2021-12-30 15:50:02 +01:00
Javi Martín
02981324ab Move exception tests to controller specs
System tests are used to test the application from the user's point of
view. To test for specific exceptions, particularly regarding
authorization permissions, controller tests fit better.

Another option would be to test the page displayed shows a certain text,
like "Internal server error". I'm choosing controller tests because
they're faster and we're basically testing the same scenario many times
and we've already got a test checking what happens when users access a
page raising an exception.
2021-03-31 14:42:20 +02:00
Javi Martín
155da08cf0 Use a generic name for the search parameter
This way we can use it for any model.
2020-12-04 19:57:05 +01:00
Javi Martín
50bdfd5488 Avoid redirects with unprotected query params
In theory it's possible to add a `host` parameter to a URL, and we could
end up redirecting to that host if we just redirect using query
parameters.

Generating the path using `url_for` with `only_path` solves the issue.

Note in the tests I'm using the `get` method because the `patch` method
wouldn't send query parameters. This doesn't mean the action can be
accessed through GET requests, since controller tests don't check route
verbs. Using feature specs doesn't seem to work because `controller` and
`host` parameters are filtered automatically in feature specs.

Also note I'm not testing every hidden/moderation controller because
they basically use the same code.
2019-11-12 19:27:58 +01:00