Check exact array contents instead of inclusion

We're using `eq` and `match_array` in most places, but there were a few
places where we were still checking each element is included in the
array. This is a bit dangerous, because the array could have duplicate
elements, and we wouldn't detect them with `include`.
This commit is contained in:
Javi Martín
2019-09-26 19:54:26 +02:00
parent 9f0088396e
commit fd1325768f
21 changed files with 71 additions and 97 deletions

View File

@@ -73,7 +73,7 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag) proposal.tag_list.add(tag)
proposal.save proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to include(tag) expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag]
end end
it "returns tags whose kind is 'category' and have at least one tagging whose taggable is not hidden" do it "returns tags whose kind is 'category' and have at least one tagging whose taggable is not hidden" do
@@ -82,7 +82,7 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag) proposal.tag_list.add(tag)
proposal.save proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to include(tag) expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag]
end end
it "blocks other kinds of tags" do it "blocks other kinds of tags" do
@@ -126,7 +126,7 @@ describe ActsAsTaggableOn do
proposal.tag_list.add(tag) proposal.tag_list.add(tag)
proposal.save proposal.save
expect(ActsAsTaggableOn::Tag.public_for_api).to include(tag) expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag]
proposal.delete proposal.delete

View File

@@ -14,7 +14,7 @@ describe EmailDigest do
email_digest = EmailDigest.new(user1) email_digest = EmailDigest.new(user1)
expect(email_digest.notifications).to include(notification1) expect(email_digest.notifications).to eq [notification1]
expect(email_digest.notifications).not_to include(notification2) expect(email_digest.notifications).not_to include(notification2)
end end
@@ -29,7 +29,7 @@ describe EmailDigest do
email_digest = EmailDigest.new(user) email_digest = EmailDigest.new(user)
expect(email_digest.notifications).to include(notification1) expect(email_digest.notifications).to eq [notification1]
expect(email_digest.notifications).not_to include(notification2) expect(email_digest.notifications).not_to include(notification2)
end end

View File

@@ -10,7 +10,7 @@ describe UserSegments do
active_user = create(:user) active_user = create(:user)
erased_user = create(:user, erased_at: Time.current) erased_user = create(:user, erased_at: Time.current)
expect(UserSegments.all_users).to include active_user expect(UserSegments.all_users).to eq [active_user]
expect(UserSegments.all_users).not_to include erased_user expect(UserSegments.all_users).not_to include erased_user
end end
end end
@@ -21,7 +21,7 @@ describe UserSegments do
active_admin = create(:administrator).user active_admin = create(:administrator).user
erased_user = create(:user, erased_at: Time.current) erased_user = create(:user, erased_at: Time.current)
expect(UserSegments.administrators).to include active_admin expect(UserSegments.administrators).to eq [active_admin]
expect(UserSegments.administrators).not_to include active_user expect(UserSegments.administrators).not_to include active_user
expect(UserSegments.administrators).not_to include erased_user expect(UserSegments.administrators).not_to include erased_user
end end
@@ -34,9 +34,8 @@ describe UserSegments do
create(:proposal, :retired, author: user3) create(:proposal, :retired, author: user3)
all_proposal_authors = UserSegments.all_proposal_authors all_proposal_authors = UserSegments.all_proposal_authors
expect(all_proposal_authors).to include user1
expect(all_proposal_authors).to include user2 expect(all_proposal_authors).to match_array [user1, user2, user3]
expect(all_proposal_authors).to include user3
end end
it "does not return duplicated users" do it "does not return duplicated users" do
@@ -55,8 +54,8 @@ describe UserSegments do
create(:proposal, author: user1) create(:proposal, author: user1)
proposal_authors = UserSegments.proposal_authors proposal_authors = UserSegments.proposal_authors
expect(proposal_authors).to include user1
expect(proposal_authors).not_to include user2 expect(proposal_authors).to eq [user1]
end end
it "does not return duplicated users" do it "does not return duplicated users" do
@@ -75,8 +74,8 @@ describe UserSegments do
investment.update(budget: budget) investment.update(budget: budget)
investment_authors = UserSegments.investment_authors investment_authors = UserSegments.investment_authors
expect(investment_authors).to include user1
expect(investment_authors).not_to include user2 expect(investment_authors).to eq [user1]
end end
it "does not return duplicated users" do it "does not return duplicated users" do
@@ -113,11 +112,7 @@ describe UserSegments do
unfeasible_investment_finished.update(budget: budget) unfeasible_investment_finished.update(budget: budget)
investment_authors = UserSegments.feasible_and_undecided_investment_authors investment_authors = UserSegments.feasible_and_undecided_investment_authors
expect(investment_authors).to include user1 expect(investment_authors).to match_array [user1, user2, user3, user4, user5]
expect(investment_authors).to include user2
expect(investment_authors).to include user3
expect(investment_authors).to include user4
expect(investment_authors).to include user5
expect(investment_authors).not_to include user6 expect(investment_authors).not_to include user6
end end
@@ -142,8 +137,8 @@ describe UserSegments do
unselected_investment.update(budget: budget) unselected_investment.update(budget: budget)
investment_authors = UserSegments.selected_investment_authors investment_authors = UserSegments.selected_investment_authors
expect(investment_authors).to include user1
expect(investment_authors).not_to include user2 expect(investment_authors).to eq [user1]
end end
it "does not return duplicated users" do it "does not return duplicated users" do
@@ -167,8 +162,8 @@ describe UserSegments do
selected_investment.update(budget: budget) selected_investment.update(budget: budget)
investment_authors = UserSegments.winner_investment_authors investment_authors = UserSegments.winner_investment_authors
expect(investment_authors).to include user1
expect(investment_authors).not_to include user2 expect(investment_authors).to eq [user1]
end end
it "does not return duplicated users" do it "does not return duplicated users" do
@@ -191,7 +186,8 @@ describe UserSegments do
investment1.update(budget: budget) investment1.update(budget: budget)
current_budget_investments = UserSegments.current_budget_investments current_budget_investments = UserSegments.current_budget_investments
expect(current_budget_investments).to include investment1
expect(current_budget_investments).to eq [investment1]
expect(current_budget_investments).not_to include investment2 expect(current_budget_investments).not_to include investment2
end end
end end

View File

@@ -75,8 +75,7 @@ describe Budget::Ballot::Line do
ballot_lines_by_investment = Budget::Ballot::Line.by_investment(investment1.id) ballot_lines_by_investment = Budget::Ballot::Line.by_investment(investment1.id)
expect(ballot_lines_by_investment).to include ballot_line1 expect(ballot_lines_by_investment).to match_array [ballot_line1, ballot_line2]
expect(ballot_lines_by_investment).to include ballot_line2
expect(ballot_lines_by_investment).not_to include ballot_line3 expect(ballot_lines_by_investment).not_to include ballot_line3
end end

View File

@@ -319,8 +319,7 @@ describe Budget::Investment do
investments_by_budget = Budget::Investment.by_budget(budget1) investments_by_budget = Budget::Investment.by_budget(budget1)
expect(investments_by_budget).to include investment1 expect(investments_by_budget).to match_array [investment1, investment2]
expect(investments_by_budget).to include investment2
expect(investments_by_budget).not_to include investment3 expect(investments_by_budget).not_to include investment3
end end
end end
@@ -656,8 +655,7 @@ describe Budget::Investment do
results = Budget::Investment.apply_filters_and_search(budget, search: "health") results = Budget::Investment.apply_filters_and_search(budget, search: "health")
expect(results).to include investment1 expect(results).to match_array [investment1, investment2]
expect(results).to include investment2
expect(results).not_to include investment3 expect(results).not_to include investment3
end end
end end
@@ -935,7 +933,7 @@ describe Budget::Investment do
inv2 = create(:budget_investment) inv2 = create(:budget_investment)
create(:vote, votable: inv1) create(:vote, votable: inv1)
expect(Budget::Investment.with_supports).to include(inv1) expect(Budget::Investment.with_supports).to eq [inv1]
expect(Budget::Investment.with_supports).not_to include(inv2) expect(Budget::Investment.with_supports).not_to include(inv2)
end end
end end

View File

@@ -139,7 +139,7 @@ describe Comment do
it "returns comments" do it "returns comments" do
comment = create(:comment) comment = create(:comment)
expect(Comment.public_for_api).to include(comment) expect(Comment.public_for_api).to eq [comment]
end end
it "does not return hidden comments" do it "does not return hidden comments" do
@@ -149,10 +149,9 @@ describe Comment do
end end
it "returns comments on debates" do it "returns comments on debates" do
debate = create(:debate) comment = create(:comment, commentable: create(:debate))
comment = create(:comment, commentable: debate)
expect(Comment.public_for_api).to include(comment) expect(Comment.public_for_api).to eq [comment]
end end
it "does not return comments on hidden debates" do it "does not return comments on hidden debates" do
@@ -166,7 +165,7 @@ describe Comment do
proposal = create(:proposal) proposal = create(:proposal)
comment = create(:comment, commentable: proposal) comment = create(:comment, commentable: proposal)
expect(Comment.public_for_api).to include(comment) expect(Comment.public_for_api).to eq [comment]
end end
it "does not return comments on hidden proposals" do it "does not return comments on hidden proposals" do

View File

@@ -707,7 +707,8 @@ describe Debate do
describe "#last_week" do describe "#last_week" do
it "returns debates created this week" do it "returns debates created this week" do
debate = create(:debate) debate = create(:debate)
expect(Debate.last_week.all).to include debate
expect(Debate.last_week.all).to eq [debate]
end end
it "does not show debates created more than a week ago" do it "does not show debates created more than a week ago" do
@@ -725,7 +726,8 @@ describe Debate do
describe "public_for_api scope" do describe "public_for_api scope" do
it "returns debates" do it "returns debates" do
debate = create(:debate) debate = create(:debate)
expect(Debate.public_for_api).to include(debate)
expect(Debate.public_for_api).to eq [debate]
end end
it "does not return hidden debates" do it "does not return hidden debates" do

View File

@@ -114,9 +114,7 @@ describe Legislation::Process do
it "filters past" do it "filters past" do
past_processes = ::Legislation::Process.past past_processes = ::Legislation::Process.past
expect(past_processes).to include(process_3) expect(past_processes).to eq [process_3]
expect(past_processes).not_to include(process_2)
expect(past_processes).not_to include(process_1)
end end
end end

View File

@@ -59,7 +59,7 @@ describe LocalCensusRecord do
context "search" do context "search" do
it "filter document_numbers by given terms" do it "filter document_numbers by given terms" do
expect(LocalCensusRecord.search("A")).to include a_local_census_record expect(LocalCensusRecord.search("A")).to eq [a_local_census_record]
expect(LocalCensusRecord.search("A")).not_to include b_local_census_record expect(LocalCensusRecord.search("A")).not_to include b_local_census_record
end end

View File

@@ -51,7 +51,7 @@ describe Milestone do
published_in_application_time_zone = create(:milestone, published_in_application_time_zone = create(:milestone,
publication_date: Date.current) publication_date: Date.current)
expect(Milestone.published).to include(published_in_application_time_zone) expect(Milestone.published).to eq [published_in_application_time_zone]
expect(Milestone.published).not_to include(published_in_local_time_zone) expect(Milestone.published).not_to include(published_in_local_time_zone)
end end
end end

View File

@@ -25,8 +25,7 @@ describe Notification do
read_notification2 = create(:notification, :read) read_notification2 = create(:notification, :read)
unread_notification = create(:notification) unread_notification = create(:notification)
expect(Notification.read).to include read_notification1 expect(Notification.read).to match_array [read_notification1, read_notification2]
expect(Notification.read).to include read_notification2
expect(Notification.read).not_to include unread_notification expect(Notification.read).not_to include unread_notification
end end
end end
@@ -37,8 +36,7 @@ describe Notification do
unread_notification1 = create(:notification) unread_notification1 = create(:notification)
unread_notification2 = create(:notification) unread_notification2 = create(:notification)
expect(Notification.unread).to include unread_notification1 expect(Notification.unread).to match_array [unread_notification1, unread_notification2]
expect(Notification.unread).to include unread_notification2
expect(Notification.unread).not_to include read_notification expect(Notification.unread).not_to include read_notification
end end
end end

View File

@@ -30,7 +30,7 @@ describe Poll::Booth do
booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)]) booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)])
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)]) booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
expect(Poll::Booth.available).to include(booth_for_current_poll) expect(Poll::Booth.available).to eq [booth_for_current_poll]
expect(Poll::Booth.available).not_to include(booth_for_expired_poll) expect(Poll::Booth.available).not_to include(booth_for_expired_poll)
end end

View File

@@ -140,7 +140,7 @@ describe Poll::Officer do
date: Date.current, date: Date.current,
officer: officer) officer: officer)
expect(officer.todays_booths).to include(assignment_with_application_time_zone.booth) expect(officer.todays_booths).to eq [assignment_with_application_time_zone.booth]
expect(officer.todays_booths).not_to include(assignment_with_local_time_zone.booth) expect(officer.todays_booths).not_to include(assignment_with_local_time_zone.booth)
end end
end end

View File

@@ -54,8 +54,7 @@ describe Poll::PairAnswer do
it "returns pair_answers associated to an user" do it "returns pair_answers associated to an user" do
author = pair_answer_1.author author = pair_answer_1.author
expect(Poll::PairAnswer.by_author(author)).to include(pair_answer_1) expect(Poll::PairAnswer.by_author(author)).to eq [pair_answer_1]
expect(Poll::PairAnswer.by_author(author)).not_to include(pair_answer_2)
end end
end end
@@ -65,8 +64,7 @@ describe Poll::PairAnswer do
it "returns pair_answers associated to a question" do it "returns pair_answers associated to a question" do
question = pair_answer_1.question question = pair_answer_1.question
expect(Poll::PairAnswer.by_question(question)).to include(pair_answer_1) expect(Poll::PairAnswer.by_question(question)).to eq [pair_answer_1]
expect(Poll::PairAnswer.by_question(question)).not_to include(pair_answer_2)
end end
end end

View File

@@ -212,9 +212,7 @@ describe Poll do
create(:poll_voter, user: user, poll: poll1) create(:poll_voter, user: user, poll: poll1)
expect(Poll.votable_by(user)).to include(poll2) expect(Poll.votable_by(user)).to match_array [poll2, poll3]
expect(Poll.votable_by(user)).to include(poll3)
expect(Poll.votable_by(user)).not_to include(poll1)
end end
it "returns polls that are answerable by a user" do it "returns polls that are answerable by a user" do
@@ -224,7 +222,7 @@ describe Poll do
allow(Poll).to receive(:answerable_by).and_return(Poll.where(id: poll1)) allow(Poll).to receive(:answerable_by).and_return(Poll.where(id: poll1))
expect(Poll.votable_by(user)).to include(poll1) expect(Poll.votable_by(user)).to eq [poll1]
expect(Poll.votable_by(user)).not_to include(poll2) expect(Poll.votable_by(user)).not_to include(poll2)
end end
@@ -232,7 +230,7 @@ describe Poll do
user = create(:user, :level_two) user = create(:user, :level_two)
poll = create(:poll) poll = create(:poll)
expect(Poll.votable_by(user)).to include(poll) expect(Poll.votable_by(user)).to eq [poll]
end end
end end
@@ -328,7 +326,7 @@ describe Poll do
end end
it "returns overlaping polls for the same proposal" do it "returns overlaping polls for the same proposal" do
expect(Poll.overlaping_with(overlaping_poll)).to include(poll) expect(Poll.overlaping_with(overlaping_poll)).to eq [poll]
end end
it "do not returs non overlaping polls for the same proposal" do it "do not returs non overlaping polls for the same proposal" do
@@ -349,8 +347,7 @@ describe Poll do
poll2 = create(:poll) poll2 = create(:poll)
poll3 = create(:poll, :for_budget) poll3 = create(:poll, :for_budget)
expect(Poll.not_budget).to include(poll1) expect(Poll.not_budget).to match_array [poll1, poll2]
expect(Poll.not_budget).to include(poll2)
expect(Poll.not_budget).not_to include(poll3) expect(Poll.not_budget).not_to include(poll3)
end end

View File

@@ -24,10 +24,9 @@ describe ProposalNotification do
describe "public_for_api scope" do describe "public_for_api scope" do
it "returns proposal notifications" do it "returns proposal notifications" do
proposal = create(:proposal) notification = create(:proposal_notification, proposal: create(:proposal))
notification = create(:proposal_notification, proposal: proposal)
expect(ProposalNotification.public_for_api).to include(notification) expect(ProposalNotification.public_for_api).to eq [notification]
end end
it "blocks proposal notifications whose proposal is hidden" do it "blocks proposal notifications whose proposal is hidden" do

View File

@@ -449,8 +449,7 @@ describe Proposal do
create(:vote, voter: voter1, votable: proposal) create(:vote, voter: voter1, votable: proposal)
create(:vote, voter: voter2, votable: proposal) create(:vote, voter: voter2, votable: proposal)
expect(proposal.voters).to include(voter1) expect(proposal.voters).to match_array [voter1, voter2]
expect(proposal.voters).to include(voter2)
expect(proposal.voters).not_to include(voter3) expect(proposal.voters).not_to include(voter3)
end end
@@ -463,8 +462,7 @@ describe Proposal do
create(:vote, voter: voter2, votable: proposal) create(:vote, voter: voter2, votable: proposal)
voter2.erase voter2.erase
expect(proposal.voters).to include(voter1) expect(proposal.voters).to eq [voter1]
expect(proposal.voters).not_to include(voter2)
end end
it "does not return users that have been blocked" do it "does not return users that have been blocked" do
@@ -476,8 +474,7 @@ describe Proposal do
create(:vote, voter: voter2, votable: proposal) create(:vote, voter: voter2, votable: proposal)
voter2.block voter2.block
expect(proposal.voters).to include(voter1) expect(proposal.voters).to eq [voter1]
expect(proposal.voters).not_to include(voter2)
end end
end end
@@ -743,7 +740,8 @@ describe Proposal do
describe "#last_week" do describe "#last_week" do
it "returns proposals created this week" do it "returns proposals created this week" do
proposal = create(:proposal) proposal = create(:proposal)
expect(Proposal.last_week).to include(proposal)
expect(Proposal.last_week).to eq [proposal]
end end
it "does not return proposals created more than a week ago" do it "does not return proposals created more than a week ago" do
@@ -760,7 +758,7 @@ describe Proposal do
create(:tag, :category, name: "culture") create(:tag, :category, name: "culture")
proposal = create(:proposal, tag_list: "culture") proposal = create(:proposal, tag_list: "culture")
expect(Proposal.for_summary.values.flatten).to include(proposal) expect(Proposal.for_summary.values.flatten).to eq [proposal]
end end
it "does not return proposals tagged without a category" do it "does not return proposals tagged without a category" do
@@ -777,7 +775,7 @@ describe Proposal do
california = create(:geozone, name: "california") california = create(:geozone, name: "california")
proposal = create(:proposal, geozone: california) proposal = create(:proposal, geozone: california)
expect(Proposal.for_summary.values.flatten).to include(proposal) expect(Proposal.for_summary.values.flatten).to eq [proposal]
end end
it "does not return proposals without a geozone" do it "does not return proposals without a geozone" do
@@ -791,7 +789,8 @@ describe Proposal do
it "returns proposals created this week" do it "returns proposals created this week" do
create(:tag, :category, name: "culture") create(:tag, :category, name: "culture")
proposal = create(:proposal, tag_list: "culture") proposal = create(:proposal, tag_list: "culture")
expect(Proposal.for_summary.values.flatten).to include(proposal)
expect(Proposal.for_summary.values.flatten).to eq [proposal]
end end
it "does not return proposals created more than a week ago" do it "does not return proposals created more than a week ago" do
@@ -904,7 +903,8 @@ describe Proposal do
describe "public_for_api scope" do describe "public_for_api scope" do
it "returns proposals" do it "returns proposals" do
proposal = create(:proposal) proposal = create(:proposal)
expect(Proposal.public_for_api).to include(proposal)
expect(Proposal.public_for_api).to eq [proposal]
end end
it "does not return hidden proposals" do it "does not return hidden proposals" do

View File

@@ -390,8 +390,7 @@ describe User do
user2 = create(:user, erased_at: nil) user2 = create(:user, erased_at: nil)
user3 = create(:user, erased_at: Time.current) user3 = create(:user, erased_at: Time.current)
expect(User.active).to include(user1) expect(User.active).to match_array [user1, user2]
expect(User.active).to include(user2)
expect(User.active).not_to include(user3) expect(User.active).not_to include(user3)
end end
@@ -401,8 +400,7 @@ describe User do
user3 = create(:user) user3 = create(:user)
user3.block user3.block
expect(User.active).to include(user1) expect(User.active).to match_array [user1, user2]
expect(User.active).to include(user2)
expect(User.active).not_to include(user3) expect(User.active).not_to include(user3)
end end
@@ -415,8 +413,7 @@ describe User do
user2 = create(:user, erased_at: Time.current) user2 = create(:user, erased_at: Time.current)
user3 = create(:user, erased_at: nil) user3 = create(:user, erased_at: nil)
expect(User.erased).to include(user1) expect(User.erased).to match_array [user1, user2]
expect(User.erased).to include(user2)
expect(User.erased).not_to include(user3) expect(User.erased).not_to include(user3)
end end

View File

@@ -46,7 +46,7 @@ describe Vote do
debate = create(:debate) debate = create(:debate)
vote = create(:vote, votable: debate) vote = create(:vote, votable: debate)
expect(Vote.public_for_api).to include(vote) expect(Vote.public_for_api).to eq [vote]
end end
it "blocks votes on hidden debates" do it "blocks votes on hidden debates" do
@@ -60,7 +60,7 @@ describe Vote do
proposal = create(:proposal) proposal = create(:proposal)
vote = create(:vote, votable: proposal) vote = create(:vote, votable: proposal)
expect(Vote.public_for_api).to include(vote) expect(Vote.public_for_api).to eq [vote]
end end
it "blocks votes on hidden proposals" do it "blocks votes on hidden proposals" do
@@ -74,7 +74,7 @@ describe Vote do
comment = create(:comment) comment = create(:comment)
vote = create(:vote, votable: comment) vote = create(:vote, votable: comment)
expect(Vote.public_for_api).to include(vote) expect(Vote.public_for_api).to eq [vote]
end end
it "blocks votes on hidden comments" do it "blocks votes on hidden comments" do

View File

@@ -31,8 +31,7 @@ describe Widget::Card do
card2 = create(:widget_card, header: false) card2 = create(:widget_card, header: false)
page_card = create(:widget_card, header: false, page: create(:site_customization_page)) page_card = create(:widget_card, header: false, page: create(:site_customization_page))
expect(Widget::Card.body).to include(card1) expect(Widget::Card.body).to match_array [card1, card2]
expect(Widget::Card.body).to include(card2)
expect(Widget::Card.body).not_to include(header) expect(Widget::Card.body).not_to include(header)
expect(Widget::Card.body).not_to include(page_card) expect(Widget::Card.body).not_to include(page_card)
end end

View File

@@ -7,7 +7,7 @@ shared_examples_for "verifiable" do
user1 = create(:user, verified_at: Time.current) user1 = create(:user, verified_at: Time.current)
user2 = create(:user, verified_at: nil) user2 = create(:user, verified_at: nil)
expect(model.level_three_verified).to include(user1) expect(model.level_three_verified).to eq [user1]
expect(model.level_three_verified).not_to include(user2) expect(model.level_three_verified).not_to include(user2)
end end
end end
@@ -19,10 +19,9 @@ shared_examples_for "verifiable" do
user3 = create(:user, confirmed_phone: nil, residence_verified_at: Time.current) user3 = create(:user, confirmed_phone: nil, residence_verified_at: Time.current)
user4 = create(:user, level_two_verified_at: Time.current) user4 = create(:user, level_two_verified_at: Time.current)
expect(model.level_two_verified).to include(user1) expect(model.level_two_verified).to match_array [user1, user4]
expect(model.level_two_verified).not_to include(user2) expect(model.level_two_verified).not_to include(user2)
expect(model.level_two_verified).not_to include(user3) expect(model.level_two_verified).not_to include(user3)
expect(model.level_two_verified).to include(user4)
end end
end end
@@ -34,11 +33,9 @@ shared_examples_for "verifiable" do
user4 = create(:user, confirmed_phone: nil, residence_verified_at: Time.current) user4 = create(:user, confirmed_phone: nil, residence_verified_at: Time.current)
user5 = create(:user, level_two_verified_at: Time.current) user5 = create(:user, level_two_verified_at: Time.current)
expect(model.level_two_or_three_verified).to include(user1) expect(model.level_two_or_three_verified).to match_array [user1, user2, user5]
expect(model.level_two_or_three_verified).to include(user2)
expect(model.level_two_or_three_verified).not_to include(user3) expect(model.level_two_or_three_verified).not_to include(user3)
expect(model.level_two_or_three_verified).not_to include(user4) expect(model.level_two_or_three_verified).not_to include(user4)
expect(model.level_two_or_three_verified).to include(user5)
end end
end end
@@ -53,9 +50,7 @@ shared_examples_for "verifiable" do
confirmed_phone: "123456789") confirmed_phone: "123456789")
user5 = create(:user, level_two_verified_at: Time.current) user5 = create(:user, level_two_verified_at: Time.current)
expect(model.unverified).to include(user1) expect(model.unverified).to match_array [user1, user2, user3]
expect(model.unverified).to include(user2)
expect(model.unverified).to include(user3)
expect(model.unverified).not_to include(user4) expect(model.unverified).not_to include(user4)
expect(model.unverified).not_to include(user5) expect(model.unverified).not_to include(user5)
end end
@@ -72,8 +67,7 @@ shared_examples_for "verifiable" do
user4 = create(:user, verified_at: Time.current, residence_verified_at: Time.current, user4 = create(:user, verified_at: Time.current, residence_verified_at: Time.current,
unconfirmed_phone: "123456789", confirmed_phone: "123456789") unconfirmed_phone: "123456789", confirmed_phone: "123456789")
expect(model.incomplete_verification).to include(user1) expect(model.incomplete_verification).to match_array [user1, user2]
expect(model.incomplete_verification).to include(user2)
expect(model.incomplete_verification).not_to include(user3) expect(model.incomplete_verification).not_to include(user3)
expect(model.incomplete_verification).not_to include(user4) expect(model.incomplete_verification).not_to include(user4)
end end