adds spec for recount/officers lists in booth_assignment show

This commit is contained in:
Juanjo Bazán
2017-01-05 13:00:48 +01:00
parent 186be1e7cc
commit 0e9cec2ca6
3 changed files with 53 additions and 7 deletions

View File

@@ -30,7 +30,7 @@
<% else %> <% else %>
<h3><%= t("admin.poll_booth_assignments.show.officers_list") %></h3> <h3><%= t("admin.poll_booth_assignments.show.officers_list") %></h3>
<table> <table id="officers_list">
<tbody> <tbody>
<% @booth_assignment.officers.uniq.each do |officer| %> <% @booth_assignment.officers.uniq.each do |officer| %>
<tr id="officer_<%= officer.id %>" class="officer"> <tr id="officer_<%= officer.id %>" class="officer">
@@ -50,7 +50,7 @@
</div> </div>
<% else %> <% else %>
<h3><%= t("admin.poll_booth_assignments.show.recounts_list") %></h3> <h3><%= t("admin.poll_booth_assignments.show.recounts_list") %></h3>
<table> <table id="recounts_list">
<thead> <thead>
<tr> <tr>
<th><%= t("admin.poll_booth_assignments.show.date") %></th> <th><%= t("admin.poll_booth_assignments.show.date") %></th>

View File

@@ -267,6 +267,10 @@ FactoryGirl.define do
user user
end end
factory :poll_officer, class: 'Poll::Officer' do
user
end
factory :poll do factory :poll do
sequence(:name) { |n| "Poll #{n}" } sequence(:name) { |n| "Poll #{n}" }
@@ -307,10 +311,6 @@ FactoryGirl.define do
association :booth, factory: :poll_booth association :booth, factory: :poll_booth
end end
factory :poll_officer, class: 'Poll::Officer' do
user
end
factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do
association :officer, factory: :poll_officer association :officer, factory: :poll_officer
association :booth_assignment, factory: :poll_booth_assignment association :booth_assignment, factory: :poll_booth_assignment

View File

@@ -36,7 +36,7 @@ feature 'Admin booths assignments' do
expect(page).to have_content booth.name expect(page).to have_content booth.name
end end
scenario 'remove booth from poll', :js do scenario 'Remove booth from poll', :js do
poll = create(:poll) poll = create(:poll)
booth = create(:poll_booth) booth = create(:poll_booth)
assignment = create(:poll_booth_assignment, poll: poll, booth: booth) assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
@@ -63,4 +63,50 @@ feature 'Admin booths assignments' do
expect(page).to have_content 'There are no booths assigned to this poll.' expect(page).to have_content 'There are no booths assigned to this poll.'
expect(page).to_not have_content booth.name expect(page).to_not have_content booth.name
end end
feature 'Show' do
scenario 'Lists all assigned poll oficers' do
poll = create(:poll)
booth = create(:poll_booth)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment)
officer = officer_assignment.officer
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment_2)
officer_2 = officer_assignment_2.officer
visit admin_poll_path(poll)
click_link 'Booths (2)'
click_link booth.name
click_link 'Officers'
within('#officers_list') do
expect(page).to have_content officer.name
expect(page).to_not have_content officer_2.name
end
end
scenario 'Lists all recounts for the booth assignment' do
poll = create(:poll)
booth = create(:poll_booth)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
recount = create(:poll_recount, booth_assignment: booth_assignment, count: 33)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
recount_2 = create(:poll_recount, booth_assignment: booth_assignment_2, count: 100)
visit admin_poll_path(poll)
click_link 'Booths (2)'
click_link booth.name
click_link 'Recounts'
within('#recounts_list') do
expect(page).to have_content recount.count
expect(page).to_not have_content recount_2.count
end
end
end
end end