summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-02-02 13:35:15 -0600
committerJose Ivan Vargas <jvargas@gitlab.com>2017-02-06 14:51:19 -0600
commitf3aaf906d488ee67ecd84f52febd0ce060fb7683 (patch)
treeea4ab82dcaaa25c2483a88cbe9d2d7b93dba469a /spec/controllers
parentd9d417d405c42721b300e3b4a0dc6656529c3411 (diff)
downloadgitlab-ce-f3aaf906d488ee67ecd84f52febd0ce060fb7683.tar.gz
Added tests for the variables controller #update action
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/variables_controller_spec.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb
index 315d1b66e73..9914e217d70 100644
--- a/spec/controllers/projects/variables_controller_spec.rb
+++ b/spec/controllers/projects/variables_controller_spec.rb
@@ -20,7 +20,7 @@ describe Projects::VariablesController do
end
context 'variable is invalid' do
- it 'shows a failure flash message' do
+ it 'shows an alert flash message' do
post :create, namespace_id: project.namespace.to_param, project_id: project.to_param,
variable: { key: "..one", value: "two" }
expect(flash[:alert]).to include 'Key can contain only letters, digits and \'_\'.'
@@ -28,4 +28,29 @@ describe Projects::VariablesController do
end
end
end
+
+ describe 'POST #update' do
+ let(:variable) { create(:ci_variable) }
+
+ context 'updating a variable with valid characters' do
+ before do
+ variable.gl_project_id = project.id
+ project.variables << variable
+ end
+
+ it 'shows a success flash message' do
+ post :update, namespace_id: project.namespace.to_param, project_id: project.to_param,
+ id: variable.id, variable: { key: variable.key, value: 'two' }
+ expect(flash[:notice]).to include 'Variables were successfully updated.'
+ expect(response).to redirect_to(namespace_project_settings_ci_cd_path(project.namespace, project))
+ end
+
+ it 'shows an alert flash message' do
+ post :update, namespace_id: project.namespace.to_param, project_id: project.to_param,
+ id: variable.id, variable: { key: '?', value: variable.value }
+ expect(flash[:alert]).to include 'Key can contain only letters, digits and \'_\'.'
+ expect(response).to redirect_to(namespace_project_settings_ci_cd_path(project.namespace, project))
+ end
+ end
+ end
end