{"action":"created","comment":{"url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/comments/63320316","id":63320316,"diff_hunk":"@@ -0,0 +1,97 @@\n+class OrganizationMembershipPolicy\n+  attr_reader :organization_membership, :user\n+\n+  def initialize(user, organization_membership)\n+    @user = user\n+    @organization_membership = organization_membership\n+  end\n+\n+  def index?\n+    true\n+  end\n+\n+  def create?\n+    # need to be logged in to do anything\n+    return unless user_is_logged_in?\n+    # can only create pending memberships\n+    return unless organization_membership.pending?\n+    # can't create a new membership of any type if already a member\n+    return if user_is_member?\n+\n+    true\n+  end\n+\n+  def update?\n+    # need to be logged in and member to do anything\n+    return unless user_is_logged_in? && user_is_member?\n+    # pending and contributors cant do any updates\n+    return if user_is_contributor? || user_is_pending?\n+    # admins cannot promote to admin or owner\n+    return if user_is_admin? && (organization_membership.admin? || organization_membership.owner?)\n+    # admins cannot demote from admin or owner\n+    return if user_is_admin? && (old_role_was_admin? || old_role_was_owner?)","path":"app/policies/organization_membership_policy.rb","position":32,"original_position":32,"commit_id":"fbe24c216e86e4962d832e0f8d5625dca0956a18","original_commit_id":"fbe24c216e86e4962d832e0f8d5625dca0956a18","user":{"login":"begedin","id":1925540,"avatar_url":"https://avatars.githubusercontent.com/u/1925540?v=3","gravatar_id":"","url":"https://api.github.com/users/begedin","html_url":"https://github.com/begedin","followers_url":"https://api.github.com/users/begedin/followers","following_url":"https://api.github.com/users/begedin/following{/other_user}","gists_url":"https://api.github.com/users/begedin/gists{/gist_id}","starred_url":"https://api.github.com/users/begedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/begedin/subscriptions","organizations_url":"https://api.github.com/users/begedin/orgs","repos_url":"https://api.github.com/users/begedin/repos","events_url":"https://api.github.com/users/begedin/events{/privacy}","received_events_url":"https://api.github.com/users/begedin/received_events","type":"User","site_admin":false},"body":"Generally speaking, I'm thinking users on the same credential levels should not be able to take each other's credentials. I think that should be reserved for users with higher credentials (owners, in this case).\r\n\r\nI would say the same for promoting, but there, I can see the use if admins promoting others to admins.","created_at":"2016-05-16T07:58:25Z","updated_at":"2016-05-16T07:58:25Z","html_url":"https://github.com/code-corps/code-corps-api/pull/263#discussion_r63320316","pull_request_url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263","_links":{"self":{"href":"https://api.github.com/repos/code-corps/code-corps-api/pulls/comments/63320316"},"html":{"href":"https://github.com/code-corps/code-corps-api/pull/263#discussion_r63320316"},"pull_request":{"href":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263"}}},"pull_request":{"url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263","id":63387266,"html_url":"https://github.com/code-corps/code-corps-api/pull/263","diff_url":"https://github.com/code-corps/code-corps-api/pull/263.diff","patch_url":"https://github.com/code-corps/code-corps-api/pull/263.patch","issue_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/263","number":263,"state":"open","locked":false,"title":"Allow users to join projects","user":{"login":"begedin","id":1925540,"avatar_url":"https://avatars.githubusercontent.com/u/1925540?v=3","gravatar_id":"","url":"https://api.github.com/users/begedin","html_url":"https://github.com/begedin","followers_url":"https://api.github.com/users/begedin/followers","following_url":"https://api.github.com/users/begedin/following{/other_user}","gists_url":"https://api.github.com/users/begedin/gists{/gist_id}","starred_url":"https://api.github.com/users/begedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/begedin/subscriptions","organizations_url":"https://api.github.com/users/begedin/orgs","repos_url":"https://api.github.com/users/begedin/repos","events_url":"https://api.github.com/users/begedin/events{/privacy}","received_events_url":"https://api.github.com/users/begedin/received_events","type":"User","site_admin":false},"body":"This is just a bunch of pending specs right now. I wasn't able to do anything else in time.\r\n\r\nIt would be good to get an opinion on this, though, since I'm not even sure this is the behavior we would like.","created_at":"2016-03-18T15:02:18Z","updated_at":"2016-05-16T07:58:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fd4720c8b846667aa508a9939b5de257dc07b1d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263/commits","review_comments_url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263/comments","review_comment_url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/263/comments","statuses_url":"https://api.github.com/repos/code-corps/code-corps-api/statuses/fbe24c216e86e4962d832e0f8d5625dca0956a18","head":{"label":"code-corps:allow-user-to-join-project","ref":"allow-user-to-join-project","sha":"fbe24c216e86e4962d832e0f8d5625dca0956a18","user":{"login":"code-corps","id":12991115,"avatar_url":"https://avatars.githubusercontent.com/u/12991115?v=3","gravatar_id":"","url":"https://api.github.com/users/code-corps","html_url":"https://github.com/code-corps","followers_url":"https://api.github.com/users/code-corps/followers","following_url":"https://api.github.com/users/code-corps/following{/other_user}","gists_url":"https://api.github.com/users/code-corps/gists{/gist_id}","starred_url":"https://api.github.com/users/code-corps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-corps/subscriptions","organizations_url":"https://api.github.com/users/code-corps/orgs","repos_url":"https://api.github.com/users/code-corps/repos","events_url":"https://api.github.com/users/code-corps/events{/privacy}","received_events_url":"https://api.github.com/users/code-corps/received_events","type":"Organization","site_admin":false},"repo":{"id":37823327,"name":"code-corps-api","full_name":"code-corps/code-corps-api","owner":{"login":"code-corps","id":12991115,"avatar_url":"https://avatars.githubusercontent.com/u/12991115?v=3","gravatar_id":"","url":"https://api.github.com/users/code-corps","html_url":"https://github.com/code-corps","followers_url":"https://api.github.com/users/code-corps/followers","following_url":"https://api.github.com/users/code-corps/following{/other_user}","gists_url":"https://api.github.com/users/code-corps/gists{/gist_id}","starred_url":"https://api.github.com/users/code-corps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-corps/subscriptions","organizations_url":"https://api.github.com/users/code-corps/orgs","repos_url":"https://api.github.com/users/code-corps/repos","events_url":"https://api.github.com/users/code-corps/events{/privacy}","received_events_url":"https://api.github.com/users/code-corps/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-corps/code-corps-api","description":"Rails API for Code Corps.","fork":false,"url":"https://api.github.com/repos/code-corps/code-corps-api","forks_url":"https://api.github.com/repos/code-corps/code-corps-api/forks","keys_url":"https://api.github.com/repos/code-corps/code-corps-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-corps/code-corps-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-corps/code-corps-api/teams","hooks_url":"https://api.github.com/repos/code-corps/code-corps-api/hooks","issue_events_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/events{/number}","events_url":"https://api.github.com/repos/code-corps/code-corps-api/events","assignees_url":"https://api.github.com/repos/code-corps/code-corps-api/assignees{/user}","branches_url":"https://api.github.com/repos/code-corps/code-corps-api/branches{/branch}","tags_url":"https://api.github.com/repos/code-corps/code-corps-api/tags","blobs_url":"https://api.github.com/repos/code-corps/code-corps-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-corps/code-corps-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-corps/code-corps-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-corps/code-corps-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-corps/code-corps-api/statuses/{sha}","languages_url":"https://api.github.com/repos/code-corps/code-corps-api/languages","stargazers_url":"https://api.github.com/repos/code-corps/code-corps-api/stargazers","contributors_url":"https://api.github.com/repos/code-corps/code-corps-api/contributors","subscribers_url":"https://api.github.com/repos/code-corps/code-corps-api/subscribers","subscription_url":"https://api.github.com/repos/code-corps/code-corps-api/subscription","commits_url":"https://api.github.com/repos/code-corps/code-corps-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-corps/code-corps-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-corps/code-corps-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-corps/code-corps-api/contents/{+path}","compare_url":"https://api.github.com/repos/code-corps/code-corps-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-corps/code-corps-api/merges","archive_url":"https://api.github.com/repos/code-corps/code-corps-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-corps/code-corps-api/downloads","issues_url":"https://api.github.com/repos/code-corps/code-corps-api/issues{/number}","pulls_url":"https://api.github.com/repos/code-corps/code-corps-api/pulls{/number}","milestones_url":"https://api.github.com/repos/code-corps/code-corps-api/milestones{/number}","notifications_url":"https://api.github.com/repos/code-corps/code-corps-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-corps/code-corps-api/labels{/name}","releases_url":"https://api.github.com/repos/code-corps/code-corps-api/releases{/id}","deployments_url":"https://api.github.com/repos/code-corps/code-corps-api/deployments","created_at":"2015-06-21T19:46:54Z","updated_at":"2016-02-15T02:25:28Z","pushed_at":"2016-05-09T09:16:49Z","git_url":"git://github.com/code-corps/code-corps-api.git","ssh_url":"git@github.com:code-corps/code-corps-api.git","clone_url":"https://github.com/code-corps/code-corps-api.git","svn_url":"https://github.com/code-corps/code-corps-api","homepage":"https://codecorps.org","size":1029,"stargazers_count":11,"watchers_count":11,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":20,"forks":5,"open_issues":20,"watchers":11,"default_branch":"develop"}},"base":{"label":"code-corps:develop","ref":"develop","sha":"6a72b5bfc18723d4c5029e5a75f0a49a7b0ec8da","user":{"login":"code-corps","id":12991115,"avatar_url":"https://avatars.githubusercontent.com/u/12991115?v=3","gravatar_id":"","url":"https://api.github.com/users/code-corps","html_url":"https://github.com/code-corps","followers_url":"https://api.github.com/users/code-corps/followers","following_url":"https://api.github.com/users/code-corps/following{/other_user}","gists_url":"https://api.github.com/users/code-corps/gists{/gist_id}","starred_url":"https://api.github.com/users/code-corps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-corps/subscriptions","organizations_url":"https://api.github.com/users/code-corps/orgs","repos_url":"https://api.github.com/users/code-corps/repos","events_url":"https://api.github.com/users/code-corps/events{/privacy}","received_events_url":"https://api.github.com/users/code-corps/received_events","type":"Organization","site_admin":false},"repo":{"id":37823327,"name":"code-corps-api","full_name":"code-corps/code-corps-api","owner":{"login":"code-corps","id":12991115,"avatar_url":"https://avatars.githubusercontent.com/u/12991115?v=3","gravatar_id":"","url":"https://api.github.com/users/code-corps","html_url":"https://github.com/code-corps","followers_url":"https://api.github.com/users/code-corps/followers","following_url":"https://api.github.com/users/code-corps/following{/other_user}","gists_url":"https://api.github.com/users/code-corps/gists{/gist_id}","starred_url":"https://api.github.com/users/code-corps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-corps/subscriptions","organizations_url":"https://api.github.com/users/code-corps/orgs","repos_url":"https://api.github.com/users/code-corps/repos","events_url":"https://api.github.com/users/code-corps/events{/privacy}","received_events_url":"https://api.github.com/users/code-corps/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-corps/code-corps-api","description":"Rails API for Code Corps.","fork":false,"url":"https://api.github.com/repos/code-corps/code-corps-api","forks_url":"https://api.github.com/repos/code-corps/code-corps-api/forks","keys_url":"https://api.github.com/repos/code-corps/code-corps-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-corps/code-corps-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-corps/code-corps-api/teams","hooks_url":"https://api.github.com/repos/code-corps/code-corps-api/hooks","issue_events_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/events{/number}","events_url":"https://api.github.com/repos/code-corps/code-corps-api/events","assignees_url":"https://api.github.com/repos/code-corps/code-corps-api/assignees{/user}","branches_url":"https://api.github.com/repos/code-corps/code-corps-api/branches{/branch}","tags_url":"https://api.github.com/repos/code-corps/code-corps-api/tags","blobs_url":"https://api.github.com/repos/code-corps/code-corps-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-corps/code-corps-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-corps/code-corps-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-corps/code-corps-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-corps/code-corps-api/statuses/{sha}","languages_url":"https://api.github.com/repos/code-corps/code-corps-api/languages","stargazers_url":"https://api.github.com/repos/code-corps/code-corps-api/stargazers","contributors_url":"https://api.github.com/repos/code-corps/code-corps-api/contributors","subscribers_url":"https://api.github.com/repos/code-corps/code-corps-api/subscribers","subscription_url":"https://api.github.com/repos/code-corps/code-corps-api/subscription","commits_url":"https://api.github.com/repos/code-corps/code-corps-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-corps/code-corps-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-corps/code-corps-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-corps/code-corps-api/contents/{+path}","compare_url":"https://api.github.com/repos/code-corps/code-corps-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-corps/code-corps-api/merges","archive_url":"https://api.github.com/repos/code-corps/code-corps-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-corps/code-corps-api/downloads","issues_url":"https://api.github.com/repos/code-corps/code-corps-api/issues{/number}","pulls_url":"https://api.github.com/repos/code-corps/code-corps-api/pulls{/number}","milestones_url":"https://api.github.com/repos/code-corps/code-corps-api/milestones{/number}","notifications_url":"https://api.github.com/repos/code-corps/code-corps-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-corps/code-corps-api/labels{/name}","releases_url":"https://api.github.com/repos/code-corps/code-corps-api/releases{/id}","deployments_url":"https://api.github.com/repos/code-corps/code-corps-api/deployments","created_at":"2015-06-21T19:46:54Z","updated_at":"2016-02-15T02:25:28Z","pushed_at":"2016-05-09T09:16:49Z","git_url":"git://github.com/code-corps/code-corps-api.git","ssh_url":"git@github.com:code-corps/code-corps-api.git","clone_url":"https://github.com/code-corps/code-corps-api.git","svn_url":"https://github.com/code-corps/code-corps-api","homepage":"https://codecorps.org","size":1029,"stargazers_count":11,"watchers_count":11,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":20,"forks":5,"open_issues":20,"watchers":11,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263"},"html":{"href":"https://github.com/code-corps/code-corps-api/pull/263"},"issue":{"href":"https://api.github.com/repos/code-corps/code-corps-api/issues/263"},"comments":{"href":"https://api.github.com/repos/code-corps/code-corps-api/issues/263/comments"},"review_comments":{"href":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263/comments"},"review_comment":{"href":"https://api.github.com/repos/code-corps/code-corps-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/code-corps/code-corps-api/pulls/263/commits"},"statuses":{"href":"https://api.github.com/repos/code-corps/code-corps-api/statuses/fbe24c216e86e4962d832e0f8d5625dca0956a18"}}}}