From f245ddc280f68e2df742f78536ed6acab6c8443f Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 30 Oct 2025 10:04:15 +0000 Subject: [PATCH] Fix failing tests caused by r24087 (#29664). git-svn-id: https://svn.redmine.org/redmine/trunk@24088 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/my_controller_test.rb | 8 +++++--- test/functional/webhooks_controller_test.rb | 5 +++++ test/unit/webhook_test.rb | 21 +++++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index 20f7f1062..d82660b7f 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -401,9 +401,11 @@ class MyControllerTest < Redmine::ControllerTest def test_my_account_should_toggle_webhook_link_with_setting User.find(2).roles.first.add_permission!(:use_webhooks) - get :account - assert_response :success - assert_select 'a.icon-webhook', 1 + with_settings webhooks_enabled: '1' do + get :account + assert_response :success + assert_select 'a.icon-webhook', 1 + end with_settings webhooks_enabled: '0' do get :account diff --git a/test/functional/webhooks_controller_test.rb b/test/functional/webhooks_controller_test.rb index 64fda1b6f..783a25b3e 100644 --- a/test/functional/webhooks_controller_test.rb +++ b/test/functional/webhooks_controller_test.rb @@ -12,6 +12,11 @@ class WebhooksControllerTest < Redmine::ControllerTest @hook = create_hook @other_hook = create_hook user: User.find_by_login('admin'), url: 'https://example.com/other/hook' @request.session[:user_id] = @dlopper.id + @original_webhooks_setting = Setting.webhooks_enabled = '1' + end + + teardown do + Setting.webhooks_enabled = @original_webhooks_setting end test "should require login" do diff --git a/test/unit/webhook_test.rb b/test/unit/webhook_test.rb index 2443a4d01..442d5220c 100644 --- a/test/unit/webhook_test.rb +++ b/test/unit/webhook_test.rb @@ -153,23 +153,28 @@ class WebhookTest < ActiveSupport::TestCase end test "schedule should enqueue jobs for hooks" do - hook = create_hook - assert_enqueued_jobs 1 do - assert_enqueued_with(job: WebhookJob) do - Webhook.trigger('issue.created', @issue) + with_settings webhooks_enabled: '1' do + hook = create_hook + assert_enqueued_jobs 1 do + assert_enqueued_with(job: WebhookJob) do + Webhook.trigger('issue.created', @issue) + end end end end test "should not enqueue job for inactive hook" do - hook = create_hook active: false - assert_no_enqueued_jobs do - Webhook.trigger('issue.created', @issue) + with_settings webhooks_enabled: '1' do + hook = create_hook active: false + assert_no_enqueued_jobs do + Webhook.trigger('issue.created', @issue) + end end end test "enabled? should follow setting flag" do - assert Webhook.enabled? + # Disabled by default + assert_not Webhook.enabled? with_settings webhooks_enabled: '0' do assert_not Webhook.enabled?