Sha256: e7657a3c01bb89b6581ebc0090d83e17894e4b309f7131ab1279cf2771205ee6

Contents?: true

Size: 970 Bytes

Versions: 5

Compression:

Stored size: 970 Bytes

Contents

require 'test_helper'

class Api::V2::HostgroupClassesControllerTest < ActionController::TestCase

  test "should get puppetclass ids for hostgroup" do
    get :index, {:hostgroup_id => hostgroups(:common).id }
    assert_response :success
    puppetclasses = ActiveSupport::JSON.decode(@response.body)
    assert !puppetclasses.empty?
    assert_equal puppetclasses.length, 1
  end

  test "should add a puppetclass to a hostgroup" do
    hostgroup = hostgroups(:common)
    assert_difference('hostgroup.hostgroup_classes.count') do
      post :create, { :hostgroup_id => hostgroup.id, :puppetclass_id => puppetclasses(:four).id }
    end
    assert_response :success
  end

  test "should remove a puppetclass from a hostgroup" do
    hostgroup = hostgroups(:common)
    assert_difference('hostgroup.hostgroup_classes.count', -1) do
      delete :destroy, { :hostgroup_id => hostgroup.id, :id => puppetclasses(:one).id }
    end
    assert_response :success
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/test/functional/api/v2/hostgroup_class_controller_test.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/test/functional/api/v2/hostgroup_class_controller_test.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/test/functional/api/v2/hostgroup_class_controller_test.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/test/functional/api/v2/hostgroup_class_controller_test.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/test/functional/api/v2/hostgroup_class_controller_test.rb