FIX: Support ember app routing to topics with only slugs

This commit is contained in:
Robin Ward
2014-09-17 11:18:41 -04:00
parent 943ad8d1d5
commit c16b8364ab
8 changed files with 54 additions and 6 deletions

View File

@ -542,6 +542,26 @@ describe TopicsController do
end
end
describe 'id_for_slug' do
let(:topic) { Fabricate(:post).topic }
it "returns JSON for the slug" do
xhr :get, :id_for_slug, slug: topic.slug
response.should be_success
json = ::JSON.parse(response.body)
json.should be_present
json['topic_id'].should == topic.id
json['url'].should == topic.url
json['slug'].should == topic.slug
end
it "returns invalid access if the user can't see the topic" do
Guardian.any_instance.expects(:can_see?).with(topic).returns(false)
xhr :get, :id_for_slug, slug: topic.slug
response.should_not be_success
end
end
describe 'show' do
let(:topic) { Fabricate(:post).topic }