Revision 9d43fc71
Added by Michael Moll almost 6 years ago
test/controllers/api/v2/hosts_controller_test.rb | ||
---|---|---|
end
|
||
|
||
def test_create_valid_node_from_json_facts_object_without_certname
|
||
User.current=nil
|
||
User.current = nil
|
||
hostname = fact_json['name']
|
||
facts = fact_json['facts']
|
||
post :facts, params: { :name => hostname, :facts => facts }, session: set_session_user
|
||
... | ... | |
end
|
||
|
||
def test_create_valid_node_from_json_facts_object_with_certname
|
||
User.current=nil
|
||
User.current = nil
|
||
hostname = fact_json['name']
|
||
certname = fact_json['certname']
|
||
facts = fact_json['facts']
|
||
... | ... | |
end
|
||
|
||
def test_create_invalid
|
||
User.current=nil
|
||
User.current = nil
|
||
hostname = fact_json['name']
|
||
facts = fact_json['facts'].except('operatingsystem')
|
||
post :facts, params: { :name => hostname, :facts => facts }, session: set_session_user
|
||
... | ... | |
end
|
||
|
||
test "when a bad :type is requested, :unprocessable_entity is returned" do
|
||
User.current=nil
|
||
User.current = nil
|
||
hostname = fact_json['name']
|
||
facts = fact_json['facts']
|
||
post :facts, params: { :name => hostname, :facts => facts, :type => "Host::Invalid" }, session: set_session_user
|
||
... | ... | |
errors = ActiveModel::Errors.new(Host::Managed.new)
|
||
errors.add :foo, 'A stub failure'
|
||
Host::Managed.any_instance.stubs(:errors).returns(errors)
|
||
User.current=nil
|
||
User.current = nil
|
||
hostname = fact_json['name']
|
||
facts = fact_json['facts']
|
||
post :facts, params: { :name => hostname, :facts => facts }, session: set_session_user
|
Also available in: Unified diff
Fixes #19789 - fix Layout/SpaceAroundOperators cop