Fix failing tests caused by r24087 (#29664).

git-svn-id: https://svn.redmine.org/redmine/trunk@24088 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2025-10-30 10:04:15 +00:00
parent a33d02d12b
commit f245ddc280
3 changed files with 23 additions and 11 deletions

View File

@@ -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)
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

View File

@@ -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

View File

@@ -153,6 +153,7 @@ class WebhookTest < ActiveSupport::TestCase
end
test "schedule should enqueue jobs for hooks" do
with_settings webhooks_enabled: '1' do
hook = create_hook
assert_enqueued_jobs 1 do
assert_enqueued_with(job: WebhookJob) do
@@ -160,16 +161,20 @@ class WebhookTest < ActiveSupport::TestCase
end
end
end
end
test "should not enqueue job for inactive hook" do
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?