Rename approval web hook event type to queued post

This commit is contained in:
Vinoth Kannan 2018-07-26 10:29:38 +05:30
parent 5059dad8f0
commit af5b88f8e2
8 changed files with 16 additions and 16 deletions

View File

@ -18,7 +18,7 @@ class QueuedPost < ActiveRecord::Base
end
def trigger_queued_post_event
DiscourseEvent.trigger(:queued_post, self)
DiscourseEvent.trigger(:queued_post_created, self)
true
end

View File

@ -6,7 +6,7 @@ class WebHookEventType < ActiveRecord::Base
CATEGORY = 5
TAG = 6
FLAG = 7
APPROVAL = 8
QUEUED_POST = 8
has_and_belongs_to_many :web_hooks

View File

@ -90,11 +90,11 @@ end
end
%i(
queued_post
queued_post_created
approved_post
rejected_post
).each do |event|
DiscourseEvent.on(event) do |queued_post|
WebHook.enqueue_object_hooks(:approval, queued_post, event, QueuedPostSerializer)
WebHook.enqueue_object_hooks(:queued_post, queued_post, event, QueuedPostSerializer)
end
end

View File

@ -3027,9 +3027,9 @@ en:
flag_event:
name: "Flag Event"
details: "When a flag is created, agreed, disagreed or ignored."
approval_event:
name: "Approval Event"
details: "When a new post is queued, approved or rejected."
queued_post_event:
name: "Post Approval Event"
details: "When a new queued post is created, approved or rejected."
delivery_status:
title: "Delivery Status"
inactive: "Inactive"

View File

@ -34,6 +34,6 @@ WebHookEventType.seed do |b|
end
WebHookEventType.seed do |b|
b.id = WebHookEventType::APPROVAL
b.name = "approval"
b.id = WebHookEventType::QUEUED_POST
b.name = "queued_post"
end

View File

@ -77,10 +77,10 @@ Fabricator(:flag_web_hook, from: :web_hook) do
end
end
Fabricator(:approval_web_hook, from: :web_hook) do
transient approval_hook: WebHookEventType.find_by(name: 'approval')
Fabricator(:queued_post_web_hook, from: :web_hook) do
transient queued_post_hook: WebHookEventType.find_by(name: 'queued_post')
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:approval_hook]]
web_hook.web_hook_event_types = [transients[:queued_post_hook]]
end
end

View File

@ -171,7 +171,7 @@ describe QueuedPost do
it 'triggers a extensibility event' do
event = DiscourseEvent.track_events { subject.save! }.first
expect(event[:event_name]).to eq(:queued_post)
expect(event[:event_name]).to eq(:queued_post_created)
expect(event[:params].first).to eq(subject)
end
end

View File

@ -418,12 +418,12 @@ describe WebHook do
expect(payload["id"]).to eq(post_action.id)
end
it 'should enqueue the right hooks for post approval events' do
Fabricate(:approval_web_hook)
it 'should enqueue the right hooks for queued post events' do
Fabricate(:queued_post_web_hook)
queued_post = Fabricate(:queued_post)
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
expect(job_args["event_name"]).to eq("queued_post")
expect(job_args["event_name"]).to eq("queued_post_created")
payload = JSON.parse(job_args["payload"])
expect(payload["id"]).to eq(queued_post.id)