Project

General

Profile

Download (1.17 KB) Statistics
| Branch: | Tag: | Revision:
10139fde José Luis Escalante
require 'test_helper'

class GroupParameterTest < ActiveSupport::TestCase
9fd7478e Paul Kelly
setup do
e07f9a12 Dominic Cleal
User.current = users :admin
9fd7478e Paul Kelly
end
aa1796f3 Paul Kelly
test "should have a reference_id" do
10139fde José Luis Escalante
group_parameter = GroupParameter.new
assert !group_parameter.save

group_parameter.name = "valid"
group_parameter.value = "valid"
hostgroup = Hostgroup.find_or_create_by_name("valid")
aa1796f3 Paul Kelly
group_parameter.reference_id = hostgroup.id
10139fde José Luis Escalante
assert group_parameter.save
end
aa1796f3 Paul Kelly
test "duplicate names cannot exist in a hostgroup" do
2312cccf Daniel Lobato
GroupParameter.create :name => "some_parameter", :value => "value", :reference_id => hostgroups(:common).id
25d4ca6d Joseph Mitchell Magen
parameter2 = GroupParameter.create :name => "some_parameter", :value => "value", :reference_id => hostgroups(:common).id
aa1796f3 Paul Kelly
assert !parameter2.valid?
assert parameter2.errors.full_messages[0] == "Name has already been taken"
end

test "duplicate names can exist in different hostgroups" do
2312cccf Daniel Lobato
GroupParameter.create :name => "some_parameter", :value => "value", :reference_id => hostgroups(:common).id
25d4ca6d Joseph Mitchell Magen
parameter2 = GroupParameter.create :name => "some_parameter", :value => "value", :reference_id => hostgroups(:db).id
aa1796f3 Paul Kelly
assert parameter2.valid?
end
10139fde José Luis Escalante
end