Commit 8c434a52 authored by Shinya Maeda's avatar Shinya Maeda

gb nice catches

parent 61d5b138
...@@ -20,13 +20,13 @@ module Groups ...@@ -20,13 +20,13 @@ module Groups
end end
def create def create
new_variable = group.variables.create(group_params) @variable = group.variables.create(group_params)
.present(current_user: current_user)
if new_variable.persisted? if @variable.persisted?
redirect_to group_settings_ci_cd_path(group), redirect_to group_settings_ci_cd_path(group),
notice: 'Variables were successfully updated.' notice: 'Variable was successfully created.'
else else
@variable = new_variable.present(current_user: current_user)
render "show" render "show"
end end
end end
...@@ -39,7 +39,7 @@ module Groups ...@@ -39,7 +39,7 @@ module Groups
else else
redirect_to group_settings_ci_cd_path(group), redirect_to group_settings_ci_cd_path(group),
status: 302, status: 302,
notice: 'Failed to remove the variable' notice: 'Failed to remove the variable.'
end end
end end
......
...@@ -21,13 +21,13 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -21,13 +21,13 @@ class Projects::VariablesController < Projects::ApplicationController
end end
def create def create
new_variable = project.variables.create(project_params) @variable = project.variables.create(project_params)
.present(current_user: current_user)
if new_variable.persisted? if @variable.persisted?
redirect_to project_settings_ci_cd_path(project), redirect_to project_settings_ci_cd_path(project),
notice: 'Variables were successfully updated.' notice: 'Variable was successfully created.'
else else
@variable = new_variable.present(current_user: current_user)
render "show" render "show"
end end
end end
...@@ -40,7 +40,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -40,7 +40,7 @@ class Projects::VariablesController < Projects::ApplicationController
else else
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
status: 302, status: 302,
notice: 'Failed to remove the variable' notice: 'Failed to remove the variable.'
end end
end end
......
...@@ -14,7 +14,7 @@ describe Groups::VariablesController do ...@@ -14,7 +14,7 @@ describe Groups::VariablesController do
it 'shows a success flash message' do it 'shows a success flash message' do
post :create, group_id: group, variable: { key: "one", value: "two" } post :create, group_id: group, variable: { key: "one", value: "two" }
expect(flash[:notice]).to include 'Variables were successfully updated.' expect(flash[:notice]).to include 'Variable was successfully created.'
expect(response).to redirect_to(group_settings_ci_cd_path(group)) expect(response).to redirect_to(group_settings_ci_cd_path(group))
end end
end end
......
...@@ -15,7 +15,7 @@ describe Projects::VariablesController do ...@@ -15,7 +15,7 @@ describe Projects::VariablesController do
post :create, namespace_id: project.namespace.to_param, project_id: project, post :create, namespace_id: project.namespace.to_param, project_id: project,
variable: { key: "one", value: "two" } variable: { key: "one", value: "two" }
expect(flash[:notice]).to include 'Variables were successfully updated.' expect(flash[:notice]).to include 'Variable was successfully created.'
expect(response).to redirect_to(project_settings_ci_cd_path(project)) expect(response).to redirect_to(project_settings_ci_cd_path(project))
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment