Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 23, 2019
1 parent 296f719 commit 9a544da
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 3 additions & 37 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2854,45 +2854,11 @@
sleep 1
end

it 'returns error' do
get "/dois/#{doi.doi}/get-url", nil, { 'HTTP_ACCEPT'=>'application/vnd.api+json' }

expect(last_response.status).to eq(401)
expect(json['errors']).to eq([{"status"=>"401", "title"=>"Bad credentials."}])
end
end

context 'wrong password' do
let!(:doi) { create(:doi, client: client, doi: "10.14454/05mb-q396", event: "publish") }
let(:credentials) { client.encode_auth_param(username: client.symbol.downcase, password: "12345") }

before do
Doi.import
sleep 1
end

it 'returns error' do
get "/dois/#{doi.doi}/get-url", nil, { 'HTTP_ACCEPT'=>'application/vnd.api+json', 'HTTP_AUTHORIZATION' => 'Basic ' + credentials }

expect(last_response.status).to eq(401)
expect(json['errors']).to eq([{"status"=>"401", "title"=>"Bad credentials."}])
end
end

context 'no permission' do
let(:other_client) { create(:client, provider: provider) }
let!(:doi) { create(:doi, client: other_client, doi: "10.14454/8syz-ym47", event: "publish") }

before do
Doi.import
sleep 1
end

it 'returns error' do
it 'returns url' do
get "/dois/#{doi.doi}/get-url", nil, headers

expect(last_response.status).to eq(403)
expect(json['errors']).to eq([{"status"=>"403", "title"=>"You are not authorized to access this resource."}])
expect(json["url"]).to eq("https://www.datacite.org/roadmap.html")
expect(last_response.status).to eq(200)
end
end

Expand Down

0 comments on commit 9a544da

Please sign in to comment.