records participation of user via web

answering a poll question creates a voter with the user data to record
participation in question’s poll
This commit is contained in:
Juanjo Bazán
2017-01-25 14:21:03 +01:00
parent 086f4a4170
commit b13a76963a
8 changed files with 73 additions and 25 deletions

View File

@@ -13,4 +13,18 @@ describe Poll::Answer do
end
end
describe "#record_voter_participation" do
it "creates a poll_voter with user and poll data" do
answer = create(:poll_answer)
expect(answer.voter).to be_nil
answer.record_voter_participation
voter = answer.reload.voter
expect(voter.answer).to eq(answer)
expect(voter.document_number).to eq(answer.author.document_number)
expect(voter.poll_id).to eq(answer.poll.id)
end
end
end