Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-03 02:16:24 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-02-03 02:18:25 +0300
commit20714ee90232b5577fc99f2a773ddccf71482c08 (patch)
tree87d84e442bdf9bee58d1ef6f67d658035ac1e777 /app
parent79efb9d0b2d08764ac1a7b0b8e3004c6da9236c1 (diff)
Change UserCallout feautre_name to enum
Diffstat (limited to 'app')
-rw-r--r--app/controllers/user_callouts_controller.rb6
-rw-r--r--app/helpers/user_callouts_helper.rb5
-rw-r--r--app/models/user_callout.rb9
3 files changed, 13 insertions, 7 deletions
diff --git a/app/controllers/user_callouts_controller.rb b/app/controllers/user_callouts_controller.rb
index 69dc444f13a..aa048a9a1fc 100644
--- a/app/controllers/user_callouts_controller.rb
+++ b/app/controllers/user_callouts_controller.rb
@@ -1,6 +1,6 @@
class UserCalloutsController < ApplicationController
def create
- if ensure_callout
+ if check_feature_name && ensure_callout
respond_to do |format|
format.json { head :ok }
end
@@ -13,6 +13,10 @@ class UserCalloutsController < ApplicationController
private
+ def check_feature_name
+ UserCallout.feature_names.keys.include?(callout_param)
+ end
+
def ensure_callout
current_user.callouts.find_or_create_by(feature_name: callout_param)
end
diff --git a/app/helpers/user_callouts_helper.rb b/app/helpers/user_callouts_helper.rb
index 3725545d4cc..a292f676331 100644
--- a/app/helpers/user_callouts_helper.rb
+++ b/app/helpers/user_callouts_helper.rb
@@ -1,11 +1,6 @@
module UserCalloutsHelper
GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze
- # Higher value = higher priority
- PRIORITY = {
- GKE_CLUSTER_INTEGRATION: 0
- }.freeze
-
def show_gke_cluster_integration_callout?(project)
current_user && !user_dismissed?(GKE_CLUSTER_INTEGRATION) &&
can?(current_user, :create_cluster, project)
diff --git a/app/models/user_callout.rb b/app/models/user_callout.rb
index 8b31aa6fa5c..a7cfe5df7c0 100644
--- a/app/models/user_callout.rb
+++ b/app/models/user_callout.rb
@@ -1,6 +1,13 @@
class UserCallout < ActiveRecord::Base
belongs_to :user
+ enum feature_name: {
+ gke_cluster_integration: 0
+ }
+
validates :user, presence: true
- validates :feature_name, presence: true, uniqueness: { scope: :user_id }
+ validates :feature_name,
+ presence: true,
+ uniqueness: { scope: :user_id },
+ inclusion: { in: UserCallout.feature_names.keys }
end