Project

General

Profile

« Previous | Next » 

Revision 0d6ea512

Added by Martin Bacovsky about 9 years ago

Fixes #7378 - fixed API lookup keys filters

(cherry picked from commit bc68c48da5b718084c3e531e61e48124e8e00d36)

View differences:

test/functional/api/v2/smart_class_parameters_controller_test.rb
assert_equal "cluster", results['results'][0]['parameter']
end
test "should get :not_found for a non-existing host" do
non_existing_id = 100000
get :index, {:host_id => non_existing_id}
assert_response :not_found
results = ActiveSupport::JSON.decode(@response.body)
assert_equal "Host with id '#{non_existing_id}' was not found", results["error"]["message"]
end
test "should get smart class parameters for a specific hostgroup" do
get :index, {:hostgroup_id => hostgroups(:common).to_param}
assert_response :success
......
assert_equal "cluster", results['results'][0]['parameter']
end
test "should get :not_found for a non-existing hostgroup" do
non_existing_id = 100000
get :index, {:hostgroup_id => non_existing_id}
assert_response :not_found
results = ActiveSupport::JSON.decode(@response.body)
assert_equal "Hostgroup with id '#{non_existing_id}' was not found", results["error"]["message"]
end
test "should get smart class parameters for a specific puppetclass" do
get :index, {:puppetclass_id => puppetclasses(:two).id}
assert_response :success
......
assert_equal "custom_class_param", results['results'][0]['parameter']
end
test "should get :not_found for a non-existing puppetclass" do
non_existing_id = 100000
get :index, {:puppetclass_id => non_existing_id}
assert_response :not_found
results = ActiveSupport::JSON.decode(@response.body)
assert_equal "Puppet class with id '#{non_existing_id}' was not found", results["error"]["message"]
end
test "should get smart class parameters for a specific environment" do
get :index, {:environment_id => environments(:production).id}
assert_response :success
......
assert_equal ["cluster", "custom_class_param"], results['results'].map {|cp| cp["parameter"] }.sort
end
test "should get :not_found for a non-existing environment" do
non_existing_id = 100000
get :index, {:environment_id => non_existing_id}
assert_response :not_found
results = ActiveSupport::JSON.decode(@response.body)
assert_equal "Environment with id '#{non_existing_id}' was not found", results["error"]["message"]
end
test "should get smart class parameters for a specific environment and puppetclass combination" do
get :index, {:environment_id => environments(:production).id, :puppetclass_id => puppetclasses(:two).id}
assert_response :success

Also available in: Unified diff