Skip to content

Add notes to history #85

Merged
merged 7 commits into from Mar 3, 2014

2 participants

@bishboria

Don't merge until is alphagov/gds-api-adapters#125 is accepted and version bumped, and the version of gds-api-adapters updated in the Gemfile.

@benilovj benilovj commented on an outdated diff Feb 28, 2014
app/controllers/notes_controller.rb
@@ -0,0 +1,18 @@
+require 'gds_api/need_api'
+require 'plek'
+require 'json'
+
+class NotesController < ApplicationController
+ def create
+ text = params["notes"]["text"]
+ need_id = params["need_id"]
+ @note = Note.new(text, need_id, current_user)
+
+ if @note.save
+ flash[:notice] = "Note saved"
+ else
+ flash[:error] = "Error saving note"
@benilovj
benilovj added a note Feb 28, 2014

This is a bit cryptic; now that the API returns specific errors, could these be displayed to the user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@benilovj benilovj commented on the diff Feb 28, 2014
test/fixtures/needs/101350.json
@@ -67,7 +89,18 @@
"goal": [ "apply for a school place", "apply for a secondary school place" ],
"role": [ "grandparent", null ]
},
- "created_at": "2013-01-01T13:00:00+00:00"
+ "created_at": "2013-01-01T13:00:00+00:00",
+ "notes": [
+ {
+ "text": "oops",
+ "author": {
+ "name": "Goofy",
+ "email": null,
+ "uid": null
+ },
+ "created_at": "2013-01-02T13:00:00+00:00"
+ }
+ ]
@benilovj
benilovj added a note Feb 28, 2014

I'm really not a fan of using fixtures for test data; this ought to be created dynamically by builder code. But that's a bigger change and not part of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bishboria

@benilovj Updated the code and tests based on exposed errors from Need API

@benilovj benilovj merged commit ff706a4 into master Mar 3, 2014

1 check passed

Details default "Build #10 succeeded on Jenkins"
@benilovj benilovj deleted the add-notes-to-history branch Mar 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.