summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-02-22 11:51:46 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-23 09:32:42 -0600
commit75f5fa997de148c9bc0e5bd6e6f6050526a0b164 (patch)
treee2fd6db5b1190817c062a8df20018dd00be68ce0 /app
parent7d4b52b27dcbe30d85d4fad27e983cee51cf6677 (diff)
downloadgitlab-ce-75f5fa997de148c9bc0e5bd6e6f6050526a0b164.tar.gz
Enable Rails/Delegate
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_settings_helper.rb25
-rw-r--r--app/helpers/visibility_level_helper.rb10
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/project.rb8
-rw-r--r--app/models/project_wiki.rb8
-rw-r--r--app/models/repository.rb8
-rw-r--r--app/policies/base_policy.rb4
-rw-r--r--app/services/base_service.rb4
-rw-r--r--app/services/ci/create_pipeline_builds_service.rb4
-rw-r--r--app/views/layouts/nav/_admin.html.haml2
11 files changed, 21 insertions, 60 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb
index 60485160495..4b025669f69 100644
--- a/app/helpers/application_settings_helper.rb
+++ b/app/helpers/application_settings_helper.rb
@@ -1,28 +1,15 @@
module ApplicationSettingsHelper
- def gravatar_enabled?
- current_application_settings.gravatar_enabled?
- end
-
- def signup_enabled?
- current_application_settings.signup_enabled?
- end
-
- def signin_enabled?
- current_application_settings.signin_enabled?
- end
+ delegate :gravatar_enabled?,
+ :signup_enabled?,
+ :signin_enabled?,
+ :akismet_enabled?,
+ :koding_enabled?,
+ to: :current_application_settings
def user_oauth_applications?
current_application_settings.user_oauth_applications
end
- def askimet_enabled?
- current_application_settings.akismet_enabled?
- end
-
- def koding_enabled?
- current_application_settings.koding_enabled?
- end
-
def allowed_protocols_present?
current_application_settings.enabled_git_access_protocol.present?
end
diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb
index fc93acfe63e..169cedeb796 100644
--- a/app/helpers/visibility_level_helper.rb
+++ b/app/helpers/visibility_level_helper.rb
@@ -89,13 +89,9 @@ module VisibilityLevelHelper
current_application_settings.restricted_visibility_levels || []
end
- def default_project_visibility
- current_application_settings.default_project_visibility
- end
-
- def default_group_visibility
- current_application_settings.default_group_visibility
- end
+ delegate :default_project_visibility,
+ :default_group_visibility,
+ to: :current_application_settings
def skip_level?(form_model, level)
form_model.is_a?(Project) && !form_model.visibility_level_allowed?(level)
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 7e21eb22e27..d2a53315f1d 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -233,9 +233,7 @@ module Ci
gl_project_id
end
- def project_name
- project.name
- end
+ delegate :name, to: :project, prefix: true
def repo_url
auth = "gitlab-ci-token:#{ensure_token!}@"
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 999720d2ea3..d2312215f85 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -153,9 +153,7 @@ module Ci
builds.latest.with_artifacts_not_expired.includes(project: [:namespace])
end
- def project_id
- project.id
- end
+ delegate :id, to: :project, prefix: true
# For now the only user who participates is the user who triggered
def participants(_current_user = nil)
diff --git a/app/models/project.rb b/app/models/project.rb
index f2be9e6a80c..a1b29d335b3 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -838,9 +838,7 @@ class Project < ActiveRecord::Base
false
end
- def empty_repo?
- repository.empty_repo?
- end
+ delegate :empty_repo?, to: :repository
def repo
repository.raw
@@ -1029,9 +1027,7 @@ class Project < ActiveRecord::Base
forked? && project == forked_from_project
end
- def forks_count
- forks.count
- end
+ delegate :count, to: :forks, prefix: true
def origin_merge_requests
merge_requests.where(source_project_id: self.id)
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index de36fd3b252..2f55b853232 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -60,9 +60,7 @@ class ProjectWiki
!!repository.exists?
end
- def empty?
- pages.empty?
- end
+ delegate :empty?, to: :pages
# Returns an Array of Gitlab WikiPage instances or an
# empty Array if this Wiki has no pages.
@@ -160,9 +158,7 @@ class ProjectWiki
}
end
- def repository_storage_path
- project.repository_storage_path
- end
+ delegate :repository_storage_path, to: :project
private
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 7113879417e..d1dd900d597 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -487,9 +487,7 @@ class Repository
end
cache_method :exists?
- def empty?
- raw_repository.empty?
- end
+ delegate :empty?, to: :raw_repository
cache_method :empty?
# The size of this repository in megabytes.
@@ -508,9 +506,7 @@ class Repository
end
cache_method :branch_names, fallback: []
- def tag_names
- raw_repository.tag_names
- end
+ delegate :tag_names, to: :raw_repository
cache_method :tag_names, fallback: []
def branch_count
diff --git a/app/policies/base_policy.rb b/app/policies/base_policy.rb
index b9f1c29c32e..e07b144355a 100644
--- a/app/policies/base_policy.rb
+++ b/app/policies/base_policy.rb
@@ -6,9 +6,7 @@ class BasePolicy
@cannot_set = cannot_set
end
- def size
- to_set.size
- end
+ delegate :size, to: :to_set
def self.empty
new(Set.new, Set.new)
diff --git a/app/services/base_service.rb b/app/services/base_service.rb
index fa45506317e..745c2c4b681 100644
--- a/app/services/base_service.rb
+++ b/app/services/base_service.rb
@@ -28,9 +28,7 @@ class BaseService
SystemHooksService.new
end
- def repository
- project.repository
- end
+ delegate :repository, to: :project
# Add an error to the specified model for restricted visibility levels
def deny_visibility_level(model, denied_visibility_level = nil)
diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb
index c5da757c840..4cbbd366cc4 100644
--- a/app/services/ci/create_pipeline_builds_service.rb
+++ b/app/services/ci/create_pipeline_builds_service.rb
@@ -10,9 +10,7 @@ module Ci
end
end
- def project
- pipeline.project
- end
+ delegate :project, to: :pipeline
private
diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml
index 19a947af4ca..d068c895fa3 100644
--- a/app/views/layouts/nav/_admin.html.haml
+++ b/app/views/layouts/nav/_admin.html.haml
@@ -33,7 +33,7 @@
Abuse Reports
%span.badge.count= number_with_delimiter(AbuseReport.count(:all))
- - if askimet_enabled?
+ - if akismet_enabled?
= nav_link(controller: :spam_logs) do
= link_to admin_spam_logs_path, title: "Spam Logs" do
%span