Module: Integrations::Actions

Extended by:
ActiveSupport::Concern
Included in:
Admin::IntegrationsController, Groups::Settings::IntegrationsController
Defined in:
app/controllers/concerns/integrations/actions.rb

Instance Method Summary collapse

Instance Method Details

#editObject



23
24
25
# File 'app/controllers/concerns/integrations/actions.rb', line 23

def edit
  render 'shared/integrations/edit'
end

#resetObject



56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/concerns/integrations/actions.rb', line 56

def reset
  if integration.manual_activation?
    integration.destroy!

    flash[:notice] = s_('Integrations|This integration, and inheriting projects were reset.')

    render json: {}, status: :ok
  else
    render json: { message: s_('Integrations|Integration cannot be reset.') }, status: :unprocessable_entity
  end
end

#testObject



48
49
50
51
52
53
54
# File 'app/controllers/concerns/integrations/actions.rb', line 48

def test
  if integration.testable?
    render json: integration_test_response, status: :ok
  else
    render json: {}, status: :not_found
  end
end

#updateObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/concerns/integrations/actions.rb', line 27

def update
  saved = integration.update(integration_params[:integration])

  respond_to do |format|
    format.html do
      if saved
        PropagateIntegrationWorker.perform_async(integration.id)
        redirect_to scoped_edit_integration_path(integration, project: integration.project, group: integration.group), notice: success_message
      else
        render 'shared/integrations/edit'
      end
    end

    format.json do
      status = saved ? :ok : :unprocessable_entity

      render json: serialize_as_json, status: status
    end
  end
end