Sha256: 7711896ba71664ba13f97cf9327f480551ffae98c50a4b4432e1c8aa85a47596

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

module ForemanSalt
  module Api
    module V2
      # Tests for the controller to CRUD Salt Variables
      class SaltVariablesControllerTest < ActionController::TestCase
        setup do
          @variable = FactoryBot.create(:salt_variable)
        end

        test 'should get index' do
          get :index, session: set_session_user
          response = JSON.parse(@response.body)

          assert_not_empty response['results']
          assert_response :success
        end

        test 'should destroy' do
          delete :destroy, params: { id: @variable.id }, session: set_session_user

          assert_response :ok
          assert_not SaltVariable.exists?(@variable.id)
        end

        test 'should create' do
          params = { key: 'test name', salt_state_id: FactoryBot.create(:salt_module).id }
          post :create, params: params, session: set_session_user

          assert_response :success
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_salt-17.0.0 test/functional/api/v2/salt_variables_controller_test.rb
foreman_salt-16.0.3 test/functional/api/v2/salt_variables_controller_test.rb
foreman_salt-16.0.2 test/functional/api/v2/salt_variables_controller_test.rb
foreman_salt-16.0.1 test/functional/api/v2/salt_variables_controller_test.rb