mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-14 13:51:26 +00:00
Add match-related factories
This commit is contained in:
parent
7635051f49
commit
5825ac33f5
5 changed files with 64 additions and 7 deletions
10
spec/factories/contest.rb
Executable file
10
spec/factories/contest.rb
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :contest do
|
||||||
|
sequence(:name) { |n| "Contest ##{n}" }
|
||||||
|
|
||||||
|
start Date.yesterday
|
||||||
|
self.end Date.tomorrow
|
||||||
|
status Contest::STATUS_PROGRESS
|
||||||
|
default_time "12:00:00"
|
||||||
|
end
|
||||||
|
end
|
8
spec/factories/contester.rb
Executable file
8
spec/factories/contester.rb
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :contester do
|
||||||
|
contest
|
||||||
|
team do
|
||||||
|
create(:user_with_team).team
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
26
spec/factories/group.rb
Normal file → Executable file
26
spec/factories/group.rb
Normal file → Executable file
|
@ -1,27 +1,39 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :group do
|
factory :group do
|
||||||
sequence(:id) { |n| n + 100 } # Preserve first 100
|
sequence(:id) { |n| n + 100 } # Preserve first 100
|
||||||
sequence(:name) { |n| "Group#{n}" }
|
sequence(:name) { |n| "Group#{n}" }
|
||||||
association :founder, factory: :user
|
association :founder, factory: :user
|
||||||
|
|
||||||
|
initialize_with { Group.find_or_create_by_id(id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :admin do
|
trait :admin do
|
||||||
name "Admins"
|
name "Admins"
|
||||||
id Group::ADMINS
|
id Group::ADMINS
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :caster do
|
||||||
|
name "Shoutcasters"
|
||||||
|
id Group::CASTERS
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :champions do
|
trait :champions do
|
||||||
name "Champions"
|
name "Champions"
|
||||||
id Group::CHAMPIONS
|
id Group::CHAMPIONS
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :donors do
|
trait :donors do
|
||||||
name "Donors"
|
name "Donors"
|
||||||
id Group::DONORS
|
id Group::DONORS
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :gather_moderator do
|
trait :gather_moderator do
|
||||||
name "Gather Moderator"
|
name "Gather Moderator"
|
||||||
id Group::GATHER_MODERATORS
|
id Group::GATHER_MODERATORS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :ref do
|
||||||
|
name "Referees"
|
||||||
|
id Group::REFEREES
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
13
spec/factories/match.rb
Executable file
13
spec/factories/match.rb
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :match do
|
||||||
|
contest
|
||||||
|
contester1 do
|
||||||
|
create(:contester, contest: contest)
|
||||||
|
end
|
||||||
|
contester2 do
|
||||||
|
create(:contester, contest: contest)
|
||||||
|
end
|
||||||
|
|
||||||
|
match_time 1.hour.from_now
|
||||||
|
end
|
||||||
|
end
|
14
spec/factories/user.rb
Normal file → Executable file
14
spec/factories/user.rb
Normal file → Executable file
|
@ -20,6 +20,20 @@ FactoryGirl.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :caster do
|
||||||
|
after(:create) do |user|
|
||||||
|
group = create(:group, :caster)
|
||||||
|
create :grouper, user: user, group: group
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :ref do
|
||||||
|
after(:create) do |user|
|
||||||
|
group = create(:group, :ref)
|
||||||
|
create :grouper, user: user, group: group
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trait :chris do
|
trait :chris do
|
||||||
steamid "0:1:58097444"
|
steamid "0:1:58097444"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue