Skip to content

Commit

Permalink
Merge pull request #32 from GCheung55/bug/classic-sustain
Browse files Browse the repository at this point in the history
Fix sustain to work with classic app structure.
  • Loading branch information
runspired committed Mar 22, 2016
2 parents b4138ef + c1688e1 commit 2c5a804
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addon/lib/sustain.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ export default Obj.extend({
// pre Ember 2.0, layout is a computed property that MUST be set
// via get/set
if (!this._component.get('layout')) {
this._component.set('layout', this.owner.lookup(`template:${name}`));
let template = this.owner.lookup(`template:${name}`);
if (!template) {
template = this.owner.lookup(`template:components/${name}`);
}
this._component.set('layout', template);
}
this._component.set('model', model);

Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/sustain-classic-component-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | sustain classic');

test('visiting /tests/sustain-classic-component', function(assert) {
visit('/tests/sustain-classic-component');

andThen(function() {
assert.equal(currentURL(), '/tests/sustain-classic-component', 'We transitioned to the initial route');

assert.equal(find('h2.classic-component').eq(0).text(), 'Classic Component', 'We rendered the sustain');
});
});
3 changes: 3 additions & 0 deletions tests/dummy/app/components/classic-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Ember from 'ember';

export default Ember.Component.extend();
1 change: 1 addition & 0 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Router.map(function() {
this.route('sustain-labels');
this.route('sustain-labels-2');
this.route('sustain-hooks');
this.route('sustain-classic-component');
});

this.route('docs', function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Ember from 'ember';

export default Ember.Route.extend({
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{sustain 'classic-component'}}
1 change: 1 addition & 0 deletions tests/dummy/app/templates/components/classic-component.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h2 class="classic-component">Classic Component</h2>

0 comments on commit 2c5a804

Please sign in to comment.