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:
Enabled: true
##################### RSpec ##################################
FactoryBot/AttributeDefinedStatically:
Enabled: true

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,26 +4,26 @@
FactoryBot.define do
factory :email_settings do
send_on_registration true
send_on_accepted false
send_on_rejected false
send_on_confirmed_without_registration false
send_on_conference_dates_updated true
send_on_conference_registration_dates_updated true
send_on_program_schedule_public true
send_on_cfp_dates_updated true
conference_dates_updated_body 'Sample Conference\n New Dates: January 17 - 21 2014'
conference_dates_updated_subject 'Conference 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'
send_on_venue_updated true
venue_updated_subject 'Venue has been updated'
venue_updated_body 'Venue has been Updated to Sample Location'
registration_subject 'Lorem Ipsum Dolsum'
registration_body 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit'
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'
program_schedule_public_subject 'Sample Conference Cfp schedule is Public'
program_schedule_public_body 'Call for Papers schedule is Public.Checkout the link'
send_on_registration { true }
send_on_accepted { false }
send_on_rejected { false }
send_on_confirmed_without_registration { false }
send_on_conference_dates_updated { true }
send_on_conference_registration_dates_updated { true }
send_on_program_schedule_public { true }
send_on_cfp_dates_updated { true }
conference_dates_updated_body { 'Sample Conference\n New Dates: January 17 - 21 2014' }
conference_dates_updated_subject { 'Conference 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' }
send_on_venue_updated { true }
venue_updated_subject { 'Venue has been updated' }
venue_updated_body { 'Venue has been Updated to Sample Location' }
registration_subject { 'Lorem Ipsum Dolsum' }
registration_body { 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' }
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' }
program_schedule_public_subject { 'Sample Conference Cfp schedule is Public' }
program_schedule_public_body { 'Call for Papers schedule is Public.Checkout the link' }
end
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,10 +20,10 @@ FactoryBot.define do
sequence(:email) { |n| "example#{n}@example.com" }
sequence(:name) { |n| "name#{n}" }
sequence(:username) { |n| "username#{n}" }
password 'changeme'
password_confirmation 'changeme'
password { 'changeme' }
password_confirmation { 'changeme' }
confirmed_at { Time.now }
biography <<-EOS
biography { <<-EOS }
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim
nunc, venenatis non sapien convallis, dictum suscipit purus. Vestibulum
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
gravida.
EOS
is_disabled false
is_disabled { false }
after(:create) do |user|
user.is_admin = false
@ -49,12 +49,12 @@ FactoryBot.define do
end
trait :disabled do
is_disabled true
is_disabled { true }
end
end
factory :user_xss, parent: :user do
biography '<div id="divInjectedElement"></div>'
biography { '<div id="divInjectedElement"></div>' }
end
end

View file

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

View file

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

View file

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