Skip to content
Browse files

Send post form data to save action

We get the component test to pass by making the input an Ember input helper, retrieving the saved value in it, and sending that in an object to the `save` action closure.

Inner green; outer green

The unit and acceptance test both pass. We've successfully let our acceptance test drive out the behavior of this feature!

Interestingly, note that the tests didn't drive us to actually add attributes to our Post model. Apparently Ember will allow assigning arbitrary attributes to a model in-memory and will preserve them. But we know we need those attributes to be defined.

The TDD way to approach this problem is to find the test that will demonstrate the problem with the attributes not being defined. In this case, a test of the post retrieval page pulling up a post from the backend will show the problem.
  • Loading branch information...
CodingItWrong committed Jan 11, 2018
1 parent 8259752 commit b6593ff912bda508a6c1cf3cb4a6d5c5fb256d68
Showing with 7 additions and 3 deletions.
  1. +5 −1 app/components/post-form.js
  2. +2 −2 app/templates/components/post-form.hbs
@@ -3,7 +3,11 @@ import Component from '@ember/component';
export default Component.extend({
actions: {
submitForm() {
const postData = {
title: this.title,
body: this.body,
@@ -1,11 +1,11 @@
<label for="js-post-form-title">Title</label>
<input type="text" class="js-post-form-title">
{{input type="text" class="js-post-form-title" value=title}}
<label for="js-post-form-body">Body</label>
<textarea class="js-post-form-body" />
{{textarea class="js-post-form-body" value=body}}

<button type="button" class="js-post-form-save" onclick={{action "submitForm"}}>Save</button>

0 comments on commit b6593ff

Please sign in to comment.
You can’t perform that action at this time.