Created
October 13, 2014 16:44
-
-
Save davetheninja/e46b955a2542704e7e46 to your computer and use it in GitHub Desktop.
Daddy needs a tissue for these issues....
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
"{"presentation":{"title":""}}" |
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
Subject: | |
Acceptance testing | |
Whats happening: | |
1. Test runs | |
2. I can see the text field being filled | |
3. It is pressing the save button (I can see a mockjax request to POST) | |
Whats not happening: | |
1. The request being sent does not include the title value details | |
My assumptions: | |
1. I am a total fool and am doing it wrong | |
2. fillIn is not doing what I think it should | |
3. There is some ember voodoo going on that i am missing... |
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
`import Ember from 'ember'` | |
PresentationsNewRoute = Ember.Route.extend | |
model: -> | |
@store.createRecord 'presentation' | |
actions: | |
save: -> | |
route = @ | |
@currentModel.save().then (model) -> | |
debugger | |
route.transitionTo 'presentations.show', model | |
cancel: -> | |
@transitionTo 'presentations.index' | |
willTransition: -> | |
@currentModel.rollback() if @currentModel.get 'isNew' | |
`export default PresentationsNewRoute` |
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
<form> | |
<label for='title'>Presentation Title</label> | |
{{view Ember.TextField valueBinding='title' id='title' }} | |
<button id='save' {{action 'save'}}>Save</button> | |
<button {{action 'cancel'}}>Cancel</button> | |
</form> | |
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
`import Ember from 'ember'` | |
`import startApp from '../../helpers/start-app'` | |
App = null | |
module 'Presentations: Creating a presentation', | |
setup: -> | |
App = startApp() | |
teardown: -> | |
Ember.run App, 'destroy' | |
test 'I can successfully create a presentation', -> | |
Ember.$.mockjax | |
url: '/api/presentations' | |
type: 'POST', | |
status: 201, | |
response: JSON.stringify | |
presentation: | |
id: 1, | |
title: 'Law of Demeter' | |
visit '/presentations/new' | |
fillIn 'input#title', 'Law of Demeter' | |
click 'button#save' | |
andThen -> | |
equal currentPath(), 'presentations.show' | |
equal $('#presentations li:eq(0)').text(), 'Law of Demeter' |
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
Presentations: Creating a presentation: I can successfully create a presentation (2, 0, 2)Rerun817 ms | |
failed | |
Expected: | |
"presentations.show" | |
Result: | |
"presentations.new" | |
Diff: | |
"presentations.show" "presentations.new" | |
Source: | |
at http://localhost:7357/assets/test-support.js:1912:13 | |
at eval (web/tests/acceptance/presentations/create-test.js:36:15) | |
at andThen (http://localhost:7357/assets/vendor.js:48991:35) | |
at http://localhost:7357/assets/vendor.js:49698:25 | |
at isolate (http://localhost:7357/assets/vendor.js:49892:15) | |
at http://localhost:7357/assets/vendor.js:49875:16 | |
failed | |
Expected: | |
"Law of Demeter" | |
Result: | |
"" | |
Diff: | |
"Law of Demeter" "" | |
Source: | |
at http://localhost:7357/assets/test-support.js:1912:13 | |
at eval (web/tests/acceptance/presentations/create-test.js:37:51) | |
at andThen (http://localhost:7357/assets/vendor.js:48991:35) | |
at http://localhost:7357/assets/vendor.js:49698:25 | |
at isolate (http://localhost:7357/assets/vendor.js:49892:15) | |
at http://localhost:7357/assets/vendor.js:49875:16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hard to say without working code but a couple of points, use the input helper instead of textfield
{{input type="text" value=title}}
Don't override the id in any control like you are doing with id='title'
Use Fixtures instead of mock ajax, look at this jsbin