Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display all polls for current booth #3361

Merged
merged 3 commits into from
May 28, 2019
Merged

Display all polls for current booth #3361

merged 3 commits into from
May 28, 2019

Conversation

voodoorai2000
Copy link
Member

@voodoorai2000 voodoorai2000 commented Mar 13, 2019

References

Display all polls for current booth AyuntamientoMadrid#1919

Context

Polls that were not votable by a user were not being displayed in the officing interface. Creating a confusing situation for officers.

Objectives

Polls that are not votable by a user should be displayed and a corresponding message displayed explaining that a poll can only be voted by residents of a certain geozone.

Visual Changes

unvotable poll english

spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
spec/features/officing/voters_spec.rb Show resolved Hide resolved
@javierm javierm changed the title Display all polls for current booth [Backport] Display all polls for current booth Mar 14, 2019
@javierm javierm changed the title [Backport] Display all polls for current booth Display all polls for current booth May 23, 2019
Polls that were not votable by a user were not being displayed in the officing interface. Creating a confusing situation for officers.

With this commit polls that are not votable by a user will be displayed, with the corresponding message explaining that that poll can only be voted by residents of a certain geozone.
Budget polls behave slightly differently to non-budget polls.

In budget polls we use Budget::Ballot::Lines to verify if a user has already voted online. In non-budget polls we use Poll::Voter to verify this.

In this commit we are adding an extra check to make sure that the correct message is displayed if the user has already voted online for a budget poll[1]

[1] https://github.com/AyuntamientoMadrid/consul/blob/master/spec/features/budget_polls/voter_spec.rb#L122
booth_assignment2 = create(:poll_booth_assignment, poll: poll2, booth: booth2)

officer_assignment1 = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment1)
officer_assignment2 = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment2. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [115/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

booth_assignment1 = create(:poll_booth_assignment, poll: poll1, booth: booth1)
booth_assignment2 = create(:poll_booth_assignment, poll: poll2, booth: booth2)

officer_assignment1 = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment1. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [115/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario "Do not display expired polls" do
expired_poll = create(:poll, :expired)
booth_assignment = create(:poll_booth_assignment, poll: expired_poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [113/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario "Display polls that the user cannot vote" do
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
booth_assignment = create(:poll_booth_assignment, poll: unvotable_poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [113/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

end

scenario "Display polls that the user cannot vote" do
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [121/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario "Display polls that the user can vote" do
votable_poll = create(:poll, :current, geozone_restricted: true, geozones: [Geozone.first])
booth_assignment = create(:poll_booth_assignment, poll: votable_poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [113/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario "Display current polls assigned to a booth" do
poll = create(:poll, :current)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [113/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario "Cannot vote" do
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
booth_assignment = create(:poll_booth_assignment, poll: unvotable_poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - officer_assignment. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Metrics/LineLength: Line is too long. [111/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

@@ -36,7 +36,22 @@
expect(Poll::Voter.last.officer_id).to eq(officer.id)
end

scenario "Already voted", :js do
scenario "Cannot vote" do
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [119/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

@javierm javierm merged commit c43a1a2 into master May 28, 2019
@javierm javierm deleted the polls_unanswerable branch May 28, 2019 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants