{"action":"created","comment":{"url":"https://api.github.com/repos/opf/openproject/pulls/comments/22820167","id":22820167,"diff_hunk":"@@ -0,0 +1,122 @@\n+#-- copyright\n+# OpenProject is a project management system.\n+# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)\n+#\n+# This program is free software; you can redistribute it and/or\n+# modify it under the terms of the GNU General Public License version 3.\n+#\n+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:\n+# Copyright (C) 2006-2013 Jean-Philippe Lang\n+# Copyright (C) 2010-2013 the ChiliProject Team\n+#\n+# This program is free software; you can redistribute it and/or\n+# modify it under the terms of the GNU General Public License\n+# as published by the Free Software Foundation; either version 2\n+# of the License, or (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program; if not, write to the Free Software\n+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n+#\n+# See doc/COPYRIGHT.rdoc for more details.\n+#++\n+\n+require 'spec_helper'\n+require 'rack/test'\n+\n+describe 'API v3 UserLock resource', type: :request do\n+  include Rack::Test::Methods\n+\n+  let(:current_user) { FactoryGirl.build_stubbed(:user) }\n+  let(:user) { FactoryGirl.create(:user, status: User::STATUSES[:active]) }\n+  let(:model) { ::API::V3::Users::UserModel.new(user) }\n+  let(:representer) { ::API::V3::Users::UserRepresenter.new(model) }\n+  let(:lock_path) { \"/api/v3/users/#{user.id}/lock\" }\n+  subject(:response) { last_response }\n+\n+  describe '#post' do\n+    before do\n+      allow(User).to receive(:current).and_return current_user\n+      post lock_path\n+      # lock manually\n+      user.lock\n+    end\n+\n+    # Locking is only available for admins\n+    context 'when logged in as admin' do\n+      let(:current_user) { FactoryGirl.build_stubbed(:admin) }\n+\n+      context 'user account can be locked' do\n+        it 'should respond with 200' do\n+          expect(subject.status).to eq(200)\n+        end\n+\n+        it 'should respond with an updated lock status in the user model' do\n+          expect(parse_json(subject.body, 'status')).to eq 'locked'\n+        end\n+      end\n+\n+      context 'user account is incompatible' do\n+        let(:user) { FactoryGirl.create(:user,","path":"spec/requests/api/v3/user/userlock_resource_spec.rb","position":65,"original_position":65,"commit_id":"9e6da9179831f60860e64e07dfbd0c6f787027fc","original_commit_id":"9e6da9179831f60860e64e07dfbd0c6f787027fc","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","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":"Block body expression is on the same line as the block start.","created_at":"2015-01-12T20:39:44Z","updated_at":"2015-01-12T20:39:44Z","html_url":"https://github.com/opf/openproject/pull/2405#discussion_r22820167","pull_request_url":"https://api.github.com/repos/opf/openproject/pulls/2405","_links":{"self":{"href":"https://api.github.com/repos/opf/openproject/pulls/comments/22820167"},"html":{"href":"https://github.com/opf/openproject/pull/2405#discussion_r22820167"},"pull_request":{"href":"https://api.github.com/repos/opf/openproject/pulls/2405"}}},"pull_request":{"url":"https://api.github.com/repos/opf/openproject/pulls/2405","id":27087903,"html_url":"https://github.com/opf/openproject/pull/2405","diff_url":"https://github.com/opf/openproject/pull/2405.diff","patch_url":"https://github.com/opf/openproject/pull/2405.patch","issue_url":"https://api.github.com/repos/opf/openproject/issues/2405","number":2405,"state":"open","locked":false,"title":"apiv3: User (Un-)Locking functionality","user":{"login":"oliverguenther","id":459462,"avatar_url":"https://avatars.githubusercontent.com/u/459462?v=3","gravatar_id":"","url":"https://api.github.com/users/oliverguenther","html_url":"https://github.com/oliverguenther","followers_url":"https://api.github.com/users/oliverguenther/followers","following_url":"https://api.github.com/users/oliverguenther/following{/other_user}","gists_url":"https://api.github.com/users/oliverguenther/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverguenther/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverguenther/subscriptions","organizations_url":"https://api.github.com/users/oliverguenther/orgs","repos_url":"https://api.github.com/users/oliverguenther/repos","events_url":"https://api.github.com/users/oliverguenther/events{/privacy}","received_events_url":"https://api.github.com/users/oliverguenther/received_events","type":"User","site_admin":false},"body":"This commit implements the proposed user locking/unlocking functionality\r\nin https://github.com/opf/openproject/pull/2401.\r\n\r\nThe APIv3 is extended with a resource ``/user/:id/lock`` with the following properties:\r\n\r\n* ``POST /lock``: Set the lock of user(:id), if its account status is 'active'.\r\n\r\n* ``DELETE /lock``: Remove an active lock of user(:id), if its account status is 'locked'.\r\n\r\nThis commit also implements the following changes to ``UserRepresenter``:\r\n\r\n* Replaced the integer status field with the textual status name (i.e., 'active')\r\n* Added two entries to *_links* for admin users: ``lock``, ``unlock``.","created_at":"2015-01-09T09:20:28Z","updated_at":"2015-01-12T20:39:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f85300be030aa9641002e79610a5af9d483022d2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opf/openproject/pulls/2405/commits","review_comments_url":"https://api.github.com/repos/opf/openproject/pulls/2405/comments","review_comment_url":"https://api.github.com/repos/opf/openproject/pulls/comments/{number}","comments_url":"https://api.github.com/repos/opf/openproject/issues/2405/comments","statuses_url":"https://api.github.com/repos/opf/openproject/statuses/9e6da9179831f60860e64e07dfbd0c6f787027fc","head":{"label":"oliverguenther:feature/apiv3-user-lockunlock","ref":"feature/apiv3-user-lockunlock","sha":"9e6da9179831f60860e64e07dfbd0c6f787027fc","user":{"login":"oliverguenther","id":459462,"avatar_url":"https://avatars.githubusercontent.com/u/459462?v=3","gravatar_id":"","url":"https://api.github.com/users/oliverguenther","html_url":"https://github.com/oliverguenther","followers_url":"https://api.github.com/users/oliverguenther/followers","following_url":"https://api.github.com/users/oliverguenther/following{/other_user}","gists_url":"https://api.github.com/users/oliverguenther/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverguenther/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverguenther/subscriptions","organizations_url":"https://api.github.com/users/oliverguenther/orgs","repos_url":"https://api.github.com/users/oliverguenther/repos","events_url":"https://api.github.com/users/oliverguenther/events{/privacy}","received_events_url":"https://api.github.com/users/oliverguenther/received_events","type":"User","site_admin":false},"repo":{"id":26265397,"name":"openproject","full_name":"oliverguenther/openproject","owner":{"login":"oliverguenther","id":459462,"avatar_url":"https://avatars.githubusercontent.com/u/459462?v=3","gravatar_id":"","url":"https://api.github.com/users/oliverguenther","html_url":"https://github.com/oliverguenther","followers_url":"https://api.github.com/users/oliverguenther/followers","following_url":"https://api.github.com/users/oliverguenther/following{/other_user}","gists_url":"https://api.github.com/users/oliverguenther/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverguenther/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverguenther/subscriptions","organizations_url":"https://api.github.com/users/oliverguenther/orgs","repos_url":"https://api.github.com/users/oliverguenther/repos","events_url":"https://api.github.com/users/oliverguenther/events{/privacy}","received_events_url":"https://api.github.com/users/oliverguenther/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oliverguenther/openproject","description":"OpenProject is a web based project management system built on Ruby on Rails","fork":true,"url":"https://api.github.com/repos/oliverguenther/openproject","forks_url":"https://api.github.com/repos/oliverguenther/openproject/forks","keys_url":"https://api.github.com/repos/oliverguenther/openproject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oliverguenther/openproject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oliverguenther/openproject/teams","hooks_url":"https://api.github.com/repos/oliverguenther/openproject/hooks","issue_events_url":"https://api.github.com/repos/oliverguenther/openproject/issues/events{/number}","events_url":"https://api.github.com/repos/oliverguenther/openproject/events","assignees_url":"https://api.github.com/repos/oliverguenther/openproject/assignees{/user}","branches_url":"https://api.github.com/repos/oliverguenther/openproject/branches{/branch}","tags_url":"https://api.github.com/repos/oliverguenther/openproject/tags","blobs_url":"https://api.github.com/repos/oliverguenther/openproject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oliverguenther/openproject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oliverguenther/openproject/git/refs{/sha}","trees_url":"https://api.github.com/repos/oliverguenther/openproject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oliverguenther/openproject/statuses/{sha}","languages_url":"https://api.github.com/repos/oliverguenther/openproject/languages","stargazers_url":"https://api.github.com/repos/oliverguenther/openproject/stargazers","contributors_url":"https://api.github.com/repos/oliverguenther/openproject/contributors","subscribers_url":"https://api.github.com/repos/oliverguenther/openproject/subscribers","subscription_url":"https://api.github.com/repos/oliverguenther/openproject/subscription","commits_url":"https://api.github.com/repos/oliverguenther/openproject/commits{/sha}","git_commits_url":"https://api.github.com/repos/oliverguenther/openproject/git/commits{/sha}","comments_url":"https://api.github.com/repos/oliverguenther/openproject/comments{/number}","issue_comment_url":"https://api.github.com/repos/oliverguenther/openproject/issues/comments/{number}","contents_url":"https://api.github.com/repos/oliverguenther/openproject/contents/{+path}","compare_url":"https://api.github.com/repos/oliverguenther/openproject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oliverguenther/openproject/merges","archive_url":"https://api.github.com/repos/oliverguenther/openproject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oliverguenther/openproject/downloads","issues_url":"https://api.github.com/repos/oliverguenther/openproject/issues{/number}","pulls_url":"https://api.github.com/repos/oliverguenther/openproject/pulls{/number}","milestones_url":"https://api.github.com/repos/oliverguenther/openproject/milestones{/number}","notifications_url":"https://api.github.com/repos/oliverguenther/openproject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oliverguenther/openproject/labels{/name}","releases_url":"https://api.github.com/repos/oliverguenther/openproject/releases{/id}","created_at":"2014-11-06T10:38:55Z","updated_at":"2014-11-06T10:24:20Z","pushed_at":"2015-01-12T20:39:37Z","git_url":"git://github.com/oliverguenther/openproject.git","ssh_url":"git@github.com:oliverguenther/openproject.git","clone_url":"https://github.com/oliverguenther/openproject.git","svn_url":"https://github.com/oliverguenther/openproject","homepage":"https://www.openproject.org","size":58213,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"opf:dev","ref":"dev","sha":"24f496a9a08f8eb0af88feb6599a8554dd856562","user":{"login":"opf","id":1756674,"avatar_url":"https://avatars.githubusercontent.com/u/1756674?v=3","gravatar_id":"","url":"https://api.github.com/users/opf","html_url":"https://github.com/opf","followers_url":"https://api.github.com/users/opf/followers","following_url":"https://api.github.com/users/opf/following{/other_user}","gists_url":"https://api.github.com/users/opf/gists{/gist_id}","starred_url":"https://api.github.com/users/opf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opf/subscriptions","organizations_url":"https://api.github.com/users/opf/orgs","repos_url":"https://api.github.com/users/opf/repos","events_url":"https://api.github.com/users/opf/events{/privacy}","received_events_url":"https://api.github.com/users/opf/received_events","type":"Organization","site_admin":false},"repo":{"id":6899875,"name":"openproject","full_name":"opf/openproject","owner":{"login":"opf","id":1756674,"avatar_url":"https://avatars.githubusercontent.com/u/1756674?v=3","gravatar_id":"","url":"https://api.github.com/users/opf","html_url":"https://github.com/opf","followers_url":"https://api.github.com/users/opf/followers","following_url":"https://api.github.com/users/opf/following{/other_user}","gists_url":"https://api.github.com/users/opf/gists{/gist_id}","starred_url":"https://api.github.com/users/opf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opf/subscriptions","organizations_url":"https://api.github.com/users/opf/orgs","repos_url":"https://api.github.com/users/opf/repos","events_url":"https://api.github.com/users/opf/events{/privacy}","received_events_url":"https://api.github.com/users/opf/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opf/openproject","description":"OpenProject is a web based project management system built on Ruby on Rails","fork":false,"url":"https://api.github.com/repos/opf/openproject","forks_url":"https://api.github.com/repos/opf/openproject/forks","keys_url":"https://api.github.com/repos/opf/openproject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opf/openproject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opf/openproject/teams","hooks_url":"https://api.github.com/repos/opf/openproject/hooks","issue_events_url":"https://api.github.com/repos/opf/openproject/issues/events{/number}","events_url":"https://api.github.com/repos/opf/openproject/events","assignees_url":"https://api.github.com/repos/opf/openproject/assignees{/user}","branches_url":"https://api.github.com/repos/opf/openproject/branches{/branch}","tags_url":"https://api.github.com/repos/opf/openproject/tags","blobs_url":"https://api.github.com/repos/opf/openproject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opf/openproject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opf/openproject/git/refs{/sha}","trees_url":"https://api.github.com/repos/opf/openproject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opf/openproject/statuses/{sha}","languages_url":"https://api.github.com/repos/opf/openproject/languages","stargazers_url":"https://api.github.com/repos/opf/openproject/stargazers","contributors_url":"https://api.github.com/repos/opf/openproject/contributors","subscribers_url":"https://api.github.com/repos/opf/openproject/subscribers","subscription_url":"https://api.github.com/repos/opf/openproject/subscription","commits_url":"https://api.github.com/repos/opf/openproject/commits{/sha}","git_commits_url":"https://api.github.com/repos/opf/openproject/git/commits{/sha}","comments_url":"https://api.github.com/repos/opf/openproject/comments{/number}","issue_comment_url":"https://api.github.com/repos/opf/openproject/issues/comments/{number}","contents_url":"https://api.github.com/repos/opf/openproject/contents/{+path}","compare_url":"https://api.github.com/repos/opf/openproject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opf/openproject/merges","archive_url":"https://api.github.com/repos/opf/openproject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opf/openproject/downloads","issues_url":"https://api.github.com/repos/opf/openproject/issues{/number}","pulls_url":"https://api.github.com/repos/opf/openproject/pulls{/number}","milestones_url":"https://api.github.com/repos/opf/openproject/milestones{/number}","notifications_url":"https://api.github.com/repos/opf/openproject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opf/openproject/labels{/name}","releases_url":"https://api.github.com/repos/opf/openproject/releases{/id}","created_at":"2012-11-28T09:59:11Z","updated_at":"2015-01-12T15:02:59Z","pushed_at":"2015-01-12T17:59:50Z","git_url":"git://github.com/opf/openproject.git","ssh_url":"git@github.com:opf/openproject.git","clone_url":"https://github.com/opf/openproject.git","svn_url":"https://github.com/opf/openproject","homepage":"https://www.openproject.org","size":160249,"stargazers_count":465,"watchers_count":465,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":211,"mirror_url":null,"open_issues_count":47,"forks":211,"open_issues":47,"watchers":465,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/opf/openproject/pulls/2405"},"html":{"href":"https://github.com/opf/openproject/pull/2405"},"issue":{"href":"https://api.github.com/repos/opf/openproject/issues/2405"},"comments":{"href":"https://api.github.com/repos/opf/openproject/issues/2405/comments"},"review_comments":{"href":"https://api.github.com/repos/opf/openproject/pulls/2405/comments"},"review_comment":{"href":"https://api.github.com/repos/opf/openproject/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/opf/openproject/pulls/2405/commits"},"statuses":{"href":"https://api.github.com/repos/opf/openproject/statuses/9e6da9179831f60860e64e07dfbd0c6f787027fc"}}}}