Sha256: 762ff5cd7837d955a5a8e078ab3056a05a25927577f76b0efd7fa06512a4d395

Contents?: true

Size: 1.96 KB

Versions: 55

Compression:

Stored size: 1.96 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
      transient 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", "imageA.tif")
    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", "imageA.tif")
    end
  end

end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
ddr-models-2.6.2 spec/factories/test_model_factories.rb
ddr-models-2.6.1 spec/factories/test_model_factories.rb
ddr-models-2.6.0 spec/factories/test_model_factories.rb
ddr-models-2.6.0.rc4 spec/factories/test_model_factories.rb
ddr-models-2.6.0.rc3 spec/factories/test_model_factories.rb
ddr-models-2.6.0.rc2 spec/factories/test_model_factories.rb
ddr-models-2.6.0.rc1 spec/factories/test_model_factories.rb
ddr-models-2.5.3 spec/factories/test_model_factories.rb
ddr-models-2.5.2 spec/factories/test_model_factories.rb
ddr-models-2.5.1 spec/factories/test_model_factories.rb
ddr-models-2.5.0 spec/factories/test_model_factories.rb
ddr-models-2.5.0.rc1 spec/factories/test_model_factories.rb
ddr-models-2.4.16 spec/factories/test_model_factories.rb
ddr-models-2.4.15 spec/factories/test_model_factories.rb
ddr-models-2.4.14 spec/factories/test_model_factories.rb
ddr-models-2.4.13 spec/factories/test_model_factories.rb
ddr-models-2.4.12 spec/factories/test_model_factories.rb
ddr-models-2.4.11 spec/factories/test_model_factories.rb
ddr-models-2.4.10 spec/factories/test_model_factories.rb
ddr-models-2.4.9 spec/factories/test_model_factories.rb