Sha256: f2dd4638ce720f330ce517ac1d788cb109a78330f96608fa10ba9081e37d3dd5

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require "ostruct"

describe RepoObject do
  let(:pid) { "TEST:#{noid}" }
  let(:noid) { '1234' }
  let(:bad_fedora_object) { nil }
  let(:create_date) { DateTime.new(2000,-11,-26,-20,-55,-54,'+7') }
  let(:date_added) { DateTime.new(2001,-11,-26,-20,-55,-54,'+7') }
  let(:modified_date) { DateTime.new(2002,-11,-26,-20,-55,-54,'+7') }

  let(:fedora_object) {
    double(
      'FedoraObject',
      to_param: noid,
      date_added: date_added,
      modified_date: modified_date,
      create_date: create_date
    )
  }

  describe ".create_repo_object" do
    let(:expected_url) { File.join(Rails.configuration.application_url, "show", fedora_object.to_param) }
    it 'should raise exception if no object given' do
      expect {
        RepoObject.create_from_fedora_object(nil)
      }.to raise_error(ArgumentError)
    end

    it 'should_create_data_in_purl_database' do
      RepoObject.create_from_fedora_object(fedora_object)
      results = RepoObject.where(:filename => fedora_object.to_param)
      object = results.first

      expect(object.filename).to eq(fedora_object.to_param)
      expect(object.url).to eq(expected_url)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curate-0.3.2 spec/models/repo_object_spec.rb
curate-0.3.1 spec/models/repo_object_spec.rb
curate-0.2.0 spec/models/repo_object_spec.rb
curate-0.1.3 spec/models/repo_object_spec.rb
curate-0.1.2 spec/models/repo_object_spec.rb
curate-0.1.1 spec/models/repo_object_spec.rb
curate-0.1.0 spec/models/repo_object_spec.rb