diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6 index c96a4f9e31e..c6be242fa26 100644 --- a/app/assets/javascripts/discourse/models/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/post-stream.js.es6 @@ -704,7 +704,7 @@ const PostStream = RestModel.extend({ the text to the correct values. **/ errorLoading(result) { - const status = result.status; + const status = result.jqXHR.status; const topic = this.get('topic'); this.set('loadingFilter', false); diff --git a/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 b/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 index 040b4bb5f02..bfb8468cd7f 100644 --- a/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 +++ b/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 @@ -54,6 +54,8 @@ export default Discourse.Route.extend({ ignoreIfChanged: true }); } + }).catch(function(e) { + Ember.warn('Could not view topic', e); }); } diff --git a/test/javascripts/acceptance/topic-anonymous-test.js.es6 b/test/javascripts/acceptance/topic-anonymous-test.js.es6 index 1789fdc6d30..2703ad0faa5 100644 --- a/test/javascripts/acceptance/topic-anonymous-test.js.es6 +++ b/test/javascripts/acceptance/topic-anonymous-test.js.es6 @@ -15,3 +15,19 @@ test("Enter without an id", () => { ok(exists("#topic"), "The topic was rendered"); }); }); + +test("Enter without access", (assert) => { + visit("/t/i-dont-have-access/403"); + andThen(() => { + assert.ok(!exists("#topic"), "The topic was not rendered"); + assert.ok(exists(".topic-error"), "An error message is displayed"); + }); +}); + +test("Enter with 500 errors", (assert) => { + visit("/t/throws-error/500"); + andThen(() => { + assert.ok(!exists("#topic"), "The topic was not rendered"); + assert.ok(exists(".topic-error"), "An error message is displayed"); + }); +}); diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6 index 2b1c0d36fc7..247f09b299f 100644 --- a/test/javascripts/helpers/create-pretender.js.es6 +++ b/test/javascripts/helpers/create-pretender.js.es6 @@ -175,6 +175,14 @@ export default function() { return response(200, data.post); }); + this.get('/t/403.json', () => { + return response(403, {}); + }); + + this.get('/t/500.json', () => { + return response(502, {}); + }); + this.put('/t/:slug/:id', (request) => { const data = parsePostData(request.requestBody);