Revision acfbc458
Added by Marek Hulán about 10 years ago
test/functional/api/v1/config_templates_controller_test.rb | ||
---|---|---|
test "should get index" do
|
||
get :index
|
||
templates = ActiveSupport::JSON.decode(@response.body)
|
||
assert !templates.empty?, "Should response with template"
|
||
assert_not_empty templates
|
||
assert_response :success
|
||
end
|
||
|
||
... | ... | |
get :show, { :id => config_templates(:pxekickstart).to_param }
|
||
assert_response :success
|
||
template = ActiveSupport::JSON.decode(@response.body)
|
||
assert !template.empty?
|
||
assert_not_empty template
|
||
assert_equal template["config_template"]["name"], config_templates(:pxekickstart).name
|
||
end
|
||
|
||
test "should not create invalid" do
|
||
post :create
|
||
assert_response 422
|
||
assert_response :unprocessable_entity
|
||
end
|
||
|
||
test "should create valid" do
|
||
... | ... | |
post :create, { :config_template => valid_attrs }
|
||
template = ActiveSupport::JSON.decode(@response.body)
|
||
assert template["config_template"]["name"] == "RandomName"
|
||
assert_response 200
|
||
assert_response :success
|
||
end
|
||
|
||
test "should not update invalid" do
|
||
put :update, { :id => config_templates(:pxekickstart).to_param,
|
||
:config_template => { :name => "" } }
|
||
assert_response 422
|
||
assert_response :unprocessable_entity
|
||
end
|
||
|
||
test "should update valid" do
|
||
... | ... | |
put :update, { :id => config_templates(:pxekickstart).to_param,
|
||
:config_template => { :template => "blah" } }
|
||
template = ActiveSupport::JSON.decode(@response.body)
|
||
assert_response :ok
|
||
assert_response :success
|
||
end
|
||
|
||
test "should not destroy template with associated hosts" do
|
||
config_template = config_templates(:pxekickstart)
|
||
delete :destroy, { :id => config_template.to_param }
|
||
assert_response 422
|
||
assert_response :unprocessable_entity
|
||
assert ConfigTemplate.exists?(config_template.id)
|
||
end
|
||
|
||
... | ... | |
config_template.os_default_templates.clear
|
||
delete :destroy, { :id => config_template.to_param }
|
||
template = ActiveSupport::JSON.decode(@response.body)
|
||
assert_response :ok
|
||
assert_response :success
|
||
assert !ConfigTemplate.exists?(config_template.id)
|
||
end
|
||
|
||
... | ... | |
ProxyAPI::TFTP.any_instance.stubs(:create_default).returns(true)
|
||
ProxyAPI::TFTP.any_instance.stubs(:fetch_boot_file).returns(true)
|
||
get :build_pxe_default
|
||
assert_response 200
|
||
assert_response :success
|
||
end
|
||
|
||
test "should add audit comment" do
|
Also available in: Unified diff
fixes #812 - new permissions model, user group role and nest support, role filters for better granularity
Contributions from: