Initial commit
This commit is contained in:
14
spec/factories/activity.rb
Normal file
14
spec/factories/activity.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :activity do
|
||||
user { FactoryBot.create(:user) }
|
||||
user_ip { Faker::Internet.ip_v4_address }
|
||||
user_agent { Faker::Internet.user_agent }
|
||||
category { %w[admin user].sample }
|
||||
topic { %w[session password otp account].sample }
|
||||
action { %w[otp::enable login logout signup].sample }
|
||||
result { %w[succeed failed].sample }
|
||||
data { {data: Faker::Lorem.sentence(word_count: 3, supplemental: true, random_words_to_add: 4)}.to_json }
|
||||
end
|
||||
end
|
||||
18
spec/factories/api_keys.rb
Normal file
18
spec/factories/api_keys.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :api_key, class: 'APIKey' do
|
||||
kid { Faker::Crypto.sha256 }
|
||||
secret { SecureRandom.hex(16) }
|
||||
scope { %w[trade] }
|
||||
algorithm { 'HS256' }
|
||||
|
||||
trait :with_service_account do
|
||||
key_holder_account { create(:service_account) }
|
||||
end
|
||||
|
||||
trait :with_user do
|
||||
key_holder_account { create(:user) }
|
||||
end
|
||||
end
|
||||
end
|
||||
15
spec/factories/document.rb
Normal file
15
spec/factories/document.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :document do
|
||||
user
|
||||
|
||||
doc_type { 'Passport' }
|
||||
doc_number { Faker::Code.asin }
|
||||
doc_expire { Faker::Business.credit_card_expiry_date }
|
||||
|
||||
after(:build) do |doc|
|
||||
doc.upload.download!(Faker::Company.logo)
|
||||
end
|
||||
end
|
||||
end
|
||||
10
spec/factories/label.rb
Normal file
10
spec/factories/label.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :label do
|
||||
key { ::Faker::Internet.slug(glue: '-') }
|
||||
value { ::Faker::Internet.slug(glue: '-') }
|
||||
scope { 'public' }
|
||||
user { create(:user) }
|
||||
end
|
||||
end
|
||||
9
spec/factories/level.rb
Normal file
9
spec/factories/level.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :level do
|
||||
key { Faker::Hacker.noun }
|
||||
value { Faker::Hacker.adjective }
|
||||
description { Faker::Hacker.say_something_smart }
|
||||
end
|
||||
end
|
||||
10
spec/factories/permission.rb
Normal file
10
spec/factories/permission.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :permission do
|
||||
role { %w[member trader broker admin accountant support technical compliance superadmin] }
|
||||
path { 'api/v2' }
|
||||
action { 'ACCEPT' }
|
||||
verb { %w[get post put delete head patch all] }
|
||||
end
|
||||
end
|
||||
8
spec/factories/phones.rb
Normal file
8
spec/factories/phones.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :phone do
|
||||
number { '12345678911' }
|
||||
user
|
||||
end
|
||||
end
|
||||
15
spec/factories/profile.rb
Normal file
15
spec/factories/profile.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :profile do
|
||||
user { FactoryBot.create(:user) }
|
||||
author { }
|
||||
first_name { Faker::Name.first_name }
|
||||
last_name { Faker::Name.last_name }
|
||||
dob { Faker::Date.birthday }
|
||||
address { Faker::Address.state }
|
||||
city { Faker::Address.city }
|
||||
country { Faker::Address.country_code_long }
|
||||
postcode { Faker::Address.postcode }
|
||||
end
|
||||
end
|
||||
8
spec/factories/restriction.rb
Normal file
8
spec/factories/restriction.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :restriction do
|
||||
scope { 'ip_subnet' }
|
||||
value { '0.0.0.0/0' }
|
||||
end
|
||||
end
|
||||
13
spec/factories/service_account.rb
Normal file
13
spec/factories/service_account.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :service_account do
|
||||
user { FactoryBot.create(:user) }
|
||||
email { Faker::Internet.email }
|
||||
uid { UIDGenerator.generate("SI") }
|
||||
|
||||
trait :without_user do
|
||||
user { nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
36
spec/factories/user.rb
Normal file
36
spec/factories/user.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :user do
|
||||
email { Faker::Internet.email }
|
||||
password { 'Tecohvi0' }
|
||||
password_confirmation { 'Tecohvi0' }
|
||||
state { 'active' }
|
||||
|
||||
trait :with_profile do
|
||||
after(:create) do |user, _|
|
||||
create(:profile, user: user)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_document do
|
||||
after(:create) do |user, _|
|
||||
create(:document, user: user)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_phone do
|
||||
after(:create) do |user, _|
|
||||
create(:phone, user: user)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_document_phone_profile do
|
||||
after(:create) do |user, _|
|
||||
create(:phone, user: user)
|
||||
create(:profile, user: user)
|
||||
create(:document, user: user)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user