Revision feacea35
Added by Amos Benari about 11 years ago
- ID feacea35f07f362d9e2c694a83516bbc902321a0
test/unit/subnet_test.rb | ||
---|---|---|
@subnet.mask = nil
|
||
assert !@subnet.save
|
||
|
||
set_attr(:mask=)
|
||
@subnet.mask = "255.255.255.0"
|
||
assert @subnet.save
|
||
end
|
||
|
||
... | ... | |
test "the name should be unique in the domain scope" do
|
||
create_a_domain_with_the_subnet
|
||
|
||
other_subnet = Subnet.create( :mask => "111.111.111.1",
|
||
other_subnet = Subnet.new( :mask => "111.111.111.1",
|
||
:network => "255.255.252.0",
|
||
:name => "valid",
|
||
:domains => [@domain] )
|
||
other_subnet.valid?
|
||
:domain_ids => [domains(:mydomain).id] )
|
||
assert !other_subnet.valid?
|
||
assert !other_subnet.save
|
||
end
|
||
|
||
... | ... | |
end
|
||
|
||
test "should find the subnet by ip" do
|
||
set_attr(:network=, :mask=, :domains=, :name=)
|
||
@subnet = Subnet.new(:network => "123.123.123.1",:mask => "255.255.255.0",:name => "valid")
|
||
assert @subnet.save
|
||
assert @subnet.domain_ids = [domains(:mydomain).id]
|
||
assert_equal @subnet, Subnet.subnet_for("123.123.123.1")
|
||
end
|
||
|
||
... | ... | |
|
||
def create_a_domain_with_the_subnet
|
||
@domain = Domain.find_or_create_by_name("domain")
|
||
set_attr(:network=, :mask=, :name=)
|
||
@subnet.domains = [@domain]
|
||
@subnet.save
|
||
@subnet = Subnet.new(:network => "123.123.123.1",:mask => "255.255.255.0",:name => "valid")
|
||
assert @subnet.save
|
||
assert @subnet.domain_ids = [domains(:mydomain).id]
|
||
@subnet.save!
|
||
end
|
||
|
||
def setup_user operation
|
||
... | ... | |
|
||
test "user with create permissions should be able to create" do
|
||
setup_user "create"
|
||
record = Subnet.create :name => "dummy2", :network => "1.2.3.4", :mask => "255.255.255.0", :domains => [Domain.first]
|
||
record = Subnet.create :name => "dummy2", :network => "1.2.3.4", :mask => "255.255.255.0"
|
||
assert record.domain_ids = [Domain.first.id]
|
||
assert record.valid?
|
||
assert !record.new_record?
|
||
end
|
||
|
||
test "user with view permissions should not be able to create" do
|
||
setup_user "view"
|
||
record = Subnet.create :name => "dummy", :network => "1.2.3.4", :mask => "255.255.255.0", :domains => [Domain.first]
|
||
record = Subnet.new :name => "dummy", :network => "1.2.3.4", :mask => "255.255.255.0"
|
||
assert record.valid?
|
||
assert !record.save
|
||
assert record.new_record?
|
||
end
|
||
|
Also available in: Unified diff
upgrade foreman to rails 3.2.13
This commit updates from rails 3.0.x to 3.2.x, main changes include:
Users who uses foreman in production, make sure that you now compile
your assets, e.g
rake assets:precompile
Paired-with: Joseph Mitchell Magen <jmagen@redhat.com>
Paired-with: Ohad Levy <ohadlevy@gmail.com>
Signed-off-by: Ohad Levy <ohadlevy@gmail.com>