GitHub PullRequestReviewCommentEvent at 2014-06-25 10:47:05
Repository: alaveteli
Actor: houndci
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mysociety/alaveteli/pulls/comments/14178876","id":14178876,"diff_hunk":"@@ -75,311 +91,431 @@\n         new_request.info_request_events[0].event_type.should == 'sent'\n         new_request.info_request_events[0].calculated_state.should == 'waiting_response'\n     end\n-\n-    def _create_request\n-        post :create_request,\n-            :k => public_bodies(:geraldine_public_body).api_key,\n-            :request_json => {\n-                \"title\" => \"Tell me about your chickens\",\n-                \"body\" => \"Dear Sir,\\n\\nI should like to know about your chickens.\\n\\nYours in faith,\\nBob\\n\",\n-\n-                \"external_url\" => \"http://www.example.gov.uk/foi/chickens_23\",\n-                \"external_user_name\" => \"Bob Smith\",\n-            }.to_json\n-        response.content_type.should == \"application/json\"\n-        return ActiveSupport::JSON.decode(response.body)[\"id\"]\n     end\n \n-    it \"should add a response to a request\" do\n-        # First we need an external request\n-        request_id = info_requests(:external_request).id\n-\n-        # Initially it has no incoming messages\n-        IncomingMessage.count(:conditions => [\"info_request_id = ?\", request_id]).should == 0\n-\n-        # Now add one\n-        sent_at = \"2012-05-28T12:35:39+01:00\"\n-        response_body = \"Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\\n\\nYours sincerely,\\nJohn Gandermulch,\\nExample Council FOI Officer\\n\"\n-        post :add_correspondence,\n-            :k => public_bodies(:geraldine_public_body).api_key,\n-            :id => request_id,\n-            :correspondence_json => {\n-                \"direction\" => \"response\",\n-                \"sent_at\" => sent_at,\n-                \"body\" => response_body\n-            }.to_json\n-\n-        # And make sure it worked\n-        response.should be_success\n-        incoming_messages = IncomingMessage.all(:conditions => [\"info_request_id = ?\", request_id])\n-        incoming_messages.count.should == 1\n-        incoming_message = incoming_messages[0]\n-\n-        incoming_message.sent_at.should == Time.iso8601(sent_at)\n-        incoming_message.get_main_body_text_folded.should be_equal_modulo_whitespace_to(response_body)\n-    end\n+    # POST /api/v2/request/:id/add_correspondence.json\n+    describe 'adding correspondence to a request' do\n+      it \"should add a response to a request\" do\n+          # First we need an external request\n+          request_id = info_requests(:external_request).id\n+\n+          # Initially it has no incoming messages\n+          IncomingMessage.count(:conditions => [\"info_request_id = ?\", request_id]).should == 0\n+\n+          # Now add one\n+          sent_at = \"2012-05-28T12:35:39+01:00\"\n+          response_body = \"Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\\n\\nYours sincerely,\\nJohn Gandermulch,\\nExample Council FOI Officer\\n\"\n+          post :add_correspondence,\n+               :k => public_bodies(:geraldine_public_body).api_key,\n+               :id => request_id,\n+               :correspondence_json => {\n+                   \"direction\" => \"response\",\n+                   \"sent_at\" => sent_at,\n+                   \"body\" => response_body\n+               }.to_json\n+\n+          # And make sure it worked\n+          response.should be_success\n+          incoming_messages = IncomingMessage.all(:conditions => [\"info_request_id = ?\", request_id])\n+          incoming_messages.count.should == 1\n+          incoming_message = incoming_messages[0]\n+\n+          incoming_message.sent_at.should == Time.iso8601(sent_at)\n+          incoming_message.get_main_body_text_folded.should be_equal_modulo_whitespace_to(response_body)\n+      end\n \n-    it \"should add a followup to a request\" do\n-        # First we need an external request\n-        request_id = info_requests(:external_request).id\n-\n-        # Initially it has one outgoing message\n-        OutgoingMessage.count(:conditions => [\"info_request_id = ?\", request_id]).should == 1\n-\n-        # Add another, as a followup\n-        sent_at = \"2012-05-29T12:35:39+01:00\"\n-        followup_body = \"Pls answer ASAP.\\nkthxbye\\n\"\n-        post :add_correspondence,\n-            :k => public_bodies(:geraldine_public_body).api_key,\n-            :id => request_id,\n-            :correspondence_json => {\n-                \"direction\" => \"request\",\n-                \"sent_at\" => sent_at,\n-                \"body\" => followup_body\n-            }.to_json\n-\n-        # Make sure it worked\n-        response.should be_success\n-        followup_messages = OutgoingMessage.all(\n-            :conditions => [\"info_request_id = ? and message_type = 'followup'\", request_id]\n-        )\n-        followup_messages.size.should == 1\n-        followup_message = followup_messages[0]\n+      it \"should add a followup to a request\" do\n+          # First we need an external request\n+          request_id = info_requests(:external_request).id\n+\n+          # Initially it has one outgoing message\n+          OutgoingMessage.count(:conditions => [\"info_request_id = ?\", request_id]).should == 1\n+\n+          # Add another, as a followup\n+          sent_at = \"2012-05-29T12:35:39+01:00\"\n+          followup_body = \"Pls answer ASAP.\\nkthxbye\\n\"\n+          post :add_correspondence,\n+               :k => public_bodies(:geraldine_public_body).api_key,","path":"spec/controllers/api_controller_spec.rb","position":140,"original_position":140,"commit_id":"ae50dbd7306b514f6d2c8794ccdfbfa34a2a6a23","original_commit_id":"ae50dbd7306b514f6d2c8794ccdfbfa34a2a6a23","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Use the new Ruby 1.9 hash syntax.","created_at":"2014-06-25T10:47:05Z","updated_at":"2014-06-25T10:47:05Z","html_url":"https://github.com/mysociety/alaveteli/pull/1631#discussion_r14178876","pull_request_url":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631","_links":{"self":{"href":"https://api.github.com/repos/mysociety/alaveteli/pulls/comments/14178876"},"html":{"href":"https://github.com/mysociety/alaveteli/pull/1631#discussion_r14178876"},"pull_request":{"href":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631"}}},"pull_request":{"url":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631","id":17484753,"html_url":"https://github.com/mysociety/alaveteli/pull/1631","diff_url":"https://github.com/mysociety/alaveteli/pull/1631.diff","patch_url":"https://github.com/mysociety/alaveteli/pull/1631.patch","issue_url":"https://api.github.com/repos/mysociety/alaveteli/issues/1631","number":1631,"state":"open","title":"Add request state updating functionality to API","user":{"login":"lizconlan","id":27760,"avatar_url":"https://avatars.githubusercontent.com/u/27760?","gravatar_id":"f943610b98a484c0e703a1567cad8d4d","url":"https://api.github.com/users/lizconlan","html_url":"https://github.com/lizconlan","followers_url":"https://api.github.com/users/lizconlan/followers","following_url":"https://api.github.com/users/lizconlan/following{/other_user}","gists_url":"https://api.github.com/users/lizconlan/gists{/gist_id}","starred_url":"https://api.github.com/users/lizconlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lizconlan/subscriptions","organizations_url":"https://api.github.com/users/lizconlan/orgs","repos_url":"https://api.github.com/users/lizconlan/repos","events_url":"https://api.github.com/users/lizconlan/events{/privacy}","received_events_url":"https://api.github.com/users/lizconlan/received_events","type":"User","site_admin":false},"body":"WIP\r\n\r\nAdds a new `update_state` method to the API that uses the existing API key mechanism to send a status update to a request created via an external API request. Intended usage - foi-register end-users confirming whether the information they requested has been disclosed ([the parallel work on foi-register can be found here](https://github.com/mysociety/foi-register/tree/issues/169-ask-user-to-confirm-request-state)). Status description mismatches should be handled on the foi-register side but unexpected status values are rejected with a 500 error by the API.\r\n\r\nAdds an optional parameter to the pre-existing `add_correspondence` API method to allow it to update status (intended use - updates from a public body) if a `state` value is supplied. Again, the foi-register code is responsible for handling state description mismatches but in this case the API deals with erroneous data by ignoring that part of the request.\r\n\r\nApologies for having restructured `api_controller_spec` but I kept losing track of which API methods the various tests were targeting. I will be happy to change it back before finalising the Pull Request if I've caused trouble.","created_at":"2014-06-23T16:37:59Z","updated_at":"2014-06-25T10:47:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"37ecc267a8414f960be7184444413a4c53201b4d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631/commits","review_comments_url":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631/comments","review_comment_url":"https://api.github.com/repos/mysociety/alaveteli/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mysociety/alaveteli/issues/1631/comments","statuses_url":"https://api.github.com/repos/mysociety/alaveteli/statuses/ae50dbd7306b514f6d2c8794ccdfbfa34a2a6a23","head":{"label":"mysociety:issues/1418-update-described-state-via-api","ref":"issues/1418-update-described-state-via-api","sha":"ae50dbd7306b514f6d2c8794ccdfbfa34a2a6a23","user":{"login":"mysociety","id":141338,"avatar_url":"https://avatars.githubusercontent.com/u/141338?","gravatar_id":"cb4e9c9ec6d33ee844baa03bd8f58cd3","url":"https://api.github.com/users/mysociety","html_url":"https://github.com/mysociety","followers_url":"https://api.github.com/users/mysociety/followers","following_url":"https://api.github.com/users/mysociety/following{/other_user}","gists_url":"https://api.github.com/users/mysociety/gists{/gist_id}","starred_url":"https://api.github.com/users/mysociety/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysociety/subscriptions","organizations_url":"https://api.github.com/users/mysociety/orgs","repos_url":"https://api.github.com/users/mysociety/repos","events_url":"https://api.github.com/users/mysociety/events{/privacy}","received_events_url":"https://api.github.com/users/mysociety/received_events","type":"Organization","site_admin":false},"repo":{"id":1125389,"name":"alaveteli","full_name":"mysociety/alaveteli","owner":{"login":"mysociety","id":141338,"avatar_url":"https://avatars.githubusercontent.com/u/141338?","gravatar_id":"cb4e9c9ec6d33ee844baa03bd8f58cd3","url":"https://api.github.com/users/mysociety","html_url":"https://github.com/mysociety","followers_url":"https://api.github.com/users/mysociety/followers","following_url":"https://api.github.com/users/mysociety/following{/other_user}","gists_url":"https://api.github.com/users/mysociety/gists{/gist_id}","starred_url":"https://api.github.com/users/mysociety/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysociety/subscriptions","organizations_url":"https://api.github.com/users/mysociety/orgs","repos_url":"https://api.github.com/users/mysociety/repos","events_url":"https://api.github.com/users/mysociety/events{/privacy}","received_events_url":"https://api.github.com/users/mysociety/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mysociety/alaveteli","description":"Provide a Freedom of Information request system for your jurisdiction","fork":false,"url":"https://api.github.com/repos/mysociety/alaveteli","forks_url":"https://api.github.com/repos/mysociety/alaveteli/forks","keys_url":"https://api.github.com/repos/mysociety/alaveteli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mysociety/alaveteli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mysociety/alaveteli/teams","hooks_url":"https://api.github.com/repos/mysociety/alaveteli/hooks","issue_events_url":"https://api.github.com/repos/mysociety/alaveteli/issues/events{/number}","events_url":"https://api.github.com/repos/mysociety/alaveteli/events","assignees_url":"https://api.github.com/repos/mysociety/alaveteli/assignees{/user}","branches_url":"https://api.github.com/repos/mysociety/alaveteli/branches{/branch}","tags_url":"https://api.github.com/repos/mysociety/alaveteli/tags","blobs_url":"https://api.github.com/repos/mysociety/alaveteli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mysociety/alaveteli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mysociety/alaveteli/git/refs{/sha}","trees_url":"https://api.github.com/repos/mysociety/alaveteli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mysociety/alaveteli/statuses/{sha}","languages_url":"https://api.github.com/repos/mysociety/alaveteli/languages","stargazers_url":"https://api.github.com/repos/mysociety/alaveteli/stargazers","contributors_url":"https://api.github.com/repos/mysociety/alaveteli/contributors","subscribers_url":"https://api.github.com/repos/mysociety/alaveteli/subscribers","subscription_url":"https://api.github.com/repos/mysociety/alaveteli/subscription","commits_url":"https://api.github.com/repos/mysociety/alaveteli/commits{/sha}","git_commits_url":"https://api.github.com/repos/mysociety/alaveteli/git/commits{/sha}","comments_url":"https://api.github.com/repos/mysociety/alaveteli/comments{/number}","issue_comment_url":"https://api.github.com/repos/mysociety/alaveteli/issues/comments/{number}","contents_url":"https://api.github.com/repos/mysociety/alaveteli/contents/{+path}","compare_url":"https://api.github.com/repos/mysociety/alaveteli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mysociety/alaveteli/merges","archive_url":"https://api.github.com/repos/mysociety/alaveteli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mysociety/alaveteli/downloads","issues_url":"https://api.github.com/repos/mysociety/alaveteli/issues{/number}","pulls_url":"https://api.github.com/repos/mysociety/alaveteli/pulls{/number}","milestones_url":"https://api.github.com/repos/mysociety/alaveteli/milestones{/number}","notifications_url":"https://api.github.com/repos/mysociety/alaveteli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mysociety/alaveteli/labels{/name}","releases_url":"https://api.github.com/repos/mysociety/alaveteli/releases{/id}","created_at":"2010-11-30T13:11:39Z","updated_at":"2014-06-25T10:02:14Z","pushed_at":"2014-06-25T10:46:55Z","git_url":"git://github.com/mysociety/alaveteli.git","ssh_url":"git@github.com:mysociety/alaveteli.git","clone_url":"https://github.com/mysociety/alaveteli.git","svn_url":"https://github.com/mysociety/alaveteli","homepage":"http://alaveteli.org","size":82553,"stargazers_count":119,"watchers_count":119,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":76,"mirror_url":null,"open_issues_count":407,"forks":76,"open_issues":407,"watchers":119,"default_branch":"rails-3-develop"}},"base":{"label":"mysociety:rails-3-develop","ref":"rails-3-develop","sha":"a9389e60e3e2f912ef3131351ab37551a3929a2a","user":{"login":"mysociety","id":141338,"avatar_url":"https://avatars.githubusercontent.com/u/141338?","gravatar_id":"cb4e9c9ec6d33ee844baa03bd8f58cd3","url":"https://api.github.com/users/mysociety","html_url":"https://github.com/mysociety","followers_url":"https://api.github.com/users/mysociety/followers","following_url":"https://api.github.com/users/mysociety/following{/other_user}","gists_url":"https://api.github.com/users/mysociety/gists{/gist_id}","starred_url":"https://api.github.com/users/mysociety/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysociety/subscriptions","organizations_url":"https://api.github.com/users/mysociety/orgs","repos_url":"https://api.github.com/users/mysociety/repos","events_url":"https://api.github.com/users/mysociety/events{/privacy}","received_events_url":"https://api.github.com/users/mysociety/received_events","type":"Organization","site_admin":false},"repo":{"id":1125389,"name":"alaveteli","full_name":"mysociety/alaveteli","owner":{"login":"mysociety","id":141338,"avatar_url":"https://avatars.githubusercontent.com/u/141338?","gravatar_id":"cb4e9c9ec6d33ee844baa03bd8f58cd3","url":"https://api.github.com/users/mysociety","html_url":"https://github.com/mysociety","followers_url":"https://api.github.com/users/mysociety/followers","following_url":"https://api.github.com/users/mysociety/following{/other_user}","gists_url":"https://api.github.com/users/mysociety/gists{/gist_id}","starred_url":"https://api.github.com/users/mysociety/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysociety/subscriptions","organizations_url":"https://api.github.com/users/mysociety/orgs","repos_url":"https://api.github.com/users/mysociety/repos","events_url":"https://api.github.com/users/mysociety/events{/privacy}","received_events_url":"https://api.github.com/users/mysociety/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mysociety/alaveteli","description":"Provide a Freedom of Information request system for your jurisdiction","fork":false,"url":"https://api.github.com/repos/mysociety/alaveteli","forks_url":"https://api.github.com/repos/mysociety/alaveteli/forks","keys_url":"https://api.github.com/repos/mysociety/alaveteli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mysociety/alaveteli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mysociety/alaveteli/teams","hooks_url":"https://api.github.com/repos/mysociety/alaveteli/hooks","issue_events_url":"https://api.github.com/repos/mysociety/alaveteli/issues/events{/number}","events_url":"https://api.github.com/repos/mysociety/alaveteli/events","assignees_url":"https://api.github.com/repos/mysociety/alaveteli/assignees{/user}","branches_url":"https://api.github.com/repos/mysociety/alaveteli/branches{/branch}","tags_url":"https://api.github.com/repos/mysociety/alaveteli/tags","blobs_url":"https://api.github.com/repos/mysociety/alaveteli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mysociety/alaveteli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mysociety/alaveteli/git/refs{/sha}","trees_url":"https://api.github.com/repos/mysociety/alaveteli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mysociety/alaveteli/statuses/{sha}","languages_url":"https://api.github.com/repos/mysociety/alaveteli/languages","stargazers_url":"https://api.github.com/repos/mysociety/alaveteli/stargazers","contributors_url":"https://api.github.com/repos/mysociety/alaveteli/contributors","subscribers_url":"https://api.github.com/repos/mysociety/alaveteli/subscribers","subscription_url":"https://api.github.com/repos/mysociety/alaveteli/subscription","commits_url":"https://api.github.com/repos/mysociety/alaveteli/commits{/sha}","git_commits_url":"https://api.github.com/repos/mysociety/alaveteli/git/commits{/sha}","comments_url":"https://api.github.com/repos/mysociety/alaveteli/comments{/number}","issue_comment_url":"https://api.github.com/repos/mysociety/alaveteli/issues/comments/{number}","contents_url":"https://api.github.com/repos/mysociety/alaveteli/contents/{+path}","compare_url":"https://api.github.com/repos/mysociety/alaveteli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mysociety/alaveteli/merges","archive_url":"https://api.github.com/repos/mysociety/alaveteli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mysociety/alaveteli/downloads","issues_url":"https://api.github.com/repos/mysociety/alaveteli/issues{/number}","pulls_url":"https://api.github.com/repos/mysociety/alaveteli/pulls{/number}","milestones_url":"https://api.github.com/repos/mysociety/alaveteli/milestones{/number}","notifications_url":"https://api.github.com/repos/mysociety/alaveteli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mysociety/alaveteli/labels{/name}","releases_url":"https://api.github.com/repos/mysociety/alaveteli/releases{/id}","created_at":"2010-11-30T13:11:39Z","updated_at":"2014-06-25T10:02:14Z","pushed_at":"2014-06-25T10:46:55Z","git_url":"git://github.com/mysociety/alaveteli.git","ssh_url":"git@github.com:mysociety/alaveteli.git","clone_url":"https://github.com/mysociety/alaveteli.git","svn_url":"https://github.com/mysociety/alaveteli","homepage":"http://alaveteli.org","size":82553,"stargazers_count":119,"watchers_count":119,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":76,"mirror_url":null,"open_issues_count":407,"forks":76,"open_issues":407,"watchers":119,"default_branch":"rails-3-develop"}},"_links":{"self":{"href":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631"},"html":{"href":"https://github.com/mysociety/alaveteli/pull/1631"},"issue":{"href":"https://api.github.com/repos/mysociety/alaveteli/issues/1631"},"comments":{"href":"https://api.github.com/repos/mysociety/alaveteli/issues/1631/comments"},"review_comments":{"href":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631/comments"},"review_comment":{"href":"https://api.github.com/repos/mysociety/alaveteli/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mysociety/alaveteli/pulls/1631/commits"},"statuses":{"href":"https://api.github.com/repos/mysociety/alaveteli/statuses/ae50dbd7306b514f6d2c8794ccdfbfa34a2a6a23"}}}}