From 46786b508595fac3976e63c5b730f68a1e723217 Mon Sep 17 00:00:00 2001 From: Jan Sandbrink Date: Thu, 19 Mar 2026 14:45:02 +0100 Subject: [PATCH] Address minor style details after community contribution Those were too small for me to point out and thus block the corresponding PR further. But I wanted to address them anyways: * actor should be exposed the same way as resource for consistency * usage of actor can be simplified * one regression test didn't need repetition for actor case --- .../app/workers/represented_webhook_job.rb | 9 +++--- .../workers/work_package_webhook_job_spec.rb | 28 ------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/modules/webhooks/app/workers/represented_webhook_job.rb b/modules/webhooks/app/workers/represented_webhook_job.rb index 6ce165f1a34..a1b79bac47d 100644 --- a/modules/webhooks/app/workers/represented_webhook_job.rb +++ b/modules/webhooks/app/workers/represented_webhook_job.rb @@ -29,7 +29,7 @@ #++ class RepresentedWebhookJob < WebhookJob - attr_reader :resource + attr_reader :resource, :actor def perform(webhook_id, resource, event_name, actor: nil) @resource = resource @@ -89,15 +89,14 @@ class RepresentedWebhookJob < WebhookJob # have all the custom field visibility permissions set up correctly. User.system.run_given do payload = { action: event_name, payload_key => represented_payload } - actor = actor_payload - payload[:actor] = actor if actor + payload[:actor] = actor_payload if actor payload.to_json end end def actor_payload - return nil unless @actor + return nil unless actor - ::API::V3::Users::UserRepresenter.create(@actor, current_user: User.current) + ::API::V3::Users::UserRepresenter.create(actor, current_user: User.current) end end diff --git a/modules/webhooks/spec/workers/work_package_webhook_job_spec.rb b/modules/webhooks/spec/workers/work_package_webhook_job_spec.rb index ba094f40055..90866e42691 100644 --- a/modules/webhooks/spec/workers/work_package_webhook_job_spec.rb +++ b/modules/webhooks/spec/workers/work_package_webhook_job_spec.rb @@ -239,32 +239,4 @@ RSpec.describe WorkPackageWebhookJob, :webmock, type: :model do end end end - - describe "admin custom field regression with actor (PR #16912)" do - shared_let(:project) { work_package.project } - shared_let(:custom_field) do - create(:project_custom_field, :string, admin_only: true, projects: [project]) - end - shared_let(:custom_value) do - create(:custom_value, - custom_field:, - customized: project, - value: "wat") - end - let(:updater) { create(:admin) } - - it_behaves_like "a work package webhook call" do - let(:event) { "work_package:updated" } - let(:actor) { updater } - - it "includes the custom field value" do - subject - expect(stub).to have_been_requested - - log = Webhooks::Log.last - embedded_project = JSON.parse(log.request_body)["work_package"]["_embedded"]["project"] - expect(embedded_project[custom_field.attribute_name(:camel_case)]).to eq "wat" - end - end - end end