Files
nairobi/spec/components/polls/callout_component_spec.rb
Javi Martín 5402cb6042 Move poll callout partial to a component
This way it'll be easier to refactor it.

Note there was a system test which tested both the callout and the form
when unverified users visit a poll. We've split this system test in two
component tests.
2025-08-14 13:06:43 +02:00

28 lines
925 B
Ruby

require "rails_helper"
describe Polls::CalloutComponent do
it "asks anonymous users to sign in" do
render_inline Polls::CalloutComponent.new(create(:poll))
expect(page).to have_content "You must sign in or sign up to participate"
end
it "shows a message to level 2 users when a poll has finished" do
sign_in(create(:user, :level_two))
render_inline Polls::CalloutComponent.new(create(:poll, :expired))
expect(page).to have_content "This poll has finished"
end
it "asks unverified users to verify their account" do
sign_in(create(:user, :incomplete_verification))
render_inline Polls::CalloutComponent.new(create(:poll))
expect(page).to have_content "You must verify your account in order to answer"
expect(page).not_to have_content "You have already participated in this poll. " \
"If you vote again it will be overwritten"
end
end