Commit 82ae973a9909bd82d75ce493a0a151efa0a98621

Authored by Dmitriy Zaporozhets
1 parent 64db5f80

Describe for Roles

app/roles/account.rb
  1 +# == Account role
  2 +#
  3 +# Describe behaviour of User in application
  4 +#
  5 +# Used by User
  6 +#
1 7 module Account
2 8 # Returns a string for use as a Gitolite user identifier
3 9 #
... ...
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 7 module Authority
2 8 # Compatible with all access rights
3 9 # Should be rewrited for new access rights
... ...
app/roles/git_host.rb
  1 +# == GitHost role
  2 +#
  3 +# Provide a shortcut to Gitlab::Gitolite instance
  4 +#
  5 +# Used by Project, UsersProject
  6 +#
1 7 module GitHost
2 8 def git_host
3 9 Gitlab::Gitolite.new
... ...
app/roles/issue_commonality.rb
  1 +# == IssueCommonality role
  2 +#
1 3 # Contains common functionality shared between Issues and MergeRequests
  4 +#
  5 +# Used by Issue, MergeRequest
  6 +#
2 7 module IssueCommonality
3 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 10 module NamespacedProject
2 11 def transfer(new_namespace)
3 12 Project.transaction do
... ...
app/roles/note_event.rb
  1 +# == NoteEvent role
  2 +#
  3 +# Extends Event model functionality by providing extra methods related to comment events
  4 +#
  5 +# Used by Event
  6 +#
1 7 module NoteEvent
2 8 def note_commit_id
3 9 target.commit_id
... ...
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 7 module PushEvent
2 8 def valid_push?
3 9 data[:ref]
... ... @@ -58,7 +64,7 @@ module PushEvent
58 64 @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse
59 65 end
60 66  
61   - def commits_count
  67 + def commits_count
62 68 data[:total_commits_count] || commits.count || 0
63 69 end
64 70  
... ... @@ -88,7 +94,7 @@ module PushEvent
88 94 nil
89 95 end
90 96  
91   - def push_with_commits?
  97 + def push_with_commits?
92 98 md_ref? && commits.any? && parent_commit && last_commit
93 99 rescue Grit::NoSuchPathError
94 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 7 # Triggered by PostReceive job
  8 +#
4 9 module PushObserver
5 10 # This method will be called after each post receive and only if the provided
6 11 # user is present in GitLab.
... ...
app/roles/repository.rb
  1 +# == Repository role
  2 +#
  3 +# Provides access to git repository resources like commits, branches etc..
  4 +# Allows you to manage repository via gitolite interface(git_host)
  5 +#
  6 +# Used by Project
  7 +#
1 8 module Repository
2 9 include GitHost
3 10  
... ...
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 10 module Team
2 11 def team_member_by_name_or_email(name = nil, email = nil)
3 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 8 module Votes
2 9 # Return the number of +1 comments (upvotes)
3 10 def upvotes
... ...