Commit Graph

209 Commits

Author SHA1 Message Date
Javi Martín
ef24962f40 Simplify variable usage in features specs
We usually check against the literal text instead of storing the text in
a variable.
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
b431273869 Simplify creating officer assignments in specs
Note we usually cannot make it simple because officer assignments are
usually assigned to both a poll and a booth, and on a certain date.
However, in the few cases where the booth nor the date don't matter, we
can make the code a bit easier to read.
2019-09-30 14:10:45 +02:00
Javi Martín
c6acc70570 Simplify assigning a name to an officer 2019-09-30 14:10:45 +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
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
Javi Martín
086e960d09 Add trait to simplify image creation in specs 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
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
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
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
DenisNikolski
5627c8ccf4 add test for booths search 2019-09-21 16:25:20 +03:00
DenisNikolski
54c4a8d34b fix shifts_spec 2019-09-13 22:51:07 +03:00
decabeza
08e820c134 Hide polls created by users on admin poll booth assigments 2019-09-11 18:44:32 +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
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
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
Javi Martín
e64289c5f9 Fix double quotes inside double quotes
The interpolation was being evaluated as a comment.
2019-08-27 17:22:22 +02:00
Javi Martín
0b55097820 Remove system count from old booth assigments
This number was not the important one; the important one is the one
given by the recounts.

Note we're also removing the votes by date, since they're also system
votes.
2019-08-07 20:31:45 +02:00
Javi Martín
bddfee2b86 Remove system count column for old polls
System count isn't a relevant number because the important one is the
number of votes counted by poll officers. We're still maintaining it for
a month in case poll officers would like to review the results.
2019-08-07 20:31:45 +02:00
Senén Rodero Rodríguez
3176be43d9 Rename "translatable" shared example to "edit_translatable"
Also rename all specs calls
2019-06-27 09:20:25 +02:00
lalo
23d36835d7 Add Admin changes to create Poll:Questions with votation type 2019-06-12 19:44:14 +02:00
Alberto
2f8505332e Merge pull request #3574 from consul/remove-dashboard-polls
Allow users to delete dashboard polls
2019-06-01 11:06:34 +02:00
decabeza
bc1fc5d929 Add button to delete a poll 2019-05-31 11:55:05 +02:00
decabeza
cec1d5e5f0 Hide polls created by users from proposals dashboard on admin poll index 2019-05-31 11:34:55 +02:00
Javi Martín
123196e4ed Display the same results for stats and recounts
In the recounts we were incorrectly assuming the total amount included
the blank and invalid ballots.
2019-05-30 17:22:39 +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
Javier Martín
cbfa2c1df8 Merge pull request #3504 from consul/backport-poll_slugs
Add slug to polls
2019-05-21 13:42:47 +02:00
decabeza
625c34bac2 Add officer email on admin poll shifts table 2019-05-17 17:41:42 +02:00
Alberto
d845c6e973 Merge pull request #3476 from consul/delete-poll
Allow delete polls with associated questions and answers
2019-05-17 17:38:20 +02:00
María Checa
0c6e7e7580 Adds Sluggable concern to Poll model 2019-05-17 05:41:09 +02:00
decabeza
e026412389 Add button to delete a poll 2019-05-14 16:46:56 +02:00
Javi Martín
63fef66f41 Remove obsolete reference to proposal question 2019-05-09 12:58:14 +02:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Senén Rodero Rodríguez
9d9ad5003b Add given_order to related poll question answers forms
Since given order is no longer being generated automatically we need
to add it to related forms and to strong parameters methods
2019-03-21 14:51:17 +01:00
Javi Martín
d69adbccb7 Avoid creating extra poll records in tests
The line:

create(:poll_voter, booth_assignment: booth_assignment_final_recounted)

Creates a new poll for the poll voter. Not only it wastes time by
creating new database records, but it doesn't make sense to have a poll
voter for a poll which isn't the same as its booth assignment's poll.
2019-03-19 13:29:45 +01:00
Javi Martín
8118926ba7 Simplify tests creating poll voters 2019-03-19 13:29:43 +01:00
Julian Herrero
58f22915e9 Use double quotes 2019-03-15 09:57:09 +01:00
Julian Herrero
da04f6caa7 Add test for booth votes case 2019-03-15 09:55:12 +01:00
Alberto
3c313c9c52 Merge pull request #3334 from consul/admin-polish
Improve UX on admin section
2019-03-13 17:15:22 +01:00
decabeza
b31b65f246 Add link to proposal if question was created from a proposal 2019-03-13 15:35:31 +01:00
decabeza
000819e928 Move create question to admin poll questions
Also move question actions to admin polls questions
2019-03-13 15:33:14 +01:00
decabeza
83e8d6035a Remove questions link on admin polls menu 2019-03-13 13:33:49 +01:00
decabeza
74958fab02 Always show create question button on admin proposal show 2019-03-13 13:28:12 +01:00
Javi Martín
db6229e38e Add specs for cumulative recounts totals 2019-03-07 02:09:17 +01:00
Julian Nicolas Herrero
2f84d17cc9 Merge pull request #3155 from jaflutz/2824-options-display-results-polls
Enable options to show stats and results with any type of voter
2019-03-06 11:14:54 +01:00
decabeza
51d74ed7ab Replace poll name link in admin polls booth assignments 2019-02-25 14:10:25 +01:00
Julian Herrero
884274c4ad Add a description for open polls 2019-02-18 13:34:07 +01:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00