Big commit:

- Support for a popup that shows similar topics
- Cleaned up a lot of Javascript
- Cleaned up use of Promises
This commit is contained in:
Robin Ward
2013-03-14 14:45:29 -04:00
parent 7714e2050e
commit ad082cea70
39 changed files with 584 additions and 560 deletions

View File

@ -70,10 +70,39 @@ describe TopicsController do
end
end
end
context 'similar_to' do
let(:title) { 'this title is long enough to search for' }
let(:raw) { 'this body is long enough to search for' }
it "requires a title" do
-> { xhr :get, :similar_to, raw: raw }.should raise_error(Discourse::InvalidParameters)
end
it "requires a raw body" do
-> { xhr :get, :similar_to, title: title }.should raise_error(Discourse::InvalidParameters)
end
it "raises an error if the title length is below the minimum" do
SiteSetting.stubs(:min_title_similar_length).returns(100)
-> { xhr :get, :similar_to, title: title, raw: raw }.should raise_error(Discourse::InvalidParameters)
end
it "raises an error if the body length is below the minimum" do
SiteSetting.stubs(:min_body_similar_length).returns(100)
-> { xhr :get, :similar_to, title: title, raw: raw }.should raise_error(Discourse::InvalidParameters)
end
it "delegates to Topic.similar_to" do
Topic.expects(:similar_to).with(title, raw).returns([Fabricate(:topic)])
xhr :get, :similar_to, title: title, raw: raw
end
end
context 'clear_pin' do
it 'needs you to be logged in' do
lambda { xhr :put, :clear_pin, topic_id: 1 }.should raise_error(Discourse::NotLoggedIn)