Sha256: 419da7318df5e9bd6235bdf29f9cad00a8460286c0399dc612a26e27a5c22347

Contents?: true

Size: 1.71 KB

Versions: 41

Compression:

Stored size: 1.71 KB

Contents

require 'foreman_tasks_test_helper'

module ForemanRecurringLogic
  class Api::RecurringLogicControllerTest < ActionController::TestCase
    describe 'recurring logic api controller' do
      tests ForemanTasks::Api::RecurringLogicsController

      before do
        User.current = User.where(:login => 'apiadmin').first
        @request.env['HTTP_ACCEPT'] = 'application/json'
        @request.env['CONTENT_TYPE'] = 'application/json'
        @recurring_logic = FactoryBot.create(:recurring_logic)
      end

      describe 'GET /api/recurring_logics' do
        it 'gets index' do
          get :index
          assert_response :success
          assert_template 'api/recurring_logics/index'
        end
      end

      describe 'GET /api/recurring_logics/:id' do
        it 'searches for recurring logic' do
          get :show, params: { :id => @recurring_logic.id }
          assert_response :success
          assert_template 'api/recurring_logics/show'
        end
      end

      describe 'PUT /api/recurring_logics/:id' do
        it 'updates a recurring logic' do
          @recurring_logic.start(::Support::DummyRecurringDynflowAction)

          put :update, params: { :id => @recurring_logic.id, :recurring_logic => { :enabled => false } }
          assert_response :success
          assert_template 'api/recurring_logics/update'
          assert @recurring_logic.reload.disabled?
        end
      end

      describe 'POST /api/recurring_logics/:id/cancel' do
        it 'cancels recurring logic' do
          post :cancel, params: { :id => @recurring_logic.id }
          assert_response :success
          @recurring_logic.reload
          assert @recurring_logic.state == 'cancelled'
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
foreman-tasks-2.0.3 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-2.0.2 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.1.3 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.1.2 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-2.0.1 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-2.0.0 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.2.0 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.1.1 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.1.0 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.17.6 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.0.1 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-1.0.0 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.17.5 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.17.4 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.17.3 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.17.2 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.16.3 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.17.1 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.15.11 test/controllers/api/recurring_logics_controller_test.rb
foreman-tasks-0.16.2 test/controllers/api/recurring_logics_controller_test.rb