Merge pull request #1841 from basecamp/fix-access-control-issues
Allow only the owner of a reaction to delete it
This commit is contained in:
@@ -2,7 +2,7 @@ require "test_helper"
|
||||
|
||||
class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :jz
|
||||
sign_in_as :david
|
||||
@comment = comments(:logo_agreement_jz)
|
||||
@card = @comment.card
|
||||
end
|
||||
@@ -15,10 +15,19 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
reaction = reactions(:kevin)
|
||||
reaction = reactions(:david)
|
||||
assert_difference -> { @comment.reactions.count }, -1 do
|
||||
delete card_comment_reaction_path(@comment.card, @comment, reaction, format: :turbo_stream)
|
||||
assert_turbo_stream action: :remove, target: dom_id(reaction)
|
||||
end
|
||||
end
|
||||
|
||||
test "non-owner cannot destroy reaction" do
|
||||
reaction = reactions(:kevin)
|
||||
|
||||
assert_no_difference -> { @comment.reactions.count } do
|
||||
delete card_comment_reaction_path(@comment.card, @comment, reaction, format: :turbo_stream)
|
||||
assert_response :forbidden
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user