services_controller.rb 730 Bytes
Newer Older
1
2
3
class ServicesController < ProjectResourceController
  # Authorize
  before_filter :authorize_admin_project!
4
  before_filter :service, only: [:edit, :update, :test]
5
6
7
8

  respond_to :html

  def index
9
10
    @project.build_missing_services
    @services = @project.services
11
12
13
14
15
16
17
  end

  def edit
  end

  def update
    if @service.update_attributes(params[:service])
18
      redirect_to edit_project_service_path(@project, @service.to_param)
19
20
21
22
23
24
    else
      render 'edit'
    end
  end

  def test
25
    data = GitPushService.new.sample_data(project, current_user)
26
27
28
29
30

    @service.execute(data)

    redirect_to :back
  end
31
32
33
34
35
36

  private

  def service
    @service ||= @project.services.find { |service| service.to_param == params[:id] }
  end
37
end