mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Merge pull request #22410 from opf/webhook-post-review
Address minor style details after community contribution
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user