BUGFIX: broken specs after pulling in closed poll stuff

This commit is contained in:
Sam 2014-04-09 12:38:21 +10:00
parent 90a26ddbb5
commit 93d79080bb
1 changed files with 11 additions and 3 deletions

View File

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