Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add create_note method for need api #125

Merged
merged 2 commits into from

2 participants

@bishboria bishboria referenced this pull request in alphagov/maslow
Merged

Add notes to history #85

@benilovj
Collaborator

@bishboria could you please add a corresponding stub method for note creation in https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/need_api.rb?

@bishboria

@benilovj pushed the changes.

@benilovj benilovj merged commit 9d6d377 into master
@benilovj benilovj deleted the add-create-note-for-need-api branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2014
  1. @bishboria
Commits on Feb 28, 2014
  1. @bishboria
This page is out of date. Refresh to see the latest.
View
4 lib/gds_api/need_api.rb
@@ -37,4 +37,8 @@ def reopen(need_id, author)
# author params: { "author" => { ... } }"
delete_json!("#{endpoint}/needs/#{CGI.escape(need_id.to_s)}/closed", author)
end
+
+ def create_note(note)
+ post_json!("#{endpoint}/notes", note)
+ end
end
View
6 lib/gds_api/test_helpers/need_api.rb
@@ -77,6 +77,12 @@ def need_api_has_no_need(need_id)
headers: {}
)
end
+
+ def stub_create_note(note_details = nil)
+ post_stub = stub_request(:post, NEED_API_ENDPOINT + "/notes")
+ post_stub.with(:body => note_details.to_json) unless note_details.nil?
+ post_stub.to_return(:status => 201)
+ end
end
end
end
View
18 test/need_api_test.rb
@@ -238,4 +238,22 @@
assert_requested reopen_stub
end
end
+
+ describe "creating notes" do
+ it "should send a post request" do
+ fields = {
+ "text" => "test",
+ "need_id" => "100001",
+ "author" => {
+ "name" => "Winston Smith-Churchill",
+ "email" => "winston@alphagov.co.uk"
+ }
+ }
+ request_stub = stub_create_note(fields)
+
+ @api.create_note(fields)
+
+ assert_requested(request_stub)
+ end
+ end
end
Something went wrong with that request. Please try again.