Merge pull request #1994 from consul/feature/1985#voting_token
Voter Answer unique Token
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -46,7 +46,7 @@ describe Poll::Answer do
|
||||
answer = create(:poll_answer, question: question, author: author, answer: "Yes")
|
||||
expect(answer.poll.voters).to be_blank
|
||||
|
||||
answer.record_voter_participation
|
||||
answer.record_voter_participation('token')
|
||||
expect(poll.reload.voters.size).to eq(1)
|
||||
voter = poll.voters.first
|
||||
|
||||
@@ -57,12 +57,12 @@ describe Poll::Answer do
|
||||
|
||||
it "updates a poll_voter with user and poll data" do
|
||||
answer = create(:poll_answer, question: question, author: author, answer: "Yes")
|
||||
answer.record_voter_participation
|
||||
answer.record_voter_participation('token')
|
||||
|
||||
expect(poll.reload.voters.size).to eq(1)
|
||||
|
||||
answer = create(:poll_answer, question: question, author: author, answer: "No")
|
||||
answer.record_voter_participation
|
||||
answer.record_voter_participation('token')
|
||||
|
||||
expect(poll.reload.voters.size).to eq(1)
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ describe :voter do
|
||||
|
||||
it "should not be valid if the user has voted via web" do
|
||||
answer = create(:poll_answer)
|
||||
answer.record_voter_participation
|
||||
answer.record_voter_participation('token')
|
||||
|
||||
voter = build(:poll_voter, poll: answer.question.poll, user: answer.author)
|
||||
expect(voter).to_not be_valid
|
||||
@@ -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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user