mirror of
https://github.com/redmine/redmine.git
synced 2025-11-03 03:46:19 +01:00
Patch by Katsuya HIDAKA (user:hidakatsuya). git-svn-id: https://svn.redmine.org/redmine/trunk@24039 e93f8b46-1217-0410-a6f0-8f06a7374b81
37 lines
1.0 KiB
Ruby
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
|