mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 01:06:00 +01:00
Introduces issue webhooks (#29664):
* users can set up hooks for issue creation, update and deletion events, for any number of projects * hooks run in the context of the creating user, and only if the object in question is visible to that user * the actual HTTP call is done in ActiveJob * webhook calls are optionally signed the same way GitHub does Patch by Jens Krämer (user:jkraemer). git-svn-id: https://svn.redmine.org/redmine/trunk@24034 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
40
test/unit/webhook_payload_test.rb
Normal file
40
test/unit/webhook_payload_test.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class WebhookPayloadTest < ActiveSupport::TestCase
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
fixtures :projects, :users, :trackers, :projects_trackers, :versions,
|
||||
:issue_statuses, :issue_categories, :issue_relations,
|
||||
:enumerations, :issues, :journals, :journal_details
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user