Commit Graph

14352 Commits

Author SHA1 Message Date
Javi Martín
086e960d09 Add trait to simplify image creation in specs 2019-09-24 21:34:06 +02:00
Javi Martín
52e54363ae Add trait to create a poll associated to a budget 2019-09-24 21:34:06 +02:00
Javi Martín
4edab79910 Use yes_no trait to simplify creating answers
We lose some variety in our answers, though, but on the plus side, we
reduce the risk of trademark issues :P.
2019-09-24 21:34:06 +02:00
Javi Martín
19a41eb651 Rename trait with_answers to yes_no
We barely use this trait. In the votation type spec we're probably using
it wrong, and in the answer spec we assume one of the answers is going
to be "Yes".

The name `yes_no` is more expressive, since it makes it clear what the
answers are.
2019-09-24 21:34:06 +02:00
Javi Martín
aeb1655961 Use budget phase traits
We were already using them in many places, but not everywhere.
2019-09-24 21:34:06 +02:00
Javi Martín
cced12c3a0 Use feasibility traits to simplify code 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
30a30c5f00 Use with_administrator trait to simplify code
It's more concise than writing `administrator: create(:administrator)`
2019-09-24 21:34:06 +02:00
Javi Martín
2b2c528098 Use hidden trait in specs
We were using it in most places, but there were a few where we still
used `hidden_at: Time.current`.
2019-09-24 21:34:06 +02:00
Javi Martín
f27beb1e47 Simplify testing array contents
We were testing for the size and the content of the elements when we
could test for the array itself.
2019-09-24 21:32:52 +02:00
Javi Martín
4301937e85 Check arrays are empty instead of size 0
In ruby we check for `array.empty?` instead of `array.size == 0`, so
it's natural to write the tests in the same way.
2019-09-24 21:32:28 +02:00
Javi Martín
98fe8349d7 Use match_array instead of sorting arrays
It does the same thing, and it's easier to read.
2019-09-24 20:50:49 +02:00
Javi Martín
4a80653d2f Remove redundant checks for array size
If we check the exact contents of the array, checking the size is
implicit.
2019-09-24 20:50:48 +02:00
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
9d627f2db9 Remove redundant I18nContent scope
Since two records cannot have the same key, having a scope that will
always return just one record is the same as using `find_by_key`.
2019-09-24 19:29:46 +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
da425b9164 Remove commented graphql code
This code was commented in commit ad8aba07.
2019-09-24 19:27:17 +02:00
Javi Martín
82ea866b6d Remove commented graphql tests
These tests use a "proceeding" method in proposals, which does not
exist.
2019-09-24 19:27:08 +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
Javi Martín
06030933a4 Remove obsolete poll answers variable
This code is obsolete since commit c6e4b248.
2019-09-24 18:29:33 +02:00
Javi Martín
f767f231dc Remove obsolete notices in booth assignments
This code is obsolete since commit 085e6ecb.
2019-09-24 18:26:11 +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
Javier Martín
671d49c8df Merge pull request #3713 from consul/reduce_translatable_specs
Make translatable specs faster
2019-09-24 14:30:10 +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
66334b5757 Add globalizable tests for all translatable models
So now we test in depth at the model level, and can be a bit more
relaxed about integration tests for translations.

Note we're defining some extra factories to make sure all translatable
attributes with presence validation rules are mandatory. This way we can
simplify the way we obtain required fields, using `required_attribute?`.
Otherwise, fields having an `unless` condition in their presence
validation rules would count as mandatory even when they're not.
2019-09-23 18:01:44 +02:00
Javi Martín
5d6038f17f Add model tests for globalizable concern
These tests are much faster than feature tests, so we're going to use
them to test translatable models.
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
a0ee0e661f Fix missing sequences in notification factory
If we don't define a sequence, `n` becomes an object instead of a
number.
2019-09-23 18:01:44 +02:00
Javi Martín
2db8c80633 Simplify globalizable specs
We don't need `before` blocks because we've removed the `after` blocks,
and we don't need to define available locales because we already do so
in the test environment file.
2019-09-23 18:01:44 +02:00
Javier Martín
6542c6f0b1 Merge pull request #3714 from consul/simplify_investment_creation
Simplify investments creation in specs
2019-09-23 17:56:43 +02:00
Javier Martín
6eb5ad4fff Merge pull request #3715 from consul/describedclass_rule
Apply explict RSpec/DescribedClass rubocop rule
2019-09-23 17:35:13 +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
ffc50246c2 Apply explict RSpec/DescribedClass rubocop rule
We settled on using this style in commit 4cbe81a1, but didn't add the
rule enforcing this style and we didn't apply it to existing code.
2019-09-23 16:51:00 +02:00
Javier Martín
1faa659c89 Merge pull request #3702 from consul/remove_after_blocks
Simplify after blocks in specs
2019-09-23 16:12:03 +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