-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from thefrontside/ember-data-rollback-error
Don't update value if tearing component down
- Loading branch information
Showing
11 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* jshint expr:true */ | ||
import { describe, it, beforeEach, afterEach } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import startApp from '../helpers/start-app'; | ||
import Ember from 'ember'; | ||
|
||
describe('Acceptance: EmberData', function() { | ||
let application; | ||
|
||
beforeEach(function() { | ||
application = startApp(); | ||
visit('/ember-data'); | ||
}); | ||
|
||
afterEach(function() { | ||
Ember.run(application, 'destroy'); | ||
}); | ||
|
||
it('can visit /ember-data', function() { | ||
expect(currentPath()).to.equal('ember-data'); | ||
}); | ||
|
||
describe("selecting a new value", function() { | ||
beforeEach(function() { | ||
select('.x-select', "Ollie"); | ||
}); | ||
|
||
describe("navigating to another route", function() { | ||
beforeEach(function() { | ||
return click("a:contains('Single')"); | ||
}); | ||
|
||
it("doesn't blow up", function() { | ||
expect(currentPath()).to.equal('single'); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
actions: { | ||
rollback() { | ||
this.get('model').rollbackAttributes(); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
name: DS.attr('string', { defaultValue: "Wally" }) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.createRecord('person'); | ||
}, | ||
actions: { | ||
willTransition() { | ||
this._super.apply(this, arguments); | ||
|
||
this.controller.send('rollback'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ a { | |
a.active { | ||
color: blue; | ||
} | ||
|
||
div { | ||
margin: 10px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div> | ||
{{#x-select value=model.name}} | ||
{{#x-option value="Larry"}}Larry{{/x-option}} | ||
{{#x-option value="Ollie"}}Ollie{{/x-option}} | ||
{{#x-option value="Wally"}}Wally{{/x-option}} | ||
{{/x-select}} | ||
|
||
<p>Model: {{model.name}}</p> | ||
|
||
</div> |