Sha256: ebd773a7f5035e622359cc3ab578e15957bc28b34ad244a81c3fd3f2631d06c2

Contents?: true

Size: 2 KB

Versions: 7

Compression:

Stored size: 2 KB

Contents

class TestModel < Ddr::Models::Base
end

class TestContent < TestModel
  include Ddr::Models::HasContent
end

class TestParent < TestModel
  include Ddr::Models::HasChildren
  has_many :children, property: :is_part_of, class_name: 'TestChild'
end

class TestChild < TestModel
  belongs_to :parent, property: :is_part_of, class_name: 'TestParent'
end

class TestModelOmnibus < TestModel
  include Ddr::Models::Governable
  include Ddr::Models::HasContent
  include Ddr::Models::HasAttachments
  has_many :children, property: :is_part_of, class_name: 'TestChild'
  belongs_to :parent, property: :is_part_of, class_name: 'TestParent'
end

FactoryGirl.define do
  
  factory :test_model do
    title [ "DulHydra Test Object" ]
    sequence(:identifier) { |n| [ "test%05d" % n ] }
  end
  
  factory :test_parent do
    title [ "DulHydra Test Parent Object" ]
    sequence(:identifier) { |n| [ "testparent%05d" % n ] }
    
    factory :test_parent_has_children do
      ignore do
        child_count 3
      end
      after(:create) do |parent, evaluator|
        FactoryGirl.create_list(:test_child, evaluator.child_count, :parent => parent)
      end
    end
  end

  factory :test_child do
    title [ "DulHydra Test Child Object" ]
    sequence(:identifier) { |n| [ "testchild%05d" % n ] }
    
    factory :test_child_has_parent do
      association :parent, :factory => :test_parent
    end
  end
  
  factory :test_content do
    title [ "DulHydra Test Content Object" ]
    sequence(:identifier) { |n| [ "testcontent%05d" % n ] }
    after(:build) do |c|
      c.upload File.join(Ddr::Models::Engine.root, "spec", "fixtures", "library-devil.tiff")
    end
      
    factory :test_content_with_fixity_check do
      after(:create) { |c| c.fixity_check! }
    end
  end

  factory :test_model_omnibus do
    title [ "DulHydra Test Omnibus Object" ]
    sequence(:identifier) { |n| [ "test%05d" % n ] }
    after(:build) do |c|
      c.upload File.join(Ddr::Models::Engine.root, "spec", "fixtures", "library-devil.tiff")
    end
  end
  
end
  

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddr-models-1.13.2 spec/factories/test_model_factories.rb
ddr-models-1.13.1 spec/factories/test_model_factories.rb
ddr-models-1.13.0 spec/factories/test_model_factories.rb
ddr-models-1.12.3 spec/factories/test_model_factories.rb
ddr-models-1.12.2 spec/factories/test_model_factories.rb
ddr-models-1.12.1 spec/factories/test_model_factories.rb
ddr-models-1.12.0 spec/factories/test_model_factories.rb