mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: remove star concept from Discourse
This commit is contained in:
@ -562,70 +562,6 @@ describe Topic do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'toggle_star' do
|
||||
|
||||
shared_examples_for "adding a star to a topic" do
|
||||
it 'triggers a forum topic user change with true' do
|
||||
# otherwise no chance the mock will work
|
||||
freeze_time
|
||||
TopicUser.expects(:change).with(@user, @topic.id, starred: true, starred_at: DateTime.now, unstarred_at: nil)
|
||||
@topic.toggle_star(@user, true)
|
||||
end
|
||||
|
||||
it 'increases the star_count of the forum topic' do
|
||||
expect {
|
||||
@topic.toggle_star(@user, true)
|
||||
@topic.reload
|
||||
}.to change(@topic, :star_count).by(1)
|
||||
end
|
||||
|
||||
it 'triggers the rate limiter' do
|
||||
Topic::StarLimiter.any_instance.expects(:performed!)
|
||||
@topic.toggle_star(@user, true)
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
@topic = Fabricate(:topic)
|
||||
@user = @topic.user
|
||||
end
|
||||
|
||||
it_should_behave_like "adding a star to a topic"
|
||||
|
||||
describe 'removing a star' do
|
||||
before do
|
||||
@topic.toggle_star(@user, true)
|
||||
@topic.reload
|
||||
end
|
||||
|
||||
it 'rolls back the rate limiter' do
|
||||
Topic::StarLimiter.any_instance.expects(:rollback!)
|
||||
@topic.toggle_star(@user, false)
|
||||
end
|
||||
|
||||
it 'triggers a forum topic user change with false' do
|
||||
freeze_time
|
||||
TopicUser.expects(:change).with(@user, @topic.id, starred: false, unstarred_at: DateTime.now)
|
||||
@topic.toggle_star(@user, false)
|
||||
end
|
||||
|
||||
it 'reduces the star_count' do
|
||||
expect {
|
||||
@topic.toggle_star(@user, false)
|
||||
@topic.reload
|
||||
}.to change(@topic, :star_count).by(-1)
|
||||
end
|
||||
|
||||
describe 'and adding a star again' do
|
||||
before do
|
||||
@topic.toggle_star(@user, false)
|
||||
@topic.reload
|
||||
end
|
||||
it_should_behave_like "adding a star to a topic"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "banner" do
|
||||
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
|
Reference in New Issue
Block a user