diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index e558b7261..256807928 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -32,6 +32,11 @@ feature "Voter" do expect(page).to_not have_link('Yes') 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.first.origin).to eq("web") end @@ -101,6 +106,8 @@ feature "Voter" do 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." within("#poll_question_#{question.id}_answers") do expect(page).to_not have_link('Yes') diff --git a/spec/models/poll/voter_spec.rb b/spec/models/poll/voter_spec.rb index bbd22011a..ae0f84a49 100644 --- a/spec/models/poll/voter_spec.rb +++ b/spec/models/poll/voter_spec.rb @@ -162,11 +162,12 @@ describe :voter do it "sets user info" do 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 expect(voter.document_number).to eq("1234A") expect(voter.document_type).to eq("1") + expect(voter.token).to eq("1234abcd") end end end