gitlab-org--gitlab-foss/spec
Robert Speicher e71cd7a300 Merge branch 'refactor/add-policies' into 'master'
Refactor ability.rb into Policies

## What does this MR do?
Factors out `ability.rb` into a new abstraction - the "policy" (stored in `app/policies`). A policy is a class named `#{class_name}Policy` (looked up automatically as needed) that implements `rules` as follows:

``` ruby
class ThingPolicy < BasePolicy
  def rules
    @user # this is a user to determine abilities for, optionally nil in the anonymous case
    @subject # this is the subject of the ability, guaranteed to be an instance of `Thing`
    can! :some_ability # grant the :some_ability permission
    cannot! :some_ability # ensure that :some_ability is not allowed. this overrides any `can!` that is called before or after
    delegate! @subject.other_thing # merge the abilities (can!) and prohibitions (cannot!) from `@subject.other_thing`
    can? :some_ability # test whether, so far, :some_ability is allowed
  end

  def anonymous_rules
    # optional. if not implemented `rules` is called where `@user` is nil. otherwise this method is called when `@user` is nil.
  end
end
```

See merge request !5796
2016-08-31 20:53:40 +00:00
..
config
controllers Merge branch 'refactor/add-policies' into 'master' 2016-08-31 20:53:40 +00:00
factories api: expose wiki_page_events project hook field in the API 2016-08-24 10:33:51 -04:00
features Merge branch 'fix-todo-pagination' into 'master' 2016-08-31 20:26:12 +00:00
finders add specs for tags finder 2016-08-31 19:16:47 +01:00
fixtures Fix JSON schema to issues in issue board lists 2016-08-19 11:47:33 -03:00
helpers Show "Create Merge Request" widget for push events to fork projects on the source project 2016-08-24 18:54:26 +02:00
initializers
javascripts Merge branch 'improve-application_spec' into 'master' 2016-08-31 20:19:08 +00:00
lib Merge branch 'refactor/add-policies' into 'master' 2016-08-31 20:53:40 +00:00
mailers Merge branch 'master' into 'expiration-date-on-memberships' 2016-08-19 10:58:01 +00:00
models don't use a deprecated api in ability_spec 2016-08-30 12:34:28 -07:00
policies add project_policy_spec to replace .project_abilities spec 2016-08-30 11:35:06 -07:00
requests Add BroadcastMessage API implementation 2016-08-31 17:03:18 -03:00
routing Fix markdown help references 2016-08-26 09:38:21 -05:00
services Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce 2016-08-30 14:48:17 -07:00
support Merge branch 'shorten-task-status-phrase' into 'master' 2016-08-30 17:46:03 +00:00
tasks/gitlab
uploaders
views Fix test 2016-08-30 13:05:40 +02:00
workers Merge branch '21010-emailsonpushworker-incorrectly-claims-deleted-a-commit-after-a-push' into 'master' 2016-08-19 18:16:55 +00:00
factories_spec.rb
rails_helper.rb
simplecov_env.rb Bump SimpleCov merge timeout to 365 days 2016-08-22 13:44:14 +02:00
spec_helper.rb Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name 2016-08-24 20:56:30 +08:00
teaspoon_env.rb