Files
nairobi/spec/system/comments/polls_spec.rb
2024-03-25 07:59:42 +01:00

84 lines
1.8 KiB
Ruby

require "rails_helper"
describe "Commenting polls" do
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }
describe "Voting comments" do
let(:verified) { create(:user, verified_at: Time.current) }
let(:unverified) { create(:user) }
let(:poll) { create(:poll) }
let!(:comment) { create(:comment, commentable: poll) }
before do
login_as(verified)
end
scenario "Create" do
visit poll_path(poll)
within("#comment_#{comment.id}_votes") do
click_button "I agree"
within(".in-favor") do
expect(page).to have_content "1"
end
within(".against") do
expect(page).to have_content "0"
end
expect(page).to have_content "1 vote"
end
end
scenario "Update" do
visit poll_path(poll)
within("#comment_#{comment.id}_votes") do
click_button "I agree"
within(".in-favor") do
expect(page).to have_content "1"
end
click_button "I disagree"
within(".in-favor") do
expect(page).to have_content "0"
end
within(".against") do
expect(page).to have_content "1"
end
expect(page).to have_content "1 vote"
end
end
scenario "Allow undoing votes" do
visit poll_path(poll)
within("#comment_#{comment.id}_votes") do
click_button "I agree"
within(".in-favor") do
expect(page).to have_content "1"
end
click_button "I agree"
within(".in-favor") do
expect(page).to have_content "0"
end
within(".against") do
expect(page).to have_content "0"
end
expect(page).to have_content "No votes"
end
end
end
end