{"action":"created","comment":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/comments/42262073","id":42262073,"diff_hunk":"@@ -1,63 +1,21 @@\n module Spree\n   module TestingSupport\n     module AuthorizationHelpers\n-      module CustomAbility\n-        def build_ability(&block)\n-          block ||= proc{ |u| can :manage, :all }\n-          Class.new do\n-            include CanCan::Ability\n-            define_method(:initialize, block)\n-          end\n-        end\n+      def stub_authorization!(user: Spree.user_class.new, permission_sets: [Spree::PermissionSets::SuperUser])\n+        ability = Spree::Ability.new(user)\n+        permission_sets.each { |ps| ps.new(ability).activate! }\n+        before { allow(Spree::Ability).to receive(:new) { ability } }","path":"core/lib/spree/testing_support/authorization_helpers.rb","position":15,"original_position":15,"commit_id":"ddc42433817646d45b40fd5f2c067452024f46c2","original_commit_id":"ddc42433817646d45b40fd5f2c067452024f46c2","user":{"login":"Senjai","id":1831235,"avatar_url":"https://avatars.githubusercontent.com/u/1831235?v=3","gravatar_id":"","url":"https://api.github.com/users/Senjai","html_url":"https://github.com/Senjai","followers_url":"https://api.github.com/users/Senjai/followers","following_url":"https://api.github.com/users/Senjai/following{/other_user}","gists_url":"https://api.github.com/users/Senjai/gists{/gist_id}","starred_url":"https://api.github.com/users/Senjai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Senjai/subscriptions","organizations_url":"https://api.github.com/users/Senjai/orgs","repos_url":"https://api.github.com/users/Senjai/repos","events_url":"https://api.github.com/users/Senjai/events{/privacy}","received_events_url":"https://api.github.com/users/Senjai/received_events","type":"User","site_admin":false},"body":"Might be able to get away with stubbing :current_ability on controller here, instead of stubbing new at the ability level. Could cause curious issues depending on the test.","created_at":"2015-10-16T16:33:49Z","updated_at":"2015-10-16T16:33:49Z","html_url":"https://github.com/solidusio/solidus/pull/449#discussion_r42262073","pull_request_url":"https://api.github.com/repos/solidusio/solidus/pulls/449","_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments/42262073"},"html":{"href":"https://github.com/solidusio/solidus/pull/449#discussion_r42262073"},"pull_request":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/449"}}},"pull_request":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/449","id":47925311,"html_url":"https://github.com/solidusio/solidus/pull/449","diff_url":"https://github.com/solidusio/solidus/pull/449.diff","patch_url":"https://github.com/solidusio/solidus/pull/449.patch","issue_url":"https://api.github.com/repos/solidusio/solidus/issues/449","number":449,"state":"open","locked":false,"title":"RFC: Clean up authorization test helpers.","user":{"login":"athal7","id":467872,"avatar_url":"https://avatars.githubusercontent.com/u/467872?v=3","gravatar_id":"","url":"https://api.github.com/users/athal7","html_url":"https://github.com/athal7","followers_url":"https://api.github.com/users/athal7/followers","following_url":"https://api.github.com/users/athal7/following{/other_user}","gists_url":"https://api.github.com/users/athal7/gists{/gist_id}","starred_url":"https://api.github.com/users/athal7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athal7/subscriptions","organizations_url":"https://api.github.com/users/athal7/orgs","repos_url":"https://api.github.com/users/athal7/repos","events_url":"https://api.github.com/users/athal7/events{/privacy}","received_events_url":"https://api.github.com/users/athal7/received_events","type":"User","site_admin":false},"body":"The current way that authorization is stubbed on controller and feature\r\nspecs allows anonymous authorization blocks to changes abilities at a global\r\nlevel and revokes that change after the spec. With the addition of permission\r\nsets. The addition of permission sets gives us a type of user that we\r\nwant to assert against, but we don't yet have a great way of testing the\r\nabilities of that type of user at the controller / feature level, plus\r\nour anonymous authorization changes might not be a great representation\r\nof the behavior we are trying to test.\r\n\r\nThis change removes the global ability registering, simplifies the\r\nauthorization helper code, and allows for the testing of permission sets\r\nat a controller level more easily.\r\n\r\n========================================\r\n\r\nI'm confident there are a bunch of failing specs from this, but I wanted to get\r\nsome feedback before going all the way down the path of fixing them.\r\n\r\ncc @jhawthorn @Senjai","created_at":"2015-10-16T15:33:01Z","updated_at":"2015-10-16T16:33:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57442f0c71b9723913ba5e948414b7865364d8da","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/solidusio/solidus/pulls/449/commits","review_comments_url":"https://api.github.com/repos/solidusio/solidus/pulls/449/comments","review_comment_url":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solidusio/solidus/issues/449/comments","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/ddc42433817646d45b40fd5f2c067452024f46c2","head":{"label":"athal7:fix-user-management-permissions","ref":"fix-user-management-permissions","sha":"ddc42433817646d45b40fd5f2c067452024f46c2","user":{"login":"athal7","id":467872,"avatar_url":"https://avatars.githubusercontent.com/u/467872?v=3","gravatar_id":"","url":"https://api.github.com/users/athal7","html_url":"https://github.com/athal7","followers_url":"https://api.github.com/users/athal7/followers","following_url":"https://api.github.com/users/athal7/following{/other_user}","gists_url":"https://api.github.com/users/athal7/gists{/gist_id}","starred_url":"https://api.github.com/users/athal7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athal7/subscriptions","organizations_url":"https://api.github.com/users/athal7/orgs","repos_url":"https://api.github.com/users/athal7/repos","events_url":"https://api.github.com/users/athal7/events{/privacy}","received_events_url":"https://api.github.com/users/athal7/received_events","type":"User","site_admin":false},"repo":{"id":40505533,"name":"solidus","full_name":"athal7/solidus","owner":{"login":"athal7","id":467872,"avatar_url":"https://avatars.githubusercontent.com/u/467872?v=3","gravatar_id":"","url":"https://api.github.com/users/athal7","html_url":"https://github.com/athal7","followers_url":"https://api.github.com/users/athal7/followers","following_url":"https://api.github.com/users/athal7/following{/other_user}","gists_url":"https://api.github.com/users/athal7/gists{/gist_id}","starred_url":"https://api.github.com/users/athal7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athal7/subscriptions","organizations_url":"https://api.github.com/users/athal7/orgs","repos_url":"https://api.github.com/users/athal7/repos","events_url":"https://api.github.com/users/athal7/events{/privacy}","received_events_url":"https://api.github.com/users/athal7/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/athal7/solidus","description":"Solidus e-commerce system","fork":true,"url":"https://api.github.com/repos/athal7/solidus","forks_url":"https://api.github.com/repos/athal7/solidus/forks","keys_url":"https://api.github.com/repos/athal7/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/athal7/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/athal7/solidus/teams","hooks_url":"https://api.github.com/repos/athal7/solidus/hooks","issue_events_url":"https://api.github.com/repos/athal7/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/athal7/solidus/events","assignees_url":"https://api.github.com/repos/athal7/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/athal7/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/athal7/solidus/tags","blobs_url":"https://api.github.com/repos/athal7/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/athal7/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/athal7/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/athal7/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/athal7/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/athal7/solidus/languages","stargazers_url":"https://api.github.com/repos/athal7/solidus/stargazers","contributors_url":"https://api.github.com/repos/athal7/solidus/contributors","subscribers_url":"https://api.github.com/repos/athal7/solidus/subscribers","subscription_url":"https://api.github.com/repos/athal7/solidus/subscription","commits_url":"https://api.github.com/repos/athal7/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/athal7/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/athal7/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/athal7/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/athal7/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/athal7/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/athal7/solidus/merges","archive_url":"https://api.github.com/repos/athal7/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/athal7/solidus/downloads","issues_url":"https://api.github.com/repos/athal7/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/athal7/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/athal7/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/athal7/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/athal7/solidus/labels{/name}","releases_url":"https://api.github.com/repos/athal7/solidus/releases{/id}","created_at":"2015-08-10T20:51:06Z","updated_at":"2015-08-10T20:51:09Z","pushed_at":"2015-10-16T15:54:37Z","git_url":"git://github.com/athal7/solidus.git","ssh_url":"git@github.com:athal7/solidus.git","clone_url":"https://github.com/athal7/solidus.git","svn_url":"https://github.com/athal7/solidus","homepage":"","size":59823,"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":"solidusio:master","ref":"master","sha":"8cc7bbcbd9e7f1fe5de07098b3ecd240d39f06b6","user":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"repo":{"id":30985840,"name":"solidus","full_name":"solidusio/solidus","owner":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solidusio/solidus","description":"Solidus, Rails eCommerce System","fork":false,"url":"https://api.github.com/repos/solidusio/solidus","forks_url":"https://api.github.com/repos/solidusio/solidus/forks","keys_url":"https://api.github.com/repos/solidusio/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solidusio/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solidusio/solidus/teams","hooks_url":"https://api.github.com/repos/solidusio/solidus/hooks","issue_events_url":"https://api.github.com/repos/solidusio/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/solidusio/solidus/events","assignees_url":"https://api.github.com/repos/solidusio/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/solidusio/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/solidusio/solidus/tags","blobs_url":"https://api.github.com/repos/solidusio/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solidusio/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solidusio/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/solidusio/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/solidusio/solidus/languages","stargazers_url":"https://api.github.com/repos/solidusio/solidus/stargazers","contributors_url":"https://api.github.com/repos/solidusio/solidus/contributors","subscribers_url":"https://api.github.com/repos/solidusio/solidus/subscribers","subscription_url":"https://api.github.com/repos/solidusio/solidus/subscription","commits_url":"https://api.github.com/repos/solidusio/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/solidusio/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/solidusio/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/solidusio/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/solidusio/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/solidusio/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solidusio/solidus/merges","archive_url":"https://api.github.com/repos/solidusio/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solidusio/solidus/downloads","issues_url":"https://api.github.com/repos/solidusio/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/solidusio/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/solidusio/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/solidusio/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solidusio/solidus/labels{/name}","releases_url":"https://api.github.com/repos/solidusio/solidus/releases{/id}","created_at":"2015-02-18T20:41:58Z","updated_at":"2015-10-14T23:35:40Z","pushed_at":"2015-10-16T15:54:57Z","git_url":"git://github.com/solidusio/solidus.git","ssh_url":"git@github.com:solidusio/solidus.git","clone_url":"https://github.com/solidusio/solidus.git","svn_url":"https://github.com/solidusio/solidus","homepage":"http://solidus.io/","size":67820,"stargazers_count":64,"watchers_count":64,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":55,"forks":38,"open_issues":55,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/449"},"html":{"href":"https://github.com/solidusio/solidus/pull/449"},"issue":{"href":"https://api.github.com/repos/solidusio/solidus/issues/449"},"comments":{"href":"https://api.github.com/repos/solidusio/solidus/issues/449/comments"},"review_comments":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/449/comments"},"review_comment":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/449/commits"},"statuses":{"href":"https://api.github.com/repos/solidusio/solidus/statuses/ddc42433817646d45b40fd5f2c067452024f46c2"}}}}