Commit Graph

2813 Commits

Author SHA1 Message Date
Javi Martín
8ec8002acd Enable featured proposals when they're used
These specs were added before we disabled featured proposals by default.
After that, they were passing, but they were not testing the scenario
they were supposed to test.
2019-09-24 20:05:02 +02:00
Javi Martín
52c8691aae Don't create featured proposals if disabled
Before we disabled featured proposals by default, there were many tests
creating them because they were needed in order to create non-featured
proposals.

But now these tests don't need to create featured proposals anymore.
2019-09-24 20:04:39 +02:00
Javi Martín
2ad6ced12f Create featured proposals if enabled
We had a case where we created 5 extra records in pagination and checked
2 records were present, because the other 3 were automatically
considered featured proposals.

Explicitely creating featured proposals let us create 2 extra records
 and check 2 records are present, which is far more intuitive.
2019-09-24 20:03:52 +02:00
Javi Martín
01862d6664 Remove unused attributes creating a heading
The "name" attribute is automatically generated by the budget heading
factory. And the "price" attribute is out of context and not needed
since this test doesn't create investments.
2019-09-24 20:02:09 +02:00
Javi Martín
f5849cb5d8 Remove unnecessary question creating answers
Questions are automatically created by the poll_question_answer factory.
2019-09-24 19:55:42 +02:00
Javi Martín
e1c09769a8 Remove unnecessary data in polls spec
This data was added in commit 62088bc6, but the changes in that commit
don't seem to be related to the number of questions in a poll.
2019-09-24 19:55:37 +02:00
Javi Martín
ef0330f671 Remove duplicate test
One test was testing regular users can't access results, and another one
was testing neither regular users nor managers can. So the second test
can just test the admin scenario, and we're still covering everything.
2019-09-24 19:50:18 +02:00
Javi Martín
adf59cc963 Move related tests together 2019-09-24 19:50:18 +02:00
Javi Martín
7db32b337b Remove unnecessary author variables in specs
The factories creating proposals and debates automatically create an
author.
2019-09-24 19:50:14 +02:00
Javi Martín
fe5b45ed18 Remove unnecessary poll creating assignments
The factory creating assignments automatically assigns a poll to it, so
we don't use the poll for anything else, there's no need to explicitely
create it.
2019-09-24 19:48:22 +02:00
Javi Martín
9fcea17849 Remove useless parameter in URL
The proposal parameter was accidentally added in commit 16692c93, but
the proposals index doesn't receive a proposal as parameter.
2019-09-24 19:28:36 +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
fcaa30dc57 Remove obsolete URL reference
This URL was accidentally copied from Madrid's repository. However, we
don't use it in CONSUL.
2019-09-24 18:49:40 +02:00
Javi Martín
fb6d12c8ab Remove obsolete data creation
This data is obsolete since commit 9d1ca3bf.

Note we should have probably moved the test to the model, since now the
`to_csv` method isn't tested anywhwere, and we should probably add a
test in the future. The code now uses the new DownloadSetting model,
though, making it hard to test.
2019-09-24 18:49:40 +02:00
Javi Martín
748ee3d804 Remove obsolete confirm messages references
This code is obsolete since commits 122b1703 and bbf3faa7.
2019-09-24 18:33:47 +02:00
Javier Martín
989b2e23f7 Merge pull request #3711 from consul/fix_managers_suggestions
Allow managers to read investment suggestions
2019-09-24 14:32:20 +02:00
Javi Martín
11d16e7aad Simplify translatable tests in the public area 2019-09-23 18:01:44 +02:00
Javi Martín
44d137a4c0 Simplify translatable tests in admin section
These feature tests were taking too long, we can't run them for every
single model.

I'm taking the approach of using one different model for each test, but
in theory only using a few models covering every possible scenario
would be enough.
2019-09-23 18:01:44 +02:00
Javi Martín
ef7606bb45 Move translatable file to features folder
This change breaks the tests, but makes future commits easier to review.
2019-09-23 18:01:44 +02:00
Javi Martín
41c99d9b27 Let Globalize use I18n locale
This is a mistake I made in commit f2ef27d3. Back then I thought we
needed to keep Globalize.locale and I18n.locale in sync, but the truth
is it automatically happens when setting Globalize.locale to nil.

So now we can use I18n.with_locale (at least in the tests) and forget
about Globalize, which will make it easier to switch to Mobility in the
future.
2019-09-23 18:01:44 +02:00
Javi Martín
c8c8a7bc30 Simplify investment creation in specs
Now factories define default headings for investments, so there's no
need to create a group and a heading to create an investment.

Likewise, in order to create a heading it isn't necessary to specify a
group anymore; specifying the budget is enough.

It's possible that there are more similar cases we haven't simplified
yet; I'm only addressing the obvious ones.
2019-09-23 16:51:30 +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
eb7a052207 Simplify tests using delayed_job
Among other advantages, now we can run these tests with
`rspec --tag delayed_jobs`.
2019-09-23 13:47:45 +02:00
Javi Martín
7be72df5bf Remove redundant I18n resets in after blocks
We already configure `I18n.locale` and we reset Globalize's fallbacks
before every test.

On the other hand, RSpec automatically resets anything which is stub
with `allow`, so there's no need to use `and_call_original` in an
`after` block.
2019-09-23 13:47:45 +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
DenisNikolski
5627c8ccf4 add test for booths search 2019-09-21 16:25:20 +03:00
Javi Martín
53670602e0 Allow managers to read investment suggestions
When creating a budget investment with an unverified manager (for
example, a manager who isn't part of the local census), there's a
request to `Budgets::InvestmentsController#suggest`. Since the manager
isn't verified, suggestions can't be obtained.

There are serveral ways to fix this problem:

* Add a `suggest` action to Management::Budgets::InvestmentsController,
doing the same thing the main `suggest` action does.
* Give unverified users permission to access investment suggestions
* Give managers permission to access investment suggestions

I've chosen the last one because I thought it was simple and only
changed existing behaviour for managers, but any other solution would be
as valid. I haven't added the `phase: "accepting"` condition to keep it
simple, since a read-only action like this one in the management portal
isn't gonna create security risks.
2019-09-20 12:51:26 +02:00
DenisNikolski
54c4a8d34b fix shifts_spec 2019-09-13 22:51:07 +03:00
Javier Martín
f5a6df4316 Merge pull request #3692 from consul/admin-booth-assignments
Hide polls created by users on admin poll booth assigments
2019-09-12 12:54:42 +02:00
Javier Martín
760deb1682 Merge pull request #3613 from consul/dashboard-related-content
Add related content section on proposal dashboard
2019-09-12 12:52:32 +02:00
decabeza
0ff7a327b7 Refactor selected proposals specs 2019-09-11 22:18:56 +02:00
decabeza
8440208597 Hide comments count on selected proposals 2019-09-11 22:18:43 +02:00
decabeza
1a0f0215a7 Hide related content on selected proposals 2019-09-11 22:18:42 +02:00
decabeza
b15048ec7d Hide proposal code on selected proposals 2019-09-11 22:17:40 +02:00
decabeza
e879fddba4 Hide view mode on selected proposals list 2019-09-11 22:17:40 +02:00
decabeza
abf04bea4c Add related content section on proposal dashboard 2019-09-11 19:45:19 +02:00
Javi Martín
cf5b538c1c Check page between AJAX requests
While the test should work without this assertion, the intention of the
test is to check what happens if a user selects and investment and, once
it's selected, clicks the "next" link.
2019-09-11 19:38:35 +02:00
Javi Martín
9d6ed7a085 Show only defined columns on inserted rows
When we were inserting a row or replacing an existing one (just like we
do when we click the link to select an investment), we were entering a
row containing all columns, and all of them were displayed even if they
had been excluded using the column selector.

This caused the table to move in a strange way, which sometimes made the
investment selection tests fail.
2019-09-11 19:38:34 +02:00
decabeza
08e820c134 Hide polls created by users on admin poll booth assigments 2019-09-11 18:44:32 +02:00
Javier Martín
cb6539d170 Merge pull request #3537 from PierreMesure/set-locales-in-test-environment
Set locales in test environment to avoid failed specs
2019-09-11 18:43:03 +02:00
Javi Martín
7f8474ea95 Reduce locales used in remote translations tests
This way we can reduce the number of locales used in the test
environment as well, while still testing every possible scenario for
remote translations.
2019-09-11 16:33:25 +02:00
Javi Martín
2f10005739 Fix text confirming investment heading support
We accidentally removed the `count` option in commit 55fb14ac, which
made the translation return a hash.

The test is a bit hacky, which makes me think changing the user
interface would probably be a better solution.
2019-09-11 03:18:12 +02:00
Javi Martín
5ad41d9ac7 Add a break to avoid case fallthrough
In JavaScript, when there isn't a `break` or `return` statement inside a
`switch` case, the next case will be executed as well.

That wasn't a problem here because CoffeeScript automatically inserts a
`return` statement in this specific situation. However, since we don't
want to return the result of the `hide()` operation, it might be easy to
accidentally remove the `return` statement, causing the code to break.

I've added a test for the scenario where neither `break` nor `return`
statements are present, so we don't run into this error.
2019-09-11 02:05:04 +02:00
Javi Martín
2af09d65c7 Remove unused JavaScript poll token code
We don't load the token message since commit 585f9ea5, so the JavaScript
to show it wasn't doing anything anymore.
2019-09-11 01:56:27 +02:00
Javi Martín
c05b9c2aac Apply Capybara/CurrentPathExpectation rubocop rule 2019-09-10 21:43:39 +02:00
Javi Martín
969a4e21c9 Apply RSpec/RepeatedExample rubocop rule 2019-09-10 21:43:39 +02:00
Javi Martín
044eabd7ef Apply Rspec/LetSetup rubocop rule 2019-09-10 21:43:39 +02:00
Javi Martín
adc5906253 Apply Rails/PluralizationGrammar rubocop rule 2019-09-10 21:43:38 +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
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00