diff --git a/.erb-lint.yml b/.erb-lint.yml index 5e93f2fae..07676c3fc 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -38,5 +38,9 @@ linters: Enabled: false Lint/UselessAssignment: Enabled: false + Rails/HttpStatus: + Enabled: true + Exclude: + - app/views/dashboard/* Rails/OutputSafety: Enabled: false diff --git a/.rubocop.yml b/.rubocop.yml index e0429c99f..ffe504b19 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -443,6 +443,9 @@ Rails/PluralizationGrammar: Rails/Presence: Enabled: true +Rails/RedundantActiveRecordAllMethod: + Enabled: true + Rails/RedundantTravelBack: Enabled: true @@ -466,6 +469,9 @@ Rails/SaveBang: Enabled: true Severity: refactor +Rails/SelectMap: + Enabled: true + Rails/SkipsModelValidations: Enabled: true ForbiddenMethods: @@ -689,6 +695,7 @@ Style/InvertibleUnlessCondition: Enabled: true InverseMethods: :blank?: :present? + :include?: ~ :present?: :blank? :zero?: ~ diff --git a/Gemfile b/Gemfile index 69cc9ddf9..b8edf42b3 100644 --- a/Gemfile +++ b/Gemfile @@ -109,7 +109,7 @@ group :development do gem "rubocop-capybara", "~> 2.19.0", require: false gem "rubocop-factory_bot", "~> 2.24.0", require: false gem "rubocop-performance", "~> 1.19.1", require: false - gem "rubocop-rails", "~> 2.20.2", require: false + gem "rubocop-rails", "~> 2.21.2", require: false gem "rubocop-rspec", "~> 2.24.1", require: false gem "rvm1-capistrano3", "~> 1.4.0", require: false gem "scss_lint", "~> 0.60.0", require: false diff --git a/Gemfile.lock b/Gemfile.lock index f5694dce5..ff21da3d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -536,7 +536,7 @@ GEM rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.20.2) + rubocop-rails (2.21.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -754,7 +754,7 @@ DEPENDENCIES rubocop-capybara (~> 2.19.0) rubocop-factory_bot (~> 2.24.0) rubocop-performance (~> 1.19.1) - rubocop-rails (~> 2.20.2) + rubocop-rails (~> 2.21.2) rubocop-rspec (~> 2.24.1) rvm1-capistrano3 (~> 1.4.0) sassc-rails (~> 2.1.2) diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index 04c3e74df..c4d68ae43 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -115,7 +115,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController end def load_valuator_groups - @valuator_groups = ValuatorGroup.all.order(name: :asc) + @valuator_groups = ValuatorGroup.order(name: :asc) end def load_tags diff --git a/app/controllers/admin/geozones_controller.rb b/app/controllers/admin/geozones_controller.rb index 794a5985f..a9d2e652c 100644 --- a/app/controllers/admin/geozones_controller.rb +++ b/app/controllers/admin/geozones_controller.rb @@ -4,7 +4,7 @@ class Admin::GeozonesController < Admin::BaseController load_and_authorize_resource def index - @geozones = Geozone.all.order(Arel.sql("LOWER(name)")) + @geozones = Geozone.order(Arel.sql("LOWER(name)")) end def new diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index 7d9a462ea..1ad6d28e8 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -46,7 +46,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController end def manage - @booths = ::Poll::Booth.all.order(name: :asc).page(params[:page]).per(300) + @booths = ::Poll::Booth.order(name: :asc).page(params[:page]).per(300) @poll = Poll.find(params[:poll_id]) end diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index 82e45a182..71432bb2a 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -7,7 +7,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController @officers = ::Poll::Officer .includes(:user) .order("users.username") - .where(id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id)) + .where(id: @poll.officer_assignments.distinct.pluck(:officer_id)) .page(params[:page]) .per(50) end diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 68ba02a01..3f1d65e55 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -59,7 +59,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController private def load_geozones - @geozones = Geozone.all.order(:name) + @geozones = Geozone.order(:name) end def poll_params diff --git a/app/controllers/admin/signature_sheets_controller.rb b/app/controllers/admin/signature_sheets_controller.rb index cc417f6b8..e75a3ae90 100644 --- a/app/controllers/admin/signature_sheets_controller.rb +++ b/app/controllers/admin/signature_sheets_controller.rb @@ -1,6 +1,6 @@ class Admin::SignatureSheetsController < Admin::BaseController def index - @signature_sheets = SignatureSheet.all.order(created_at: :desc) + @signature_sheets = SignatureSheet.order(created_at: :desc) end def new diff --git a/app/controllers/admin/valuator_groups_controller.rb b/app/controllers/admin/valuator_groups_controller.rb index d2b23e60b..461207a41 100644 --- a/app/controllers/admin/valuator_groups_controller.rb +++ b/app/controllers/admin/valuator_groups_controller.rb @@ -1,6 +1,6 @@ class Admin::ValuatorGroupsController < Admin::BaseController def index - @groups = ValuatorGroup.all.page(params[:page]) + @groups = ValuatorGroup.page(params[:page]) end def show diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 86ea1dde8..1bd7fcfa5 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -83,7 +83,7 @@ module CommentableActions end def load_geozones - @geozones = Geozone.all.order(name: :asc) + @geozones = Geozone.order(name: :asc) end def set_geozone diff --git a/app/helpers/geozones_helper.rb b/app/helpers/geozones_helper.rb index 20831986d..401eb4091 100644 --- a/app/helpers/geozones_helper.rb +++ b/app/helpers/geozones_helper.rb @@ -4,6 +4,6 @@ module GeozonesHelper end def geozone_select_options - Geozone.all.order(name: :asc).map { |g| [g.name, g.id] } + Geozone.order(name: :asc).map { |g| [g.name, g.id] } end end diff --git a/app/models/concerns/statisticable.rb b/app/models/concerns/statisticable.rb index 9b32b22b3..5d3c67a07 100644 --- a/app/models/concerns/statisticable.rb +++ b/app/models/concerns/statisticable.rb @@ -171,7 +171,7 @@ module Statisticable end def geozones - Geozone.all.order("name") + Geozone.order("name") end def geozone_stats diff --git a/db/dev_seeds/budgets.rb b/db/dev_seeds/budgets.rb index bdae27338..e0d81253d 100644 --- a/db/dev_seeds/budgets.rb +++ b/db/dev_seeds/budgets.rb @@ -48,7 +48,7 @@ section "Creating Budgets" do end end - Budget.all.each do |budget| + Budget.find_each do |budget| city_group = budget.groups.create!( random_locales_attributes(name: -> { I18n.t("seeds.budgets.groups.all_city") }) ) @@ -94,7 +94,7 @@ end section "Creating Investments" do tags = Faker::Lorem.words(number: 10) 100.times do - heading = Budget::Heading.all.sample + heading = Budget::Heading.sample translation_attributes = random_locales.each_with_object({}) do |locale, attributes| attributes["title_#{locale.to_s.underscore}"] = "Title for locale #{locale}" @@ -102,7 +102,7 @@ section "Creating Investments" do end investment = Budget::Investment.create!({ - author: User.all.sample, + author: User.sample, heading: heading, group: heading.group, budget: heading.group.budget, @@ -145,9 +145,9 @@ end section "Winner Investments" do budget = Budget.finished.first 50.times do - heading = budget.headings.all.sample + heading = budget.headings.sample investment = Budget::Investment.create!( - author: User.all.sample, + author: User.sample, heading: heading, group: heading.group, budget: heading.group.budget, @@ -169,6 +169,6 @@ end section "Creating Valuation Assignments" do (1..50).to_a.sample.times do - Budget::Investment.all.sample.valuators << Valuator.first + Budget::Investment.sample.valuators << Valuator.first end end diff --git a/db/dev_seeds/comments.rb b/db/dev_seeds/comments.rb index 03bb9bbe0..30e14bba3 100644 --- a/db/dev_seeds/comments.rb +++ b/db/dev_seeds/comments.rb @@ -1,8 +1,8 @@ section "Commenting Investments, Debates & Proposals" do %w[Budget::Investment Debate Proposal].each do |commentable_class| 100.times do - commentable = commentable_class.constantize.all.sample - Comment.create!(user: User.all.sample, + commentable = commentable_class.constantize.sample + Comment.create!(user: User.sample, created_at: rand(commentable.created_at..Time.current), commentable: commentable, body: Faker::Lorem.sentence) @@ -12,8 +12,8 @@ end section "Commenting Comments" do 200.times do - parent = Comment.all.sample - Comment.create!(user: User.all.sample, + parent = Comment.sample + Comment.create!(user: User.sample, created_at: rand(parent.created_at..Time.current), commentable_id: parent.commentable_id, commentable_type: parent.commentable_type, diff --git a/db/dev_seeds/communities.rb b/db/dev_seeds/communities.rb index febf5b9e3..22c15653d 100644 --- a/db/dev_seeds/communities.rb +++ b/db/dev_seeds/communities.rb @@ -5,15 +5,15 @@ end section "Creating Communities Topics" do Community.find_each do |community| - Topic.create(community: community, author: User.all.sample, + Topic.create(community: community, author: User.sample, title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: Faker::Lorem.sentence) end end section "Commenting Community Topics" do 30.times do - author = User.all.sample - topic = Topic.all.sample + author = User.sample + topic = Topic.sample Comment.create!(user: author, created_at: rand(topic.created_at..Time.current), commentable: topic, diff --git a/db/dev_seeds/debates.rb b/db/dev_seeds/debates.rb index 6e2737e09..82d1345d4 100644 --- a/db/dev_seeds/debates.rb +++ b/db/dev_seeds/debates.rb @@ -1,14 +1,14 @@ section "Creating Debates" do tags = Faker::Lorem.words(number: 25) 30.times do - author = User.all.sample + author = User.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" debate = Debate.create!(author: author, title: Faker::Lorem.sentence(word_count: 3).truncate(60), created_at: rand((1.week.ago)..Time.current), description: description, tag_list: tags.sample(3).join(","), - geozone: Geozone.all.sample, + geozone: Geozone.sample, terms_of_service: "1") random_locales.map do |locale| Globalize.with_locale(locale) do @@ -21,7 +21,7 @@ section "Creating Debates" do tags = Tag.where(kind: "category") 30.times do - author = User.all.sample + author = User.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" debate = Debate.create!(author: author, @@ -29,7 +29,7 @@ section "Creating Debates" do created_at: rand((1.week.ago)..Time.current), description: description, tag_list: tags.sample(3).join(","), - geozone: Geozone.all.sample, + geozone: Geozone.sample, terms_of_service: "1") random_locales.map do |locale| Globalize.with_locale(locale) do diff --git a/db/dev_seeds/flags.rb b/db/dev_seeds/flags.rb index a31c0e550..582bd088f 100644 --- a/db/dev_seeds/flags.rb +++ b/db/dev_seeds/flags.rb @@ -1,19 +1,19 @@ section "Flagging Debates & Comments" do 40.times do - debate = Debate.all.sample - flagger = User.where.not(id: debate.author_id).all.sample + debate = Debate.sample + flagger = User.where.not(id: debate.author_id).sample Flag.flag(flagger, debate) end 40.times do - comment = Comment.all.sample - flagger = User.where.not(id: comment.user_id).all.sample + comment = Comment.sample + flagger = User.where.not(id: comment.user_id).sample Flag.flag(flagger, comment) end 40.times do - proposal = Proposal.all.sample - flagger = User.where.not(id: proposal.author_id).all.sample + proposal = Proposal.sample + flagger = User.where.not(id: proposal.author_id).sample Flag.flag(flagger, proposal) end end diff --git a/db/dev_seeds/legislation_proposals.rb b/db/dev_seeds/legislation_proposals.rb index a305219c5..31dc0ff15 100644 --- a/db/dev_seeds/legislation_proposals.rb +++ b/db/dev_seeds/legislation_proposals.rb @@ -3,8 +3,8 @@ section "Creating legislation proposals" do Legislation::Proposal.create!(title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: Faker::Lorem.paragraphs.join("\n\n"), summary: Faker::Lorem.paragraph, - author: User.all.sample, - process: Legislation::Process.all.sample, + author: User.sample, + process: Legislation::Process.sample, terms_of_service: "1", selected: rand <= 1.0 / 3) end diff --git a/db/dev_seeds/milestones.rb b/db/dev_seeds/milestones.rb index 1733468bc..214341921 100644 --- a/db/dev_seeds/milestones.rb +++ b/db/dev_seeds/milestones.rb @@ -11,7 +11,7 @@ section "Creating investment milestones" do rand(1..5).times do milestone = record.milestones.build( publication_date: Date.tomorrow, - status_id: Milestone::Status.all.sample + status_id: Milestone::Status.sample ) random_locales.map do |locale| diff --git a/db/dev_seeds/polls.rb b/db/dev_seeds/polls.rb index 9fc1cfd69..e0b62a899 100644 --- a/db/dev_seeds/polls.rb +++ b/db/dev_seeds/polls.rb @@ -56,7 +56,7 @@ section "Creating Poll Questions & Answers" do Poll.find_each do |poll| (3..5).to_a.sample.times do question_title = Faker::Lorem.sentence(word_count: 3).truncate(60) + "?" - question = Poll::Question.new(author: User.all.sample, + question = Poll::Question.new(author: User.sample, title: question_title, poll: poll) I18n.available_locales.map do |locale| @@ -96,13 +96,13 @@ section "Creating Poll Booths & BoothAssignments" do 20.times do |i| Poll::Booth.create(name: "Booth #{i}", location: Faker::Address.street_address, - polls: [Poll.all.sample]) + polls: [Poll.sample]) end end section "Creating Poll Shifts for Poll Officers" do Poll.find_each do |poll| - Poll::BoothAssignment.where(poll: poll).each do |booth_assignment| + Poll::BoothAssignment.where(poll: poll).find_each do |booth_assignment| scrutiny = (poll.ends_at.to_datetime..poll.ends_at.to_datetime + Poll::RECOUNT_DURATION) Poll::Officer.find_each do |poll_officer| { @@ -125,8 +125,8 @@ end section "Commenting Polls" do 30.times do - author = User.all.sample - poll = Poll.all.sample + author = User.sample + poll = Poll.sample Comment.create!(user: author, created_at: rand(poll.created_at..Time.current), commentable: poll, @@ -136,7 +136,7 @@ end section "Creating Poll Voters" do def vote_poll_on_booth(user, poll) - officer = Poll::Officer.all.sample + officer = Poll::Officer.sample Poll::Voter.create!(document_type: user.document_type, document_number: user.document_number, @@ -230,7 +230,7 @@ end section "Creating Poll Questions from Proposals" do 3.times do - proposal = Proposal.all.sample + proposal = Proposal.sample poll = Poll.current.first question = Poll::Question.new(poll: poll) question.copy_attributes_from_proposal(proposal) @@ -260,7 +260,7 @@ end section "Creating Successful Proposals" do 10.times do - proposal = Proposal.all.sample + proposal = Proposal.sample poll = Poll.current.first question = Poll::Question.new(poll: poll) question.copy_attributes_from_proposal(proposal) diff --git a/db/dev_seeds/proposals.rb b/db/dev_seeds/proposals.rb index 6e48cc25d..a3fc4fa94 100644 --- a/db/dev_seeds/proposals.rb +++ b/db/dev_seeds/proposals.rb @@ -19,7 +19,7 @@ section "Creating Proposals" do 30.times do title = Faker::Lorem.sentence(word_count: 3).truncate(60) summary = Faker::Lorem.sentence(word_count: 3) - author = User.all.sample + author = User.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, @@ -29,7 +29,7 @@ section "Creating Proposals" do description: description, created_at: rand((1.week.ago)..Time.current), tag_list: tags.sample(3).join(","), - geozone: Geozone.all.sample, + geozone: Geozone.sample, terms_of_service: "1", published_at: Time.current) random_locales.map do |locale| @@ -47,7 +47,7 @@ end section "Creating Archived Proposals" do tags = Faker::Lorem.words(number: 25) 5.times do - author = User.all.sample + author = User.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(word_count: 3).truncate(60), @@ -55,7 +55,7 @@ section "Creating Archived Proposals" do responsible_name: Faker::Name.name, description: description, tag_list: tags.sample(3).join(","), - geozone: Geozone.all.sample, + geozone: Geozone.sample, terms_of_service: "1", created_at: Setting.archived_proposals_date_limit, published_at: Setting.archived_proposals_date_limit) @@ -74,7 +74,7 @@ end section "Creating Successful Proposals" do tags = Faker::Lorem.words(number: 25) 10.times do - author = User.all.sample + author = User.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(word_count: 3).truncate(60), @@ -83,7 +83,7 @@ section "Creating Successful Proposals" do description: description, created_at: rand((1.week.ago)..Time.current), tag_list: tags.sample(3).join(","), - geozone: Geozone.all.sample, + geozone: Geozone.sample, terms_of_service: "1", cached_votes_up: Setting["votes_for_proposal_success"], published_at: Time.current) @@ -100,7 +100,7 @@ section "Creating Successful Proposals" do tags = Tag.where(kind: "category") 30.times do - author = User.all.sample + author = User.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, title: Faker::Lorem.sentence(word_count: 4).truncate(60), @@ -109,7 +109,7 @@ section "Creating Successful Proposals" do description: description, created_at: rand((1.week.ago)..Time.current), tag_list: tags.sample(3).join(","), - geozone: Geozone.all.sample, + geozone: Geozone.sample, terms_of_service: "1", published_at: Time.current) random_locales.map do |locale| @@ -128,7 +128,7 @@ section "Creating proposal notifications" do 100.times do |i| ProposalNotification.create!(title: "Proposal notification title #{i}", body: "Proposal notification body #{i}", - author: User.all.sample, - proposal: Proposal.all.sample) + author: User.sample, + proposal: Proposal.sample) end end diff --git a/db/dev_seeds/sdg.rb b/db/dev_seeds/sdg.rb index 7f90b594d..5a65c0265 100644 --- a/db/dev_seeds/sdg.rb +++ b/db/dev_seeds/sdg.rb @@ -32,7 +32,7 @@ section "Creating Sustainable Development Goals" do end section "Creating SDG homepage cards" do - SDG::Phase.all.each do |phase| + SDG::Phase.find_each do |phase| Widget::Card.create!(cardable: phase, title: "#{phase.title} card", link_text: "Link Text", link_url: "/any_path") end diff --git a/db/dev_seeds/users.rb b/db/dev_seeds/users.rb index 679c42cdd..9cbd2a027 100644 --- a/db/dev_seeds/users.rb +++ b/db/dev_seeds/users.rb @@ -110,7 +110,7 @@ section "Creating Users" do confirmed_phone: Faker::PhoneNumber.phone_number, document_number: unique_document_number, document_type: "1", - geozone: Geozone.all.sample) + geozone: Geozone.sample) end if level == 3 user.update(verified_at: Time.current, document_number: unique_document_number) diff --git a/db/dev_seeds/votes.rb b/db/dev_seeds/votes.rb index 749df9be8..eb7711136 100644 --- a/db/dev_seeds/votes.rb +++ b/db/dev_seeds/votes.rb @@ -1,22 +1,22 @@ section "Voting Debates, Proposals & Comments" do not_org_users = User.where.not(id: User.organizations) 100.times do - voter = not_org_users.level_two_or_three_verified.all.sample + voter = not_org_users.level_two_or_three_verified.sample vote = [true, false].sample - debate = Debate.all.sample + debate = Debate.sample debate.vote_by(voter: voter, vote: vote) end 100.times do - voter = not_org_users.all.sample + voter = not_org_users.sample vote = [true, false].sample - comment = Comment.all.sample + comment = Comment.sample comment.vote_by(voter: voter, vote: vote) end 100.times do - voter = not_org_users.level_two_or_three_verified.all.sample - proposal = Proposal.all.sample + voter = not_org_users.level_two_or_three_verified.sample + proposal = Proposal.sample proposal.vote_by(voter: voter, vote: true) end end diff --git a/lib/acts_as_paranoid_aliases.rb b/lib/acts_as_paranoid_aliases.rb index f4c813ab0..369bdc6c9 100644 --- a/lib/acts_as_paranoid_aliases.rb +++ b/lib/acts_as_paranoid_aliases.rb @@ -63,7 +63,7 @@ module ActsAsParanoidAliases def restore_all(ids) return if ids.blank? - only_hidden.where(id: ids).each(&:restore) + only_hidden.where(id: ids).find_each(&:restore) end end end diff --git a/spec/components/shared/banner_component_spec.rb b/spec/components/shared/banner_component_spec.rb index ef36de26a..6d2512373 100644 --- a/spec/components/shared/banner_component_spec.rb +++ b/spec/components/shared/banner_component_spec.rb @@ -75,7 +75,7 @@ describe Shared::BannerComponent do end it "does not render anything with no active banners" do - Banner.all.each { |banner| banner.update!(post_ended_at: Date.current - 1.day) } + Banner.find_each { |banner| banner.update!(post_ended_at: Date.current - 1.day) } render_inline Shared::BannerComponent.new("debates") diff --git a/spec/models/poll/booth_assignment_spec.rb b/spec/models/poll/booth_assignment_spec.rb index e42e637ad..046f27144 100644 --- a/spec/models/poll/booth_assignment_spec.rb +++ b/spec/models/poll/booth_assignment_spec.rb @@ -24,6 +24,6 @@ describe Poll::BoothAssignment do assignment.destroy! - expect(Poll::Shift.all.count).to eq(0) + expect(Poll::Shift.count).to eq 0 end end diff --git a/spec/models/poll/shift_spec.rb b/spec/models/poll/shift_spec.rb index be7d3f7d5..0b22c6fca 100644 --- a/spec/models/poll/shift_spec.rb +++ b/spec/models/poll/shift_spec.rb @@ -71,7 +71,7 @@ describe Poll::Shift do expect do create(:poll_shift, booth: booth, officer: officer, date: Date.current) - end.to change { Poll::OfficerAssignment.all.count }.by(2) + end.to change { Poll::OfficerAssignment.count }.by(2) officer_assignments = Poll::OfficerAssignment.all oa1 = officer_assignments.first @@ -91,7 +91,7 @@ describe Poll::Shift do booth_assignment: booth_assignment1, date: Date.tomorrow) - expect { Poll::Shift.last.destroy }.to change { Poll::OfficerAssignment.all.count }.by(-2) + expect { Poll::Shift.last.destroy }.to change { Poll::OfficerAssignment.count }.by(-2) end it "creates final officer_assignments" do diff --git a/spec/models/proposal_notification_spec.rb b/spec/models/proposal_notification_spec.rb index 2279ab542..c92773c81 100644 --- a/spec/models/proposal_notification_spec.rb +++ b/spec/models/proposal_notification_spec.rb @@ -167,7 +167,7 @@ describe ProposalNotification do it "removes all notifications related to the proposal notification" do proposal_notification.moderate_system_email(admin.user) - expect(Notification.all.count).to be(0) + expect(Notification.count).to be 0 end it "records the moderation action in the Activity table" do diff --git a/spec/system/notifications_spec.rb b/spec/system/notifications_spec.rb index 0d23d9b02..379aaed3a 100644 --- a/spec/system/notifications_spec.rb +++ b/spec/system/notifications_spec.rb @@ -241,7 +241,7 @@ describe "Notifications" do end def users_without_notifications - User.all.select do |user| + User.select do |user| user.notifications.not_emailed.where(notifiable_type: "ProposalNotification").blank? end end