summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-03-01 21:23:00 +0100
committerToon Claes <toon@gitlab.com>2017-03-02 12:15:25 +0100
commita3fdd6acd27f5aa98f13e7a0083d0c3208003ccb (patch)
treee174834a5aaf50b0444f829e8a2cfd678e833455 /app
parentbc20fa9b02d5fea8f5781b6397af10f006983111 (diff)
downloadgitlab-ce-a3fdd6acd27f5aa98f13e7a0083d0c3208003ccb.tar.gz
Use string based `visibility` getter & setter
Add `visibility` & `visibility=` methods to the `Gitlab::VisibilityLevel` module so the `visibility_level` can be get/set with a string value.
Diffstat (limited to 'app')
-rw-r--r--app/models/group.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/snippet.rb2
-rw-r--r--app/services/projects/create_service.rb2
-rw-r--r--app/services/system_hooks_service.rb4
5 files changed, 6 insertions, 6 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 240a17f1dc1..7d23f655225 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -93,7 +93,7 @@ class Group < Namespace
end
def visibility_level_field
- visibility_level
+ :visibility_level
end
def visibility_level_allowed_by_projects
diff --git a/app/models/project.rb b/app/models/project.rb
index 472736c48c4..fa031b061d8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1003,7 +1003,7 @@ class Project < ActiveRecord::Base
end
def visibility_level_field
- visibility_level
+ :visibility_level
end
def archive!
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 2665a7249a3..dbd564e5e7d 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -120,7 +120,7 @@ class Snippet < ActiveRecord::Base
end
def visibility_level_field
- visibility_level
+ :visibility_level
end
def no_highlighting?
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 6dc3d8c2416..fbdaa455651 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -12,7 +12,7 @@ module Projects
@project = Project.new(params)
# Make sure that the user is allowed to use the specified visibility level
- unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
+ unless Gitlab::VisibilityLevel.allowed_for?(current_user, @project.visibility_level)
deny_visibility_level(@project)
return @project
end
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb
index 9b6dd013e3a..868fa7b3f21 100644
--- a/app/services/system_hooks_service.rb
+++ b/app/services/system_hooks_service.rb
@@ -84,7 +84,7 @@ class SystemHooksService
project_id: model.id,
owner_name: owner.name,
owner_email: owner.respond_to?(:email) ? owner.email : "",
- project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase
+ project_visibility: Project.visibility_levels.key(model.visibility_level_value).downcase
}
end
@@ -101,7 +101,7 @@ class SystemHooksService
user_email: model.user.email,
user_id: model.user.id,
access_level: model.human_access,
- project_visibility: Project.visibility_levels.key(project.visibility_level_field).downcase
+ project_visibility: Project.visibility_levels.key(project.visibility_level_value).downcase
}
end