Added new tests for vote token

This commit is contained in:
María Checa
2017-10-07 16:16:39 +02:00
parent e127b52225
commit 84e35edca7
2 changed files with 9 additions and 1 deletions

View File

@@ -32,6 +32,11 @@ feature "Voter" do
expect(page).to_not have_link('Yes') expect(page).to_not have_link('Yes')
end end
find(:css, ".js-token-message").should be_visible
token = find(:css, ".js-question-answer")[:href].gsub(/.+?(?=token)/, '').gsub('token=', '')
expect(page).to have_content "You can write down this vote identifier, to check your vote on the final results: #{token}"
expect(Poll::Voter.count).to eq(1) expect(Poll::Voter.count).to eq(1)
expect(Poll::Voter.first.origin).to eq("web") expect(Poll::Voter.first.origin).to eq("web")
end end
@@ -101,6 +106,8 @@ feature "Voter" do
visit poll_path(poll) visit poll_path(poll)
expect(page).to_not have_selector('.js-token-message')
expect(page).to have_content "You have already participated in this poll. If you vote again it will be overwritten." expect(page).to have_content "You have already participated in this poll. If you vote again it will be overwritten."
within("#poll_question_#{question.id}_answers") do within("#poll_question_#{question.id}_answers") do
expect(page).to_not have_link('Yes') expect(page).to_not have_link('Yes')

View File

@@ -162,11 +162,12 @@ describe :voter do
it "sets user info" do it "sets user info" do
user = create(:user, document_number: "1234A", document_type: "1") user = create(:user, document_number: "1234A", document_type: "1")
voter = build(:poll_voter, user: user) voter = build(:poll_voter, user: user, token: "1234abcd")
voter.save voter.save
expect(voter.document_number).to eq("1234A") expect(voter.document_number).to eq("1234A")
expect(voter.document_type).to eq("1") expect(voter.document_type).to eq("1")
expect(voter.token).to eq("1234abcd")
end end
end end
end end