Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #13966 - newer version of apipie validates types for arrays
Therefore we no longer can send network interfaces in hashes even though the server would cope with it.
- Loading branch information
Tomas Strachota
committed
Mar 15, 2016
1 parent
361b8e8
commit b414187
Showing
5 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require File.join(File.dirname(__FILE__), 'test_helper') | ||
|
||
|
||
describe "host create" do | ||
let(:cmd) { ["host", "create"] } | ||
let(:minimal_params) { ['--hostgroup-id=1', '--location-id=1', '--organization-id=1', '--name=test'] } | ||
|
||
it "passes interface attributes to server" do | ||
params = ['--interface', 'identifier=eth0,ip=10.0.0.4,primary=true,provision=true'] | ||
|
||
api_expects(:hosts, :create, 'Create host with interfaces params') do |par| | ||
ifces = par['host']['interfaces_attributes'] | ||
|
||
ifces.length == 1 && | ||
ifces[0]['ip'] == '10.0.0.4' && | ||
ifces[0]['identifier'] == 'eth0' | ||
end.returns({}) | ||
|
||
expected_result = success_result("Host created\n") | ||
|
||
result = run_cmd(cmd + minimal_params + params) | ||
assert_cmd(expected_result, result) | ||
end | ||
|
||
it "sends empty hash for no interfaces" do | ||
# For some reason the Foreman replaces empty interfaces_attributes to nil, | ||
# which causes failure in nested attributes assignment in the host model | ||
|
||
api_expects(:hosts, :create, 'Create host with empty interfaces') do |par| | ||
par['host']['interfaces_attributes'] == {} | ||
end.returns({}) | ||
|
||
expected_result = success_result("Host created\n") | ||
|
||
result = run_cmd(cmd + minimal_params) | ||
assert_cmd(expected_result, result) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters