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

gb nice catches

parent 61d5b138
......@@ -20,13 +20,13 @@ module Groups
end
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),
notice: 'Variables were successfully updated.'
notice: 'Variable was successfully created.'
else
@variable = new_variable.present(current_user: current_user)
render "show"
end
end
......@@ -39,7 +39,7 @@ module Groups
else
redirect_to group_settings_ci_cd_path(group),
status: 302,
notice: 'Failed to remove the variable'
notice: 'Failed to remove the variable.'
end
end
......
......@@ -21,13 +21,13 @@ class Projects::VariablesController < Projects::ApplicationController
end
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),
notice: 'Variables were successfully updated.'
notice: 'Variable was successfully created.'
else
@variable = new_variable.present(current_user: current_user)
render "show"
end
end
......@@ -40,7 +40,7 @@ class Projects::VariablesController < Projects::ApplicationController
else
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
status: 302,
notice: 'Failed to remove the variable'
notice: 'Failed to remove the variable.'
end
end
......
......@@ -14,7 +14,7 @@ describe Groups::VariablesController do
it 'shows a success flash message' do
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))
end
end
......
......@@ -15,7 +15,7 @@ describe Projects::VariablesController do
post :create, namespace_id: project.namespace.to_param, project_id: project,
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))
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