Commit 722764b

mokha <mokha@cisco.com>
2018-09-22 17:44:34
split factory files.
1 parent f08a806
spec/factories/authentication.rb
@@ -0,0 +1,7 @@
+FactoryBot.define do
+  factory :authentication do
+    user
+
+    factory :password_authentication, class: PasswordAuthentication
+  end
+end
spec/factories/authorization.rb
@@ -0,0 +1,6 @@
+FactoryBot.define do
+  factory :authorization do
+    user
+    client
+  end
+end
spec/factories/client.rb
@@ -0,0 +1,7 @@
+FactoryBot.define do
+  factory :client do
+    uuid { SecureRandom.uuid }
+    name { FFaker::Name.name }
+    redirect_uri { FFaker::Internet.uri('https') }
+  end
+end
spec/factories/token.rb
@@ -0,0 +1,24 @@
+FactoryBot.define do
+  factory :token do
+    uuid { SecureRandom.uuid }
+    authorization { nil }
+    association :audience, factory: :client
+    association :subject, factory: :user
+
+    factory :access_token do
+      token_type { :access }
+    end
+
+    factory :refresh_token do
+      token_type { :refresh }
+    end
+
+    trait :revoked do
+      revoked_at { Time.now }
+    end
+
+    trait :expired do
+      expired_at { 1.minute.ago }
+    end
+  end
+end
spec/factories/user.rb
@@ -0,0 +1,11 @@
+FactoryBot.define do
+  factory :user do
+    email { FFaker::Internet.email }
+    uuid { SecureRandom.uuid }
+    password { FFaker::Internet.password }
+
+    trait :mfa_configured do
+      mfa_secret { ::ROTP::Base32.random_base32 }
+    end
+  end
+end
spec/factories.rb
@@ -1,48 +1,4 @@
 FactoryBot.define do
   sequence(:email) { |n| FFaker::Internet.email }
   sequence(:password) { |n| FFaker::Internet.password }
-
-  factory :token do
-    uuid { SecureRandom.uuid }
-    authorization { nil }
-    association :audience, factory: :client
-    association :subject, factory: :user
-
-    factory :access_token do
-      token_type { :access }
-    end
-
-    factory :refresh_token do
-      token_type { :refresh }
-    end
-
-    trait :revoked do
-      revoked_at { Time.now }
-    end
-
-    trait :expired do
-      expired_at { 1.minute.ago }
-    end
-  end
-
-  factory :authorization do
-    user
-    client
-  end
-
-  factory :client do
-    uuid { SecureRandom.uuid }
-    name { FFaker::Name.name }
-    redirect_uri { FFaker::Internet.uri('https') }
-  end
-
-  factory :user do
-    email { FFaker::Internet.email }
-    uuid { SecureRandom.uuid }
-    password { FFaker::Internet.password }
-
-    trait :mfa_configured do
-      mfa_secret { ::ROTP::Base32.random_base32 }
-    end
-  end
 end