Skip to content

Commit

Permalink
feat(FactoryBot): expand factories
Browse files Browse the repository at this point in the history
  • Loading branch information
toastercup committed Aug 13, 2018
1 parent ebb3d45 commit d6c15e8
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 7 deletions.
7 changes: 7 additions & 0 deletions spec/factories/content_item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryBot.define do
factory :content_item do
state {%w(draft published).sample}
association :creator, factory: :user
content_type
end
end
8 changes: 8 additions & 0 deletions spec/factories/content_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryBot.define do
factory :content_type do
name {Faker::Commerce.product_name}
contract
description {Faker::Lorem.sentence(4, false, 0)}
association :creator, factory: :user
end
end
2 changes: 1 addition & 1 deletion spec/factories/contracts.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :cortex_contract, class: 'Cortex::Contract' do
name 'Bogus'
name {Faker::Lorem.word}
association :tenant, factory: :cortex_tenant
end
end
2 changes: 1 addition & 1 deletion spec/factories/decorators.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :cortex_decorator, class: 'Cortex::Decorator' do
name 'Wizard'
data {}
data {{}}
association :tenant, factory: :cortex_tenant
end
end
15 changes: 15 additions & 0 deletions spec/factories/field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FactoryBot.define do
factory :field do
content_type
field_type {"text_field_type"}
required false
name {Faker::Lorem.word}
name_id {name.downcase}
validations {{}}
metadata {{}}

trait :slug do
validations {{length: {maximum: 75}, presence: true, uniqueness: true}}
end
end
end
7 changes: 7 additions & 0 deletions spec/factories/field_item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryBot.define do
factory :field_item do
data {{}}
field
content_item
end
end
2 changes: 1 addition & 1 deletion spec/factories/tenants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
factory :cortex_tenant, class: 'Cortex::Tenant' do
sequence(:name) {|n| "tenant #{n}"}
sequence(:name_id) {|n| "tenant_#{n}"}
description { Faker::Lorem.sentence(4, false, 0) }
description {Faker::Lorem.sentence(4, false, 0)}
end
end
8 changes: 4 additions & 4 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FactoryBot.define do
factory :cortex_user, class: 'Cortex::User' do
firstname { Faker::Name.first_name }
lastname { Faker::Name.last_name }
email { Faker::Internet.unique.safe_email }
password { Faker::Internet.password }
firstname {Faker::Name.first_name}
lastname {Faker::Name.last_name}
email {Faker::Internet.unique.safe_email}
password {Faker::Internet.password}

transient do
tenants_count 5
Expand Down

0 comments on commit d6c15e8

Please sign in to comment.