From 64dec1368c01038ac06bcc3c2488af8a5880fb40 Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Mon, 10 Jul 2023 11:34:17 +0800 Subject: [PATCH] DEV: Cleanup an old spec (#22503) Introduced in #22297, now clear to remove since we don't have a habit of keeping migration specs. --- ...041219_delete_duplicate_poll_votes_spec.rb | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 plugins/poll/spec/20230614041219_delete_duplicate_poll_votes_spec.rb diff --git a/plugins/poll/spec/20230614041219_delete_duplicate_poll_votes_spec.rb b/plugins/poll/spec/20230614041219_delete_duplicate_poll_votes_spec.rb deleted file mode 100644 index 2435893dcf6..00000000000 --- a/plugins/poll/spec/20230614041219_delete_duplicate_poll_votes_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -require Rails.root.join("plugins/poll/db/migrate/20230614041219_delete_duplicate_poll_votes.rb") - -describe DeleteDuplicatePollVotes do - subject(:up) { described_class.new.up } - - fab!(:user) { Fabricate(:user, username: "galahad", email: "galahad@knights.com") } - - fab!(:poll_regular) { Fabricate(:poll_regular) } - fab!(:poll_regular_option1) { Fabricate(:poll_option, poll: poll_regular, html: "Option 1") } - fab!(:poll_regular_option2) { Fabricate(:poll_option, poll: poll_regular, html: "Option 2") } - - fab!(:poll_multiple) { Fabricate(:poll_multiple) } - fab!(:poll_multiple_optionA) { Fabricate(:poll_option, poll: poll_multiple, html: "Option A") } - fab!(:poll_multiple_optionB) { Fabricate(:poll_option, poll: poll_multiple, html: "Option B") } - - it "deletes the older duplicate poll vote for regular polls" do - Fabricate( - :poll_vote, - poll: poll_regular, - user: user, - poll_option: poll_regular_option1, - created_at: 2.years.ago, - ) - Fabricate( - :poll_vote, - poll: poll_regular, - user: user, - poll_option: poll_regular_option2, - created_at: 1.year.ago, - ) - - expect { up }.to change { PollVote.count }.from(2).to(1) - expect(PollVote.first.poll_option).to eq(poll_regular_option2) - end - - it "keeps non-duplicates" do - Fabricate(:poll_vote, poll: poll_regular, user: user, poll_option: poll_regular_option1) - - expect { up }.not_to change { PollVote.count } - end - - it "keeps votes on polls with type multiple" do - Fabricate(:poll_vote, poll: poll_multiple, user: user, poll_option: poll_multiple_optionA) - Fabricate(:poll_vote, poll: poll_multiple, user: user, poll_option: poll_multiple_optionB) - - expect { up }.not_to change { PollVote.count } - end -end