Skip to content
Extraits de code Groupes Projets
Valider 6c9f1916 rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Merge pull request #5491 from collimarco/solved5348

Solve #5348
parents 30eaf827 76cc5e2d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -78,6 +78,7 @@ This is disabled by default since it requires the installation of additional pac
* Replace `opengraph_parser` with `open_graph_reader` [#5462](https://github.com/diaspora/diaspora/pull/5462)
* Make sure conversations without any visibilities left are deleted [#5478](https://github.com/diaspora/diaspora/pull/5478)
* Change tooltip for delete button in conversations view [#5477](https://github.com/diaspora/diaspora/pull/5477)
* Replace a modifier-rescue with a specific rescue [#5491](https://github.com/diaspora/diaspora/pull/5491)
## Bug fixes
* orca cannot see 'Add Contact' button [#5158](https://github.com/diaspora/diaspora/pull/5158)
......
......@@ -11,7 +11,13 @@ class LikesController < ApplicationController
:json
def create
@like = current_user.like!(target) if target rescue ActiveRecord::RecordInvalid
begin
@like = if target
current_user.like!(target)
end
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid => e
# do nothing
end
if @like
respond_to do |format|
......
......@@ -72,6 +72,22 @@ describe LikesController, :type => :controller do
expect(response.code).to eq('422')
end
end
context "when an the exception is raised" do
it "should be catched when it means that the target is not found" do
allow(@target).to receive(:id).and_return(-1)
post :create, like_hash.merge(:format => :json)
expect(response.code).to eq('422')
end
it "should not be catched when it is unexpected" do
@target = alice.post :status_message, :text => "AWESOME", :to => @alices_aspect.id
@target = alice.comment!(@target, "hey") if class_const == Comment
allow(alice).to receive(:like!).and_raise("something")
allow(@controller).to receive(:current_user).and_return(alice)
expect { post :create, like_hash.merge(:format => :json) }.to raise_error("something")
end
end
end
describe '#index' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter