summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-01-23 19:34:06 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-05 18:58:17 +0100
commitdcc23530bd1e2bd1600bd523c90c040f84f8c354 (patch)
tree34b4bb95fc9ca9b5c93e772bbb574343a4628d7d
parentcc2bed9283039db726f42184ea635f057534205f (diff)
downloadgitlab-ce-dcc23530bd1e2bd1600bd523c90c040f84f8c354.tar.gz
Remove redundant routes in Groups::VariablesController
-rw-r--r--app/controllers/groups/variables_controller.rb49
-rw-r--r--config/routes/group.rb6
-rw-r--r--spec/controllers/groups/variables_controller_spec.rb41
3 files changed, 2 insertions, 94 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb
index 3c303b64b65..5fbf532b98e 100644
--- a/app/controllers/groups/variables_controller.rb
+++ b/app/controllers/groups/variables_controller.rb
@@ -1,36 +1,7 @@
module Groups
class VariablesController < Groups::ApplicationController
- before_action :variable, only: [:show, :update, :destroy]
before_action :authorize_admin_build!
- def index
- redirect_to group_settings_ci_cd_path(group)
- end
-
- def show
- end
-
- def update
- if variable.update(variable_params)
- redirect_to group_variables_path(group),
- notice: 'Variable was successfully updated.'
- else
- render "show"
- end
- end
-
- def create
- @variable = group.variables.create(variable_params)
- .present(current_user: current_user)
-
- if @variable.persisted?
- redirect_to group_settings_ci_cd_path(group),
- notice: 'Variable was successfully created.'
- else
- render "show"
- end
- end
-
def save_multiple
respond_to do |format|
format.json do
@@ -41,24 +12,8 @@ module Groups
end
end
- def destroy
- if variable.destroy
- redirect_to group_settings_ci_cd_path(group),
- status: 302,
- notice: 'Variable was successfully removed.'
- else
- redirect_to group_settings_ci_cd_path(group),
- status: 302,
- notice: 'Failed to remove the variable.'
- end
- end
-
private
- def variable_params
- params.require(:variable).permit(*variable_params_attributes)
- end
-
def variables_params
params.permit(variables_attributes: [*variable_params_attributes])
end
@@ -67,10 +22,6 @@ module Groups
%i[id key value protected _destroy]
end
- def variable
- @variable ||= group.variables.find(params[:id]).present(current_user: current_user)
- end
-
def authorize_admin_build!
return render_404 unless can?(current_user, :admin_build, group)
end
diff --git a/config/routes/group.rb b/config/routes/group.rb
index cdf2647415d..b3afbb4152f 100644
--- a/config/routes/group.rb
+++ b/config/routes/group.rb
@@ -27,10 +27,8 @@ constraints(GroupUrlConstrainer.new) do
resource :ci_cd, only: [:show], controller: 'ci_cd'
end
- resources :variables, only: [:index, :show, :update, :create, :destroy] do
- collection do
- post :save_multiple
- end
+ namespace :variables do
+ post :save_multiple
end
resources :children, only: [:index]
diff --git a/spec/controllers/groups/variables_controller_spec.rb b/spec/controllers/groups/variables_controller_spec.rb
index 294e712f45d..8570df15f34 100644
--- a/spec/controllers/groups/variables_controller_spec.rb
+++ b/spec/controllers/groups/variables_controller_spec.rb
@@ -9,47 +9,6 @@ describe Groups::VariablesController do
group.add_master(user)
end
- describe 'POST #create' do
- context 'variable is valid' do
- it 'shows a success flash message' do
- post :create, group_id: group, variable: { key: "one", value: "two" }
-
- expect(flash[:notice]).to include 'Variable was successfully created.'
- expect(response).to redirect_to(group_settings_ci_cd_path(group))
- end
- end
-
- context 'variable is invalid' do
- it 'renders show' do
- post :create, group_id: group, variable: { key: "..one", value: "two" }
-
- expect(response).to render_template("groups/variables/show")
- end
- end
- end
-
- describe 'POST #update' do
- let!(:variable) { create(:ci_group_variable, group: group) }
-
- context 'updating a variable with valid characters' do
- it 'shows a success flash message' do
- post :update, group_id: group,
- id: variable.id, variable: { key: variable.key, value: 'two' }
-
- expect(flash[:notice]).to include 'Variable was successfully updated.'
- expect(response).to redirect_to(group_variables_path(group))
- end
-
- it 'renders the action #show if the variable key is invalid' do
- post :update, group_id: group,
- id: variable.id, variable: { key: '?', value: variable.value }
-
- expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template :show
- end
- end
- end
-
describe 'POST #save_multiple' do
let!(:variable) { create(:ci_group_variable, group: group) }