Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/webhooks/activations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
class Webhooks::ActivationsController < ApplicationController
include BoardScoped

before_action :ensure_admin

def create
webhook = Current.account.webhooks.find(params[:webhook_id])
webhook = @board.webhooks.find(params[:webhook_id])
webhook.activate

redirect_to webhook
Expand Down
16 changes: 16 additions & 0 deletions test/controllers/webhooks/activations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ class Webhooks::ActivationsControllerTest < ActionDispatch::IntegrationTest

assert_redirected_to board_webhook_path(webhook.board, webhook)
end

test "cannot activate webhook on board without access" do
logout_and_sign_in_as :jason
webhook = webhooks(:inactive) # on private board, jason has no access

post board_webhook_activation_path(webhook.board, webhook)
assert_response :not_found
end

test "non-admin cannot activate webhook" do
logout_and_sign_in_as :jz # member with writebook access, but not admin
webhook = webhooks(:active) # on writebook board

post board_webhook_activation_path(webhook.board, webhook)
assert_response :forbidden
end
end
9 changes: 9 additions & 0 deletions test/controllers/webhooks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,13 @@ class WebhooksControllerTest < ActionDispatch::IntegrationTest

assert_redirected_to board_webhooks_path(webhook.board)
end

test "cannot access webhooks on board without access" do
logout_and_sign_in_as :jason

webhook = webhooks(:inactive) # on private board, jason has no access

get board_webhooks_path(webhook.board)
assert_response :not_found
end
end