Skip to content

Commit

Permalink
Merge pull request #6 from kimroen/tests-for-5
Browse files Browse the repository at this point in the history
Add failing test for #5
  • Loading branch information
kimroen committed Mar 7, 2015
2 parents 7da73a1 + ab599ae commit 18336fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/acceptance/document-title-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ test('dynamic title based on a model', function(assert) {
assert.equal(router._title, 'Ember is omakase - Posts - My Blog');
});
});

test('dynamic title based on route attributes', function(assert) {
assert.expect(1);

visit('/friendship-status');

andThen(function() {
assert.equal(router._title, 'We are friends - My Blog');
});
});
1 change: 1 addition & 0 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Router.map(function() {
this.resource('posts', function() {});
this.route('about');
this.route('team');
this.route('friendship-status');
});

export default Router;
9 changes: 9 additions & 0 deletions tests/dummy/app/routes/friendship-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Ember from 'ember';

export default Ember.Route.extend({
status: 'friends',

titleToken: function(model) {
return 'We are ' + this.get('status');
}
});
2 changes: 1 addition & 1 deletion vendor/document-title/document-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Ember.Route.reopen({
collectTitleTokens: function(tokens) {
var titleToken = get(this, 'titleToken');
if (typeof titleToken === 'function') {
titleToken = titleToken(get(this, 'currentModel'));
titleToken = titleToken.call(this, get(this, 'currentModel'));
}

if (Ember.isArray(titleToken)) {
Expand Down

0 comments on commit 18336fa

Please sign in to comment.