Javi Martín
9ad5d82e9d
Fix typos to make tests more robust
...
Apparently we forgot to use the variables which meant the tests weren't
testing exactly what they were supposed to test.
2019-09-29 22:31:14 +02:00
Javi Martín
92acd0f2b1
Remove redundant publication date attribute
...
The attribute made sense before we changed it in commit ba1a6b4c . Since
then, all milestones have the same date, so the attribute doesn't affect
the test at all.
2019-09-29 22:31:14 +02:00
Javi Martín
49b47dd5f4
Remove useless valuation comment creation
...
The valuation comment doesn't show up in the comment show action because
it's not a child of the parent comment. With a regular comment, the test
passes as well.
However, if we make the valuation comment a child of the parent comment,
it shows up both in the index and show actions. That's because the
method `root_descendants` in the `CommentTree` class doesn't filter
valuation comments. I'm not sure whether it's a bug or the intended
behaviour.
2019-09-29 22:31:14 +02:00
Javi Martín
ce2b81f790
Fix typo in communities spec
...
We were using the same order for most commented and for newest, so the
test wasn't as effective as it could be.
2019-09-29 22:31:14 +02:00
Javi Martín
1cfc6c121d
Remove unnecessary attributes in communities spec
2019-09-29 22:31:13 +02:00
Javi Martín
db90672fdd
Fix notifiable in-app topic specs
...
These specs had never been tested before and were always broken.
2019-09-29 22:31:13 +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
b8d3f426a5
Fix wrong file name for test file
...
The file name finished with `_specs.rb` instead of `_spec.rb`, and so it
wasn't being tested at all.
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
087b4bf2a6
Remove unused variables
2019-09-29 22:31:13 +02:00
Javi Martín
7ee9c0d042
Remove obsolete method to get voted headings
...
This method isn't used since commit e47cbe2a , where we replaced it with
`headings_voted_within_group`.
2019-09-29 22:31:13 +02:00
Javi Martín
bfd39a13e0
Remove unnecessary attributes in proposals spec
...
These tests are only checking which proposals are not included in the
recommendations, so we don't need to sort the included ones, just like
we don't use the cached votes up attribute in the tests preceeding these
ones.
2019-09-29 22:31:13 +02:00
Javi Martín
97375f557f
Fix typo in proposals spec
...
The test passed even if proposal recommendations returned archived
proposals, because we forgot to add the tag list the user is interested
in.
2019-09-29 22:31:07 +02:00
Javi Martín
028f1e3fc4
Fix typo in direct message spec
...
Now the test makes more sense, since it checks the third message for the
same sender is valid.
2019-09-29 22:31:07 +02:00
Javier Martín
1ba610071f
Merge pull request #3729 from consul/fix_extra_records
...
Fix extra records in investments and polls
2019-09-29 22:25:33 +02:00
Javi Martín
3b11f8b567
Avoid duplicate records in current_or_recounting
...
Joining two scopes with `+` does not remove duplicate records. Luckily
now that we've upgraded to Rails 5, we can join scopes using `.or`.
The test was testing for the presence of elements, bud didn't test for
duplicate records. Testing the exact contents of the array revealed this
behaviour.
2019-09-26 19:58:02 +02:00
Javi Martín
45c6a70d91
Fix extra nil added to assigned investment IDs
...
When `valuator_group` was `nil`, `[valuator_group&.investment_ids]` is
evaluated to `nil`, and so we were adding an extra element to the array.
We could add a `compact` call to the resulting array, but I find it
easier to convert `nil` to an array using `to_a`.
2019-09-26 19:58:02 +02:00
Javier Martín
edc396a8e2
Merge pull request #3726 from consul/test_calculate_winner
...
Add more tests to calculate winners
2019-09-25 16:05:38 +02:00
Javi Martín
1bb53b11fb
Add a test for an edge case calculating winners
...
We weren't testing what happens if the next investment exceeds the
budget, but the following one doesn't.
2019-09-25 15:24:59 +02:00
Javi Martín
5a934de5a6
Add test for lines order calculating winners
...
We were creating the investments with more ballot counts first in every
test, so the tests would pass if we ordered the investments by creation
date instead of ordering them by the number of ballot lines.
2019-09-25 15:19:55 +02:00
Javier Martín
5463753553
Merge pull request #3724 from consul/isolated_unused_variables
...
Remove isolated useless assignments
2019-09-25 14:54:03 +02:00
Javier Martín
6ae764c414
Merge pull request #3723 from consul/simplify_poll_factories
...
Simplify data creation in poll factories
2019-09-25 14:42:19 +02:00
Javi Martín
5fa155ceda
Simplify tests checking for invalid email
...
We also remove useless assignments, and use a neutral email address in
the sample data.
2019-09-25 12:43:44 +02:00
Javi Martín
ee0031ccb3
Remove isolated data creation useless assignments
...
While there are other variables in these tests, they're not part of the
setup of the test, and so these ones can be removed while keeping the
code easy to read.
2019-09-25 12:43:44 +02:00
Javi Martín
7b0771106e
Remove isolated useless assignments
...
These variables are not surrounded by other assignments, and so they can
safely be removed without making it harder to read the code vertically.
2019-09-25 12:43:44 +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
24aa4744f1
Simplify login for officer user in tests
...
The same way it's done in other places. We also remove a useless
assignment.
2019-09-25 12:43:44 +02:00
Javi Martín
175163adb6
Use named parameter in mappable shared example
...
Boolean arguments are harder to read, so we added a useless variable.
This is the perfect scenario for a named parameter.
2019-09-25 12:43:44 +02:00
Javi Martín
4e72d9f3b7
Remove useless assignments to return values
2019-09-25 12:43:44 +02:00
Javi Martín
cfaa6d6567
Remove useless assignment in i18n content spec
2019-09-25 12:43:44 +02:00
Javi Martín
320b7550ed
Simplify assigning poll to a booth in specs
...
We were creating booth assignments explicitely, but we can use the
`has_many :through` relationship to make the code easier to read.
2019-09-25 12:38:37 +02:00
Javi Martín
12cdbf6196
Simplify assigning officer to a poll in specs
...
While it could be argued we're hiding the real way we've defined
associations in our models, the tests are so much easier to read when we
don't have so many lines just creating data.
Furthermore, developers who care about vertically aligning the code will
be glad to see some variables disrupting this alignment are now gone.
2019-09-25 12:38:37 +02:00
Javier Martín
d059a564f2
Merge pull request #3722 from consul/use_traits
...
Use traits to simplify specs
2019-09-25 12:29:33 +02:00
Javier Martín
08730ba7f1
Merge pull request #3721 from consul/simplify_testing_array
...
Simplify testing array contents
2019-09-25 11:58:17 +02:00
Javier Martín
0bb6f8029e
Merge pull request #3720 from consul/featured_proposals_specs
...
Update featured proposals specs
2019-09-25 11:55:24 +02:00
Javier Martín
4ee494a46d
Merge pull request #3719 from consul/remove_redundant_code
...
Remove redundant code
2019-09-25 11:53:36 +02:00
Javier Martín
8d41114066
Merge pull request #3718 from consul/remove_obsolete_code
...
Remove unused and obsolete code
2019-09-25 11:46:09 +02:00
Javi Martín
49f81c9488
Add trait to create users with proposal and debate
2019-09-24 21:34:06 +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
53fa527118
Add invisible_to_valuators trait to investments
...
Now the code is symmetrical since we also use `visible_to_valuators`.
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
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