Commit Graph

14377 Commits

Author SHA1 Message Date
cyrillefr
44b2a07878 Moderate legislation proposals (#3602)
Moderate legislation proposals

- added a controller for moderation/legislation
- updated view to appropriate link + added route
- added a spec
- Feature test
- test for faded
- javascripts for visual effects
2019-10-05 04:02:39 +02:00
Javi Martín
27522f60e7 Remove unneeded GET method
Links already use GET by default, so there's no need to specify it.
Furthermore, using `method: :get` makes a link incompatible with
turbolinks.
2019-10-05 03:38:44 +02:00
Javi Martín
ad14636255 Use Tag instead of ActsAsTaggableOn::Tag
It's shorter, it's easier to extend its behaviour, and it's easier to
integrate with other parts of our application, like translations.
2019-10-05 03:38:44 +02:00
Javi Martín
f444533956 Remove legacy reference to flash[:html_safe]
This code doesn't work since commit a5338a44.
2019-10-05 03:38:44 +02:00
Javi Martín
c6c3ff5423 Remove leftover sandbox code
The rest of the sandbox code was removed in commit d679c1eb.
2019-10-05 03:38:44 +02:00
Javi Martín
21fcdba8c8 Remove obsolete method
This method wasn't used since commit 24dde9c3.
2019-10-05 03:38:44 +02:00
Javier Martín
d193fd9740 Merge pull request #3666 from consul/dependabot/bundler/foundation_rails_helper-3.0.0
Bump foundation_rails_helper from 2.0.0 to 3.0.0
2019-10-05 03:02:51 +02:00
Javi Martín
e524374293 Use new foundation helper classes in tests 2019-10-03 17:30:12 +02:00
dependabot-preview[bot]
26201d4fc2 Bump foundation_rails_helper from 2.0.0 to 3.0.0
Bumps [foundation_rails_helper](https://github.com/sgruhier/foundation_rails_helper) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/sgruhier/foundation_rails_helper/releases)
- [Changelog](https://github.com/sgruhier/foundation_rails_helper/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sgruhier/foundation_rails_helper/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-03 03:22:21 +00:00
Javi Martín
74500db173 Update indentation consistency rubocop rule
The indentation mode has been renamed.
2019-10-01 18:01:08 +02:00
dependabot-preview[bot]
d827946a10 Bump rubocop from 0.60.0 to 0.75.0
Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.60.0 to 0.75.0.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.60.0...v0.75.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 14:32:18 +00:00
Javier Martín
460d3271b3 Merge pull request #3737 from consul/dependabot/bundler/rubyzip-1.3.0
[Security] Bump rubyzip from 1.2.2 to 1.3.0
2019-10-01 16:30:16 +02:00
dependabot-preview[bot]
235ee0fb83 [Security] Bump rubyzip from 1.2.2 to 1.3.0
Bumps [rubyzip](https://github.com/rubyzip/rubyzip) from 1.2.2 to 1.3.0. **This update includes a security fix.**
- [Release notes](https://github.com/rubyzip/rubyzip/releases)
- [Changelog](https://github.com/rubyzip/rubyzip/blob/master/Changelog.md)
- [Commits](https://github.com/rubyzip/rubyzip/compare/v1.2.2...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 13:06:28 +00:00
Javier Martín
fd4e007ada Merge pull request #3597 from consul/original_heading_id
Add original heading id to investments
2019-10-01 14:52:17 +02:00
taitus
11d8bd6a3d Stub the response to an external request 2019-10-01 13:20:09 +02:00
Javier Martín
3bb7c9bc90 Merge pull request #3736 from consul/rspec_instance_variables
Remove instance variables in RSpec
2019-09-30 17:26:49 +02:00
Javier Martín
c6b9bcc80d Merge pull request #3734 from consul/remove_unused_variables
Fix remaining unused variables warnings
2019-09-30 16:43:45 +02:00
Javi Martín
4de4045fcc Allow instance variables in has filter/order specs
These files create a fake class using an instance variable. While the
proper thing to do would be to refactor the `HasOrders` and `HasFilters`
concerns so they didn't use instance variables but methods, I don't
think that's going to happen in the near future.
2019-09-30 16:43:10 +02:00
Javi Martín
2ce3cfab5e Remove @process instance variable
Note we cannot name this variable `process` because in a controller spec
the word `process` is a method, like `get` or `post`.
2019-09-30 16:43:10 +02:00
Javi Martín
a8903d80ce Remove instance variables in draft version spec
This one is a bit different than our usual scenario, since we create
three annotations and we only use two of them in the specs (because we
visit the path to that annotation). So there are probably better options
than the combination of `let!` and `before` I've chosen.
2019-09-30 16:43:10 +02:00
Javi Martín
5c81a70fa7 Use factory bot blocks to create complex data
Having two questions, each of them with two comments, made the code hard
to follow.

Grouping the comments inside the block creating the questions makes it
easier to know which comment belongs to which question, even if the code
is still not 100% readable.

We also remove instance variables, which by the way used the same
variable name for two different things.
2019-09-30 16:43:10 +02:00
Javi Martín
86366da28c Declare local variables outside a block
We couldn't declare them inside the block because they would be
considered local variables and its value would be lost when the block
was finished. So we were using instance variables instead.

However, with instance variables we don't get any warnings when we
misspell their names. We can avoid them by declaring the local variables
before the block starts.
2019-09-30 16:43:10 +02:00
Javi Martín
91c21b0982 Remove instance variables in RSpec
Instance variables might lead to hard-to-detect issues, since using a
nonexistent instance variable will return `nil` instead of raising an
error.
2019-09-30 16:43:10 +02:00
Javi Martín
f70e10fe9f Remove unused instance variables
These variables were declared but never used.
2019-09-30 16:37:34 +02:00
Javier Martín
a43a313da0 Merge pull request #3728 from consul/use_let
Use `let` to remove duplication in specs
2019-09-30 16:18:22 +02:00
Javier Martín
a1670e2a8d Merge pull request #3727 from consul/simplify_valuator_factories
Simplify valuator factories
2019-09-30 15:57:34 +02:00
Javi Martín
7783547419 Remove rest of unused variables
I haven't found an elegant way to remove them, but since they were the
only three variables left out of 383 we used to have, I can live with
this low percentage of inelegant solutions.
2019-09-30 15:47:13 +02:00
Javi Martín
f5fe8c1279 Use factory bot blocks to create complex data
We had four headings, some of them had investments, and some of them
didn't, and it was very hard to scan the code and check which investment
belongs to which heading.

Grouping the investments inside the block creating the heading makes
that task much easier, even if the code is still not 100% readable.

We also avoid unused variables which were there to keep the code
vertically algined.
2019-09-30 15:47:13 +02:00
Javi Martín
4c5104d03d Avoid unused variables in notification spec
We can change the code a bit so the useless assignment is either part of
the setup (where only another variable was present) or isolated in the
"action" part of the test.
2019-09-30 15:47:13 +02:00
Javi Martín
d0d1c9972c Remove unused variables following their parent
There's a very common pattern in our test, where the setup only has two
lines:

variable = create(:something)
unused_variable = create(:something_else, something: variable)

In this case, since there's a blank line below these ones and then we'll
get to the body of the test, and the second variable is going to be
created based on the first variable, we can remove the useless
assignment and the readability is still OK.

Another option we almost unanimously discarded was:

variable = create(:something)
_unused_variable = create(:something_else, something: variable)

We don't use it anywhere else, either.

One more option we considered but found a bit too much for simple tests:

variable = create(:something) do |something|
  create(:something_else, something: variable)
end

Then of course we could move the setup to `let` and `before` blocks, but
the tests could get over-structured really quickly.
2019-09-30 15:47:13 +02:00
Javi Martín
9f64129be5 Remove isolated useless assignments
These variables can be considered a block, and so removing them doesn't
make the test much harder to undestand.

Sometimes these variables formed the setup, sometimes they formed an
isolated part of the setup, and sometimes they were the part of the test
that made the test different from other tests.
2019-09-30 15:47:13 +02:00
Javi Martín
802be29773 Simplify maximum limit of direct messages specs
Now the tests are easier to understand: when the limit is 3, if you
create 3, the fourth one is invalid. If you create 2, the third one is
valid.
2019-09-30 15:47:13 +02:00
Javi Martín
d09be11a08 Make test for feed limit more explicit
The limit parameter wasn't specified in the test but in the default
value in the database, making the test hard to read.

Since now we've moved the other processes to separate tests, now we can
create four processes using `times` and keep the test simple.
2019-09-30 15:47:13 +02:00
Javi Martín
d410fcbc0e Split scope tests
In the scenario where we want to test scopes and use `match_array`, we
usually declare variables we never use, which raises a warning in the
Ruby interpreter (since the main cause for an unused variable is a
typo).

So I've decided to just split the tests into cases where every record is
returned and cases were no records are returned, just like we do in
other places.

There are several other options we've considered:

1. Don't declare unused variables, but declare the ones we use
2. Prefix unused variables with un underscore
3. Declare just one variable being an array containing all elements, and
access the elements using Array#[]
4. Don't declare any variables, and compare results against attributes
such as titles

None of these options was met with enthusiasm.
2019-09-30 15:46:58 +02:00
Javi Martín
5a84dcb534 Rename unfinished trait to open
So now it's more consistent with the name we use in the rest of the
code.
2019-09-30 15:30:40 +02:00
Javi Martín
e5c502b1cc Split tests checking permissions to vote in a poll
The test was hard to follow, and splitting the test in three it's easier
to read and doesn't create unused variables anymore. On the minus side,
now there's one extra request during the tests.
2019-09-30 15:30:40 +02:00
Javi Martín
72c10ab279 Remove duplication in email specs using let 2019-09-30 15:23:52 +02:00
Javi Martín
4ead96b666 Use let only in the examples using the variables
These variables were only used in the `validations` block; the rest of
the tests re-defined them, making the code hard to follow.
2019-09-30 15:23:52 +02:00
Javi Martín
55c4a953ea Remove let only used once 2019-09-30 15:23:52 +02:00
Javi Martín
d5c0e1c8df Use let to creat users in voter spec
We remove duplication, and we better isolate useless assignments.
2019-09-30 15:23:52 +02:00
Javi Martín
e3a2c0c3a9 Use let in valuator group
This way we can remove a useless assignment without making the code
harder to read vertically.
2019-09-30 15:23:52 +02:00
Javi Martín
2522144ddf Remove useless assignments in draft versions specs
Now that we've moved the `draft_version` variable with `let`, these
variables can be removed without making it harder to read the code
vertically.
2019-09-30 15:23:52 +02:00
Javi Martín
297466fc80 Extract draft version variable to a let block
This way we can reuse the code (in some cases) and we can avoid instance
variables (in some other cases).
2019-09-30 15:23:52 +02:00
Javi Martín
c6808c9c12 Directly assign valuator groups in specs 2019-09-30 15:20:56 +02:00
Javi Martín
05f63ca08d Add trait to create an investment with a valuator 2019-09-30 15:08:27 +02:00
Javi Martín
a9159e0ec8 Directly assign valuators in specs
Creating a record and then assigning an association makes the code even
harder to follow.
2019-09-30 15:08:27 +02:00
Javier Martín
3ecab8af13 Merge pull request #3725 from consul/attributes_in_specs
Check page content from the user's perspective
2019-09-30 15:07:44 +02:00
Javier Martín
59e3e3232d Merge pull request #3732 from consul/voters_in_specs
Simplify creating  associations in specs
2019-09-30 14:38:05 +02:00
Javi Martín
1ebfa04578 Check texts from the user's point of view
This way we also simplify the code by avoiding instance variables.
2019-09-30 14:29:15 +02:00
Javi Martín
2a95676935 Check content instead of current path
This way we check the page from the user's point of view.
2019-09-30 14:29:15 +02:00