Add and apply FactoryBot/AssociationStyle rule
This rule was added in rubocop-factory_bot 2.23.0. We were following it sometimes, and sometimes we were not.
This commit is contained in:
@@ -32,6 +32,9 @@ Capybara/SpecificActions:
|
||||
Capybara/VisibilityMatcher:
|
||||
Enabled: true
|
||||
|
||||
FactoryBot/AssociationStyle:
|
||||
Enabled: true
|
||||
|
||||
FactoryBot/ConsistentParenthesesStyle:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :banner_section, class: "Banner::Section" do
|
||||
association :banner_id, factory: :banner
|
||||
association :web_section
|
||||
banner_id factory: :banner
|
||||
web_section
|
||||
end
|
||||
|
||||
factory :site_customization_page, class: "SiteCustomization::Page" do
|
||||
@@ -83,7 +83,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :budget_investment_map_location do
|
||||
association :investment, factory: :budget_investment
|
||||
investment factory: :budget_investment
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ FactoryBot.define do
|
||||
sequence(:name) { |n| "Group #{n}" }
|
||||
|
||||
trait :drafting_budget do
|
||||
association :budget, factory: [:budget, :drafting]
|
||||
budget factory: [:budget, :drafting]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,7 +98,7 @@ FactoryBot.define do
|
||||
group { association :budget_group, budget: budget || association(:budget) }
|
||||
|
||||
trait :drafting_budget do
|
||||
association :group, factory: [:budget_group, :drafting_budget]
|
||||
group factory: [:budget_group, :drafting_budget]
|
||||
end
|
||||
|
||||
trait :with_investment_with_milestone do
|
||||
@@ -113,7 +113,7 @@ FactoryBot.define do
|
||||
sequence(:title) { |n| "Budget Investment #{n} title" }
|
||||
heading { budget&.headings&.reload&.sample || association(:budget_heading, budget: budget) }
|
||||
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
description { "Spend money on this" }
|
||||
price { 10 }
|
||||
unfeasibility_explanation { "" }
|
||||
@@ -251,7 +251,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :budget_ballot, class: "Budget::Ballot" do
|
||||
association :user
|
||||
user
|
||||
budget
|
||||
|
||||
transient { investments { [] } }
|
||||
@@ -264,7 +264,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :budget_ballot_line, class: "Budget::Ballot::Line" do
|
||||
association :investment, factory: :budget_investment
|
||||
investment factory: :budget_investment
|
||||
|
||||
transient { user { nil } }
|
||||
|
||||
@@ -275,7 +275,7 @@ FactoryBot.define do
|
||||
|
||||
factory :budget_reclassified_vote, class: "Budget::ReclassifiedVote" do
|
||||
user
|
||||
association :investment, factory: :budget_investment
|
||||
investment factory: :budget_investment
|
||||
reason { "unfeasible" }
|
||||
end
|
||||
|
||||
@@ -284,7 +284,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :heading_content_block, class: "Budget::ContentBlock" do
|
||||
association :heading, factory: :budget_heading
|
||||
heading factory: :budget_heading
|
||||
locale { "en" }
|
||||
body { "Some heading contents" }
|
||||
end
|
||||
|
||||
@@ -21,14 +21,14 @@ FactoryBot.define do
|
||||
|
||||
factory :tagging do
|
||||
context { "tags" }
|
||||
association :taggable, factory: :proposal
|
||||
taggable factory: :proposal
|
||||
tag
|
||||
end
|
||||
|
||||
factory :topic do
|
||||
sequence(:title) { |n| "Topic title #{n}" }
|
||||
sequence(:description) { |n| "Description as comment #{n}" }
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
|
||||
trait :with_community do
|
||||
community { create(:proposal).community }
|
||||
@@ -38,18 +38,18 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :related_content do
|
||||
association :author, factory: :user
|
||||
association :parent_relationable, factory: [:proposal, :debate].sample
|
||||
association :child_relationable, factory: [:proposal, :debate].sample
|
||||
author factory: :user
|
||||
parent_relationable factory: [:proposal, :debate].sample
|
||||
child_relationable factory: [:proposal, :debate].sample
|
||||
|
||||
trait :proposals do
|
||||
association :parent_relationable, factory: :proposal
|
||||
association :child_relationable, factory: :proposal
|
||||
parent_relationable factory: :proposal
|
||||
child_relationable factory: :proposal
|
||||
end
|
||||
|
||||
trait :budget_investments do
|
||||
association :parent_relationable, factory: :budget_investment
|
||||
association :child_relationable, factory: :budget_investment
|
||||
parent_relationable factory: :budget_investment
|
||||
child_relationable factory: :budget_investment
|
||||
end
|
||||
|
||||
trait :from_machine_learning do
|
||||
@@ -58,7 +58,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :related_content_score do
|
||||
association :user
|
||||
association :related_content
|
||||
user
|
||||
related_content
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
FactoryBot.define do
|
||||
factory :comment do
|
||||
association :commentable, factory: :debate
|
||||
commentable factory: :debate
|
||||
user
|
||||
sequence(:body) { |n| "Comment body #{n}" }
|
||||
|
||||
%i[budget_investment debate legislation_annotation legislation_question legislation_proposal
|
||||
poll proposal topic_with_community].each do |model|
|
||||
factory :"#{model}_comment" do
|
||||
association :commentable, factory: model
|
||||
commentable factory: model
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ FactoryBot.define do
|
||||
|
||||
trait :valuation do
|
||||
valuation { true }
|
||||
association :commentable, factory: :budget_investment
|
||||
commentable factory: :budget_investment
|
||||
before :create do |valuation|
|
||||
valuator = create(:valuator)
|
||||
valuation.author = valuator.user
|
||||
|
||||
@@ -3,7 +3,7 @@ FactoryBot.define do
|
||||
sequence(:title) { |n| "Debate #{n} title" }
|
||||
description { "Debate description" }
|
||||
terms_of_service { "1" }
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
|
||||
trait :hidden do
|
||||
hidden_at { Time.current }
|
||||
@@ -46,7 +46,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :flag do
|
||||
association :flaggable, factory: :debate
|
||||
association :user
|
||||
flaggable factory: :debate
|
||||
user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,36 +2,36 @@ FactoryBot.define do
|
||||
factory :image do
|
||||
attachment { Rack::Test::UploadedFile.new("spec/fixtures/files/clippy.jpg") }
|
||||
title { "Lorem ipsum dolor sit amet" }
|
||||
association :user
|
||||
user
|
||||
|
||||
trait :proposal_image do
|
||||
association :imageable, factory: :proposal
|
||||
imageable factory: :proposal
|
||||
end
|
||||
|
||||
trait :budget_image do
|
||||
association :imageable, factory: :budget
|
||||
imageable factory: :budget
|
||||
end
|
||||
|
||||
trait :budget_investment_image do
|
||||
association :imageable, factory: :budget_investment
|
||||
imageable factory: :budget_investment
|
||||
end
|
||||
end
|
||||
|
||||
factory :document do
|
||||
sequence(:title) { |n| "Document title #{n}" }
|
||||
association :user
|
||||
user
|
||||
attachment { Rack::Test::UploadedFile.new("spec/fixtures/files/empty.pdf") }
|
||||
|
||||
trait :proposal_document do
|
||||
association :documentable, factory: :proposal
|
||||
documentable factory: :proposal
|
||||
end
|
||||
|
||||
trait :budget_investment_document do
|
||||
association :documentable, factory: :budget_investment
|
||||
documentable factory: :budget_investment
|
||||
end
|
||||
|
||||
trait :poll_question_document do
|
||||
association :documentable, factory: :poll_question
|
||||
documentable factory: :poll_question
|
||||
end
|
||||
|
||||
trait :admin do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :machine_learning_job do
|
||||
association :user
|
||||
user
|
||||
script { "script.py" }
|
||||
started_at { Time.current }
|
||||
finished_at { nil }
|
||||
|
||||
@@ -5,8 +5,8 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :milestone do
|
||||
association :milestoneable, factory: :budget_investment
|
||||
association :status, factory: :milestone_status
|
||||
milestoneable factory: :budget_investment
|
||||
status factory: :milestone_status
|
||||
sequence(:title) { |n| "Milestone #{n} title" }
|
||||
description { "Milestone description" }
|
||||
publication_date { Date.current }
|
||||
@@ -25,7 +25,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :progress_bar do
|
||||
association :progressable, factory: :budget_investment
|
||||
progressable factory: :budget_investment
|
||||
percentage { rand(0..100) }
|
||||
kind { :primary }
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
FactoryBot.define do
|
||||
factory :notification do
|
||||
user
|
||||
association :notifiable, factory: :proposal
|
||||
notifiable factory: :proposal
|
||||
|
||||
trait :read do
|
||||
read_at { Time.current }
|
||||
end
|
||||
|
||||
trait :for_proposal_notification do
|
||||
association :notifiable, factory: :proposal_notification
|
||||
notifiable factory: :proposal_notification
|
||||
end
|
||||
|
||||
trait :for_comment do
|
||||
association :notifiable, factory: :comment
|
||||
notifiable factory: :comment
|
||||
end
|
||||
|
||||
trait :for_poll_question do
|
||||
association :notifiable, factory: :poll_question
|
||||
notifiable factory: :poll_question
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :for_budget do
|
||||
association :budget
|
||||
budget
|
||||
end
|
||||
|
||||
trait :with_image do
|
||||
@@ -49,7 +49,7 @@ FactoryBot.define do
|
||||
|
||||
factory :poll_question, class: "Poll::Question" do
|
||||
poll
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
sequence(:title) { |n| "Question title #{n}" }
|
||||
|
||||
trait :yes_no do
|
||||
@@ -124,11 +124,11 @@ FactoryBot.define do
|
||||
|
||||
factory :poll_booth_assignment, class: "Poll::BoothAssignment" do
|
||||
poll
|
||||
association :booth, factory: :poll_booth
|
||||
booth factory: :poll_booth
|
||||
end
|
||||
|
||||
factory :poll_officer_assignment, class: "Poll::OfficerAssignment" do
|
||||
association :officer, factory: :poll_officer
|
||||
officer factory: :poll_officer
|
||||
date { Date.current }
|
||||
|
||||
transient { poll { association(:poll) } }
|
||||
@@ -144,8 +144,8 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :poll_shift, class: "Poll::Shift" do
|
||||
association :booth, factory: :poll_booth
|
||||
association :officer, factory: :poll_officer
|
||||
booth factory: :poll_booth
|
||||
officer factory: :poll_officer
|
||||
date { Date.current }
|
||||
|
||||
trait :vote_collection_task do
|
||||
@@ -158,7 +158,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :poll_voter, class: "Poll::Voter" do
|
||||
association :user, :level_two
|
||||
user factory: [:user, :level_two]
|
||||
from_web
|
||||
|
||||
transient { budget { nil } }
|
||||
@@ -196,20 +196,20 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :poll_answer, class: "Poll::Answer" do
|
||||
association :question, factory: [:poll_question, :yes_no]
|
||||
association :author, factory: [:user, :level_two]
|
||||
question factory: [:poll_question, :yes_no]
|
||||
author factory: [:user, :level_two]
|
||||
answer { question.question_answers.sample.title }
|
||||
end
|
||||
|
||||
factory :poll_partial_result, class: "Poll::PartialResult" do
|
||||
association :question, factory: [:poll_question, :yes_no]
|
||||
association :author, factory: :user
|
||||
question factory: [:poll_question, :yes_no]
|
||||
author factory: :user
|
||||
origin { "web" }
|
||||
answer { question.question_answers.sample.title }
|
||||
end
|
||||
|
||||
factory :poll_recount, class: "Poll::Recount" do
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
origin { "web" }
|
||||
|
||||
trait :from_booth do
|
||||
@@ -224,19 +224,19 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :poll_ballot_sheet, class: "Poll::BallotSheet" do
|
||||
association :poll
|
||||
association :officer_assignment, factory: :poll_officer_assignment
|
||||
poll
|
||||
officer_assignment factory: :poll_officer_assignment
|
||||
data { "1234;9876;5678\n1000;2000;3000;9999" }
|
||||
end
|
||||
|
||||
factory :poll_ballot, class: "Poll::Ballot" do
|
||||
association :ballot_sheet, factory: :poll_ballot_sheet
|
||||
ballot_sheet factory: :poll_ballot_sheet
|
||||
data { "1,2,3" }
|
||||
end
|
||||
|
||||
factory :officing_residence, class: "Officing::Residence" do
|
||||
user
|
||||
association :officer, factory: :poll_officer
|
||||
officer factory: :poll_officer
|
||||
document_number
|
||||
document_type { "1" }
|
||||
year_of_birth { "1980" }
|
||||
|
||||
@@ -8,7 +8,7 @@ FactoryBot.define do
|
||||
terms_of_service { "1" }
|
||||
published_at { Time.current }
|
||||
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
|
||||
trait :hidden do
|
||||
hidden_at { Time.current }
|
||||
@@ -96,7 +96,7 @@ FactoryBot.define do
|
||||
sequence(:title) { |n| "Thank you for supporting my proposal #{n}" }
|
||||
sequence(:body) { |n| "Please let others know so we can make it happen #{n}" }
|
||||
proposal
|
||||
association :author, factory: :user
|
||||
author factory: :user
|
||||
|
||||
trait :moderated do
|
||||
moderated { true }
|
||||
@@ -116,8 +116,8 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :signature_sheet do
|
||||
association :signable, factory: :proposal
|
||||
association :author, factory: :user
|
||||
signable factory: :proposal
|
||||
author factory: :user
|
||||
required_fields_to_verify { "123A, 456B, 789C" }
|
||||
|
||||
trait :with_title do
|
||||
@@ -133,7 +133,7 @@ FactoryBot.define do
|
||||
factory :activity do
|
||||
user
|
||||
action { "hide" }
|
||||
association :actionable, factory: :proposal
|
||||
actionable factory: :proposal
|
||||
end
|
||||
|
||||
factory :dashboard_action, class: "Dashboard::Action" do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory :remote_translation do
|
||||
association :remote_translatable, factory: :debate
|
||||
remote_translatable factory: :debate
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ FactoryBot.define do
|
||||
SDG::Related::RELATABLE_TYPES.map { |relatable_type| relatable_type.downcase.gsub("::", "_") }
|
||||
.each do |relatable|
|
||||
trait :"#{relatable}_review" do
|
||||
association :relatable, factory: relatable
|
||||
relatable factory: relatable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,21 +126,21 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :follow do
|
||||
association :user
|
||||
user
|
||||
|
||||
trait :followed_proposal do
|
||||
association :followable, factory: :proposal
|
||||
followable factory: :proposal
|
||||
end
|
||||
|
||||
trait :followed_investment do
|
||||
association :followable, factory: :budget_investment
|
||||
followable factory: :budget_investment
|
||||
end
|
||||
end
|
||||
|
||||
factory :direct_message do
|
||||
title { "Hey" }
|
||||
body { "How are You doing?" }
|
||||
association :sender, factory: :user
|
||||
association :receiver, factory: :user
|
||||
sender factory: :user
|
||||
receiver factory: :user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,6 @@ FactoryBot.define do
|
||||
max_votes { 3 }
|
||||
end
|
||||
|
||||
association :questionable, factory: :poll_question
|
||||
questionable factory: :poll_question
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :vote do
|
||||
association :votable, factory: :debate
|
||||
association :voter, factory: :user
|
||||
votable factory: :debate
|
||||
voter factory: :user
|
||||
vote_flag { true }
|
||||
after(:create) do |vote, _|
|
||||
vote.votable.update_cached_votes
|
||||
|
||||
Reference in New Issue
Block a user