Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 21, 2019
1 parent f774e3a commit f742143
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def registerable?
# end

def is_registered_or_findable?
%w(registered findable).include?(aasm_state) || agency != "DataCite"
%w(registered findable).include?(aasm_state) || %w(crossref).include?(provider_id)
end

def validatable?
Expand All @@ -560,7 +560,7 @@ def validatable?
# update URL in handle system for registered and findable state
# providers europ and ethz do their own handle registration, so fetch url from handle system instead
def update_url
return nil if current_user.nil? || !is_registered_or_findable? || %w(Crossref).include?(agency)
return nil if current_user.nil? || !is_registered_or_findable?

if %w(europ ethz).include?(provider_id)
UrlJob.perform_later(doi)
Expand Down
11 changes: 4 additions & 7 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1377,18 +1377,16 @@
end
end

context 'state change with test prefix' do
let(:prefix) { create(:prefix, prefix: "10.5072") }
context 'draft doi no url' do
let(:prefix) { create(:prefix, prefix: "10.14454") }
let!(:client_prefix) { create(:client_prefix, client: client, prefix: prefix) }

let(:valid_attributes) do
{
"data" => {
"type" => "dois",
"attributes" => {
"doi" => "10.5072/10704",
"url" => "http://www.bl.uk/pdf/patspec.pdf",
"event" => "publish"
"doi" => "10.14454/10704"
}
}
}
Expand All @@ -1398,8 +1396,7 @@
post '/dois', valid_attributes, headers

expect(last_response.status).to eq(201)
expect(json.dig('data', 'attributes', 'url')).to eq("http://www.bl.uk/pdf/patspec.pdf")
expect(json.dig('data', 'attributes', 'doi')).to eq("10.5072/10704")
expect(json.dig('data', 'attributes', 'doi')).to eq("10.14454/10704")
expect(json.dig('data', 'attributes', 'state')).to eq("draft")
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/requests/events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
expect(last_response.status).to eq(201)
expect(json["errors"]).to be_nil
expect(json.dig("data", "id")).to eq(event.uuid)
expect(json.dig("data", "relationships", "subj", "data")).to eq("id"=>event.subj_id, "type"=>"objects")
expect(json.dig("data", "relationships", "dois", "data")).to eq([{"id"=>"10.1371/journal.pmed.0030186", "type"=>"dois"}])
end
end

Expand Down Expand Up @@ -228,7 +228,7 @@
expect(last_response.status).to eq(200)
expect(json["errors"]).to be_nil
expect(json.dig("data", "id")).to eq(event.uuid)
expect(json.dig("data", "relationships", "subj", "data")).to eq("id" => event.subj_id, "type"=>"objects")
expect(json.dig("data", "relationships", "dois", "data")).to eq([{"id"=>"10.1371/journal.pmed.0030186", "type"=>"dois"}])
end
end
end
Expand All @@ -254,7 +254,7 @@
expect(last_response.status).to eq(201)
expect(json["errors"]).to be_nil
expect(json.dig("data", "id")).to eq(event.uuid)
expect(json.dig("data", "relationships", "subj", "data")).to eq("id"=>event.subj_id, "type"=>"objects")
expect(json.dig("data", "relationships", "dois", "data")).to eq([{"id"=>"10.1371/journal.pmed.0030186", "type"=>"dois"}])
end
end

Expand Down Expand Up @@ -390,7 +390,7 @@

expect(last_response.status).to eq(200)
expect(json["errors"]).to be_nil
expect(json.dig("data", "relationships", "subj", "data")).to eq("id"=>event.subj_id, "type"=>"objects")
expect(json.dig("data", "relationships", "dois", "data")).to eq([{"id"=>"10.1371/journal.pmed.0030186", "type"=>"dois"}])
end
end
end
Expand All @@ -417,7 +417,7 @@

expect(last_response.status).to eq(200)
expect(json["errors"]).to be_nil
expect(json.dig("data", "relationships", "subj", "data")).to eq("id"=>event.subj_id, "type"=>"objects")
expect(json.dig("data", "relationships", "dois", "data")).to eq([{"id"=>"10.1371/journal.pmed.0030186", "type"=>"dois"}])
end
end

Expand Down

0 comments on commit f742143

Please sign in to comment.