Revision 768aad03
Added by Tom Caspy over 8 years ago
test/functional/api/v1/fact_values_controller_test.rb | ||
---|---|---|
end
|
||
|
||
test "should get facts as non-admin user with joined search" do
|
||
user = as_admin { FactoryGirl.create(:user, :roles => [roles(:viewer)]) }
|
||
setup_user
|
||
@host.update_attribute(:hostgroup, FactoryGirl.create(:hostgroup))
|
||
as_user(user) do
|
||
as_user(users(:one)) do
|
||
get :index, {:search => "host.hostgroup = #{@host.hostgroup.name}"}
|
||
end
|
||
assert_response :success
|
||
... | ... | |
expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
|
||
assert_equal expected_hash, fact_values
|
||
end
|
||
end
|
||
|
||
private
|
||
|
||
def setup_user
|
||
@request.session[:user] = users(:one).id
|
||
users(:one).roles = [Role.find_by_name('Anonymous'), Role.find_by_name('Viewer')]
|
||
end
|
||
end
|
test/functional/api/v2/fact_values_controller_test.rb | ||
---|---|---|
end
|
||
|
||
test "should get facts as non-admin user with joined search" do
|
||
user = as_admin { FactoryGirl.create(:user, :roles => [roles(:viewer)]) }
|
||
setup_user
|
||
@host.update_attribute(:hostgroup, FactoryGirl.create(:hostgroup))
|
||
as_user(user) do
|
||
as_user(users(:one)) do
|
||
get :index, {:search => "host.hostgroup = #{@host.hostgroup.name}"}
|
||
end
|
||
assert_response :success
|
||
... | ... | |
expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
|
||
assert_equal expected_hash, fact_values
|
||
end
|
||
end
|
||
|
||
private
|
||
|
||
def setup_user
|
||
@request.session[:user] = users(:one).id
|
||
users(:one).roles = [Role.find_by_name('Anonymous'), Role.find_by_name('Viewer')]
|
||
end
|
||
end
|
Also available in: Unified diff
refs #12147 - compatible test updates for api fact value controller