Skip to content

Commit 444f7d2

Browse files
author
Kelly Selden
authored
Merge pull request #364 from kellyselden/redirect-to-self
add test coverage for noop redirects
2 parents 2edb5f1 + e44c95f commit 444f7d2

6 files changed

Lines changed: 56 additions & 0 deletions

File tree

test/fastboot-location-test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,38 @@ describe('FastBootLocation', function () {
9898
expect(response.body).to.contain('/my-root/test-passed');
9999
});
100100
});
101+
102+
it('should NOT redirect when transitionTo is called with identical route name', function () {
103+
return get({
104+
url: 'http://localhost:49741/my-root/noop-transition-to',
105+
followRedirect: false
106+
})
107+
.then(function (response) {
108+
if (response.statusCode === 500) throw new Error (response.body);
109+
expect(response.statusCode).to.equal(200);
110+
111+
expect(response.headers).to.not.include.keys('location');
112+
expect(response.headers).to.include.keys('x-fastboot-path');
113+
expect(response.headers['x-fastboot-path']).to.equal('/my-root/noop-transition-to');
114+
115+
expect(response.body).to.contain('Redirect to self');
116+
});
117+
});
118+
119+
it('should NOT redirect when replaceWith is called with identical route name', function () {
120+
return get({
121+
url: 'http://localhost:49741/my-root/noop-replace-with',
122+
followRedirect: false
123+
})
124+
.then(function (response) {
125+
if (response.statusCode === 500) throw new Error (response.body);
126+
expect(response.statusCode).to.equal(200);
127+
128+
expect(response.headers).to.not.include.keys('location');
129+
expect(response.headers).to.include.keys('x-fastboot-path');
130+
expect(response.headers['x-fastboot-path']).to.equal('/my-root/noop-replace-with');
131+
132+
expect(response.body).to.contain('Redirect to self');
133+
});
134+
});
101135
});

test/fixtures/fastboot-location/app/router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const Router = Ember.Router.extend({
77
});
88

99
Router.map(function() {
10+
this.route('noop-transition-to');
11+
this.route('noop-replace-with');
1012
this.route('redirect-on-intermediate-transition-to');
1113
this.route('redirect-on-transition-to');
1214
this.route('redirect-on-replace-with');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Route.extend({
4+
beforeModel() {
5+
this.replaceWith('noop-replace-with');
6+
}
7+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Route.extend({
4+
beforeModel() {
5+
this.replaceWith('noop-transition-to');
6+
}
7+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>Redirect to self</h1>
2+
3+
<p>We should render this because a redirect to self should be a noop in Ember.</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>Redirect to self</h1>
2+
3+
<p>We should render this because a redirect to self should be a noop in Ember.</p>

0 commit comments

Comments
 (0)