Commit Graph

209 Commits

Author SHA1 Message Date
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
Javi Martín
0f80dabfe4 Compare against literal title in feature specs
We were creating records with a title we manually set, so to be
consistent with the rest of the code, in the test we check the title is
present using a string literal.

This way we can also remove useless assignments while keeping the code
vertically aligned.
2019-09-30 14:29:15 +02:00
Javi Martín
0fe0d8e57c Use title in specs add_to_ballot method 2019-09-30 14:29:15 +02:00
Javi Martín
92bfc9ed17 Use text instead of IDs in feature specs
This way we write the tests from the user's point of view: users can see
(for example) a proposal with the title "Make everything awesome", but
they don't see a proposal with a certain ID.

There are probably dozens, if not hundreds, of places where we could
write tests this way. However, it's very hard to filter which ones are
safe to edit, since not many of them have an HTML class we can use in
the tests, and adding a class might generate conflicts with CSS styles.

So, for now, I'm only changing the ones allowing us to cleanly remove
useless assignements while maintaining the code vertically aligned.
2019-09-30 14:29:15 +02:00
Javi Martín
71c24f844d Simplify creating ballot lines in specs 2019-09-30 14:10:44 +02:00
Javi Martín
818b442d52 Simplify creating voters in specs 2019-09-30 00:36:40 +02:00
Javi Martín
a04a289850 Simplify testing arrays exact contents
Instead of testing the contents of each element, we can test the whole
array at once.
2019-09-29 23:24:53 +02:00
Javi Martín
dcc9a6b561 Use symbols instead of constants for behaviours
This way we can be more flexible about the factory we can pass as
parameter.
2019-09-29 22:31:13 +02:00
Javi Martín
0719b834c9 Remove unnecessary attributes in investment specs
The group is automatically assigned when we assign the heading. The
budget isn't needed either, except for a special case related to the
reason to be rejected.
2019-09-29 22:31:13 +02:00
Javi Martín
5cbd160f11 Move login_as after creating data for a test
It doesn't really affect the tests, but it helps isolate useless
assignments, and we already did it this way 94% of the time.
2019-09-25 12:43:44 +02:00
Javi Martín
24e8f07dae Add unfinished trait to investment factories
Now the code is symmetrical since we also use `finished`.
2019-09-24 21:34:06 +02:00
Javi Martín
086e960d09 Add trait to simplify image creation in specs 2019-09-24 21:34:06 +02:00
Javi Martín
eb53e033be Use finished trait to simplify code
It's more concise than writing `valuation_finished: true`.
2019-09-24 21:34:06 +02:00
Javi Martín
cb2069858c Remove unnecessary code
It looks like these variables were left by accident. The Ruby
interpreter was giving us warnings about unused variables.
2019-09-24 18:49:40 +02:00
Javi Martín
11d16e7aad Simplify translatable tests in the public area 2019-09-23 18:01:44 +02:00
Javi Martín
2ec176a2a8 Remove redundant feature settings enabled in tests
These settings are enabled by default.

It could be argued explicitely enabling the features makes tests more
consistent, because they'll work if we change the default setting. It
could also be argued that it makes tests more expressive because it
makes the reader realize certain things will only work if a setting is
enabled.

However, we were only doing so in a few tests. The truth is, thousands
of our tests depend on certain features being enabled. So IMHO we should
be consistent and either set them on every test, or not at all. I'm
choosing the latter option for simplicity.
2019-09-23 15:15:51 +02:00
Javi Martín
da121ebc53 Remove redundant setting resets in after blocks
Settings are stored in the database, and so any changes to the settings
done during the tests are automatically rolled back between one test and
the next one.

There were also a few places where we weren't using an `after` block but
changing the setting at the end of the test.
2019-09-23 13:47:45 +02:00
Javi Martín
969a4e21c9 Apply RSpec/RepeatedExample rubocop rule 2019-09-10 21:43:39 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
taitus
b3ae9038c3 Add remote translations to budget investments 2019-06-27 09:21:19 +02:00
Senén Rodero Rodríguez
264b3f0f82 Simpler calls to *_translatable shared specs
Enable translations interface setting inside shared specs when needed.

Co-Authored-By: javierm <javim@elretirao.net>
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
7e3f0b5c18 Add translation interface feature setting
Allow to enable/disable translation interface at frontend
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
1abcd95441 Add "new_translatable" shared example to budget investments feature specs 2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
9a459070e9 Fix budget investment suggest feature 2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
5eb5f02cbe Fix budget investment specs
After adding investment translatable fields to forms, they will be
generated with nested translations names and ids so we can no longer
use standard id locator.

Using input label text to fill in fields works with both types of forms.
2019-06-27 09:20:24 +02:00
Julian Herrero
b122302c58 Use find instead of find_by_id
Better raise a 404 HTML NotFound exception than any other unexpected error.
2019-06-03 17:54:19 +02:00
rgarcia
998b4d9e39 Load budgets using slugs 2019-06-03 16:54:39 +02:00
voodoorai2000
cb9c3696f4 Use budget investments in useful specs 2019-05-31 18:23:03 +02:00
Javi Martín
307cf24846 Use describe on feature tests
The `type: :feature` is automatically detected by RSpec because these
tests are inside the `spec/features` folder. Using `feature` re-adds a
`type: :feature` to these files, which will result in a conflict when we
upgrade to Rails 5.1's system tests.

Because of this change, we also need to change `background` to `before`
or else these tests will fail.
2019-05-28 16:36:54 +02:00
Javi Martín
4f4dc2c2af Add show results and stats form to budgets 2019-05-22 11:50:03 +02:00
Javier Martín
844ab5fb0e Merge pull request #3405 from consul/remove_obsolete_test
Fix investment pagination tests
2019-04-03 21:13:07 +02:00
decabeza
d7bde5818e Update texts on check my ballot links 2019-03-28 17:16:15 +01:00
Javi Martín
f6da20da64 Fix typos in investment order tests
There was a typo: `new_order = eq(all(` instead of `new_order = all(`,
which was causing the tests to pass.

However, the final expectation should test that we keep the same order
in the same session, and we were accidentally testing the opposite.

We're also adding an extra check to verify there are investments on the
page, since in some cases we were accessing pages with no investments,
and so these tests were always passing.
2019-03-28 13:51:51 +01:00
Javi Martín
5a529e5eb7 Use investments per page instead of Kaminari's
This is the actual number of investments per page in the index action.

Also note one test was generating 100 extra records, which made the test
take more than 40 seconds (on my machine).
2019-03-28 01:34:27 +01:00
Javi Martín
2b4e1cf358 Add missing double quotes
We overlooked a few single quotes while we changed thousands of them.
2019-03-25 13:22:35 +01:00
decabeza
55a2bcb559 Show unfeasible budget investment messages only when valuation finished 2019-03-06 10:46:03 +01:00
Javi Martín
6682121069 Reuse code to set and order by a random seed 2019-02-20 12:10:12 +01:00
Javier Martín
70a1b7d1ff Merge pull request #3318 from consul/backport-refactor_investments_index
Show all investments in the map
2019-02-20 11:49:06 +01:00
Javi Martín
facfb807e1 Show all investments in the map
We were showing only the ones being shown in the current page because
we were modifying `@investments` using a method which used
`@investments`, and we were calling that method twice.

There are many possible solutions: using a local variable to store the
result of the `investments` method, modifying `@investments` after
modifying `@investments_map_coordinates`, ... I've used the one which in
my humble opinion is a bit less fragile: not using `@investments` inside
the `investments` method. That way, the `investments` method will always
return the same result.

Note `stub_const("Budgets::InvestmentsController::PER_PAGE", 2)`
wouldn't work because `Budgets::InvestmentsController` isn't loaded when
that line is executed. So we need to load it. Instead of requiring the
file, using `#{Budgets::InvestmentsController}` seems to be an easier
solution.
2019-02-19 13:22:49 +01:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Julian Herrero
922600252c Make budget headings translatable 2019-02-13 13:35:07 +01:00
rgarcia
55fb14ac14 do not display alert when supporting for whole city 2019-02-07 16:55:24 +01:00
Julian Nicolas Herrero
9da2783814 Merge pull request #3272 from consul/backport_show_unfeasible_and_unselected_investments
[Backport] Show unfeasible and unselected investments for finished budgets
2019-02-06 14:44:43 +01:00
Julian Herrero
c9522b424b Show unfeasible and unselected investments for finished budgets
We were filtering by winners investments for finished budget without
having in consideration other filters.
We want the default filter to be `winners` for finished budgets.
2019-02-06 13:50:50 +01:00
decabeza
a2161f3ace Hide voted group css class if current filter is unfeasible 2019-02-05 17:16:04 +01:00
decabeza
025bcedce9 Show project winner label only if budget is finished 2019-02-05 17:15:40 +01:00
decabeza
773302f0d7 Show only random order for unfeasible and unselected investments 2019-01-30 14:16:25 +01:00
Julian Herrero
2081269a67 fix Hound violations 2019-01-02 10:46:31 +01:00
Julian Nicolas Herrero
a421df31db Merge pull request #3115 from consul/backport-1758-flaky_spec_currency_symbol
[Backport] Fix flaky spec checking price without currency symbol
2018-12-19 17:27:54 +01:00