diff --git a/plugins/poll/spec/poll_plugin/poll_spec.rb b/plugins/poll/spec/poll_plugin/poll_spec.rb index 36c4506ec71..1c32d87fb5a 100644 --- a/plugins/poll/spec/poll_plugin/poll_spec.rb +++ b/plugins/poll/spec/poll_plugin/poll_spec.rb @@ -19,6 +19,7 @@ describe PollPlugin::Poll do topic.save expect(PollPlugin::Poll.new(post).is_poll?).to be_false I18n.expects(:t).with('poll.prefix').returns("Poll\\s?:") + I18n.expects(:t).with('poll.closed_prefix').returns("Closed Poll\\s?:") expect(PollPlugin::Poll.new(post).is_poll?).to be_true end @@ -59,10 +60,17 @@ describe PollPlugin::Poll do end it "should serialize correctly" do - poll.serialize(user).should eq({options: poll.details, selected: nil}) + poll.serialize(user).should eq({options: poll.details, selected: nil, closed: false}) poll.set_vote!(user, "Onodera") - poll.serialize(user).should eq({options: poll.details, selected: "Onodera"}) - poll.serialize(nil).should eq({options: poll.details, selected: nil}) + poll.serialize(user).should eq({options: poll.details, selected: "Onodera", closed: false}) + poll.serialize(nil).should eq({options: poll.details, selected: nil, closed: false}) + + topic.title = "Closed Poll: my poll" + topic.save + + post.topic.reload + poll = PollPlugin::Poll.new(post) + poll.serialize(nil).should eq({options: poll.details, selected: nil, closed: true}) end it "should serialize to nil if there are no poll options" do