Loading app/controllers/likes_controller.rb +6 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,12 @@ class LikesController < ApplicationController end def destroy begin @like = Like.find_by_id_and_author_id!(params[:id], current_user.person.id) rescue ActiveRecord::RecordNotFound render text: I18n.t("likes.destroy.error"), status: 404 return end current_user.retract(@like) respond_to do |format| Loading config/locales/diaspora/en.yml +2 −0 Original line number Diff line number Diff line Loading @@ -591,6 +591,8 @@ en: likes: create: error: "Failed to like." destroy: error: "Failed to unlike." notifications: started_sharing: Loading spec/controllers/likes_controller_spec.rb +3 −5 Original line number Diff line number Diff line Loading @@ -133,14 +133,12 @@ describe LikesController, :type => :controller do it 'does not let a user destroy other likes' do like2 = eve.like!(@message) like_count = Like.count expect { delete :destroy, :format => :json, id_field => like2.target_id, :id => like2.id }.to raise_error(ActiveRecord::RecordNotFound) delete :destroy, :format => :json, id_field => like2.target_id, :id => like2.id expect(response.status).to eq(404) expect(response.body).to eq(I18n.t("likes.destroy.error")) expect(Like.count).to eq(like_count) end end end Loading Loading
app/controllers/likes_controller.rb +6 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,12 @@ class LikesController < ApplicationController end def destroy begin @like = Like.find_by_id_and_author_id!(params[:id], current_user.person.id) rescue ActiveRecord::RecordNotFound render text: I18n.t("likes.destroy.error"), status: 404 return end current_user.retract(@like) respond_to do |format| Loading
config/locales/diaspora/en.yml +2 −0 Original line number Diff line number Diff line Loading @@ -591,6 +591,8 @@ en: likes: create: error: "Failed to like." destroy: error: "Failed to unlike." notifications: started_sharing: Loading
spec/controllers/likes_controller_spec.rb +3 −5 Original line number Diff line number Diff line Loading @@ -133,14 +133,12 @@ describe LikesController, :type => :controller do it 'does not let a user destroy other likes' do like2 = eve.like!(@message) like_count = Like.count expect { delete :destroy, :format => :json, id_field => like2.target_id, :id => like2.id }.to raise_error(ActiveRecord::RecordNotFound) delete :destroy, :format => :json, id_field => like2.target_id, :id => like2.id expect(response.status).to eq(404) expect(response.body).to eq(I18n.t("likes.destroy.error")) expect(Like.count).to eq(like_count) end end end Loading