Files
Redmine/test/unit/webhook_payload_test.rb
Go MAEDA 8ce553727d Remove unnecessary fixture declarations (#29664).
Patch by Katsuya HIDAKA (user:hidakatsuya).


git-svn-id: https://svn.redmine.org/redmine/trunk@24039 e93f8b46-1217-0410-a6f0-8f06a7374b81
2025-10-08 04:56:24 +00:00

37 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
class WebhookPayloadTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
setup do
@dlopper = User.find_by_login 'dlopper'
@project = Project.find 'ecookbook'
@issue = @project.issues.first
end
test "issue update payload should contain journal" do
@issue.init_journal(@dlopper)
@issue.subject = "new subject"
@issue.save
p = WebhookPayload.new('issue.updated', @issue, @dlopper)
assert h = p.to_h
assert_equal 'issue.updated', h[:type]
assert j = h.dig(:data, :journal)
assert_equal 'Dave Lopper', j[:user][:name]
assert i = h.dig(:data, :issue)
assert_equal 'new subject', i[:subject], i.inspect
end
test "should compute payload of deleted issue" do
@issue.destroy
p = WebhookPayload.new('issue.deleted', @issue, @dlopper)
assert h = p.to_h
assert_equal 'issue.deleted', h[:type]
assert_nil h.dig(:data, :journal)
assert i = h.dig(:data, :issue)
assert_equal @issue.subject, i[:subject], i.inspect
end
end