mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
Improve MessageBus.track_publish
to allow filter by channel.
This commit is contained in:
@ -15,9 +15,8 @@ describe PostMerger do
|
||||
reply3 = create_post(topic: topic, raw: 'The third reply', post_number: 4, user: user)
|
||||
replies = [reply3, reply2, reply1]
|
||||
|
||||
message = MessageBus.track_publish { PostMerger.new(admin, replies).merge }.last
|
||||
message = MessageBus.track_publish("/topic/#{topic.id}") { PostMerger.new(admin, replies).merge }.last
|
||||
|
||||
expect(message.channel).to eq("/topic/#{topic.id}")
|
||||
expect(message.data[:type]).to eq(:revised)
|
||||
expect(message.data[:post_number]).to eq(reply3.post_number)
|
||||
|
||||
|
@ -382,11 +382,10 @@ describe PostRevisor do
|
||||
it "should publish topic changes to clients" do
|
||||
revisor = described_class.new(topic.ordered_posts.first, topic)
|
||||
|
||||
messages = MessageBus.track_publish do
|
||||
message = MessageBus.track_publish("/topic/#{topic.id}") do
|
||||
revisor.revise!(newuser, title: 'this is a test topic')
|
||||
end
|
||||
end.first
|
||||
|
||||
message = messages.find { |m| m.channel == "/topic/#{topic.id}" }
|
||||
payload = message.data
|
||||
expect(payload[:reload_topic]).to eq(true)
|
||||
end
|
||||
|
@ -145,11 +145,11 @@ describe SiteSettingExtension do
|
||||
settings.setting("test_setting", 100)
|
||||
settings.setting("test_setting", nil, client: true)
|
||||
|
||||
messages = MessageBus.track_publish do
|
||||
message = MessageBus.track_publish('/client_settings') do
|
||||
settings.test_setting = 88
|
||||
end
|
||||
end.first
|
||||
|
||||
expect(messages.map(&:channel).include?('/client_settings')).to eq(true)
|
||||
expect(message).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user