mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 21:03:59 +08:00
b58867b6e9
Includes support for flags, reviewable users and queued posts, with REST API backwards compatibility. Co-Authored-By: romanrizzi <romanalejandro@gmail.com> Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
25 lines
521 B
Ruby
25 lines
521 B
Ruby
module DiscourseEvent::TestHelper
|
|
def trigger(event_name, *params)
|
|
super(event_name, *params)
|
|
|
|
if @events_trigger
|
|
@events_trigger << { event_name: event_name, params: params }
|
|
end
|
|
end
|
|
|
|
def track_events
|
|
@events_trigger = events_trigger = []
|
|
yield
|
|
@events_trigger = nil
|
|
events_trigger
|
|
end
|
|
|
|
def track(event_type)
|
|
events = track_events { yield }
|
|
events.find { |e| e[:event_name] == event_type }
|
|
end
|
|
|
|
end
|
|
|
|
DiscourseEvent.singleton_class.prepend DiscourseEvent::TestHelper
|