mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
DEV: Ensure DiscourseEvent handlers cleaned up during specs (#11205)
This commit is contained in:
@ -853,21 +853,22 @@ describe Group do
|
||||
end
|
||||
|
||||
it 'triggers a user_added_to_group event' do
|
||||
begin
|
||||
automatic = nil
|
||||
called = false
|
||||
automatic = nil
|
||||
called = false
|
||||
|
||||
DiscourseEvent.on(:user_added_to_group) do |_u, _g, options|
|
||||
automatic = options[:automatic]
|
||||
called = true
|
||||
end
|
||||
block = Proc.new do |_u, _g, options|
|
||||
automatic = options[:automatic]
|
||||
called = true
|
||||
end
|
||||
begin
|
||||
DiscourseEvent.on(:user_added_to_group, &block)
|
||||
|
||||
group.add(user)
|
||||
|
||||
expect(automatic).to eql(false)
|
||||
expect(called).to eq(true)
|
||||
ensure
|
||||
DiscourseEvent.off(:user_added_to_group)
|
||||
DiscourseEvent.off(:user_added_to_group, &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user