Skip to content

Commit

Permalink
Merge pull request #4590 from sul-dlss/cocina_update
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgiarlo authored Sep 13, 2023
2 parents fb4cf04 + 23e4eab commit a816da6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails', '~> 7.0'

# DLSS/domain-specific dependencies
gem 'cocina-models', '~> 0.90.0'
gem 'cocina-models', '~> 0.91.0'
gem 'datacite', '~> 0.3.0'
gem 'dor-workflow-client', '~> 5.0'
gem 'druid-tools', '~> 2.2'
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ GEM
capistrano-bundler (>= 1.1, < 3)
capistrano-shared_configs (0.2.2)
chronic (0.10.2)
cocina-models (0.90.0)
cocina-models (0.91.0)
activesupport
deprecation
dry-struct (~> 1.0)
Expand All @@ -114,15 +114,15 @@ GEM
jsonpath
nokogiri
openapi3_parser
openapi_parser (>= 0.11.1, < 1.0)
openapi_parser (~> 1.0)
rss
super_diff
thor
zeitwerk (~> 2.1)
coderay (1.1.3)
committee (4.99.1)
committee (5.0.0)
json_schema (~> 0.14, >= 0.14.3)
openapi_parser (>= 0.11.1, < 1.0)
openapi_parser (~> 1.0)
rack (>= 1.5)
commonmarker (0.23.10)
concurrent-ruby (1.2.2)
Expand Down Expand Up @@ -312,7 +312,7 @@ GEM
okcomputer (1.18.4)
openapi3_parser (0.9.2)
commonmarker (~> 0.17)
openapi_parser (0.15.0)
openapi_parser (1.0.0)
optimist (3.1.0)
parallel (1.23.0)
parser (3.2.2.3)
Expand Down Expand Up @@ -526,7 +526,7 @@ DEPENDENCIES
capistrano-passenger
capistrano-rails
capistrano-shared_configs
cocina-models (~> 0.90.0)
cocina-models (~> 0.91.0)
committee
config
datacite (~> 0.3.0)
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/create_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@
view: 'stanford',
download: 'none',
controlledDigitalLending: false,
embargo: { view: 'world', download: 'world', releaseDate: '2020-02-29' }
embargo: { view: 'world', download: 'world', releaseDate: '2020-02-29T07:00:00.000+00:00' }
})
end
let(:data) do
Expand All @@ -688,7 +688,7 @@
"cocinaVersion":"#{Cocina::Models::VERSION}",
"type":"#{Cocina::Models::ObjectType.book}",
"label":"This is my label","version":1,"access":{"view":"stanford","download":"none","controlledDigitalLending":false,
"embargo":{"view":"world","download":"world","releaseDate":"2020-02-29"}},
"embargo":{"view":"world","download":"world","releaseDate":"2020-02-29T07:00:00.000+00:00"}},
"administrative":{"releaseTags":[],"hasAdminPolicy":"#{admin_policy_id}"},
"description":{"title":[{"value":"This is my title"}]},
"identification":{"sourceId":"googlebooks:999999"},
Expand Down
18 changes: 6 additions & 12 deletions spec/requests/start_accession_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
end

it 'does not open or close a version and starts default workflow' do
post("/v1/objects/#{druid}/accession",
params:,
post("/v1/objects/#{druid}/accession?#{params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" })
expect(response).to be_successful
expect(EventFactory).to have_received(:create).with(
Expand All @@ -55,8 +54,7 @@
end

it 'can override the default workflow' do
post "/v1/objects/#{druid}/accession",
params: params.merge(workflow: 'accessionWF'),
post "/v1/objects/#{druid}/accession?#{params.merge(workflow: 'accessionWF').to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response).to be_successful
expect(workflow_client).to have_received(:create_workflow_by_name).with(druid, 'accessionWF', version: '1')
Expand All @@ -71,17 +69,15 @@
end

it 'opens and closes a version and starts default workflow' do
post("/v1/objects/#{druid}/accession",
params:,
post("/v1/objects/#{druid}/accession?#{params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" })
expect(workflow_client).to have_received(:create_workflow_by_name).with(druid, default_start_accession_workflow, version: '2')
expect(VersionService).to have_received(:open).with(cocina_object:, **params)
expect(VersionService).to have_received(:close).with(druid:, version: 2, **close_params)
end

it 'can override the default workflow' do
post "/v1/objects/#{druid}/accession",
params: params.merge(workflow: 'accessionWF'),
post "/v1/objects/#{druid}/accession?#{params.merge(workflow: 'accessionWF').to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(workflow_client).to have_received(:create_workflow_by_name).with(druid, 'accessionWF', version: '2')
expect(VersionService).to have_received(:open).with(cocina_object:, **params)
Expand All @@ -95,8 +91,7 @@
end

it 'closes a version and starts default workflow' do
post("/v1/objects/#{druid}/accession",
params:,
post("/v1/objects/#{druid}/accession?#{params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" })
expect(response).to have_http_status(:success)
expect(workflow_client).to have_received(:create_workflow_by_name).with(druid, default_start_accession_workflow, version: '1')
Expand All @@ -111,8 +106,7 @@
end

it 'returns an unacceptable response and does not start any workflows' do
post("/v1/objects/#{druid}/accession",
params:,
post("/v1/objects/#{druid}/accession?#{params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" })
expect(EventFactory).to have_received(:create).with(
{ data: { workflow: 'assemblyWF' },
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/update_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
embargo: {
view: 'world',
download: 'world',
releaseDate: '2020-02-29'
releaseDate: '2020-02-29T07:00:00.000+00:00'
}
}
)
Expand All @@ -807,7 +807,7 @@
"type":"#{Cocina::Models::ObjectType.book}",
"label":"This is my label","version":1,
"access":{"view":"stanford","download":"stanford",
"embargo":{"view":"world","download":"world","releaseDate":"2020-02-29"}
"embargo":{"view":"world","download":"world","releaseDate":"2020-02-29T07:00:00.000+00:00"}
},
"administrative":{"releaseTags":[],"hasAdminPolicy":"#{apo_druid}"},
"description":{
Expand Down
18 changes: 6 additions & 12 deletions spec/requests/versions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
end

it 'closes the current version when posted to' do
post '/v1/objects/druid:mx123qw2323/versions/current/close',
params: close_params,
post "/v1/objects/druid:mx123qw2323/versions/current/close?#{close_params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response).to have_http_status :ok
expect(response.body).to match(/version 1 closed/)
Expand All @@ -64,8 +63,7 @@
end

it 'returns an error' do
post '/v1/objects/druid:mx123qw2323/versions/current/close',
params: close_params,
post "/v1/objects/druid:mx123qw2323/versions/current/close?#{close_params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response).to have_http_status :unprocessable_entity
expect(response.body).to eq(
Expand Down Expand Up @@ -95,8 +93,7 @@
end

it 'opens a new object version when posted to' do
post '/v1/objects/druid:mx123qw2323/versions',
params: open_params,
post "/v1/objects/druid:mx123qw2323/versions?#{open_params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response).to be_successful
expect(response.body).to equal_cocina_model(cocina_object)
Expand All @@ -116,8 +113,7 @@
end

it 'returns a bad request error' do
post '/v1/objects/druid:mx123qw2323/versions',
params: incomplete_params,
post "/v1/objects/druid:mx123qw2323/versions?#{incomplete_params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response.body).to match('missing required parameters: description, significance')
expect(response).to have_http_status :bad_request
Expand All @@ -131,8 +127,7 @@
end

it 'returns an error' do
post '/v1/objects/druid:mx123qw2323/versions',
params: open_params,
post "/v1/objects/druid:mx123qw2323/versions?#{open_params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response.body).to eq('{"errors":[{"status":"422","title":"Unable to open version","detail":"Object net yet accessioned"}]}')
expect(response).to have_http_status :unprocessable_entity
Expand All @@ -145,8 +140,7 @@
end

it 'returns an error' do
post '/v1/objects/druid:mx123qw2323/versions',
params: open_params,
post "/v1/objects/druid:mx123qw2323/versions?#{open_params.to_query}",
headers: { 'Authorization' => "Bearer #{jwt}" }
expect(response.body).to eq('{"errors":[{"status":"500","title":"Unable to open version due to preservation client error","detail":"Oops, a 500"}]}')
expect(response).to have_http_status :internal_server_error
Expand Down

0 comments on commit a816da6

Please sign in to comment.