diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-02 22:35:15 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-06 23:51:19 +0300 |
commit | f3aaf906d488ee67ecd84f52febd0ce060fb7683 (patch) | |
tree | ea4ab82dcaaa25c2483a88cbe9d2d7b93dba469a /spec/controllers | |
parent | d9d417d405c42721b300e3b4a0dc6656529c3411 (diff) |
Added tests for the variables controller #update action
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/variables_controller_spec.rb | 27 |
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 |