Fixes #3794 - Example payload in webhook view leads to 500 error

This commit is contained in:
Martin Gruner 2021-10-08 08:23:20 +02:00 committed by Thorsten Eckel
parent e6c3b07b0d
commit 54417cd416
2 changed files with 18 additions and 4 deletions

View File

@ -4,9 +4,7 @@ class WebhooksController < ApplicationController
prepend_before_action { authentication_check && authorize! }
def preview
access_condition = Ticket.access_condition(current_user, 'read')
ticket = Ticket.where(access_condition).last
ticket = TicketPolicy::ReadScope.new(current_user).resolve.last
render json: JSON.pretty_generate({
ticket: TriggerWebhookJob::RecordPayload.generate(ticket),

View File

@ -3,7 +3,23 @@
require 'rails_helper'
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!(:trigger) { create(:trigger, perform: { 'notification.webhook' => { 'webhook_id' => webhook.id.to_s } }) }