- <%= render "callout" %>
+ <%= render Polls::CalloutComponent.new(@poll) %>
<% if @poll.voted_in_booth?(current_user) %>
diff --git a/spec/components/polls/callout_component_spec.rb b/spec/components/polls/callout_component_spec.rb
new file mode 100644
index 000000000..40866e636
--- /dev/null
+++ b/spec/components/polls/callout_component_spec.rb
@@ -0,0 +1,27 @@
+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
diff --git a/spec/components/polls/form_component_spec.rb b/spec/components/polls/form_component_spec.rb
index 754b7f72e..c6dd44b0b 100644
--- a/spec/components/polls/form_component_spec.rb
+++ b/spec/components/polls/form_component_spec.rb
@@ -20,6 +20,19 @@ describe Polls::FormComponent do
expect(page).to have_button "Vote", disabled: true
end
+ it "renders disabled answers to unverified users" do
+ sign_in(create(:user, :incomplete_verification))
+
+ render_inline Polls::FormComponent.new(web_vote)
+
+ page.find("fieldset[disabled]") do |fieldset|
+ expect(fieldset).to have_field "Yes"
+ expect(fieldset).to have_field "No"
+ end
+
+ expect(page).to have_button "Vote", disabled: true
+ end
+
context "expired poll" do
let(:poll) { create(:poll, :expired) }
diff --git a/spec/system/polls/polls_spec.rb b/spec/system/polls/polls_spec.rb
index 49043ccf2..5d9c55e3d 100644
--- a/spec/system/polls/polls_spec.rb
+++ b/spec/system/polls/polls_spec.rb
@@ -168,14 +168,6 @@ describe "Polls" do
end
end
- scenario "Non-logged in users" do
- create(:poll_question, :yes_no, poll: poll)
-
- visit poll_path(poll)
-
- expect(page).to have_content("You must sign in or sign up to participate")
- end
-
scenario "Level 1 users" do
poll.update!(geozone_restricted_to: [geozone])
create(:poll_question, :yes_no, poll: poll)
@@ -186,17 +178,6 @@ describe "Polls" do
expect(page).to have_content("You must verify your account in order to answer")
end
- scenario "Level 2 users in an expired poll" do
- expired_poll = create(:poll, :expired)
- create(:poll_question, :yes_no, poll: expired_poll)
-
- login_as(create(:user, :level_two, geozone: geozone))
-
- visit poll_path(expired_poll)
-
- expect(page).to have_content("This poll has finished")
- end
-
scenario "Level 2 users answering" do
poll.update!(geozone_restricted_to: [geozone])
create(:poll_question, :yes_no, poll: poll, title: "Do you agree?")
diff --git a/spec/system/polls/voter_spec.rb b/spec/system/polls/voter_spec.rb
index 2dd53d315..0a4f2947f 100644
--- a/spec/system/polls/voter_spec.rb
+++ b/spec/system/polls/voter_spec.rb
@@ -28,22 +28,6 @@ describe "Voter" do
"If you vote again it will be overwritten."
end
- scenario "Voting via web as unverified user" do
- user = create(:user, :incomplete_verification)
-
- login_as user
- visit poll_path(poll)
-
- within_fieldset "Is this question stupid?" do
- expect(page).to have_field "Yes", type: :radio, disabled: true
- expect(page).to have_field "No", type: :radio, disabled: true
- end
-
- 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
-
scenario "Voting in booth" do
admin_user = admin.user
login_through_form_as_officer(officer)