Revision 5ddb3741
Added by Marek Hulán about 9 years ago
test/unit/host_test.rb | ||
---|---|---|
assert host.save!
|
||
end
|
||
|
||
test 'host can be searched in multiple taxonomies' do
|
||
org1 = FactoryGirl.create(:organization)
|
||
org2 = FactoryGirl.create(:organization)
|
||
org3 = FactoryGirl.create(:organization)
|
||
user = FactoryGirl.create(:user, :organizations => [org1, org2])
|
||
host1 = FactoryGirl.create(:host, :organization => org1)
|
||
host2 = FactoryGirl.create(:host, :organization => org2)
|
||
host3 = FactoryGirl.create(:host, :organization => org3)
|
||
hosts = nil
|
||
|
||
assert_nil Organization.current
|
||
as_user(user) do
|
||
hosts = Host::Managed.all
|
||
end
|
||
assert_includes hosts, host1
|
||
assert_includes hosts, host2
|
||
refute_includes hosts, host3
|
||
|
||
as_user(:one) do
|
||
hosts = Host::Managed.all
|
||
end
|
||
assert_includes hosts, host1
|
||
assert_includes hosts, host2
|
||
assert_includes hosts, host3
|
||
end
|
||
|
||
context "location or organizations are not enabled" do
|
||
before do
|
||
SETTINGS[:locations_enabled] = false
|
Also available in: Unified diff
Fixes #9947 - restrict user taxonomies if none is set
(cherry picked from commit abe910f2a46f4ecc1f349263d0b4751ed46ff200)