From 55fcc68e5161c84449465a529217fe8177abac33 Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Fri, 31 Aug 2018 17:39:14 +0200 Subject: [PATCH] added trasnfer field --- app/controllers/dois_controller.rb | 8 +++++--- spec/fixtures/files/transfer.json | 3 +-- spec/requests/dois_spec.rb | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index ece8a4a38..3af1ed6a5 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -223,10 +223,12 @@ def update exists = @doi.present? if exists - if safe_params[:xml].present? || safe_params[:url].present? || safe_params[:event].present? + if params[:data][:attributes][:mode] == "transfer" + authorize! :transfer, @doi + elsif safe_params[:xml].present? || safe_params[:url].present? || safe_params[:event].present? authorize! :update, @doi else - authorize! :transfer, @doi + fail ActionController::ParameterMissing end @doi.assign_attributes(safe_params.except(:doi)) @@ -391,7 +393,7 @@ def safe_params last_landing_page_status: p["last-landing-page-status"], last_landing_page_status_check: p["last-landing-page-status-check"], last_landing_page_content_type: p["last-landing-page-content-type"] - ).except("confirm-doi", :identifier, :prefix, :suffix, "resource-type-subtype", "metadata-version", "schema-version", :state, "is-active", :created, :registered, :updated, :mode, "last-landing-page", "last-landing-page-status", "last-landing-page-status-check", "last-landing-page-content-type") + ).except("confirm-doi", :identifier, :prefix, :suffix, "resource-type-subtype", "metadata-version", "schema-version", :state, :mode, "is-active", :created, :registered, :updated, "last-landing-page", "last-landing-page-status", "last-landing-page-status-check", "last-landing-page-content-type") end def underscore_str(str) diff --git a/spec/fixtures/files/transfer.json b/spec/fixtures/files/transfer.json index b2e55460a..a154688d7 100644 --- a/spec/fixtures/files/transfer.json +++ b/spec/fixtures/files/transfer.json @@ -31,8 +31,7 @@ "event": null, "created": "2018-08-29T13:45:34.000Z", "registered": "2018-08-29T14:07:53.000Z", - "updated": "2018-08-29T14:07:53.000Z", - "mode": "transfer" + "updated": "2018-08-29T14:07:53.000Z" }, "relationships": { "client": { diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index a61ffcdc8..da20e063e 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -405,6 +405,7 @@ "data" => { "type" => "dois", "attributes" => { + "mode" => "transfer" }, "relationships"=> { "client"=> {