mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
Add match-related factories
This commit is contained in:
parent
7a41f1294c
commit
33455ee4f0
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
|
||||
factory :group do
|
||||
sequence(:id) { |n| n + 100 } # Preserve first 100
|
||||
sequence(:id) { |n| n + 100 } # Preserve first 100
|
||||
sequence(:name) { |n| "Group#{n}" }
|
||||
association :founder, factory: :user
|
||||
|
||||
initialize_with { Group.find_or_create_by_id(id) }
|
||||
end
|
||||
|
||||
trait :admin do
|
||||
name "Admins"
|
||||
id Group::ADMINS
|
||||
name "Admins"
|
||||
id Group::ADMINS
|
||||
end
|
||||
|
||||
trait :caster do
|
||||
name "Shoutcasters"
|
||||
id Group::CASTERS
|
||||
end
|
||||
|
||||
trait :champions do
|
||||
name "Champions"
|
||||
id Group::CHAMPIONS
|
||||
name "Champions"
|
||||
id Group::CHAMPIONS
|
||||
end
|
||||
|
||||
trait :donors do
|
||||
name "Donors"
|
||||
id Group::DONORS
|
||||
name "Donors"
|
||||
id Group::DONORS
|
||||
end
|
||||
|
||||
trait :gather_moderator do
|
||||
name "Gather Moderator"
|
||||
id Group::GATHER_MODERATORS
|
||||
end
|
||||
|
||||
trait :ref do
|
||||
name "Referees"
|
||||
id Group::REFEREES
|
||||
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
|
||||
|
||||
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
|
||||
steamid "0:1:58097444"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue