diff options
author | Andrey Kumanyaev <me@zzet.org> | 2012-10-09 04:10:04 +0400 |
---|---|---|
committer | Andrey Kumanyaev <me@zzet.org> | 2012-10-09 04:10:04 +0400 |
commit | df7c52489a890ac38491682b4a3399beb7cdbc86 (patch) | |
tree | 9a81bee70285ac1e5a0c158eab5f4c981e49b86d /app/roles | |
parent | a635b9da97b0e104b8ac1a846344ec8a4abd3123 (diff) |
simple refactoring
Diffstat (limited to 'app/roles')
-rw-r--r-- | app/roles/account.rb | 2 | ||||
-rw-r--r-- | app/roles/authority.rb | 8 | ||||
-rw-r--r-- | app/roles/issue_commonality.rb | 9 | ||||
-rw-r--r-- | app/roles/push_event.rb | 8 |
4 files changed, 12 insertions, 15 deletions
diff --git a/app/roles/account.rb b/app/roles/account.rb index b8c445a3d58..19465478915 100644 --- a/app/roles/account.rb +++ b/app/roles/account.rb @@ -41,7 +41,7 @@ module Account # Remove user from all projects and # set blocked attribute to true def block - users_projects.all.each do |membership| + users_projects.find_each do |membership| return false unless membership.destroy end diff --git a/app/roles/authority.rb b/app/roles/authority.rb index 9d9153db66e..dbdd98397b9 100644 --- a/app/roles/authority.rb +++ b/app/roles/authority.rb @@ -2,12 +2,12 @@ module Authority # Compatible with all access rights # Should be rewrited for new access rights def add_access(user, *access) - access = if access.include?(:admin) - { project_access: UsersProject::MASTER } + access = if access.include?(:admin) + { project_access: UsersProject::MASTER } elsif access.include?(:write) - { project_access: UsersProject::DEVELOPER } + { project_access: UsersProject::DEVELOPER } else - { project_access: UsersProject::REPORTER } + { project_access: UsersProject::REPORTER } end opts = { user: user } opts.merge!(access) diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index 304f08fda6c..b21d92a3083 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -8,12 +8,9 @@ module IssueCommonality belongs_to :assignee, class_name: "User" has_many :notes, as: :noteable, dependent: :destroy - validates_presence_of :project_id - validates_presence_of :author_id - - validates :title, - presence: true, - length: { within: 0..255 } + validates :project, presence: true + validates :author, presence: true + validates :title, presence: true, length: { within: 0..255 } validates :closed, inclusion: { in: [true, false] } scope :opened, where(closed: false) diff --git a/app/roles/push_event.rb b/app/roles/push_event.rb index a607f212f2a..a6041f18ea8 100644 --- a/app/roles/push_event.rb +++ b/app/roles/push_event.rb @@ -5,11 +5,11 @@ module PushEvent false end - def tag? + def tag? data[:ref]["refs/tags"] end - def branch? + def branch? data[:ref]["refs/heads"] end @@ -25,7 +25,7 @@ module PushEvent commit_to =~ /^00000/ end - def md_ref? + def md_ref? !(rm_ref? || new_ref?) end @@ -37,7 +37,7 @@ module PushEvent data[:after] end - def ref_name + def ref_name if tag? tag_name else |