diff --git a/spec/concerns/helpable_spec.rb b/spec/concerns/helpable_spec.rb index 9175a7e5f..1643291f4 100644 --- a/spec/concerns/helpable_spec.rb +++ b/spec/concerns/helpable_spec.rb @@ -109,19 +109,24 @@ end end - # it 'should register on save' do - # url = "https://blog.datacite.org/" - # subject = create(:doi, doi: "10.5438/hpc4-5t22", url: url, client: client, aasm_state: "findable") + it 'should register on save' do + url = "https://blog.datacite.org/" + subject = create(:doi, doi: "10.4124/shxthpwryv", url: url, client: client, aasm_state: "findable") - # expect(subject.url).to eq(url) - # expect(subject.minted.iso8601).to be_present - - # sleep 1 - # response = subject.get_url + expect(subject.url).to eq(url) + expect(subject.minted.iso8601).to be_present - # expect(response.body.dig("data", "responseCode")).to eq(1) - # expect(response.body.dig("data", "values")).to eq([{"index"=>1, "type"=>"URL", "data"=>{"format"=>"string", "value"=>"https://blog.datacite.org/"}, "ttl"=>86400, "timestamp"=>"2018-07-24T10:43:28Z"}]) - # end + sleep 1 + response = subject.get_url + expect(response.body.dig("data", "responseCode")).to eq(1) + expect(response.body.dig("data", "values")).to eq([{"data"=> + {"format"=>"string", + "value"=>"https://staging-data.mendeley.com/datasets/shxthpwryv"}, + "index"=>1, + "timestamp"=>"2020-05-21T08:56:38Z", + "ttl"=>86400, + "type"=>"URL"}]) + end it 'should change url' do subject.url = "https://blog.datacite.org/re3data-science-europe/" diff --git a/spec/fixtures/vcr_cassettes/Doi/register_doi/should_register_on_save.yml b/spec/fixtures/vcr_cassettes/Doi/register_doi/should_register_on_save.yml new file mode 100644 index 000000000..7ca2efa3f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Doi/register_doi/should_register_on_save.yml @@ -0,0 +1,37 @@ +--- +http_interactions: +- request: + method: get + uri: https://handle.test.datacite.org/api/handles/10.4124/SHXTHPWRYV?index=1 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.6.1; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 21 May 2020 12:49:12 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Content-Encoding: + - gzip + Vary: + - Accept-Encoding + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAADWNuw6CQBBF/2VqYRdEQ7a1obAwvh+x2MgoJCxsmPFBCP/uYGJ3c+aeOz20SL6pCRdNjmCiCRS2ziuJEOkwieJEbbLjNlsd1qc9TOBlqycSmEsPZZ3j56dw50dht15KI7dswfRwb1pnWTBxW9aPvyugYPZklCK2D7kEoxE6lLkKu/DWODUSQiZFxYcL/267Fwzyhysw6TzRWnLpUAacl8FYxzrQsyCOtjo1s7mZpmcYrsMX6EoZtt4AAAA= + http_version: null + recorded_at: Thu, 21 May 2020 12:49:12 GMT +recorded_with: VCR 5.1.0