mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
Merge pull request #2166 from vikhyat/poll-plugin
Live update poll votes
This commit is contained in:
commit
b5208081b3
2 changed files with 11 additions and 0 deletions
|
@ -47,6 +47,15 @@ after_initialize do
|
|||
|
||||
poll.set_vote!(current_user, params[:option])
|
||||
|
||||
MessageBus.publish("/topic/#{post.topic_id}", {
|
||||
id: post.id,
|
||||
post_number: post.post_number,
|
||||
updated_at: Time.now,
|
||||
type: "revised"
|
||||
},
|
||||
group_ids: post.topic.secure_group_ids
|
||||
)
|
||||
|
||||
render json: poll.serialize(current_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,8 @@ describe PollPlugin::PollController, type: :controller do
|
|||
end
|
||||
|
||||
it "should save votes correctly" do
|
||||
MessageBus.expects(:publish).times(4)
|
||||
|
||||
log_in_user user1
|
||||
xhr :put, :vote, post_id: post.id, option: "Chitoge", use_route: :poll
|
||||
PollPlugin::Poll.new(post).get_vote(user1).should eq("Chitoge")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue