gitlab-org--gitlab-foss/lib
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
..
api Merge branch 'refactor/add-policies' into 'master' 2016-08-31 20:53:40 +00:00
assets
backup lib/backup: fix broken permissions when creating repo dir 2016-08-30 13:35:50 +02:00
banzai remove Ability.abilities 2016-08-30 11:35:06 -07:00
ci Add Sentry logging to API calls 2016-08-24 12:09:51 -07:00
container_registry Make rubocop happy 2016-07-15 18:05:39 +02:00
gitlab Merge branch '21567-fix-sorting-issues-by-last-updated-after-import-from-github' into 'master' 2016-08-31 19:38:48 +00:00
json_web_token Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
omni_auth
rouge/formatters Trim extra displayed carriage returns in diffs and files with CRLFs 2016-08-01 13:24:06 +02:00
support Revert "Defend against 'Host' header injection" 2016-08-08 13:02:44 +02:00
tasks Use `File::exist?` instead of `File::exists?` 2016-08-11 13:54:45 +03:00
banzai.rb Object renderer read_multi rendered entries from Cache 2016-07-12 14:35:29 +02:00
disable_email_interceptor.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
event_filter.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
extracts_path.rb Restore get_id in ExtractsPath 2016-08-24 12:54:16 +02:00
file_size_validator.rb
file_streamer.rb
gitlab.rb Update `Gitlab.com?` to support staging 2016-06-27 15:10:36 -04:00
gt_one_coercion.rb
repository_cache.rb Use project ID in repository cache to prevent stale data from persisting across projects 2016-07-25 05:09:28 -07:00
static_model.rb
unfold_form.rb
uploaded_file.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
version_check.rb