Improve MessageBus.track_publish to allow filter by channel.

This commit is contained in:
Guo Xiang Tan
2017-10-02 11:34:57 +08:00
parent b295a39977
commit c872225762
7 changed files with 28 additions and 39 deletions

View File

@ -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)

View File

@ -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

View File

@ -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