Remove redundant .all in .all.sample calls
Rubocop doesn't detect this method because we've added it in the ApplicationRecord class, but we're removing the `.all` calls for consistency.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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|
|
||||||
|
|||||||
@@ -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,7 +96,7 @@ 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
|
||||||
|
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user