gitlab-org--gitlab-foss/app/controllers/projects/triggers_controller.rb
Jose Ivan Vargas 44bb70c8c9 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
2017-02-06 14:51:19 -06:00

34 lines
816 B
Ruby

class Projects::TriggersController < Projects::ApplicationController
before_action :authorize_admin_build!
layout 'project_settings'
def index
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
end
def create
@trigger = project.triggers.new
@trigger.save
if @trigger.valid?
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Trigger was created successfully.'
else
@triggers = project.triggers.select(&:persisted?)
render action: "show"
end
end
def destroy
trigger.destroy
flash[:alert] = "Trigger removed"
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
end
private
def trigger
@trigger ||= project.triggers.find(params[:id])
end
end