Merge branch 'master' into fix/shift_date_range_expired

This commit is contained in:
Bertocq
2017-10-16 19:43:00 +02:00
30 changed files with 428 additions and 170 deletions

View File

@@ -113,4 +113,18 @@ feature 'Admin booths' do
end
end
scenario "Back link go back to available list when manage shifts" do
poll = create(:poll, :current)
booth = create(:poll_booth)
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
visit available_admin_booths_path
within("#booth_#{booth.id}") do
click_link "Manage shifts"
end
click_link "Go back"
expect(current_path).to eq(available_admin_booths_path)
end
end

View File

@@ -0,0 +1,68 @@
require 'rails_helper'
feature 'Officer Assignments' do
background do
admin = create(:administrator)
login_as(admin.user)
end
scenario "Index" do
poll = create(:poll)
booth = create(:poll_booth)
officer1 = create(:poll_officer)
officer2 = create(:poll_officer)
officer3 = create(:poll_officer)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer1)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer2)
visit admin_poll_path(poll)
click_link 'Officers (2)'
within('#officer_assignments') do
expect(page).to have_content officer1.name
expect(page).to have_content officer2.name
expect(page).to_not have_content officer3.name
end
end
scenario "Search", :js do
poll = create(:poll)
booth = create(:poll_booth)
user1 = create(:user, username: "John Snow")
user2 = create(:user, username: "John Silver")
user3 = create(:user, username: "John Edwards")
officer1 = create(:poll_officer, user: user1)
officer2 = create(:poll_officer, user: user2)
officer3 = create(:poll_officer, user: user3)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer1)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer2)
visit admin_poll_path(poll)
click_link 'Officers (2)'
fill_in "search-officers", with: "John"
click_button "Search"
within('#search-officers-results') do
expect(page).to have_content officer1.name
expect(page).to have_content officer2.name
expect(page).to_not have_content officer3.name
end
end
end

View File

@@ -92,6 +92,37 @@ feature 'Admin shifts' do
end
end
scenario "Vote Collection Shift and Recount & Scrutiny Shift don't include already assigned dates to officer", :js do
poll = create(:poll, :current)
booth = create(:poll_booth)
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer = create(:poll_officer)
shift1 = create(:poll_shift, :vote_collection_task, officer: officer, booth: booth, date: Time.zone.today)
shift2 = create(:poll_shift, :recount_scrutiny_task, officer: officer, booth: booth, date: Time.zone.tomorrow)
vote_collection_dates = (poll.starts_at.to_date..poll.ends_at.to_date).to_a
.reject { |date| date == Time.zone.today }
.map { |date| I18n.l(date, format: :long) }
recount_scrutiny_dates = (poll.ends_at.to_date..poll.ends_at.to_date + 1.week).to_a
.reject { |date| date == Time.zone.tomorrow }
.map { |date| I18n.l(date, format: :long) }
visit available_admin_booths_path
within("#booth_#{booth.id}") do
click_link "Manage shifts"
end
fill_in "search", with: officer.email
click_button "Search"
click_link "Edit shifts"
expect(page).to have_select('shift_date_vote_collection_date', options: ["Select day", *vote_collection_dates])
select "Recount & Scrutiny", from: 'shift_task'
expect(page).to have_select('shift_date_recount_scrutiny_date', options: ["Select day", *recount_scrutiny_dates])
end
scenario "Error on create", :js do
poll = create(:poll, :current)
booth = create(:poll_booth)

View File

@@ -23,7 +23,7 @@ feature 'Admin tags' do
within("form.new_tag") do
fill_in "tag_name", with: 'important issues'
click_button 'Create Topic'
click_button 'Create topic'
end
visit admin_tags_path
@@ -39,8 +39,8 @@ feature 'Admin tags' do
expect(page).to have_content @tag1.name
expect(page).to have_content tag2.name
within("#edit_tag_#{tag2.id}") do
click_link 'Destroy Topic'
within("#tag_#{tag2.id}") do
click_link 'Destroy topic'
end
visit admin_tags_path
@@ -58,8 +58,8 @@ feature 'Admin tags' do
expect(page).to have_content @tag1.name
expect(page).to have_content tag2.name
within("#edit_tag_#{tag2.id}") do
click_link 'Destroy Topic'
within("#tag_#{tag2.id}") do
click_link 'Destroy topic'
end
visit admin_tags_path
@@ -81,7 +81,7 @@ feature 'Admin tags' do
within("form.new_tag") do
fill_in "tag_name", with: "wow_category"
click_button 'Create Topic'
click_button 'Create topic'
end
expect(ActsAsTaggableOn::Tag.category.where(name: "wow_category")).to exist