Enable FactoryBot/AttributeDefinedStatically

See https://robots.thoughtbot.com/deprecating-static-attributes-in-factory_bot-4-11
This commit is contained in:
Henne Vogelsang 2018-09-08 03:58:50 +02:00
parent 5fc867a8fc
commit f866974b19
28 changed files with 146 additions and 140 deletions

View file

@ -15,3 +15,8 @@ AllCops:
Rails: Rails:
Enabled: true Enabled: true
##################### RSpec ##################################
FactoryBot/AttributeDefinedStatically:
Enabled: true

View file

@ -4,6 +4,6 @@
FactoryBot.define do FactoryBot.define do
factory :answer do factory :answer do
title 'Do you?' title { 'Do you?' }
end end
end end

View file

@ -4,7 +4,7 @@ FactoryBot.define do
factory :booth_request do factory :booth_request do
booth booth
user user
role 'responsible' role { 'responsible' }
end end
end end

View file

@ -4,8 +4,8 @@
FactoryBot.define do FactoryBot.define do
factory :campaign do factory :campaign do
name 'Test Campaign' name { 'Test Campaign' }
utm_campaign 'testcampaign' utm_campaign { 'testcampaign' }
conference conference
end end
end end

View file

@ -6,8 +6,8 @@ FactoryBot.define do
factory :cfp do factory :cfp do
start_date { 1.day.ago } start_date { 1.day.ago }
end_date { 2.days.from_now } end_date { 2.days.from_now }
cfp_type 'events' cfp_type { 'events' }
description 'This is a test description' description { 'This is a test description' }
program program
end end
end end

View file

@ -4,7 +4,7 @@
FactoryBot.define do FactoryBot.define do
factory :comment do factory :comment do
body 'Most interresting comment ever, created by a girl.' body { 'Most interresting comment ever, created by a girl.' }
user user
association :commentable, factory: :event association :commentable, factory: :event
end end

View file

@ -9,10 +9,10 @@ FactoryBot.define do
timezone { Faker::Address.time_zone } timezone { Faker::Address.time_zone }
start_date { Time.zone.today } start_date { Time.zone.today }
end_date { 6.days.from_now } end_date { 6.days.from_now }
start_hour 9 start_hour { 9 }
end_hour 20 end_hour { 20 }
registration_limit 0 registration_limit { 0 }
ticket_layout 'portrait' ticket_layout { 'portrait' }
description { Faker::Hipster.paragraph } description { Faker::Hipster.paragraph }
organization organization
after(:create) do |conference| after(:create) do |conference|

View file

@ -2,9 +2,9 @@
FactoryBot.define do FactoryBot.define do
factory :difficulty_level do factory :difficulty_level do
title 'Example Difficulty Level' title { 'Example Difficulty Level' }
description 'Lorem Ipsum dolsum' description { 'Lorem Ipsum dolsum' }
color '#ffffff' color { '#ffffff' }
program program
end end
end end

View file

@ -4,26 +4,26 @@
FactoryBot.define do FactoryBot.define do
factory :email_settings do factory :email_settings do
send_on_registration true send_on_registration { true }
send_on_accepted false send_on_accepted { false }
send_on_rejected false send_on_rejected { false }
send_on_confirmed_without_registration false send_on_confirmed_without_registration { false }
send_on_conference_dates_updated true send_on_conference_dates_updated { true }
send_on_conference_registration_dates_updated true send_on_conference_registration_dates_updated { true }
send_on_program_schedule_public true send_on_program_schedule_public { true }
send_on_cfp_dates_updated true send_on_cfp_dates_updated { true }
conference_dates_updated_body 'Sample Conference\n New Dates: January 17 - 21 2014' conference_dates_updated_body { 'Sample Conference\n New Dates: January 17 - 21 2014' }
conference_dates_updated_subject 'Conference dates have been updated' conference_dates_updated_subject { 'Conference dates have been updated' }
conference_registration_dates_updated_subject 'Conference registration dates have been updated' conference_registration_dates_updated_subject { 'Conference registration dates have been updated' }
conference_registration_dates_updated_body 'Sample Conference\n New Dates: January 17 - 21 2014' conference_registration_dates_updated_body { 'Sample Conference\n New Dates: January 17 - 21 2014' }
send_on_venue_updated true send_on_venue_updated { true }
venue_updated_subject 'Venue has been updated' venue_updated_subject { 'Venue has been updated' }
venue_updated_body 'Venue has been Updated to Sample Location' venue_updated_body { 'Venue has been Updated to Sample Location' }
registration_subject 'Lorem Ipsum Dolsum' registration_subject { 'Lorem Ipsum Dolsum' }
registration_body 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' registration_body { 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' }
cfp_dates_updated_subject 'Call for Papers dates have been updated' cfp_dates_updated_subject { 'Call for Papers dates have been updated' }
cfp_dates_updated_body 'Please checkout the new updates to submit your proposal for Sample Conference' cfp_dates_updated_body { 'Please checkout the new updates to submit your proposal for Sample Conference' }
program_schedule_public_subject 'Sample Conference Cfp schedule is Public' program_schedule_public_subject { 'Sample Conference Cfp schedule is Public' }
program_schedule_public_body 'Call for Papers schedule is Public.Checkout the link' program_schedule_public_body { 'Call for Papers schedule is Public.Checkout the link' }
end end
end end

View file

@ -4,11 +4,11 @@
FactoryBot.define do FactoryBot.define do
factory :event_type do factory :event_type do
title 'Example Event Type' title { 'Example Event Type' }
length 30 length { 30 }
minimum_abstract_length 0 minimum_abstract_length { 0 }
maximum_abstract_length 500 maximum_abstract_length { 500 }
color '#ffffff' color { '#ffffff' }
program program
end end

View file

@ -8,7 +8,7 @@ FactoryBot.define do
Hash[EventUser::ROLES].each_value do |role| Hash[EventUser::ROLES].each_value do |role|
factory role do factory role do
event_role role event_role { role }
end end
end end
end end

View file

@ -32,7 +32,7 @@ FactoryBot.define do
factory :event_scheduled do factory :event_scheduled do
transient do transient do
hour nil hour { nil }
end end
after(:build) do |event, evaluator| after(:build) do |event, evaluator|

View file

@ -4,6 +4,6 @@ FactoryBot.define do
factory :payment do factory :payment do
user user
conference conference
status 'unpaid' status { 'unpaid' }
end end
end end

View file

@ -4,8 +4,8 @@
FactoryBot.define do FactoryBot.define do
factory :program do factory :program do
schedule_public false schedule_public { false }
schedule_fluid false schedule_fluid { false }
conference conference
trait :with_cfp do trait :with_cfp do

View file

@ -4,6 +4,6 @@
FactoryBot.define do FactoryBot.define do
factory :question_type do factory :question_type do
title 'Multiple Choice' title { 'Multiple Choice' }
end end
end end

View file

@ -2,22 +2,22 @@
FactoryBot.define do FactoryBot.define do
factory :role do factory :role do
name 'my role' name { 'my role' }
factory :organizer_role do factory :organizer_role do
name 'organizer' name { 'organizer' }
end end
factory :cfp_role do factory :cfp_role do
name 'cfp' name { 'cfp' }
end end
factory :info_desk_role do factory :info_desk_role do
name 'info_desk' name { 'info_desk' }
end end
factory :volunteers_coordinator_role do factory :volunteers_coordinator_role do
name 'volunteers_coordinator' name { 'volunteers_coordinator' }
end end
end end
end end

View file

@ -4,13 +4,13 @@
FactoryBot.define do FactoryBot.define do
factory :room do factory :room do
name { "Room #{Faker::Address.country}" } name { "Room #{Faker::Address.country}" }
size 4 size { 4 }
venue venue
factory :room_for_100 do factory :room_for_100 do
name 'Room for 100' name { 'Room for 100' }
size 100 size { 100 }
end end
end end
end end

View file

@ -4,19 +4,20 @@
FactoryBot.define do FactoryBot.define do
factory :splashpage do factory :splashpage do
public false public { false }
factory :full_splashpage do factory :full_splashpage do
public true public { true }
include_tracks true
include_program true include_tracks { true }
include_social_media true include_program { true }
include_venue true include_social_media { true }
include_tickets true include_venue { true }
include_registrations true include_tickets { true }
include_sponsors true include_registrations { true }
include_lodgings true include_sponsors { true }
include_cfp true include_lodgings { true }
include_cfp { true }
end end
end end
end end

View file

@ -3,102 +3,102 @@
FactoryBot.define do FactoryBot.define do
factory :survey_question do factory :survey_question do
survey survey
title 'What about this question?' title { 'What about this question?' }
kind :boolean kind { :boolean }
min_choices nil min_choices { nil }
max_choices nil max_choices { nil }
possible_answers nil possible_answers { nil }
factory :boolean_non_mandatory do factory :boolean_non_mandatory do
title 'Have you attended the conference before? (Non mandatory)' title { 'Have you attended the conference before? (Non mandatory)' }
kind :boolean kind { :boolean }
end end
factory :boolean_mandatory do factory :boolean_mandatory do
title 'Did you attend the info talk about the conference? (Mandatory)' title { 'Did you attend the info talk about the conference? (Mandatory)' }
kind :boolean kind { :boolean }
mandatory true mandatory { true }
end end
# radio buttons # radio buttons
factory :choice_mandatory_1_reply do factory :choice_mandatory_1_reply do
title 'Choice question with only 1 answer (Mandatory)?' title { 'Choice question with only 1 answer (Mandatory)?' }
kind :choice kind { :choice }
min_choices 1 min_choices { 1 }
max_choices 1 max_choices { 1 }
possible_answers 'A, B, C' possible_answers { 'A, B, C' }
mandatory true mandatory { true }
end end
factory :choice_non_mandatory_1_reply do factory :choice_non_mandatory_1_reply do
title 'Choice question with only 1 answer (Non mandatory)' title { 'Choice question with only 1 answer (Non mandatory)' }
kind :choice kind { :choice }
min_choices 1 min_choices { 1 }
max_choices 1 max_choices { 1 }
possible_answers 'A, B, C' possible_answers { 'A, B, C' }
end end
# checkboxes # checkboxes
factory :choice_mandatory_2_replies do factory :choice_mandatory_2_replies do
title 'Choice question with 2 replies (Mandatory)?' title { 'Choice question with 2 replies (Mandatory)?' }
kind :choice kind { :choice }
min_choices 2 min_choices { 2 }
max_choices 2 max_choices { 2 }
possible_answers 'A, B, C' possible_answers { 'A, B, C' }
mandatory true mandatory { true }
end end
# checkboxes # checkboxes
factory :choice_non_mandatory_2_replies do factory :choice_non_mandatory_2_replies do
title 'Choice question with 2 replies (Non mandatory)?' title { 'Choice question with 2 replies (Non mandatory)?' }
kind :choice kind { :choice }
min_choices 2 min_choices { 2 }
max_choices 2 max_choices { 2 }
possible_answers 'A, B, C' possible_answers { 'A, B, C' }
end end
factory :string_mandatory do factory :string_mandatory do
title 'String question (Mandatory)?' title { 'String question (Mandatory)?' }
kind :string kind { :string }
mandatory true mandatory { true }
end end
factory :string_non_mandatory do factory :string_non_mandatory do
title 'String question (Non mandatory)?' title { 'String question (Non mandatory)?' }
kind :string kind { :string }
end end
factory :text_mandatory do factory :text_mandatory do
title 'Text question (Mandatory)?' title { 'Text question (Mandatory)?' }
kind :text kind { :text }
mandatory true mandatory { true }
end end
factory :text_non_mandatory do factory :text_non_mandatory do
title 'Text question (Non mandatory)?' title { 'Text question (Non mandatory)?' }
kind :text kind { :text }
end end
factory :datetime_mandatory do factory :datetime_mandatory do
title 'Datetime question (Mandatory)?' title { 'Datetime question (Mandatory)?' }
kind :datetime kind { :datetime }
mandatory true mandatory { true }
end end
factory :datetime_non_mandatory do factory :datetime_non_mandatory do
title 'Datetime question (Non mandatory)?' title { 'Datetime question (Non mandatory)?' }
kind :datetime kind { :datetime }
end end
factory :numeric_mandatory do factory :numeric_mandatory do
title 'Numeric question (Mandatory)?' title { 'Numeric question (Mandatory)?' }
kind :numeric kind { :numeric }
mandatory true mandatory { true }
end end
factory :numeric_non_mandatory do factory :numeric_non_mandatory do
title 'Numeric question (Non mandatory)?' title { 'Numeric question (Non mandatory)?' }
kind :numeric kind { :numeric }
end end
end end
end end

View file

@ -2,9 +2,9 @@
FactoryBot.define do FactoryBot.define do
factory :survey do factory :survey do
title 'This is my survey' title { 'This is my survey' }
start_date Date.current - 1.day start_date { Date.current - 1.day }
end_date Date.current + 1.day end_date { Date.current + 1.day }
factory :conference_survey do factory :conference_survey do
association :surveyable, factory: :conference association :surveyable, factory: :conference

View file

@ -5,8 +5,8 @@
FactoryBot.define do FactoryBot.define do
factory :target do factory :target do
due_date { 14.days.from_now } due_date { 14.days.from_now }
target_count 100 target_count { 100 }
unit Target.units[:submissions] unit { Target.units[:submissions] }
conference conference
end end
end end

View file

@ -5,7 +5,7 @@ FactoryBot.define do
user user
conference conference
ticket ticket
quantity 10 quantity { 10 }
factory :paid_ticket_purchase do factory :paid_ticket_purchase do
after(:build) do |ticket_purchase| after(:build) do |ticket_purchase|
payment = create(:payment) payment = create(:payment)

View file

@ -3,10 +3,10 @@
FactoryBot.define do FactoryBot.define do
factory :ticket do factory :ticket do
title { "#{Faker::Hipster.word} Ticket" } title { "#{Faker::Hipster.word} Ticket" }
price_cents 1000 price_cents { 1000 }
price_currency 'USD' price_currency { 'USD' }
factory :registration_ticket do factory :registration_ticket do
registration_ticket true registration_ticket { true }
end end
end end
end end

View file

@ -6,14 +6,14 @@ FactoryBot.define do
description { Faker::Lorem.sentence } description { Faker::Lorem.sentence }
color { Faker::Color.hex_color } color { Faker::Color.hex_color }
short_name { SecureRandom.urlsafe_base64(5) } short_name { SecureRandom.urlsafe_base64(5) }
state 'confirmed' state { 'confirmed' }
cfp_active true cfp_active { true }
program program
trait :self_organized do trait :self_organized do
association :submitter, factory: :user association :submitter, factory: :user
state 'new' state { 'new' }
cfp_active false cfp_active { false }
start_date { Time.zone.today } start_date { Time.zone.today }
end_date { Time.zone.today } end_date { Time.zone.today }
room room

View file

@ -20,10 +20,10 @@ FactoryBot.define do
sequence(:email) { |n| "example#{n}@example.com" } sequence(:email) { |n| "example#{n}@example.com" }
sequence(:name) { |n| "name#{n}" } sequence(:name) { |n| "name#{n}" }
sequence(:username) { |n| "username#{n}" } sequence(:username) { |n| "username#{n}" }
password 'changeme' password { 'changeme' }
password_confirmation 'changeme' password_confirmation { 'changeme' }
confirmed_at { Time.now } confirmed_at { Time.now }
biography <<-EOS biography { <<-EOS }
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim
nunc, venenatis non sapien convallis, dictum suscipit purus. Vestibulum nunc, venenatis non sapien convallis, dictum suscipit purus. Vestibulum
sed tincidunt tortor. Fusce viverra nisi nisi, quis congue dui faucibus sed tincidunt tortor. Fusce viverra nisi nisi, quis congue dui faucibus
@ -31,7 +31,7 @@ FactoryBot.define do
Quisque cursus facilisis consequat. Etiam volutpat ligula turpis, at Quisque cursus facilisis consequat. Etiam volutpat ligula turpis, at
gravida. gravida.
EOS EOS
is_disabled false is_disabled { false }
after(:create) do |user| after(:create) do |user|
user.is_admin = false user.is_admin = false
@ -49,12 +49,12 @@ FactoryBot.define do
end end
trait :disabled do trait :disabled do
is_disabled true is_disabled { true }
end end
end end
factory :user_xss, parent: :user do factory :user_xss, parent: :user do
biography '<div id="divInjectedElement"></div>' biography { '<div id="divInjectedElement"></div>' }
end end
end end

View file

@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :vday do factory :vday do
day { Time.zone.today } day { Time.zone.today }
description 'Lorem Ipsum dolsum' description { 'Lorem Ipsum dolsum' }
conference conference
end end

View file

@ -4,6 +4,6 @@ FactoryBot.define do
factory :vote do factory :vote do
event event
user user
rating 1 rating { 1 }
end end
end end

View file

@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :vposition do factory :vposition do
title 'Example Volunteer Position' title { 'Example Volunteer Position' }
description 'Lorem Ipsum dolsum' description { 'Lorem Ipsum dolsum' }
conference conference
after(:build) do |vposition| after(:build) do |vposition|