Project

General

Profile

« Previous | Next » 

Revision 316a4ccd

Added by Ohad Levy almost 12 years ago

  • ID 316a4ccd5fef61c7f0a9cd1ab6ff81fd8c551083

couple of test fixes after upgrading to a newer mocha/shoulda

View differences:

test/fixtures/hosts.yml
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
name: myname.mydomain.net
name: my5name.mydomain.net
ip: "2.3.4.1"
mac: aabbCCddeeee
environment: production
test/functional/environments_controller_test.rb
Environment.find_by_name("env1").puppetclasses.delete(Puppetclass.find_by_name("a"))
# db_tree of {"env1" => ["b", "c"], "env2" => ["a", "b", "c"]}
# disk_tree of {"env1" => ["a", "b", "c"],"env2" => ["a", "b", "c"]}
get :import_environments, {:proxy => smart_proxies(:puppetmaster)}, set_session_user
get :import_environments, {:proxy => smart_proxies(:puppetmaster).id}, set_session_user
assert_template "puppetclasses_or_envs_changed"
assert_select 'input#changed_new_env1[value*="a"]'
post :obsolete_and_new,
......
as_admin {Environment.create(:name => "env3")}
#db_tree of {"env1" => ["a", "b", "c"], "env2" => ["a", "b", "c"], "env3" => []}
#disk_tree of {"env1" => ["a", "b", "c"], "env2" => ["a", "b", "c"]}
get :import_environments, {:proxy => smart_proxies(:puppetmaster)}, set_session_user
get :import_environments, {:proxy => smart_proxies(:puppetmaster).id}, set_session_user
assert_template "puppetclasses_or_envs_changed"
assert_select 'input#changed_obsolete_env3'
post :obsolete_and_new,
......
assert host.errors.empty?
assert Environment.find_by_name("env1").hosts.count > 0
end
get :import_environments, {}, set_session_user # We need this to stop failures about number of calls. It is not really part of the test.
get :import_environments, {:proxy => smart_proxies(:puppetmaster).id}, set_session_user # We need this to stop failures about number of calls. It is not really part of the test.
# assert_template "puppetclasses_or_envs_changed". This assertion will fail. And it should fail. See above.
post :obsolete_and_new,
{"changed"=>
test/functional/hosts_controller_test.rb
:architecture => architectures(:x86_64),
:environment => environments(:production),
:subnet => subnets(:one),
:disk => "empty partition"
:disk => "empty partition",
:puppet_proxy => smart_proxies(:puppetmaster)
}
}, set_session_user
end
......
:architecture => architectures(:x86_64),
:environment => environments(:production),
:subnet => subnets(:one),
:disk => "empty partition"
:disk => "empty partition",
:puppet_proxy => smart_proxies(:puppetmaster)
}
}, set_session_user
end
......
test 'multiple hostgroup change by host names' do
@request.env['HTTP_REFERER'] = hosts_path
host_names = %w{temp.yourdomain.net myname.mydomain.net }
host_names = %w{temp.yourdomain.net my5name.mydomain.net }
# check that we have hosts and their hostgroup is empty
host_names.each do |name|
host = Host.find_by_name name
test/test_helper.rb
Host.any_instance.stubs(:boot_server).returns("boot_server")
Resolv::DNS.any_instance.stubs(:getname).returns("foo.fqdn")
Resolv::DNS.any_instance.stubs(:getaddress).returns("127.0.0.1")
Net::DNS::ARecord.any_instance.stubs(:conflicts).returns([])
Net::DNS::ARecord.any_instance.stubs(:conflicting?).returns(false)
Net::DNS::PTRRecord.any_instance.stubs(:conflicting?).returns(false)
Net::DNS::PTRRecord.any_instance.stubs(:conflicts).returns([])
Net::DHCP::Record.any_instance.stubs(:create).returns(true)
Net::DHCP::SparcRecord.any_instance.stubs(:create).returns(true)
Net::DHCP::Record.any_instance.stubs(:conflicting?).returns(false)
test/unit/medium_test.rb
class MediumTest < ActiveSupport::TestCase
setup do
User.current = User.find_by_login "admin"
disable_orchestration
end
test "name can't be blank" do
test/unit/usergroup_test.rb
end
test "cannot be destroyed when in use by a host" do
disable_orchestration
@ug1 = Usergroup.find_or_create_by_name :name => "ug1"
@h1 = hosts(:one)
@h1.update_attributes :owner => @ug1

Also available in: Unified diff