Commit 82ae973a9909bd82d75ce493a0a151efa0a98621
1 parent
64db5f80
Exists in
master
and in
4 other branches
Describe for Roles
Showing
11 changed files
with
75 additions
and
3 deletions
Show diff stats
app/roles/account.rb
app/roles/authority.rb
| 1 | +# == Authority role | ||
| 2 | +# | ||
| 3 | +# Control access to project repository based on users role in team | ||
| 4 | +# | ||
| 5 | +# Used by Project | ||
| 6 | +# | ||
| 1 | module Authority | 7 | module Authority |
| 2 | # Compatible with all access rights | 8 | # Compatible with all access rights |
| 3 | # Should be rewrited for new access rights | 9 | # Should be rewrited for new access rights |
app/roles/git_host.rb
app/roles/issue_commonality.rb
| 1 | +# == IssueCommonality role | ||
| 2 | +# | ||
| 1 | # Contains common functionality shared between Issues and MergeRequests | 3 | # Contains common functionality shared between Issues and MergeRequests |
| 4 | +# | ||
| 5 | +# Used by Issue, MergeRequest | ||
| 6 | +# | ||
| 2 | module IssueCommonality | 7 | module IssueCommonality |
| 3 | extend ActiveSupport::Concern | 8 | extend ActiveSupport::Concern |
| 4 | 9 |
app/roles/namespaced_project.rb
| 1 | +# == NamespacedProject role | ||
| 2 | +# | ||
| 3 | +# Provides extra functionality for Project related to namespaces like: | ||
| 4 | +# - transfer project between namespaces | ||
| 5 | +# - name, path including namespece | ||
| 6 | +# - project owner based on namespace | ||
| 7 | +# | ||
| 8 | +# Used by Project | ||
| 9 | +# | ||
| 1 | module NamespacedProject | 10 | module NamespacedProject |
| 2 | def transfer(new_namespace) | 11 | def transfer(new_namespace) |
| 3 | Project.transaction do | 12 | Project.transaction do |
app/roles/note_event.rb
app/roles/push_event.rb
| 1 | +# == PushEvent role | ||
| 2 | +# | ||
| 3 | +# Extends Event model functionality by providing extra methods related to push events | ||
| 4 | +# | ||
| 5 | +# Used by Event | ||
| 6 | +# | ||
| 1 | module PushEvent | 7 | module PushEvent |
| 2 | def valid_push? | 8 | def valid_push? |
| 3 | data[:ref] | 9 | data[:ref] |
| @@ -58,7 +64,7 @@ module PushEvent | @@ -58,7 +64,7 @@ module PushEvent | ||
| 58 | @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse | 64 | @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse |
| 59 | end | 65 | end |
| 60 | 66 | ||
| 61 | - def commits_count | 67 | + def commits_count |
| 62 | data[:total_commits_count] || commits.count || 0 | 68 | data[:total_commits_count] || commits.count || 0 |
| 63 | end | 69 | end |
| 64 | 70 | ||
| @@ -88,7 +94,7 @@ module PushEvent | @@ -88,7 +94,7 @@ module PushEvent | ||
| 88 | nil | 94 | nil |
| 89 | end | 95 | end |
| 90 | 96 | ||
| 91 | - def push_with_commits? | 97 | + def push_with_commits? |
| 92 | md_ref? && commits.any? && parent_commit && last_commit | 98 | md_ref? && commits.any? && parent_commit && last_commit |
| 93 | rescue Grit::NoSuchPathError | 99 | rescue Grit::NoSuchPathError |
| 94 | false | 100 | false |
app/roles/push_observer.rb
| 1 | -# Includes methods for handling Git Push events | 1 | +# == PushObserver role |
| 2 | # | 2 | # |
| 3 | +# Includes methods to be triggered on push to project repository. | ||
| 4 | +# | ||
| 5 | +# | ||
| 6 | +# Used by Project | ||
| 3 | # Triggered by PostReceive job | 7 | # Triggered by PostReceive job |
| 8 | +# | ||
| 4 | module PushObserver | 9 | module PushObserver |
| 5 | # This method will be called after each post receive and only if the provided | 10 | # This method will be called after each post receive and only if the provided |
| 6 | # user is present in GitLab. | 11 | # user is present in GitLab. |
app/roles/repository.rb
app/roles/team.rb
| 1 | +# == Team role | ||
| 2 | +# | ||
| 3 | +# Provides functionality to manage project team | ||
| 4 | +# - add user/users to project | ||
| 5 | +# - update existing membership | ||
| 6 | +# - remove users from project team | ||
| 7 | +# | ||
| 8 | +# Used by Project | ||
| 9 | +# | ||
| 1 | module Team | 10 | module Team |
| 2 | def team_member_by_name_or_email(name = nil, email = nil) | 11 | def team_member_by_name_or_email(name = nil, email = nil) |
| 3 | user = users.where("name like ? or email like ?", name, email).first | 12 | user = users.where("name like ? or email like ?", name, email).first |
app/roles/votes.rb
| 1 | +# == Votes role | ||
| 2 | +# | ||
| 3 | +# Provides functionality to upvote/downvote entity | ||
| 4 | +# based on +1 and -1 notes | ||
| 5 | +# | ||
| 6 | +# Used for Issue and Merge Request | ||
| 7 | +# | ||
| 1 | module Votes | 8 | module Votes |
| 2 | # Return the number of +1 comments (upvotes) | 9 | # Return the number of +1 comments (upvotes) |
| 3 | def upvotes | 10 | def upvotes |