Merge pull request #5271 from consuldemocracy/dependabot/bundler/rubocop-rails-2.21.2

Bump rubocop-rails from 2.20.2 to 2.21.2
This commit is contained in:
Javi Martín
2023-11-20 17:54:30 +01:00
committed by GitHub
32 changed files with 83 additions and 72 deletions

View File

@@ -38,5 +38,9 @@ linters:
Enabled: false Enabled: false
Lint/UselessAssignment: Lint/UselessAssignment:
Enabled: false Enabled: false
Rails/HttpStatus:
Enabled: true
Exclude:
- app/views/dashboard/*
Rails/OutputSafety: Rails/OutputSafety:
Enabled: false Enabled: false

View File

@@ -443,6 +443,9 @@ Rails/PluralizationGrammar:
Rails/Presence: Rails/Presence:
Enabled: true Enabled: true
Rails/RedundantActiveRecordAllMethod:
Enabled: true
Rails/RedundantTravelBack: Rails/RedundantTravelBack:
Enabled: true Enabled: true
@@ -466,6 +469,9 @@ Rails/SaveBang:
Enabled: true Enabled: true
Severity: refactor Severity: refactor
Rails/SelectMap:
Enabled: true
Rails/SkipsModelValidations: Rails/SkipsModelValidations:
Enabled: true Enabled: true
ForbiddenMethods: ForbiddenMethods:
@@ -689,6 +695,7 @@ Style/InvertibleUnlessCondition:
Enabled: true Enabled: true
InverseMethods: InverseMethods:
:blank?: :present? :blank?: :present?
:include?: ~
:present?: :blank? :present?: :blank?
:zero?: ~ :zero?: ~

View File

@@ -109,7 +109,7 @@ group :development do
gem "rubocop-capybara", "~> 2.19.0", require: false gem "rubocop-capybara", "~> 2.19.0", require: false
gem "rubocop-factory_bot", "~> 2.24.0", require: false gem "rubocop-factory_bot", "~> 2.24.0", require: false
gem "rubocop-performance", "~> 1.19.1", 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 "rubocop-rspec", "~> 2.24.1", require: false
gem "rvm1-capistrano3", "~> 1.4.0", require: false gem "rvm1-capistrano3", "~> 1.4.0", require: false
gem "scss_lint", "~> 0.60.0", require: false gem "scss_lint", "~> 0.60.0", require: false

View File

@@ -536,7 +536,7 @@ GEM
rubocop-performance (1.19.1) rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0) rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0) rubocop-ast (>= 0.4.0)
rubocop-rails (2.20.2) rubocop-rails (2.21.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0) rubocop (>= 1.33.0, < 2.0)
@@ -754,7 +754,7 @@ DEPENDENCIES
rubocop-capybara (~> 2.19.0) rubocop-capybara (~> 2.19.0)
rubocop-factory_bot (~> 2.24.0) rubocop-factory_bot (~> 2.24.0)
rubocop-performance (~> 1.19.1) rubocop-performance (~> 1.19.1)
rubocop-rails (~> 2.20.2) rubocop-rails (~> 2.21.2)
rubocop-rspec (~> 2.24.1) rubocop-rspec (~> 2.24.1)
rvm1-capistrano3 (~> 1.4.0) rvm1-capistrano3 (~> 1.4.0)
sassc-rails (~> 2.1.2) sassc-rails (~> 2.1.2)

View File

@@ -115,7 +115,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end end
def load_valuator_groups def load_valuator_groups
@valuator_groups = ValuatorGroup.all.order(name: :asc) @valuator_groups = ValuatorGroup.order(name: :asc)
end end
def load_tags def load_tags

View File

@@ -4,7 +4,7 @@ class Admin::GeozonesController < Admin::BaseController
load_and_authorize_resource load_and_authorize_resource
def index def index
@geozones = Geozone.all.order(Arel.sql("LOWER(name)")) @geozones = Geozone.order(Arel.sql("LOWER(name)"))
end end
def new def new

View File

@@ -46,7 +46,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
end end
def manage 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]) @poll = Poll.find(params[:poll_id])
end end

View File

@@ -7,7 +7,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
@officers = ::Poll::Officer @officers = ::Poll::Officer
.includes(:user) .includes(:user)
.order("users.username") .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]) .page(params[:page])
.per(50) .per(50)
end end

View File

@@ -59,7 +59,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
private private
def load_geozones def load_geozones
@geozones = Geozone.all.order(:name) @geozones = Geozone.order(:name)
end end
def poll_params def poll_params

View File

@@ -1,6 +1,6 @@
class Admin::SignatureSheetsController < Admin::BaseController class Admin::SignatureSheetsController < Admin::BaseController
def index def index
@signature_sheets = SignatureSheet.all.order(created_at: :desc) @signature_sheets = SignatureSheet.order(created_at: :desc)
end end
def new def new

View File

@@ -1,6 +1,6 @@
class Admin::ValuatorGroupsController < Admin::BaseController class Admin::ValuatorGroupsController < Admin::BaseController
def index def index
@groups = ValuatorGroup.all.page(params[:page]) @groups = ValuatorGroup.page(params[:page])
end end
def show def show

View File

@@ -83,7 +83,7 @@ module CommentableActions
end end
def load_geozones def load_geozones
@geozones = Geozone.all.order(name: :asc) @geozones = Geozone.order(name: :asc)
end end
def set_geozone def set_geozone

View File

@@ -4,6 +4,6 @@ module GeozonesHelper
end end
def geozone_select_options 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
end end

View File

@@ -171,7 +171,7 @@ module Statisticable
end end
def geozones def geozones
Geozone.all.order("name") Geozone.order("name")
end end
def geozone_stats def geozone_stats

View File

@@ -48,7 +48,7 @@ section "Creating Budgets" do
end end
end end
Budget.all.each do |budget| Budget.find_each do |budget|
city_group = budget.groups.create!( city_group = budget.groups.create!(
random_locales_attributes(name: -> { I18n.t("seeds.budgets.groups.all_city") }) random_locales_attributes(name: -> { I18n.t("seeds.budgets.groups.all_city") })
) )
@@ -94,7 +94,7 @@ end
section "Creating Investments" do section "Creating Investments" do
tags = Faker::Lorem.words(number: 10) tags = Faker::Lorem.words(number: 10)
100.times do 100.times do
heading = Budget::Heading.all.sample heading = Budget::Heading.sample
translation_attributes = random_locales.each_with_object({}) do |locale, attributes| translation_attributes = random_locales.each_with_object({}) do |locale, attributes|
attributes["title_#{locale.to_s.underscore}"] = "Title for locale #{locale}" attributes["title_#{locale.to_s.underscore}"] = "Title for locale #{locale}"
@@ -102,7 +102,7 @@ section "Creating Investments" do
end end
investment = Budget::Investment.create!({ investment = Budget::Investment.create!({
author: User.all.sample, author: User.sample,
heading: heading, heading: heading,
group: heading.group, group: heading.group,
budget: heading.group.budget, budget: heading.group.budget,
@@ -145,9 +145,9 @@ end
section "Winner Investments" do section "Winner Investments" do
budget = Budget.finished.first budget = Budget.finished.first
50.times do 50.times do
heading = budget.headings.all.sample heading = budget.headings.sample
investment = Budget::Investment.create!( investment = Budget::Investment.create!(
author: User.all.sample, author: User.sample,
heading: heading, heading: heading,
group: heading.group, group: heading.group,
budget: heading.group.budget, budget: heading.group.budget,
@@ -169,6 +169,6 @@ end
section "Creating Valuation Assignments" do section "Creating Valuation Assignments" do
(1..50).to_a.sample.times do (1..50).to_a.sample.times do
Budget::Investment.all.sample.valuators << Valuator.first Budget::Investment.sample.valuators << Valuator.first
end end
end end

View File

@@ -1,8 +1,8 @@
section "Commenting Investments, Debates & Proposals" do section "Commenting Investments, Debates & Proposals" do
%w[Budget::Investment Debate Proposal].each do |commentable_class| %w[Budget::Investment Debate Proposal].each do |commentable_class|
100.times do 100.times do
commentable = commentable_class.constantize.all.sample commentable = commentable_class.constantize.sample
Comment.create!(user: User.all.sample, Comment.create!(user: User.sample,
created_at: rand(commentable.created_at..Time.current), created_at: rand(commentable.created_at..Time.current),
commentable: commentable, commentable: commentable,
body: Faker::Lorem.sentence) body: Faker::Lorem.sentence)
@@ -12,8 +12,8 @@ end
section "Commenting Comments" do section "Commenting Comments" do
200.times do 200.times do
parent = Comment.all.sample parent = Comment.sample
Comment.create!(user: User.all.sample, Comment.create!(user: User.sample,
created_at: rand(parent.created_at..Time.current), created_at: rand(parent.created_at..Time.current),
commentable_id: parent.commentable_id, commentable_id: parent.commentable_id,
commentable_type: parent.commentable_type, commentable_type: parent.commentable_type,

View File

@@ -5,15 +5,15 @@ end
section "Creating Communities Topics" do section "Creating Communities Topics" do
Community.find_each do |community| 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) title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: Faker::Lorem.sentence)
end end
end end
section "Commenting Community Topics" do section "Commenting Community Topics" do
30.times do 30.times do
author = User.all.sample author = User.sample
topic = Topic.all.sample topic = Topic.sample
Comment.create!(user: author, Comment.create!(user: author,
created_at: rand(topic.created_at..Time.current), created_at: rand(topic.created_at..Time.current),
commentable: topic, commentable: topic,

View File

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

View File

@@ -1,19 +1,19 @@
section "Flagging Debates & Comments" do section "Flagging Debates & Comments" do
40.times do 40.times do
debate = Debate.all.sample debate = Debate.sample
flagger = User.where.not(id: debate.author_id).all.sample flagger = User.where.not(id: debate.author_id).sample
Flag.flag(flagger, debate) Flag.flag(flagger, debate)
end end
40.times do 40.times do
comment = Comment.all.sample comment = Comment.sample
flagger = User.where.not(id: comment.user_id).all.sample flagger = User.where.not(id: comment.user_id).sample
Flag.flag(flagger, comment) Flag.flag(flagger, comment)
end end
40.times do 40.times do
proposal = Proposal.all.sample proposal = Proposal.sample
flagger = User.where.not(id: proposal.author_id).all.sample flagger = User.where.not(id: proposal.author_id).sample
Flag.flag(flagger, proposal) Flag.flag(flagger, proposal)
end end
end end

View File

@@ -3,8 +3,8 @@ section "Creating legislation proposals" do
Legislation::Proposal.create!(title: Faker::Lorem.sentence(word_count: 3).truncate(60), Legislation::Proposal.create!(title: Faker::Lorem.sentence(word_count: 3).truncate(60),
description: Faker::Lorem.paragraphs.join("\n\n"), description: Faker::Lorem.paragraphs.join("\n\n"),
summary: Faker::Lorem.paragraph, summary: Faker::Lorem.paragraph,
author: User.all.sample, author: User.sample,
process: Legislation::Process.all.sample, process: Legislation::Process.sample,
terms_of_service: "1", terms_of_service: "1",
selected: rand <= 1.0 / 3) selected: rand <= 1.0 / 3)
end end

View File

@@ -11,7 +11,7 @@ section "Creating investment milestones" do
rand(1..5).times do rand(1..5).times do
milestone = record.milestones.build( milestone = record.milestones.build(
publication_date: Date.tomorrow, publication_date: Date.tomorrow,
status_id: Milestone::Status.all.sample status_id: Milestone::Status.sample
) )
random_locales.map do |locale| random_locales.map do |locale|

View File

@@ -56,7 +56,7 @@ section "Creating Poll Questions & Answers" do
Poll.find_each do |poll| Poll.find_each do |poll|
(3..5).to_a.sample.times do (3..5).to_a.sample.times do
question_title = Faker::Lorem.sentence(word_count: 3).truncate(60) + "?" 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, title: question_title,
poll: poll) poll: poll)
I18n.available_locales.map do |locale| I18n.available_locales.map do |locale|
@@ -96,13 +96,13 @@ section "Creating Poll Booths & BoothAssignments" do
20.times do |i| 20.times do |i|
Poll::Booth.create(name: "Booth #{i}", Poll::Booth.create(name: "Booth #{i}",
location: Faker::Address.street_address, location: Faker::Address.street_address,
polls: [Poll.all.sample]) polls: [Poll.sample])
end end
end end
section "Creating Poll Shifts for Poll Officers" do section "Creating Poll Shifts for Poll Officers" do
Poll.find_each do |poll| 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) scrutiny = (poll.ends_at.to_datetime..poll.ends_at.to_datetime + Poll::RECOUNT_DURATION)
Poll::Officer.find_each do |poll_officer| Poll::Officer.find_each do |poll_officer|
{ {
@@ -125,8 +125,8 @@ end
section "Commenting Polls" do section "Commenting Polls" do
30.times do 30.times do
author = User.all.sample author = User.sample
poll = Poll.all.sample poll = Poll.sample
Comment.create!(user: author, Comment.create!(user: author,
created_at: rand(poll.created_at..Time.current), created_at: rand(poll.created_at..Time.current),
commentable: poll, commentable: poll,
@@ -136,7 +136,7 @@ end
section "Creating Poll Voters" do section "Creating Poll Voters" do
def vote_poll_on_booth(user, poll) def vote_poll_on_booth(user, poll)
officer = Poll::Officer.all.sample officer = Poll::Officer.sample
Poll::Voter.create!(document_type: user.document_type, Poll::Voter.create!(document_type: user.document_type,
document_number: user.document_number, document_number: user.document_number,
@@ -230,7 +230,7 @@ end
section "Creating Poll Questions from Proposals" do section "Creating Poll Questions from Proposals" do
3.times do 3.times do
proposal = Proposal.all.sample proposal = Proposal.sample
poll = Poll.current.first poll = Poll.current.first
question = Poll::Question.new(poll: poll) question = Poll::Question.new(poll: poll)
question.copy_attributes_from_proposal(proposal) question.copy_attributes_from_proposal(proposal)
@@ -260,7 +260,7 @@ end
section "Creating Successful Proposals" do section "Creating Successful Proposals" do
10.times do 10.times do
proposal = Proposal.all.sample proposal = Proposal.sample
poll = Poll.current.first poll = Poll.current.first
question = Poll::Question.new(poll: poll) question = Poll::Question.new(poll: poll)
question.copy_attributes_from_proposal(proposal) question.copy_attributes_from_proposal(proposal)

View File

@@ -19,7 +19,7 @@ section "Creating Proposals" do
30.times do 30.times do
title = Faker::Lorem.sentence(word_count: 3).truncate(60) title = Faker::Lorem.sentence(word_count: 3).truncate(60)
summary = Faker::Lorem.sentence(word_count: 3) summary = Faker::Lorem.sentence(word_count: 3)
author = User.all.sample author = User.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>" description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author, proposal = Proposal.create!(author: author,
@@ -29,7 +29,7 @@ section "Creating Proposals" do
description: description, description: description,
created_at: rand((1.week.ago)..Time.current), created_at: rand((1.week.ago)..Time.current),
tag_list: tags.sample(3).join(","), tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample, geozone: Geozone.sample,
terms_of_service: "1", terms_of_service: "1",
published_at: Time.current) published_at: Time.current)
random_locales.map do |locale| random_locales.map do |locale|
@@ -47,7 +47,7 @@ end
section "Creating Archived Proposals" do section "Creating Archived Proposals" do
tags = Faker::Lorem.words(number: 25) tags = Faker::Lorem.words(number: 25)
5.times do 5.times do
author = User.all.sample author = User.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>" description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author, proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(word_count: 3).truncate(60), title: Faker::Lorem.sentence(word_count: 3).truncate(60),
@@ -55,7 +55,7 @@ section "Creating Archived Proposals" do
responsible_name: Faker::Name.name, responsible_name: Faker::Name.name,
description: description, description: description,
tag_list: tags.sample(3).join(","), tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample, geozone: Geozone.sample,
terms_of_service: "1", terms_of_service: "1",
created_at: Setting.archived_proposals_date_limit, created_at: Setting.archived_proposals_date_limit,
published_at: Setting.archived_proposals_date_limit) published_at: Setting.archived_proposals_date_limit)
@@ -74,7 +74,7 @@ end
section "Creating Successful Proposals" do section "Creating Successful Proposals" do
tags = Faker::Lorem.words(number: 25) tags = Faker::Lorem.words(number: 25)
10.times do 10.times do
author = User.all.sample author = User.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>" description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author, proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(word_count: 3).truncate(60), title: Faker::Lorem.sentence(word_count: 3).truncate(60),
@@ -83,7 +83,7 @@ section "Creating Successful Proposals" do
description: description, description: description,
created_at: rand((1.week.ago)..Time.current), created_at: rand((1.week.ago)..Time.current),
tag_list: tags.sample(3).join(","), tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample, geozone: Geozone.sample,
terms_of_service: "1", terms_of_service: "1",
cached_votes_up: Setting["votes_for_proposal_success"], cached_votes_up: Setting["votes_for_proposal_success"],
published_at: Time.current) published_at: Time.current)
@@ -100,7 +100,7 @@ section "Creating Successful Proposals" do
tags = Tag.where(kind: "category") tags = Tag.where(kind: "category")
30.times do 30.times do
author = User.all.sample author = User.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>" description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author, proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(word_count: 4).truncate(60), title: Faker::Lorem.sentence(word_count: 4).truncate(60),
@@ -109,7 +109,7 @@ section "Creating Successful Proposals" do
description: description, description: description,
created_at: rand((1.week.ago)..Time.current), created_at: rand((1.week.ago)..Time.current),
tag_list: tags.sample(3).join(","), tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample, geozone: Geozone.sample,
terms_of_service: "1", terms_of_service: "1",
published_at: Time.current) published_at: Time.current)
random_locales.map do |locale| random_locales.map do |locale|
@@ -128,7 +128,7 @@ section "Creating proposal notifications" do
100.times do |i| 100.times do |i|
ProposalNotification.create!(title: "Proposal notification title #{i}", ProposalNotification.create!(title: "Proposal notification title #{i}",
body: "Proposal notification body #{i}", body: "Proposal notification body #{i}",
author: User.all.sample, author: User.sample,
proposal: Proposal.all.sample) proposal: Proposal.sample)
end end
end end

View File

@@ -32,7 +32,7 @@ section "Creating Sustainable Development Goals" do
end end
section "Creating SDG homepage cards" do 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", Widget::Card.create!(cardable: phase, title: "#{phase.title} card",
link_text: "Link Text", link_url: "/any_path") link_text: "Link Text", link_url: "/any_path")
end end

View File

@@ -110,7 +110,7 @@ section "Creating Users" do
confirmed_phone: Faker::PhoneNumber.phone_number, confirmed_phone: Faker::PhoneNumber.phone_number,
document_number: unique_document_number, document_number: unique_document_number,
document_type: "1", document_type: "1",
geozone: Geozone.all.sample) geozone: Geozone.sample)
end end
if level == 3 if level == 3
user.update(verified_at: Time.current, document_number: unique_document_number) user.update(verified_at: Time.current, document_number: unique_document_number)

View File

@@ -1,22 +1,22 @@
section "Voting Debates, Proposals & Comments" do section "Voting Debates, Proposals & Comments" do
not_org_users = User.where.not(id: User.organizations) not_org_users = User.where.not(id: User.organizations)
100.times do 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 vote = [true, false].sample
debate = Debate.all.sample debate = Debate.sample
debate.vote_by(voter: voter, vote: vote) debate.vote_by(voter: voter, vote: vote)
end end
100.times do 100.times do
voter = not_org_users.all.sample voter = not_org_users.sample
vote = [true, false].sample vote = [true, false].sample
comment = Comment.all.sample comment = Comment.sample
comment.vote_by(voter: voter, vote: vote) comment.vote_by(voter: voter, vote: vote)
end end
100.times do 100.times do
voter = not_org_users.level_two_or_three_verified.all.sample voter = not_org_users.level_two_or_three_verified.sample
proposal = Proposal.all.sample proposal = Proposal.sample
proposal.vote_by(voter: voter, vote: true) proposal.vote_by(voter: voter, vote: true)
end end
end end

View File

@@ -63,7 +63,7 @@ module ActsAsParanoidAliases
def restore_all(ids) def restore_all(ids)
return if ids.blank? return if ids.blank?
only_hidden.where(id: ids).each(&:restore) only_hidden.where(id: ids).find_each(&:restore)
end end
end end
end end

View File

@@ -75,7 +75,7 @@ describe Shared::BannerComponent do
end end
it "does not render anything with no active banners" do 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") render_inline Shared::BannerComponent.new("debates")

View File

@@ -24,6 +24,6 @@ describe Poll::BoothAssignment do
assignment.destroy! assignment.destroy!
expect(Poll::Shift.all.count).to eq(0) expect(Poll::Shift.count).to eq 0
end end
end end

View File

@@ -71,7 +71,7 @@ describe Poll::Shift do
expect do expect do
create(:poll_shift, booth: booth, officer: officer, date: Date.current) 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 officer_assignments = Poll::OfficerAssignment.all
oa1 = officer_assignments.first oa1 = officer_assignments.first
@@ -91,7 +91,7 @@ describe Poll::Shift do
booth_assignment: booth_assignment1, booth_assignment: booth_assignment1,
date: Date.tomorrow) 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 end
it "creates final officer_assignments" do it "creates final officer_assignments" do

View File

@@ -167,7 +167,7 @@ describe ProposalNotification do
it "removes all notifications related to the proposal notification" do it "removes all notifications related to the proposal notification" do
proposal_notification.moderate_system_email(admin.user) proposal_notification.moderate_system_email(admin.user)
expect(Notification.all.count).to be(0) expect(Notification.count).to be 0
end end
it "records the moderation action in the Activity table" do it "records the moderation action in the Activity table" do

View File

@@ -241,7 +241,7 @@ describe "Notifications" do
end end
def users_without_notifications def users_without_notifications
User.all.select do |user| User.select do |user|
user.notifications.not_emailed.where(notifiable_type: "ProposalNotification").blank? user.notifications.not_emailed.where(notifiable_type: "ProposalNotification").blank?
end end
end end