Fixes #3794 - Example payload in webhook view leads to 500 error
This commit is contained in:
parent
e6c3b07b0d
commit
54417cd416
2 changed files with 18 additions and 4 deletions
|
@ -4,9 +4,7 @@ class WebhooksController < ApplicationController
|
||||||
prepend_before_action { authentication_check && authorize! }
|
prepend_before_action { authentication_check && authorize! }
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
access_condition = Ticket.access_condition(current_user, 'read')
|
ticket = TicketPolicy::ReadScope.new(current_user).resolve.last
|
||||||
|
|
||||||
ticket = Ticket.where(access_condition).last
|
|
||||||
|
|
||||||
render json: JSON.pretty_generate({
|
render json: JSON.pretty_generate({
|
||||||
ticket: TriggerWebhookJob::RecordPayload.generate(ticket),
|
ticket: TriggerWebhookJob::RecordPayload.generate(ticket),
|
||||||
|
|
|
@ -3,7 +3,23 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Manage > Webhook', type: :system do
|
RSpec.describe 'Manage > Webhook', type: :system do
|
||||||
context 'deleting' do
|
|
||||||
|
context 'when showing the example payload' do
|
||||||
|
|
||||||
|
it 'shows correctly' do
|
||||||
|
visit '/#manage/webhook'
|
||||||
|
|
||||||
|
within :active_content do
|
||||||
|
click 'a[data-type="payload"]'
|
||||||
|
end
|
||||||
|
|
||||||
|
in_modal disappears: false do
|
||||||
|
expect(page).to have_text('X-Zammad-Trigger:')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when deleting' do
|
||||||
let!(:webhook) { create(:webhook) }
|
let!(:webhook) { create(:webhook) }
|
||||||
let!(:trigger) { create(:trigger, perform: { 'notification.webhook' => { 'webhook_id' => webhook.id.to_s } }) }
|
let!(:trigger) { create(:trigger, perform: { 'notification.webhook' => { 'webhook_id' => webhook.id.to_s } }) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue