Skip to content

Commit

Permalink
add test coverage for noop redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Mar 20, 2017
1 parent b9fb4fd commit e44c95f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/fastboot-location-test.js
Expand Up @@ -98,4 +98,38 @@ describe('FastBootLocation', function () {
expect(response.body).to.contain('/my-root/test-passed');
});
});

it('should NOT redirect when transitionTo is called with identical route name', function () {
return get({
url: 'http://localhost:49741/my-root/noop-transition-to',
followRedirect: false
})
.then(function (response) {
if (response.statusCode === 500) throw new Error (response.body);
expect(response.statusCode).to.equal(200);

expect(response.headers).to.not.include.keys('location');
expect(response.headers).to.include.keys('x-fastboot-path');
expect(response.headers['x-fastboot-path']).to.equal('/my-root/noop-transition-to');

expect(response.body).to.contain('Redirect to self');
});
});

it('should NOT redirect when replaceWith is called with identical route name', function () {
return get({
url: 'http://localhost:49741/my-root/noop-replace-with',
followRedirect: false
})
.then(function (response) {
if (response.statusCode === 500) throw new Error (response.body);
expect(response.statusCode).to.equal(200);

expect(response.headers).to.not.include.keys('location');
expect(response.headers).to.include.keys('x-fastboot-path');
expect(response.headers['x-fastboot-path']).to.equal('/my-root/noop-replace-with');

expect(response.body).to.contain('Redirect to self');
});
});
});
2 changes: 2 additions & 0 deletions test/fixtures/fastboot-location/app/router.js
Expand Up @@ -7,6 +7,8 @@ const Router = Ember.Router.extend({
});

Router.map(function() {
this.route('noop-transition-to');
this.route('noop-replace-with');
this.route('redirect-on-intermediate-transition-to');
this.route('redirect-on-transition-to');
this.route('redirect-on-replace-with');
Expand Down
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Route.extend({
beforeModel() {
this.replaceWith('noop-replace-with');
}
});
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Route.extend({
beforeModel() {
this.replaceWith('noop-transition-to');
}
});
@@ -0,0 +1,3 @@
<h1>Redirect to self</h1>

<p>We should render this because a redirect to self should be a noop in Ember.</p>
@@ -0,0 +1,3 @@
<h1>Redirect to self</h1>

<p>We should render this because a redirect to self should be a noop in Ember.</p>

0 comments on commit e44c95f

Please sign in to comment.