mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FEATURE: display unpinned state, allow unpinning by clicking on pin
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
require 'spec_helper'
|
||||
require 'pinned_check'
|
||||
|
||||
describe PinnedCheck do
|
||||
|
||||
#let(:topic) { Fabricate.build(:topic) }
|
||||
|
||||
let(:pinned_at) { 12.hours.ago }
|
||||
let(:unpinned_topic) { Fabricate.build(:topic) }
|
||||
let(:pinned_topic) { Fabricate.build(:topic, pinned_at: pinned_at) }
|
||||
@ -11,11 +10,11 @@ describe PinnedCheck do
|
||||
context "without a topic_user record (either anonymous or never been in the topic)" do
|
||||
|
||||
it "returns false if the topic is not pinned" do
|
||||
PinnedCheck.new(unpinned_topic).should_not be_pinned
|
||||
PinnedCheck.pinned?(unpinned_topic).should be_false
|
||||
end
|
||||
|
||||
it "returns true if the topic is pinned" do
|
||||
PinnedCheck.new(unpinned_topic).should_not be_pinned
|
||||
PinnedCheck.pinned?(unpinned_topic).should be_false
|
||||
end
|
||||
|
||||
end
|
||||
@ -28,7 +27,7 @@ describe PinnedCheck do
|
||||
let(:topic_user) { TopicUser.new(topic: unpinned_topic, user: user) }
|
||||
|
||||
it "returns false" do
|
||||
PinnedCheck.new(unpinned_topic, topic_user).should_not be_pinned
|
||||
PinnedCheck.pinned?(unpinned_topic, topic_user).should be_false
|
||||
end
|
||||
|
||||
end
|
||||
@ -37,17 +36,17 @@ describe PinnedCheck do
|
||||
let(:topic_user) { TopicUser.new(topic: pinned_topic, user: user) }
|
||||
|
||||
it "is pinned if the topic_user's cleared_pinned_at is blank" do
|
||||
PinnedCheck.new(pinned_topic, topic_user).should be_pinned
|
||||
PinnedCheck.pinned?(pinned_topic, topic_user).should be_true
|
||||
end
|
||||
|
||||
it "is not pinned if the topic_user's cleared_pinned_at is later than when it was pinned_at" do
|
||||
topic_user.cleared_pinned_at = (pinned_at + 1.hour)
|
||||
PinnedCheck.new(pinned_topic, topic_user).should_not be_pinned
|
||||
PinnedCheck.pinned?(pinned_topic, topic_user).should be_false
|
||||
end
|
||||
|
||||
it "is pinned if the topic_user's cleared_pinned_at is earlier than when it was pinned_at" do
|
||||
topic_user.cleared_pinned_at = (pinned_at - 3.hours)
|
||||
PinnedCheck.new(pinned_topic, topic_user).should be_pinned
|
||||
PinnedCheck.pinned?(pinned_topic, topic_user).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user