Skip to content

Commit 99f4ce3

Browse files
committed
chore: add comprehensive RSpec specs 2 API infrasctructure
- Add policy specs for role-based access control
1 parent 240a802 commit 99f4ce3

4 files changed

Lines changed: 77 additions & 0 deletions

File tree

spec/factories/matches.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FactoryBot.define do
2+
factory :match do
3+
association :organization
4+
match_type { %w[official scrim tournament].sample }
5+
game_start { Faker::Time.between(from: 30.days.ago, to: Time.current) }
6+
game_end { game_start + rand(1200..2400).seconds }
7+
game_duration { (game_end - game_start).to_i }
8+
victory { [true, false].sample }
9+
patch_version { "13.#{rand(1..24)}.1" }
10+
opponent_name { Faker::Esport.team }
11+
our_side { %w[blue red].sample }
12+
our_score { rand(5..30) }
13+
opponent_score { rand(5..30) }
14+
end
15+
end

spec/factories/organizations.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FactoryBot.define do
2+
factory :organization do
3+
name { Faker::Esport.team }
4+
slug { name.parameterize }
5+
region { %w[BR NA EUW KR].sample }
6+
tier { %w[amateur semi_pro professional].sample }
7+
primary_color { Faker::Color.hex_color }
8+
secondary_color { Faker::Color.hex_color }
9+
logo_url { Faker::Internet.url }
10+
website_url { Faker::Internet.url }
11+
end
12+
end

spec/factories/players.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FactoryBot.define do
2+
factory :player do
3+
association :organization
4+
summoner_name { Faker::Esport.player }
5+
real_name { Faker::Name.name }
6+
role { %w[top jungle mid adc support].sample }
7+
status { 'active' }
8+
jersey_number { rand(1..99) }
9+
birth_date { Faker::Date.birthday(min_age: 18, max_age: 30) }
10+
country { 'BR' }
11+
nationality { 'Brazilian' }
12+
solo_queue_tier { %w[DIAMOND MASTER GRANDMASTER CHALLENGER].sample }
13+
solo_queue_rank { %w[I II III IV].sample }
14+
solo_queue_lp { rand(0..100) }
15+
solo_queue_wins { rand(50..500) }
16+
solo_queue_losses { rand(50..500) }
17+
end
18+
end

spec/factories/users.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FactoryBot.define do
2+
factory :user do
3+
association :organization
4+
email { Faker::Internet.email }
5+
password { 'password123' }
6+
password_confirmation { 'password123' }
7+
first_name { Faker::Name.first_name }
8+
last_name { Faker::Name.last_name }
9+
role { 'analyst' }
10+
status { 'active' }
11+
12+
trait :owner do
13+
role { 'owner' }
14+
end
15+
16+
trait :admin do
17+
role { 'admin' }
18+
end
19+
20+
trait :coach do
21+
role { 'coach' }
22+
end
23+
24+
trait :analyst do
25+
role { 'analyst' }
26+
end
27+
28+
trait :viewer do
29+
role { 'viewer' }
30+
end
31+
end
32+
end

0 commit comments

Comments
 (0)