Commit Graph

30 Commits

Author SHA1 Message Date
Javi Martín
0aee568977 Add and apply Rails/RedundantActiveRecordAllMethod
This rule was introduced in rubocop-rails 2.21.0.
2023-11-20 14:22:12 +01:00
Javi Martín
65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00
Javi Martín
f76930aab6 Simplify URL to destroy a booth assignment
We can find the booth through the booth assignment, so we don't need to
pass it in the URL.

Since the parameter is in the URL and not sent through a form, we can
also use `params[:poll_id]` directly, and so we can reuse the
`load_poll` method.
2020-10-19 18:48:01 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00
Javi Martín
710a1d8357 Split Poll::Booth.search in two methods
We use this method in two different scenarios. In an AJAX request, we
don't want to return every booth if the search is blank. However, in a
normal HTTP GET request, we want to return every record when the search
is empty, as we do everywhere else.

It's possible the behaviour of the AJAX call is unusual, since it
searches all booths, and not just the ones assigned to a poll. If we
changed this behaviour, we could simplify the code and remove the
`quick_search` method.
2019-10-07 14:30:39 +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
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
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Angel Perez
2c37702298 Sort booths by name and enable pagination 2018-05-23 08:08:54 -04:00
Bertocq
118deb9fc4 Fix line lenght offenses at multiple controllers 2018-02-19 11:09:19 +01:00
Bertocq
085e6ecba4 Complete booth assigment create/destroy methods to work with ajax 2017-10-19 21:32:37 +02:00
Bertocq
f8839434f7 Complete booth assignment view list without actions yet 2017-10-19 20:10:51 +02:00
Bertocq
45d91a7e50 Add Poll booth_assignments and :Poll::BoothAssignment manage routes, actions and views 2017-10-19 19:27:26 +02:00
rgarcia
39ebc5173a displays recounts for a single booth 2017-10-19 11:28:09 +02:00
rgarcia
34ee16a1c1 displays results for booth 2017-10-19 11:28:09 +02:00
Bertocq
b5cf28cb35 Swap Poll White/Null/Total usage for Poll Recount 2017-10-02 15:46:49 +02:00
BertoCQ
34568567a3 Merge pull request #1885 from consul/chore/remove_final_recounts
Remove Poll Final Recounts, replace with Total Results
2017-09-20 23:00:03 +02:00
Bertocq
a3bf69e78d Remove final result usage on admin poll officer assignments results 2017-09-19 01:13:04 +02:00
Angel Perez
0b708397df Add base controller for Admin:Poll controller
Fixes #1848

On branch aperez-fix-for-issue-1848
  Changes to be committed:
    new file:   app/controllers/admin/poll/base_controller.rb
    modified:   app/controllers/admin/poll/booth_assignments_controller.rb
    modified:   app/controllers/admin/poll/booths_controller.rb
    modified:   app/controllers/admin/poll/officer_assignments_controller.rb
    modified:   app/controllers/admin/poll/officers_controller.rb
    modified:   app/controllers/admin/poll/polls_controller.rb
    modified:   app/controllers/admin/poll/questions_controller.rb
    modified:   app/controllers/admin/poll/recounts_controller.rb
    modified:   app/controllers/admin/poll/results_controller.rb
    modified:   app/controllers/admin/poll/shifts_controller.rb
2017-09-13 12:22:57 -04:00
Bertocq
361e0efe00 Remove Poll Recount model and all usages 2017-07-23 23:29:24 +02:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02:00
Juanjo Bazán
2b68f02b95 paginates booths 2017-02-14 19:09:31 +01:00
Juanjo Bazán
4beee7bacc improves naming consistency 2017-02-14 16:05:28 +01:00
Juanjo Bazán
c359b93fd0 fixes booth search in admin 2017-02-14 16:01:09 +01:00
Juanjo Bazán
20e31133a8 extracts booth_assignment from admin's poll/show 2017-02-14 13:00:19 +01:00
Juanjo Bazán
4ee50c86c0 adds final recounts info to admins 2017-01-30 20:42:30 +01:00
Juanjo Bazán
e634e80113 adds system recounting to admin booth_assignments 2017-01-27 15:19:03 +01:00
Juanjo Bazán
70b86170a2 adds booth_assignment show with officers and recounts info 2017-01-04 21:00:36 +01:00
Juanjo Bazán
8b4f519d71 adds booth assignation to admin poll 2016-12-23 19:06:55 +01:00