adds specs

This commit is contained in:
rgarcia
2017-09-08 22:00:50 +02:00
parent 0ad24c1080
commit 4d1f61a87e
2 changed files with 47 additions and 0 deletions

View File

@@ -36,6 +36,32 @@ feature 'Admin booths' do
expect(page).to_not have_content "There are no booths"
end
scenario "Available" do
booth_for_current_poll = create(:poll_booth)
booth_for_incoming_poll = create(:poll_booth)
booth_for_expired_poll = create(:poll_booth)
current_poll = create(:poll, :current)
incoming_poll = create(:poll, :incoming)
expired_poll = create(:poll, :expired)
create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll)
create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll)
create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll)
visit admin_root_path
within('#side_menu') do
click_link "Manage shifts"
end
expect(page).to have_css(".booth", count: 2)
expect(page).to have_content booth_for_current_poll.name
expect(page).to have_content booth_for_incoming_poll.name
expect(page).to_not have_content booth_for_expired_poll.name
end
scenario 'Show' do
booth = create(:poll_booth)

View File

@@ -24,4 +24,25 @@ describe :booth do
end
end
describe "#available" do
it "returns booths associated to current or incoming polls" do
booth_for_current_poll = create(:poll_booth)
booth_for_incoming_poll = create(:poll_booth)
booth_for_expired_poll = create(:poll_booth)
current_poll = create(:poll, :current)
incoming_poll = create(:poll, :incoming)
expired_poll = create(:poll, :expired)
create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll)
create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll)
create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll)
expect(Poll::Booth.available).to include(booth_for_current_poll)
expect(Poll::Booth.available).to include(booth_for_incoming_poll)
expect(Poll::Booth.available).to_not include(booth_for_expired_poll)
end
end
end