Last stage of refactoring of the ability model and spec

This commit is contained in:
Henne Vogelsang 2015-04-14 17:33:59 +02:00
parent 762985b83d
commit 6a5cccbaad
22 changed files with 409 additions and 159 deletions

7
spec/factories/answer.rb Normal file
View file

@ -0,0 +1,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :answer do
title 'Do you?'
end
end

View file

@ -4,5 +4,6 @@ FactoryGirl.define do
factory :campaign do
name 'Test Campaign'
utm_campaign 'testcampaign'
conference
end
end

View file

@ -4,5 +4,13 @@ FactoryGirl.define do
factory :commercial do
commercial_type 'YouTube'
commercial_id 'test'
factory :conference_commercial do
association :commercialable, factory: :conference
end
factory :event_commercial do
association :commercialable, factory: :event
end
end
end

View file

@ -7,6 +7,22 @@ FactoryGirl.define do
timezone 'Amsterdam'
start_date { Date.today }
end_date { 6.days.from_now }
venue
factory :full_conference do
venue
splashpage
registration_period
call_for_paper
after(:build) do |conference|
conference.commercials << build(:conference_commercial, commercialable: conference)
conference.campaigns << build(:campaign, conference: conference)
conference.targets << build(:target, conference: conference)
conference.questions << build(:question, conference_id: conference.id)
conference.lodgings << build(:lodging, conference: conference)
conference.sponsors << build(:sponsor, conference: conference)
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
conference.tickets << build(:ticket, conference: conference)
end
end
end
end

View file

@ -3,9 +3,7 @@
FactoryGirl.define do
factory :event do
sequence(:title) { |n| "The ##{n} talk you'll ever attend." }
event_type
conference
association :room, factory: :room_for_100
abstract <<-EOS
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ante
lacus, mollis non urna vitae, varius semper leo. Nulla ac nibh dui. Mauris
@ -33,7 +31,24 @@ FactoryGirl.define do
libero quis porta ultricies. Fusce pulvinar accumsan lobortis.
EOS
after(:build) do |event|
event.event_users << build(:submitter, event: event)
event.event_users << build(:submitter)
# set an event_type if none is passed to the factory.
# needs to be created here because otherwise it doesn't belong to the
# same conference as the event
event.event_type ||= build(:event_type, conference: event.conference)
end
factory :event_full do
difficulty_level
track
room
after(:build) do |event|
event.commercials << build(:event_commercial, commercialable: event)
event.difficulty_level = build(:difficulty_level, conference: event.conference)
event.track = build(:track, conference: event.conference)
event.room = build(:room, conference: event.conference)
end
end
end
end

View file

@ -5,5 +5,6 @@ FactoryGirl.define do
name 'Example Hotel'
description 'Lorem Ipsum Dolor'
website_link 'http://www.example.com'
conference
end
end

View file

@ -0,0 +1,8 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :qanswer do
question
answer
end
end

View file

@ -0,0 +1,12 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :question do
title 'blah'
question_type
after(:build) do |question|
question.answers << build(:answer)
question.conferences << build(:conference)
end
end
end

View file

@ -0,0 +1,7 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :question_type do
title 'Multiple Choice'
end
end

View file

@ -4,5 +4,6 @@ FactoryGirl.define do
factory :registration_period do
start_date { 3.days.from_now }
end_date { 5.days.from_now }
conference
end
end

View file

@ -8,5 +8,13 @@ FactoryGirl.define do
factory :cfp_role do
name 'cfp'
end
factory :info_desk_role do
name 'info_desk'
end
factory :volunteers_coordinator_role do
name 'volunteers_coordinator'
end
end
end

View file

@ -2,6 +2,6 @@
FactoryGirl.define do
factory :splashpage do
public true
public false
end
end

View file

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

View file

@ -3,5 +3,6 @@ FactoryGirl.define do
title 'Business Ticket'
price_cents 1000
price_currency 'USD'
conference
end
end