-
Notifications
You must be signed in to change notification settings - Fork 4
/
load_geo_metadata_spec.rb
51 lines (45 loc) · 1.58 KB
/
load_geo_metadata_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Robots::DorRepo::GisAssembly::LoadGeoMetadata do
let(:workflow_client) { instance_double(Dor::Workflow::Client) }
let(:robot) { described_class.new }
before do
allow(WorkflowClientFactory).to receive(:build).and_return(workflow_client)
end
describe '#perform' do
let(:druid) { 'druid:12345' }
let(:stub_config) { double('Geohydra config', stage: '/stage') }
let(:fake_tags_client) do
instance_double(Dor::Services::Client::AdministrativeTags, list: [], create: nil)
end
let(:object_client) do
instance_double(Dor::Services::Client::Object, metadata: metadata_client)
end
let(:metadata_client) do
instance_double(Dor::Services::Client::Metadata, legacy_update: true)
end
let(:xml) do
<<~XML
<xml />
XML
end
before do
allow(Dor::Config).to receive(:geohydra).and_return(stub_config)
allow(File).to receive(:size?).and_return(100)
allow(Dor::Services::Client).to receive(:object).and_return(object_client)
allow(File).to receive(:read).and_return(xml)
allow(File).to receive(:mtime).and_return(Time.now)
allow(robot).to receive(:tags_client).with(druid).and_return(fake_tags_client)
end
it 'tags the object' do
robot.perform(druid)
expect(fake_tags_client).to have_received(:create).once.with(tags: ['Dataset : GIS'])
expect(metadata_client).to have_received(:legacy_update).with(
geo: {
updated: Time,
content: "<xml />\n"
}
)
end
end
end