From d3f2d1a35ebcc0ffc55bff8da657a142bd9a5f06 Mon Sep 17 00:00:00 2001 From: Bryceson Laing Date: Mon, 18 Nov 2024 10:39:47 -0600 Subject: [PATCH 1/4] add agency to dois response --- app/serializers/datacite_doi_serializer.rb | 1 + spec/requests/datacite_dois/datacite_dois_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/serializers/datacite_doi_serializer.rb b/app/serializers/datacite_doi_serializer.rb index fc27235c5..39682551c 100644 --- a/app/serializers/datacite_doi_serializer.rb +++ b/app/serializers/datacite_doi_serializer.rb @@ -18,6 +18,7 @@ class DataciteDoiSerializer :titles, :publisher, :container, + :agency, :publication_year, :subjects, :contributors, diff --git a/spec/requests/datacite_dois/datacite_dois_spec.rb b/spec/requests/datacite_dois/datacite_dois_spec.rb index 4aa5593e9..9bbbc13e9 100755 --- a/spec/requests/datacite_dois/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois/datacite_dois_spec.rb @@ -438,6 +438,17 @@ def clear_doi_index end end + describe "GET /dois/:id with agency values", prefix_pool_size: 1 do + let!(:doi) { create(:doi, client: client, aasm_state: "findable") } + + it "returns agency values" do + get "/dois/#{doi.doi}", nil, headers + + expect(last_response.status).to eq(200) + expect(json.dig("data", "attributes", "agency")).to eq() + end + end + describe "GET /dois with client-type filter", prefix_pool_size: 3 do let!(:dois) { create_list(:doi, 10, client: client, aasm_state: "findable", version_info: "testtag") } let(:client_igsn_id_catalog) { create(:client, provider: provider, client_type: "igsnCatalog") } From 32aa75fce00d86f4407a197d49010fd744c6715e Mon Sep 17 00:00:00 2001 From: Bryceson Laing Date: Mon, 18 Nov 2024 15:28:25 -0600 Subject: [PATCH 2/4] update spec for agency --- spec/requests/datacite_dois/datacite_dois_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/datacite_dois/datacite_dois_spec.rb b/spec/requests/datacite_dois/datacite_dois_spec.rb index 9bbbc13e9..04278b010 100755 --- a/spec/requests/datacite_dois/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois/datacite_dois_spec.rb @@ -445,7 +445,7 @@ def clear_doi_index get "/dois/#{doi.doi}", nil, headers expect(last_response.status).to eq(200) - expect(json.dig("data", "attributes", "agency")).to eq() + expect(json.dig("data", "attributes", "agency")).to eq("datacite") end end From cc8c40f3eb3c590d3aef889eff573bfd9e374378 Mon Sep 17 00:00:00 2001 From: Bryceson Laing Date: Tue, 19 Nov 2024 10:09:38 -0600 Subject: [PATCH 3/4] only return agency when include_other_registration_agencies is set --- app/serializers/datacite_doi_serializer.rb | 4 +++- spec/requests/datacite_dois/datacite_dois_spec.rb | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/serializers/datacite_doi_serializer.rb b/app/serializers/datacite_doi_serializer.rb index 39682551c..41d70982a 100644 --- a/app/serializers/datacite_doi_serializer.rb +++ b/app/serializers/datacite_doi_serializer.rb @@ -18,7 +18,6 @@ class DataciteDoiSerializer :titles, :publisher, :container, - :agency, :publication_year, :subjects, :contributors, @@ -66,6 +65,9 @@ class DataciteDoiSerializer :citations_over_time, if: Proc.new { |_object, params| params && params[:detail] } + attributes :agency, + if: Proc.new { |_object, params| params && params[:include_other_registration_agencies] } + belongs_to :client, record_type: :clients belongs_to :provider, diff --git a/spec/requests/datacite_dois/datacite_dois_spec.rb b/spec/requests/datacite_dois/datacite_dois_spec.rb index 04278b010..14c3bcf02 100755 --- a/spec/requests/datacite_dois/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois/datacite_dois_spec.rb @@ -441,12 +441,19 @@ def clear_doi_index describe "GET /dois/:id with agency values", prefix_pool_size: 1 do let!(:doi) { create(:doi, client: client, aasm_state: "findable") } - it "returns agency values" do - get "/dois/#{doi.doi}", nil, headers + it "returns agency values when flag is set" do + get "/dois/#{doi.doi}?include_other_registration_agencies=true", nil, headers expect(last_response.status).to eq(200) expect(json.dig("data", "attributes", "agency")).to eq("datacite") end + + it "does not returns agency values when flag isn't set" do + get "/dois/#{doi.doi}", nil, headers + + expect(last_response.status).to eq(200) + expect(json.dig("data", "attributes")).to_not have_key("agency") + end end describe "GET /dois with client-type filter", prefix_pool_size: 3 do From c3df4350c1f0f3802077f179220b98e278440f07 Mon Sep 17 00:00:00 2001 From: Bryceson Laing Date: Tue, 19 Nov 2024 17:08:07 -0600 Subject: [PATCH 4/4] pass include_other_registration_agencies to serializer --- app/controllers/datacite_dois_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/datacite_dois_controller.rb b/app/controllers/datacite_dois_controller.rb index 46c3d51b9..456e4822c 100644 --- a/app/controllers/datacite_dois_controller.rb +++ b/app/controllers/datacite_dois_controller.rb @@ -203,6 +203,7 @@ def index detail: params[:detail], affiliation: params[:affiliation], publisher: params[:publisher], + include_other_registration_agencies: params[:include_other_registration_agencies], is_collection: options[:is_collection], } @@ -349,6 +350,7 @@ def index composite: params[:composite], affiliation: params[:affiliation], publisher: params[:publisher], + include_other_registration_agencies: params[:include_other_registration_agencies], is_collection: options[:is_collection], } @@ -447,6 +449,7 @@ def show composite: nil, affiliation: params[:affiliation], publisher: params[:publisher], + include_other_registration_agencies: params[:include_other_registration_agencies], } render( @@ -504,7 +507,8 @@ def validate options[:params] = { current_ability: current_ability, affiliation: params[:affiliation], - publisher: params[:publisher] + publisher: params[:publisher], + include_other_registration_agencies: params[:include_other_registration_agencies], } render( @@ -535,6 +539,7 @@ def create detail: true, affiliation: params[:affiliation], publisher: params[:publisher], + include_other_registration_agencies: params[:include_other_registration_agencies], } render( @@ -595,6 +600,7 @@ def update detail: true, affiliation: params[:affiliation], publisher: params[:publisher], + include_other_registration_agencies: params[:include_other_registration_agencies], } render(