Skip to content

Commit

Permalink
fixes error wrong code
Browse files Browse the repository at this point in the history
#264

creating a new DOI reuqires to have client id but that was is obtianed in safe_params which also doesn not require auth
  • Loading branch information
kjgarza committed Oct 15, 2019
1 parent 98a1f64 commit 573d4b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def validate
def create
logger = Logger.new(STDOUT)
# logger.info safe_params.inspect
fail CanCan::AuthorizationNotPerformed unless current_user.present?

@doi = Doi.new(safe_params)

Expand Down
24 changes: 24 additions & 0 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,30 @@
end
end

context 'when the request is valid no password' do
let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) }
let(:valid_attributes) do
{
"data" => {
"type" => "dois",
"attributes" => {
"doi" => "10.14454/10703",
"url" => "http://www.bl.uk/pdf/patspec.pdf",
"xml" => xml,
"source" => "test",
"event" => "publish"
}
}
}
end

it 'fails to create a Doi' do
post '/dois', valid_attributes

expect(last_response.status).to eq(401)
end
end

context 'when the request is valid random doi' do
let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) }
let(:valid_attributes) do
Expand Down

0 comments on commit 573d4b9

Please sign in to comment.