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 def test_my_account_should_toggle_webhook_link_with_setting
User.find(2).roles.first.add_permission!(:use_webhooks) User.find(2).roles.first.add_permission!(:use_webhooks)
get :account with_settings webhooks_enabled: '1' do
assert_response :success get :account
assert_select 'a.icon-webhook', 1 assert_response :success
assert_select 'a.icon-webhook', 1
end
with_settings webhooks_enabled: '0' do with_settings webhooks_enabled: '0' do
get :account get :account

View File

@@ -12,6 +12,11 @@ class WebhooksControllerTest < Redmine::ControllerTest
@hook = create_hook @hook = create_hook
@other_hook = create_hook user: User.find_by_login('admin'), url: 'https://example.com/other/hook' @other_hook = create_hook user: User.find_by_login('admin'), url: 'https://example.com/other/hook'
@request.session[:user_id] = @dlopper.id @request.session[:user_id] = @dlopper.id
@original_webhooks_setting = Setting.webhooks_enabled = '1'
end
teardown do
Setting.webhooks_enabled = @original_webhooks_setting
end end
test "should require login" do test "should require login" do

View File

@@ -153,23 +153,28 @@ class WebhookTest < ActiveSupport::TestCase
end end
test "schedule should enqueue jobs for hooks" do test "schedule should enqueue jobs for hooks" do
hook = create_hook with_settings webhooks_enabled: '1' do
assert_enqueued_jobs 1 do hook = create_hook
assert_enqueued_with(job: WebhookJob) do assert_enqueued_jobs 1 do
Webhook.trigger('issue.created', @issue) assert_enqueued_with(job: WebhookJob) do
Webhook.trigger('issue.created', @issue)
end
end end
end end
end end
test "should not enqueue job for inactive hook" do test "should not enqueue job for inactive hook" do
hook = create_hook active: false with_settings webhooks_enabled: '1' do
assert_no_enqueued_jobs do hook = create_hook active: false
Webhook.trigger('issue.created', @issue) assert_no_enqueued_jobs do
Webhook.trigger('issue.created', @issue)
end
end end
end end
test "enabled? should follow setting flag" do test "enabled? should follow setting flag" do
assert Webhook.enabled? # Disabled by default
assert_not Webhook.enabled?
with_settings webhooks_enabled: '0' do with_settings webhooks_enabled: '0' do
assert_not Webhook.enabled? assert_not Webhook.enabled?