{"action":"created","comment":{"url":"https://api.github.com/repos/chef/supermarket/pulls/comments/47801888","id":47801888,"diff_hunk":"@@ -115,7 +115,93 @@ class FakesController < ApplicationController\n     end\n   end\n \n-  context 'removing users' do\n+  context 'adding collaborator groups' do\n+    let!(:group_member) { create(:group_member) }\n+    let(:group) { group_member.group }\n+\n+    let!(:group_member2) { create(:group_member, group: group) }\n+\n+    context 'adding a single group' do\n+      before do\n+        expect(cookbook.owner).to eq(fanny)\n+        sign_in fanny\n+\n+        allow(Group).to receive(:find).and_return(group)\n+        allow(group).to receive(:members).and_return(group.members)\n+      end\n+\n+      it 'finds the correct group' do\n+        expect(Group).to receive(:find).with(group.id.to_s).and_return(group)\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+      end\n+\n+      it 'associates the group with the resource' do\n+        expect(group).to receive(:group_resources).at_least(:once).and_return([])\n+        new_group_resource = create(:group_resource, group: group)\n+\n+        allow(GroupResource).to receive(:create!).and_return(new_group_resource)\n+\n+        expect(group.group_resources).to receive(:<<).with(new_group_resource)\n+\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+      end\n+\n+      it 'finds the members for the group' do\n+        expect(group).to receive(:members).and_return(group.members)\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+      end\n+\n+      it 'maps the user ids' do\n+        expect(group.members).to receive(:map).and_return(group.members.map(&:id))\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+      end\n+\n+      it 'transforms the user ids into a string' do\n+        member_ids = group.members.map(&:id)\n+        allow(group.members).to receive(:map).and_return(member_ids)\n+        expect(member_ids).to receive(:map).and_return(member_ids.map(&:to_s))\n+\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+      end\n+\n+      it 'makes a collaborator for each group user' do\n+        user_ids = group.members.map(&:id).map(&:to_s)\n+\n+        expect(subject).to receive(:add_users_as_collaborators).with(cookbook, user_ids, group.id.to_s)\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+      end\n+\n+      it 'associates the collaborator with the group' do\n+        expect(cookbook.collaborators).to be_empty\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}\")\n+        cookbook.collaborators.each do |collaborator|\n+          expect(collaborator.group).to eq(group)\n+        end\n+      end\n+    end\n+\n+    context 'adding multiple groups' do\n+      let!(:group2_member) { create(:group_member) }\n+      let(:group2) { group2_member.group }\n+      let!(:group2_member2) { create(:group_member, group: group2) }\n+\n+      it 'finds all groups' do\n+        expect(Group).to receive(:find).at_least(:twice).and_return(group, group2)\n+        subject.add_group_members_as_collaborators(cookbook, \"#{group.id}, #{group2.id}\")\n+      end","path":"spec/controllers/concerns/collaborator_processing_spec.rb","position":87,"original_position":87,"commit_id":"e4a31f5c831e90c9bb47846fb0b8347d038aacbb","original_commit_id":"e4a31f5c831e90c9bb47846fb0b8347d038aacbb","user":{"login":"robbkidd","id":517302,"avatar_url":"https://avatars.githubusercontent.com/u/517302?v=3","gravatar_id":"","url":"https://api.github.com/users/robbkidd","html_url":"https://github.com/robbkidd","followers_url":"https://api.github.com/users/robbkidd/followers","following_url":"https://api.github.com/users/robbkidd/following{/other_user}","gists_url":"https://api.github.com/users/robbkidd/gists{/gist_id}","starred_url":"https://api.github.com/users/robbkidd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbkidd/subscriptions","organizations_url":"https://api.github.com/users/robbkidd/orgs","repos_url":"https://api.github.com/users/robbkidd/repos","events_url":"https://api.github.com/users/robbkidd/events{/privacy}","received_events_url":"https://api.github.com/users/robbkidd/received_events","type":"User","site_admin":false},"body":"Suggest tweaking this to be similar to revised specs for the \"adding a single group\" context:\r\n\r\n* two specs for testing that `add_users_as_collaborators` and `associate_group_to_resource` get called the correct number of times with correct signatures\r\n* one spec—currently present in `makes a new collaborator for each user in both groups`—to test like a black box","created_at":"2015-12-16T16:55:08Z","updated_at":"2015-12-16T16:55:08Z","html_url":"https://github.com/chef/supermarket/pull/1151#discussion_r47801888","pull_request_url":"https://api.github.com/repos/chef/supermarket/pulls/1151","_links":{"self":{"href":"https://api.github.com/repos/chef/supermarket/pulls/comments/47801888"},"html":{"href":"https://github.com/chef/supermarket/pull/1151#discussion_r47801888"},"pull_request":{"href":"https://api.github.com/repos/chef/supermarket/pulls/1151"}}},"pull_request":{"url":"https://api.github.com/repos/chef/supermarket/pulls/1151","id":49321831,"html_url":"https://github.com/chef/supermarket/pull/1151","diff_url":"https://github.com/chef/supermarket/pull/1151.diff","patch_url":"https://github.com/chef/supermarket/pull/1151.patch","issue_url":"https://api.github.com/repos/chef/supermarket/issues/1151","number":1151,"state":"open","locked":false,"title":"Groups Feature","user":{"login":"nellshamrell","id":813007,"avatar_url":"https://avatars.githubusercontent.com/u/813007?v=3","gravatar_id":"","url":"https://api.github.com/users/nellshamrell","html_url":"https://github.com/nellshamrell","followers_url":"https://api.github.com/users/nellshamrell/followers","following_url":"https://api.github.com/users/nellshamrell/following{/other_user}","gists_url":"https://api.github.com/users/nellshamrell/gists{/gist_id}","starred_url":"https://api.github.com/users/nellshamrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nellshamrell/subscriptions","organizations_url":"https://api.github.com/users/nellshamrell/orgs","repos_url":"https://api.github.com/users/nellshamrell/repos","events_url":"https://api.github.com/users/nellshamrell/events{/privacy}","received_events_url":"https://api.github.com/users/nellshamrell/received_events","type":"User","site_admin":false},"body":"https://trello.com/b/SuBjc0us/supermarket-groups","created_at":"2015-10-30T20:59:48Z","updated_at":"2015-12-16T16:55:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2884afe0dd08e87ff2167477260f66e3dcaf96ef","assignee":{"login":"nellshamrell","id":813007,"avatar_url":"https://avatars.githubusercontent.com/u/813007?v=3","gravatar_id":"","url":"https://api.github.com/users/nellshamrell","html_url":"https://github.com/nellshamrell","followers_url":"https://api.github.com/users/nellshamrell/followers","following_url":"https://api.github.com/users/nellshamrell/following{/other_user}","gists_url":"https://api.github.com/users/nellshamrell/gists{/gist_id}","starred_url":"https://api.github.com/users/nellshamrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nellshamrell/subscriptions","organizations_url":"https://api.github.com/users/nellshamrell/orgs","repos_url":"https://api.github.com/users/nellshamrell/repos","events_url":"https://api.github.com/users/nellshamrell/events{/privacy}","received_events_url":"https://api.github.com/users/nellshamrell/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/chef/supermarket/pulls/1151/commits","review_comments_url":"https://api.github.com/repos/chef/supermarket/pulls/1151/comments","review_comment_url":"https://api.github.com/repos/chef/supermarket/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chef/supermarket/issues/1151/comments","statuses_url":"https://api.github.com/repos/chef/supermarket/statuses/e4a31f5c831e90c9bb47846fb0b8347d038aacbb","head":{"label":"nellshamrell:groups-feature-2","ref":"groups-feature-2","sha":"e4a31f5c831e90c9bb47846fb0b8347d038aacbb","user":{"login":"nellshamrell","id":813007,"avatar_url":"https://avatars.githubusercontent.com/u/813007?v=3","gravatar_id":"","url":"https://api.github.com/users/nellshamrell","html_url":"https://github.com/nellshamrell","followers_url":"https://api.github.com/users/nellshamrell/followers","following_url":"https://api.github.com/users/nellshamrell/following{/other_user}","gists_url":"https://api.github.com/users/nellshamrell/gists{/gist_id}","starred_url":"https://api.github.com/users/nellshamrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nellshamrell/subscriptions","organizations_url":"https://api.github.com/users/nellshamrell/orgs","repos_url":"https://api.github.com/users/nellshamrell/repos","events_url":"https://api.github.com/users/nellshamrell/events{/privacy}","received_events_url":"https://api.github.com/users/nellshamrell/received_events","type":"User","site_admin":false},"repo":{"id":24782030,"name":"supermarket","full_name":"nellshamrell/supermarket","owner":{"login":"nellshamrell","id":813007,"avatar_url":"https://avatars.githubusercontent.com/u/813007?v=3","gravatar_id":"","url":"https://api.github.com/users/nellshamrell","html_url":"https://github.com/nellshamrell","followers_url":"https://api.github.com/users/nellshamrell/followers","following_url":"https://api.github.com/users/nellshamrell/following{/other_user}","gists_url":"https://api.github.com/users/nellshamrell/gists{/gist_id}","starred_url":"https://api.github.com/users/nellshamrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nellshamrell/subscriptions","organizations_url":"https://api.github.com/users/nellshamrell/orgs","repos_url":"https://api.github.com/users/nellshamrell/repos","events_url":"https://api.github.com/users/nellshamrell/events{/privacy}","received_events_url":"https://api.github.com/users/nellshamrell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nellshamrell/supermarket","description":"Chef's community platform","fork":true,"url":"https://api.github.com/repos/nellshamrell/supermarket","forks_url":"https://api.github.com/repos/nellshamrell/supermarket/forks","keys_url":"https://api.github.com/repos/nellshamrell/supermarket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nellshamrell/supermarket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nellshamrell/supermarket/teams","hooks_url":"https://api.github.com/repos/nellshamrell/supermarket/hooks","issue_events_url":"https://api.github.com/repos/nellshamrell/supermarket/issues/events{/number}","events_url":"https://api.github.com/repos/nellshamrell/supermarket/events","assignees_url":"https://api.github.com/repos/nellshamrell/supermarket/assignees{/user}","branches_url":"https://api.github.com/repos/nellshamrell/supermarket/branches{/branch}","tags_url":"https://api.github.com/repos/nellshamrell/supermarket/tags","blobs_url":"https://api.github.com/repos/nellshamrell/supermarket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nellshamrell/supermarket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nellshamrell/supermarket/git/refs{/sha}","trees_url":"https://api.github.com/repos/nellshamrell/supermarket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nellshamrell/supermarket/statuses/{sha}","languages_url":"https://api.github.com/repos/nellshamrell/supermarket/languages","stargazers_url":"https://api.github.com/repos/nellshamrell/supermarket/stargazers","contributors_url":"https://api.github.com/repos/nellshamrell/supermarket/contributors","subscribers_url":"https://api.github.com/repos/nellshamrell/supermarket/subscribers","subscription_url":"https://api.github.com/repos/nellshamrell/supermarket/subscription","commits_url":"https://api.github.com/repos/nellshamrell/supermarket/commits{/sha}","git_commits_url":"https://api.github.com/repos/nellshamrell/supermarket/git/commits{/sha}","comments_url":"https://api.github.com/repos/nellshamrell/supermarket/comments{/number}","issue_comment_url":"https://api.github.com/repos/nellshamrell/supermarket/issues/comments{/number}","contents_url":"https://api.github.com/repos/nellshamrell/supermarket/contents/{+path}","compare_url":"https://api.github.com/repos/nellshamrell/supermarket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nellshamrell/supermarket/merges","archive_url":"https://api.github.com/repos/nellshamrell/supermarket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nellshamrell/supermarket/downloads","issues_url":"https://api.github.com/repos/nellshamrell/supermarket/issues{/number}","pulls_url":"https://api.github.com/repos/nellshamrell/supermarket/pulls{/number}","milestones_url":"https://api.github.com/repos/nellshamrell/supermarket/milestones{/number}","notifications_url":"https://api.github.com/repos/nellshamrell/supermarket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nellshamrell/supermarket/labels{/name}","releases_url":"https://api.github.com/repos/nellshamrell/supermarket/releases{/id}","created_at":"2014-10-04T04:49:00Z","updated_at":"2015-05-05T18:57:05Z","pushed_at":"2015-12-10T22:11:10Z","git_url":"git://github.com/nellshamrell/supermarket.git","ssh_url":"git@github.com:nellshamrell/supermarket.git","clone_url":"https://github.com/nellshamrell/supermarket.git","svn_url":"https://github.com/nellshamrell/supermarket","homepage":"https://supermarket.getchef.com","size":4512,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chef:master","ref":"master","sha":"e2796d70b95f5108a4bf3eefaf476542b6293b00","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":13633443,"name":"supermarket","full_name":"chef/supermarket","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/supermarket","description":"Chef's community platform","fork":false,"url":"https://api.github.com/repos/chef/supermarket","forks_url":"https://api.github.com/repos/chef/supermarket/forks","keys_url":"https://api.github.com/repos/chef/supermarket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/supermarket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/supermarket/teams","hooks_url":"https://api.github.com/repos/chef/supermarket/hooks","issue_events_url":"https://api.github.com/repos/chef/supermarket/issues/events{/number}","events_url":"https://api.github.com/repos/chef/supermarket/events","assignees_url":"https://api.github.com/repos/chef/supermarket/assignees{/user}","branches_url":"https://api.github.com/repos/chef/supermarket/branches{/branch}","tags_url":"https://api.github.com/repos/chef/supermarket/tags","blobs_url":"https://api.github.com/repos/chef/supermarket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/supermarket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/supermarket/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/supermarket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/supermarket/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/supermarket/languages","stargazers_url":"https://api.github.com/repos/chef/supermarket/stargazers","contributors_url":"https://api.github.com/repos/chef/supermarket/contributors","subscribers_url":"https://api.github.com/repos/chef/supermarket/subscribers","subscription_url":"https://api.github.com/repos/chef/supermarket/subscription","commits_url":"https://api.github.com/repos/chef/supermarket/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/supermarket/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/supermarket/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/supermarket/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/supermarket/contents/{+path}","compare_url":"https://api.github.com/repos/chef/supermarket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/supermarket/merges","archive_url":"https://api.github.com/repos/chef/supermarket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/supermarket/downloads","issues_url":"https://api.github.com/repos/chef/supermarket/issues{/number}","pulls_url":"https://api.github.com/repos/chef/supermarket/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/supermarket/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/supermarket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/supermarket/labels{/name}","releases_url":"https://api.github.com/repos/chef/supermarket/releases{/id}","created_at":"2013-10-16T22:54:53Z","updated_at":"2015-12-02T03:06:04Z","pushed_at":"2015-12-11T17:15:29Z","git_url":"git://github.com/chef/supermarket.git","ssh_url":"git@github.com:chef/supermarket.git","clone_url":"https://github.com/chef/supermarket.git","svn_url":"https://github.com/chef/supermarket","homepage":"https://supermarket.chef.io/","size":4819,"stargazers_count":137,"watchers_count":137,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":79,"forks":54,"open_issues":79,"watchers":137,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chef/supermarket/pulls/1151"},"html":{"href":"https://github.com/chef/supermarket/pull/1151"},"issue":{"href":"https://api.github.com/repos/chef/supermarket/issues/1151"},"comments":{"href":"https://api.github.com/repos/chef/supermarket/issues/1151/comments"},"review_comments":{"href":"https://api.github.com/repos/chef/supermarket/pulls/1151/comments"},"review_comment":{"href":"https://api.github.com/repos/chef/supermarket/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chef/supermarket/pulls/1151/commits"},"statuses":{"href":"https://api.github.com/repos/chef/supermarket/statuses/e4a31f5c831e90c9bb47846fb0b8347d038aacbb"}}}}