summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-04 03:51:55 +0900
committerShinya Maeda <shinya@gitlab.com>2017-07-06 16:33:08 +0900
commit7a5a6b830966d1dccc832df07a45f2d3d3184c40 (patch)
treedba90d63652b6328bd62429f7005b660101e8231
parentc30989c671119b0890671fb508e082aa6b13c3e8 (diff)
downloadgitlab-ce-7a5a6b830966d1dccc832df07a45f2d3d3184c40.tar.gz
Basic BE change
Fix static-snalysis Move the precedence of group secure variable before project secure variable. Allow project_id to be null. Separate Ci::VariableProject and Ci::VariableGroup Add the forgotton files Add migration file to update type of ci_variables Fix form_for fpr VariableProject Fix test Change the table structure according to the yorik advice Add necessary migration files. Remove unnecessary migration spec. Revert safe_model_attributes.yml Fix models Fix spec Avoid self.variable. Use becomes for correct routing. Use unique index on group_id and key Add null: false for t.timestamps Fix schema version
-rw-r--r--app/models/ci/variable_group.rb9
-rw-r--r--app/models/ci/variable_project.rb9
-rw-r--r--spec/models/ci/variable_group_spec.rb7
-rw-r--r--spec/models/ci/variable_project_spec.rb7
4 files changed, 32 insertions, 0 deletions
diff --git a/app/models/ci/variable_group.rb b/app/models/ci/variable_group.rb
new file mode 100644
index 00000000000..3abdb8d9cd5
--- /dev/null
+++ b/app/models/ci/variable_group.rb
@@ -0,0 +1,9 @@
+module Ci
+ class VariableGroup < Ci::Variable
+ self.table_name = 'ci_group_variables'
+
+ belongs_to :group
+
+ validates :key, uniqueness: { scope: :group_id }
+ end
+end
diff --git a/app/models/ci/variable_project.rb b/app/models/ci/variable_project.rb
new file mode 100644
index 00000000000..6d68aab8c7d
--- /dev/null
+++ b/app/models/ci/variable_project.rb
@@ -0,0 +1,9 @@
+module Ci
+ class VariableProject < Ci::Variable
+ self.table_name = 'ci_variables'
+
+ belongs_to :project
+
+ validates :key, uniqueness: { scope: :project_id }
+ end
+end
diff --git a/spec/models/ci/variable_group_spec.rb b/spec/models/ci/variable_group_spec.rb
new file mode 100644
index 00000000000..a1e4bd4a7f2
--- /dev/null
+++ b/spec/models/ci/variable_group_spec.rb
@@ -0,0 +1,7 @@
+require 'spec_helper'
+
+describe Ci::VariableGroup, models: true do
+ subject { build(:ci_variable_group) }
+
+ it { is_expected.to validate_uniqueness_of(:key).scoped_to(:group_id) }
+end
diff --git a/spec/models/ci/variable_project_spec.rb b/spec/models/ci/variable_project_spec.rb
new file mode 100644
index 00000000000..9325f584388
--- /dev/null
+++ b/spec/models/ci/variable_project_spec.rb
@@ -0,0 +1,7 @@
+require 'spec_helper'
+
+describe Ci::VariableProject, models: true do
+ subject { build(:ci_variable_project) }
+
+ it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id) }
+end