Skip to content

Commit

Permalink
BookmarksController#create should not return success on invalid input
Browse files Browse the repository at this point in the history
Closes #2665
  • Loading branch information
sandbergja committed May 6, 2022
1 parent 26edc70 commit 1ebc843
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/bookmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def create
current_or_guest_user.save! unless current_or_guest_user.persisted?

success = @bookmarks.all? do |bookmark|
current_or_guest_user.bookmarks.where(bookmark).exists? || current_or_guest_user.bookmarks.create(bookmark)
current_or_guest_user.bookmarks.where(bookmark).exists? || current_or_guest_user.bookmarks.create(bookmark).valid?
end

if request.xhr?
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/bookmarks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false)
allow(@controller).to receive_message_chain(:current_or_guest_user, :persisted?).and_return(true)
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :exists?).and_return(false)
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :create).and_return(false)
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :create, :valid?).and_return(false)
put :update, xhr: true, params: { id: 'iamabooboo', format: :js }
expect(response.code).to eq "500"
end
Expand Down

0 comments on commit 1ebc843

Please sign in to comment.