diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/protected_branch.rb | 12 | ||||
-rw-r--r-- | app/models/protected_branch/merge_access_level.rb | 2 | ||||
-rw-r--r-- | app/models/protected_branch/push_access_level.rb | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index a411cb417e2..b0fde6c6c1b 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -5,13 +5,21 @@ class ProtectedBranch < ActiveRecord::Base validates :name, presence: true validates :project, presence: true - has_one :merge_access_level - has_one :push_access_level + has_one :merge_access_level, dependent: :destroy + has_one :push_access_level, dependent: :destroy def commit project.commit(self.name) end + def developers_can_push + self.push_access_level && self.push_access_level.developers? + end + + def developers_can_merge + self.merge_access_level && self.merge_access_level.developers? + end + # Returns all protected branches that match the given branch name. # This realizes all records from the scope built up so far, and does # _not_ return a relation. diff --git a/app/models/protected_branch/merge_access_level.rb b/app/models/protected_branch/merge_access_level.rb index 78cec5bf566..cfaa9c166fe 100644 --- a/app/models/protected_branch/merge_access_level.rb +++ b/app/models/protected_branch/merge_access_level.rb @@ -1,3 +1,5 @@ class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base belongs_to :protected_branch + + enum access_level: [:masters, :developers] end diff --git a/app/models/protected_branch/push_access_level.rb b/app/models/protected_branch/push_access_level.rb index d53c4c391e3..4345dc4ede4 100644 --- a/app/models/protected_branch/push_access_level.rb +++ b/app/models/protected_branch/push_access_level.rb @@ -1,3 +1,5 @@ class ProtectedBranch::PushAccessLevel < ActiveRecord::Base belongs_to :protected_branch + + enum access_level: [:masters, :developers] end |