diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-04 01:51:34 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-06 23:51:19 +0300 |
commit | 44bb70c8c95fbee97661302e1279ed2c83f5d2e0 (patch) | |
tree | 6c8defb1cc25b0aa96df4b0f0de7df8b1ff4df86 /spec | |
parent | f3aaf906d488ee67ecd84f52febd0ce060fb7683 (diff) |
Improved code styling on the variables_controller_spec
Also updated the #update action inside the variables controller as
to render the show and not redirect back to the settings route
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/variables_controller_spec.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb index 9914e217d70..228cb513554 100644 --- a/spec/controllers/projects/variables_controller_spec.rb +++ b/spec/controllers/projects/variables_controller_spec.rb @@ -14,6 +14,7 @@ describe Projects::VariablesController do it 'shows a success flash message' do post :create, namespace_id: project.namespace.to_param, project_id: project.to_param, variable: { key: "one", 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 @@ -23,6 +24,7 @@ describe Projects::VariablesController 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 \'_\'.' expect(response).to redirect_to(namespace_project_settings_ci_cd_path(project.namespace, project)) end @@ -40,16 +42,18 @@ describe Projects::VariablesController do 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)) + id: variable.id, variable: { key: variable.key, value: 'two' } + + expect(flash[:notice]).to include 'Variable was successfully updated.' + expect(response).to redirect_to(namespace_project_variables_path(project.namespace, project)) end - it 'shows an alert flash message' do + it 'renders the action #show if the variable key is invalid' 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)) + id: variable.id, variable: { key: '?', value: variable.value } + + expect(response).to have_http_status(200) + expect(response).to render_template :show end end end |