diff --git a/app/components/polls/questions/answers_component.html.erb b/app/components/polls/questions/answers_component.html.erb index 91be9ab15..053a514ad 100644 --- a/app/components/polls/questions/answers_component.html.erb +++ b/app/components/polls/questions/answers_component.html.erb @@ -1,7 +1,7 @@
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %> <% question_answers.each do |question_answer| %> - <% if already_answered?(question_answer) && !voted_before_sign_in? %> + <% if already_answered?(question_answer) %> "> <%= question_answer.title %> diff --git a/app/components/polls/questions/answers_component.rb b/app/components/polls/questions/answers_component.rb index f51ad4e7f..e007dd1c2 100644 --- a/app/components/polls/questions/answers_component.rb +++ b/app/components/polls/questions/answers_component.rb @@ -10,12 +10,6 @@ class Polls::Questions::AnswersComponent < ApplicationComponent user_answers.find_by(answer: question_answer.title).present? end - def voted_before_sign_in? - user_answers.any? do |vote| - vote.updated_at < current_user.current_sign_in_at - end - end - def question_answers question.question_answers end diff --git a/spec/components/polls/questions/answers_component_spec.rb b/spec/components/polls/questions/answers_component_spec.rb index e0a543a16..6fadded57 100644 --- a/spec/components/polls/questions/answers_component_spec.rb +++ b/spec/components/polls/questions/answers_component_spec.rb @@ -22,7 +22,6 @@ describe Polls::Questions::AnswersComponent do it "renders a span instead of a button for existing user answers" do user = create(:user, :verified) - allow(user).to receive(:current_sign_in_at).and_return(user.created_at) create(:poll_answer, author: user, question: question, answer: "Yes") sign_in(user) @@ -33,18 +32,6 @@ describe Polls::Questions::AnswersComponent do expect(page).to have_button "No" end - it "hides current answer and shows buttons in successive sessions" do - user = create(:user, :verified) - create(:poll_answer, author: user, question: question, answer: "Yes") - allow(user).to receive(:current_sign_in_at).and_return(Time.current) - sign_in(user) - - render_inline Polls::Questions::AnswersComponent.new(question) - - expect(page).to have_button "Yes" - expect(page).to have_button "No" - end - it "when user is not signed in, renders answers links pointing to user sign in path" do render_inline Polls::Questions::AnswersComponent.new(question) diff --git a/spec/system/polls/polls_spec.rb b/spec/system/polls/polls_spec.rb index 743b342b1..59ee5b319 100644 --- a/spec/system/polls/polls_spec.rb +++ b/spec/system/polls/polls_spec.rb @@ -276,44 +276,6 @@ describe "Polls" do end end - scenario "Level 2 votes, signs out, signs in, votes again" do - poll.update!(geozone_restricted: true) - poll.geozones << geozone - - question = create(:poll_question, :yes_no, poll: poll) - user = create(:user, :level_two, geozone: geozone) - - login_as user - visit poll_path(poll) - - within("#poll_question_#{question.id}_answers") do - click_button "Yes" - - expect(page).not_to have_button "Yes" - expect(page).to have_button "No" - end - - click_link "Sign out" - login_as user - visit poll_path(poll) - within("#poll_question_#{question.id}_answers") do - click_button "Yes" - - expect(page).not_to have_button "Yes" - expect(page).to have_button "No" - end - - click_link "Sign out" - login_as user - visit poll_path(poll) - within("#poll_question_#{question.id}_answers") do - click_button "No" - - expect(page).not_to have_button "No" - expect(page).to have_button "Yes" - end - end - scenario "Shows SDG tags when feature is enabled" do Setting["feature.sdg"] = true Setting["sdg.process.polls"] = true diff --git a/spec/system/polls/voter_spec.rb b/spec/system/polls/voter_spec.rb index a629dcdf6..5d8daef34 100644 --- a/spec/system/polls/voter_spec.rb +++ b/spec/system/polls/voter_spec.rb @@ -163,31 +163,6 @@ describe "Voter" do expect(page).to have_content "1" end end - - scenario "Trying to vote in web again" do - login_as user - vote_for_poll_via_web(poll, question, answer_yes.title) - expect(Poll::Voter.count).to eq(1) - - visit poll_path(poll) - - 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).not_to have_button(answer_yes.title) - end - - unfreeze_time - - click_link "Sign out" - - login_as user - visit poll_path(poll) - - within("#poll_question_#{question.id}_answers") do - expect(page).to have_button(answer_yes.title) - expect(page).to have_button(answer_no.title) - end - end end scenario "Voting in poll and then verifiying account" do