gitlab-org--gitlab-foss/app/models
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
..
ci Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name 2016-08-26 17:31:12 +08:00
concerns Merge branch 'master' into prevent_authored_awardable_votes 2016-08-30 21:17:13 +01:00
hooks Implement pipeline hooks, extracted from !5525 2016-08-02 18:22:24 +08:00
members Merge branch 'master' into expiration-date-on-memberships 2016-08-18 15:54:07 +01:00
network
project_services Merge remote-tracking branch 'origin/master' into pipeline-hooks-without-slack 2016-08-15 20:36:06 +02:00
protected_branch Backport changes from gitlab-org/gitlab-ee!581 to CE. 2016-08-16 11:05:14 +05:30
.gitkeep
ability.rb factor out a RuleSet so that `delegate!` retains @cannot 2016-08-30 11:39:22 -07:00
abuse_report.rb
appearance.rb
application_setting.rb Remove gitorious 2016-08-25 10:10:10 +01:00
audit_event.rb
award_emoji.rb
blob.rb Limit the size of SVGs when viewing them as blobs 2016-08-15 13:42:52 +02:00
board.rb The lists: Backlog, and Done cannot be destroyed 2016-08-17 12:58:57 -03:00
broadcast_message.rb
commit.rb Fix line commenting for the initial commit 2016-08-19 16:35:44 +01:00
commit_range.rb
commit_status.rb Merge branch 'statuseable-hasstatus' into 'master' 2016-08-25 18:49:03 +00:00
compare.rb Make Compare#diffs diff_options a regular argument 2016-08-03 09:32:01 -07:00
deploy_key.rb
deploy_keys_project.rb
deployment.rb Method names changed to #includes_commit? 2016-08-12 10:43:04 +02:00
diff_note.rb Move #to_discussion to NoteOnDiff 2016-08-30 16:30:42 +01:00
discussion.rb Fix bug where notes weren’t shown in discussion when the code had changed after creation 2016-08-19 12:38:40 -05:00
email.rb
environment.rb Method names changed to #includes_commit? 2016-08-12 10:43:04 +02:00
event.rb remove Ability.abilities 2016-08-30 11:35:06 -07:00
external_issue.rb
forked_project_link.rb
generic_commit_status.rb
global_label.rb
global_milestone.rb
group.rb Add expiration date to group memberships 2016-08-18 21:09:17 +01:00
identity.rb
issue.rb Further refactor and syntax fixes. 2016-08-15 17:20:57 -05:00
key.rb Add simple identifier to public SSH keys 2016-08-02 06:56:23 +01:00
label.rb Destroy related lists when a label is removed 2016-08-17 12:58:58 -03:00
label_link.rb squashed - fixed label and milestone association problems, updated specs and refactored reader class a bit 2016-08-01 09:57:40 +02:00
legacy_diff_note.rb Move #to_discussion to NoteOnDiff 2016-08-30 16:30:42 +01:00
lfs_object.rb
lfs_objects_project.rb
list.rb Add a movable scope and a movable? method to List model 2016-08-17 12:58:59 -03:00
member.rb Allow project group links to be expired 2016-08-18 22:45:41 +01:00
merge_request.rb Merge branch 'refactor/add-policies' into 'master' 2016-08-31 20:53:40 +00:00
merge_request_diff.rb Change the way merge request diff compare works 2016-08-25 11:58:17 +03:00
milestone.rb
namespace.rb Fix bug where destroying a namespace would not always destroy projects 2016-08-11 15:36:35 -07:00
note.rb prevent authored awardable thumbs votes 2016-08-28 18:15:55 +01:00
notification_setting.rb
oauth_access_token.rb
personal_access_token.rb
personal_snippet.rb
project.rb Renamed `enable_lfs` to `lfs_enabled` for the Project field, and related fixes. 2016-08-30 17:17:45 -05:00
project_group_link.rb Allow project group links to be expired 2016-08-18 22:45:41 +01:00
project_import_data.rb
project_snippet.rb
project_team.rb Add expiration date to group memberships 2016-08-18 21:09:17 +01:00
project_wiki.rb Add method missing from EE 2016-08-12 21:56:40 -04:00
protected_branch.rb Backport changes from gitlab-org/gitlab-ee!581 to CE. 2016-08-16 11:05:14 +05:30
release.rb
repository.rb Display project icon from default branch 2016-08-25 14:52:14 +02:00
security_event.rb
sent_notification.rb
service.rb Simplify the name for data builder, feedback: 2016-08-12 16:09:29 +08:00
snippet.rb
spam_log.rb Allow `SpamLog` to be submitted as ham 2016-08-15 13:18:15 -05:00
subscription.rb
todo.rb Todos sorting dropdown 2016-08-19 16:14:20 -03:00
tree.rb
u2f_registration.rb Allow naming U2F devices. 2016-08-18 22:12:02 +05:30
user.rb remove Ability.abilities 2016-08-30 11:35:06 -07:00
user_agent_detail.rb Further refactor and syntax fixes. 2016-08-15 17:20:57 -05:00
users_star_project.rb
wiki_page.rb `WikiPage` should have a slug even when not persisted. 2016-07-25 09:22:47 +05:30