fix factories with spring
This commit is contained in:
parent
98deb40df1
commit
9f67cade7e
4 changed files with 173 additions and 158 deletions
|
|
@ -13,6 +13,8 @@ Metrics/LineLength:
|
||||||
# the code easier to read (by naming things), but can also clutter the class
|
# the code easier to read (by naming things), but can also clutter the class
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 20
|
Max: 20
|
||||||
|
Exclude:
|
||||||
|
- "lib/diaspora_federation/test/factories.rb"
|
||||||
|
|
||||||
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
|
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
|
|
@ -152,6 +154,8 @@ Metrics/PerceivedComplexity:
|
||||||
Max: 10
|
Max: 10
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 20
|
Max: 20
|
||||||
|
Exclude:
|
||||||
|
- "lib/diaspora_federation/test/factories.rb"
|
||||||
|
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Max: 1500
|
Max: 1500
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
require "diaspora_federation"
|
require "diaspora_federation"
|
||||||
require "factory_girl"
|
require "factory_girl"
|
||||||
|
|
||||||
FactoryGirl.define do
|
module DiasporaFederation
|
||||||
|
module Test
|
||||||
|
module Factories
|
||||||
|
def self.federation_factories
|
||||||
|
FactoryGirl.define do
|
||||||
initialize_with { new(attributes) }
|
initialize_with { new(attributes) }
|
||||||
sequence(:guid) { UUID.generate :compact }
|
sequence(:guid) { UUID.generate :compact }
|
||||||
sequence(:diaspora_id) {|n| "person-#{n}-#{SecureRandom.hex(3)}@localhost:3000" }
|
sequence(:diaspora_id) {|n| "person-#{n}-#{SecureRandom.hex(3)}@localhost:3000" }
|
||||||
|
|
@ -82,7 +86,8 @@ FactoryGirl.define do
|
||||||
parent_guid { generate(:guid) }
|
parent_guid { generate(:guid) }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :participation_entity, class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
|
factory :participation_entity,
|
||||||
|
class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
|
||||||
guid
|
guid
|
||||||
target_type "Post"
|
target_type "Post"
|
||||||
diaspora_id
|
diaspora_id
|
||||||
|
|
@ -175,10 +180,13 @@ FactoryGirl.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :poll_participation_entity,
|
factory :poll_participation_entity,
|
||||||
class: DiasporaFederation::Entities::PollParticipation,
|
class: DiasporaFederation::Entities::PollParticipation, parent: :relayable_entity do
|
||||||
parent: :relayable_entity do
|
|
||||||
guid
|
guid
|
||||||
diaspora_id
|
diaspora_id
|
||||||
poll_answer_guid { generate(:guid) }
|
poll_answer_guid { generate(:guid) }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
require "diaspora_federation/test"
|
||||||
|
|
||||||
|
DiasporaFederation::Test::Factories.federation_factories
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :person do
|
factory :person do
|
||||||
diaspora_id
|
diaspora_id
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ require "rspec/rails"
|
||||||
require "webmock/rspec"
|
require "webmock/rspec"
|
||||||
|
|
||||||
# load factory girl factories
|
# load factory girl factories
|
||||||
require "diaspora_federation/test"
|
|
||||||
require "factories"
|
require "factories"
|
||||||
|
|
||||||
# load test entities
|
# load test entities
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue