squall 1.2.1beta1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/squall/support/base.rb +4 -4
- data/lib/squall/support/exception.rb +0 -9
- data/lib/squall/support/version.rb +1 -1
- data/lib/squall.rb +0 -1
- data/spec/squall/data_store_zone_spec.rb +8 -20
- data/spec/squall/firewall_rule_spec.rb +0 -12
- data/spec/squall/hypervisor_spec.rb +24 -38
- data/spec/squall/hypervisor_zone_spec.rb +34 -46
- data/spec/squall/ip_address_join_spec.rb +1 -15
- data/spec/squall/ip_address_spec.rb +2 -6
- data/spec/squall/network_spec.rb +2 -12
- data/spec/squall/network_zone_spec.rb +15 -43
- data/spec/squall/payment_spec.rb +9 -22
- data/spec/squall/role_spec.rb +4 -16
- data/spec/squall/support/base_spec.rb +16 -10
- data/spec/squall/template_spec.rb +3 -8
- data/spec/squall/transaction_spec.rb +2 -6
- data/spec/squall/user_group_spec.rb +6 -14
- data/spec/squall/user_spec.rb +12 -44
- data/spec/squall/virtual_machine_spec.rb +0 -102
- data/spec/squall/whitelist_spec.rb +10 -26
- data/squall.gemspec +1 -1
- metadata +76 -161
- data/.rbenv-version +0 -1
- data/lib/squall/support/on_app_errors.rb +0 -23
@@ -8,7 +8,7 @@ describe Squall::NetworkZone do
|
|
8
8
|
|
9
9
|
describe "#list" do
|
10
10
|
use_vcr_cassette "network_zones/list"
|
11
|
-
|
11
|
+
|
12
12
|
it "returns all network zones" do
|
13
13
|
network_zoness = @network_zone.list
|
14
14
|
network_zoness.should be_an(Array)
|
@@ -19,30 +19,26 @@ describe Squall::NetworkZone do
|
|
19
19
|
network_zoness.all? {|w| w.is_a?(Hash) }.should be_true
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
describe "#show" do
|
24
24
|
use_vcr_cassette "network_zones/show"
|
25
25
|
it "requires an id" do
|
26
26
|
expect { @network_zone.show }.to raise_error(ArgumentError)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "returns not found for invalid network zone id" do
|
30
|
-
expect { @network_zone.show(404) }.to raise_error(Squall::NotFoundError)
|
31
|
-
end
|
32
|
-
|
33
29
|
it "returns a network zone" do
|
34
30
|
network_zones = @network_zone.show(1)
|
35
31
|
network_zones.should be_a(Hash)
|
36
32
|
end
|
37
33
|
end
|
38
|
-
|
34
|
+
|
39
35
|
describe "#create" do
|
40
36
|
use_vcr_cassette "network_zones/create"
|
41
37
|
it "requires label" do
|
42
38
|
invalid = @valid.reject{|k,v| k == :label }
|
43
39
|
requires_attr(:label) { @network_zone.create(invalid) }
|
44
40
|
end
|
45
|
-
|
41
|
+
|
46
42
|
it "raises error on unknown params" do
|
47
43
|
expect { @network_zone.create(@valid.merge(:what => 'what')) }.to raise_error(ArgumentError, 'Unknown params: what')
|
48
44
|
end
|
@@ -52,10 +48,10 @@ describe Squall::NetworkZone do
|
|
52
48
|
@network_zone.success.should be_true
|
53
49
|
end
|
54
50
|
end
|
55
|
-
|
51
|
+
|
56
52
|
describe "#edit" do
|
57
53
|
use_vcr_cassette "network_zones/edit"
|
58
|
-
|
54
|
+
|
59
55
|
it "allows select params" do
|
60
56
|
optional = [:label]
|
61
57
|
@network_zone.should_receive(:request).exactly(optional.size).times.and_return Hash.new()
|
@@ -63,7 +59,7 @@ describe Squall::NetworkZone do
|
|
63
59
|
@network_zone.edit(1, param => "test")
|
64
60
|
end
|
65
61
|
end
|
66
|
-
|
62
|
+
|
67
63
|
it "raises error on unknown params" do
|
68
64
|
expect { @network_zone.edit(1, @valid.merge(:what => 'what')) }.to raise_error(ArgumentError, 'Unknown params: what')
|
69
65
|
end
|
@@ -72,12 +68,8 @@ describe Squall::NetworkZone do
|
|
72
68
|
@network_zone.edit(1, :label => "Updated zone")
|
73
69
|
@network_zone.success.should be_true
|
74
70
|
end
|
75
|
-
|
76
|
-
it "raises an error for an invalid network zone id" do
|
77
|
-
expect { @network_zone.edit(404, @valid) }.to raise_error(Squall::NotFoundError)
|
78
|
-
end
|
79
71
|
end
|
80
|
-
|
72
|
+
|
81
73
|
describe "#delete" do
|
82
74
|
use_vcr_cassette "network_zones/delete"
|
83
75
|
it "requires an id" do
|
@@ -88,56 +80,36 @@ describe Squall::NetworkZone do
|
|
88
80
|
@network_zone.delete(1)
|
89
81
|
@network_zone.success.should be_true
|
90
82
|
end
|
91
|
-
|
92
|
-
it "returns NotFound for invalid network zone id" do
|
93
|
-
expect { @network_zone.delete(404) }.to raise_error(Squall::NotFoundError)
|
94
|
-
end
|
95
83
|
end
|
96
84
|
|
97
85
|
describe "#attach" do
|
98
86
|
use_vcr_cassette "network_zones/attach"
|
99
|
-
|
87
|
+
|
100
88
|
it "requires an id" do
|
101
89
|
expect { @network_zone.attach }.to raise_error(ArgumentError)
|
102
90
|
end
|
103
|
-
|
91
|
+
|
104
92
|
it "requires a network id" do
|
105
93
|
expect { @network_zone.attach(1) }.to raise_error(ArgumentError)
|
106
94
|
end
|
107
|
-
|
108
|
-
it "returns NotFound error for invalid id" do
|
109
|
-
expect { @network_zone.attach(404, 1) }.to raise_error(Squall::NotFoundError)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns NotFound error for invalid network id" do
|
113
|
-
expect { @network_zone.attach(1, 404) }.to raise_error(Squall::NotFoundError)
|
114
|
-
end
|
115
|
-
|
95
|
+
|
116
96
|
it "attaches a network to the network zone" do
|
117
97
|
request = @network_zone.attach(1, 2)
|
118
98
|
@network_zone.success.should be_true
|
119
99
|
end
|
120
100
|
end
|
121
|
-
|
101
|
+
|
122
102
|
describe "#detach" do
|
123
103
|
use_vcr_cassette "network_zones/detach"
|
124
|
-
|
104
|
+
|
125
105
|
it "requires an id" do
|
126
106
|
expect { @network_zone.detach }.to raise_error(ArgumentError)
|
127
107
|
end
|
128
|
-
|
108
|
+
|
129
109
|
it "requires a network id" do
|
130
110
|
expect { @network_zone.detach(1) }.to raise_error(ArgumentError)
|
131
111
|
end
|
132
|
-
|
133
|
-
it "returns NotFound error for invalid id" do
|
134
|
-
expect { @network_zone.detach(404, 1) }.to raise_error(Squall::NotFoundError)
|
135
|
-
end
|
136
|
-
|
137
|
-
it "returns NotFound error for invalid network id" do
|
138
|
-
expect { @network_zone.detach(1, 404) }.to raise_error(Squall::NotFoundError)
|
139
|
-
end
|
140
|
-
|
112
|
+
|
141
113
|
it "detaches a network to the network zone" do
|
142
114
|
request = @network_zone.detach(1, 2)
|
143
115
|
@network_zone.success.should be_true
|
data/spec/squall/payment_spec.rb
CHANGED
@@ -9,11 +9,11 @@ describe Squall::Payment do
|
|
9
9
|
|
10
10
|
describe "#list" do
|
11
11
|
use_vcr_cassette "payment/list"
|
12
|
-
|
12
|
+
|
13
13
|
it "requires user id" do
|
14
14
|
expect { @payment.list }.to raise_error(ArgumentError)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "returns a user list" do
|
18
18
|
payments = @payment.list(1)
|
19
19
|
payments.should be_an(Array)
|
@@ -24,14 +24,14 @@ describe Squall::Payment do
|
|
24
24
|
payment.should be_a(Hash)
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
describe "#create" do
|
29
29
|
use_vcr_cassette "payment/create"
|
30
30
|
it "requires amount" do
|
31
31
|
invalid = @valid.reject{|k,v| k == :amount }
|
32
32
|
requires_attr(:amount) { @payment.create(1, invalid) }
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "allows all optional params" do
|
36
36
|
optional = [:invoice_number]
|
37
37
|
@payment.should_receive(:request).exactly(optional.size).times.and_return Hash.new("payment" => {})
|
@@ -39,24 +39,20 @@ describe Squall::Payment do
|
|
39
39
|
@payment.create(1, @valid.merge(param => "test"))
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "raises error on unknown params" do
|
44
44
|
expect { @payment.create(1, @valid.merge(:what => 'what')) }.to raise_error(ArgumentError, 'Unknown params: what')
|
45
45
|
end
|
46
|
-
|
47
|
-
it "raises an error for an invalid user id" do
|
48
|
-
expect { @payment.create(404, @valid) }.to raise_error(Squall::NotFoundError)
|
49
|
-
end
|
50
46
|
|
51
47
|
it "creates a payment for a user" do
|
52
48
|
user = @payment.create(1, @valid)
|
53
49
|
@payment.success.should be_true
|
54
50
|
end
|
55
51
|
end
|
56
|
-
|
52
|
+
|
57
53
|
describe "#edit" do
|
58
54
|
use_vcr_cassette "payment/edit"
|
59
|
-
|
55
|
+
|
60
56
|
it "allows select params" do
|
61
57
|
optional = [:amount, :invoice_number]
|
62
58
|
@payment.should_receive(:request).exactly(optional.size).times.and_return Hash.new()
|
@@ -64,7 +60,7 @@ describe Squall::Payment do
|
|
64
60
|
@payment.edit(1, 1, param => "test")
|
65
61
|
end
|
66
62
|
end
|
67
|
-
|
63
|
+
|
68
64
|
it "raises error on unknown params" do
|
69
65
|
expect { @payment.edit(1, 1, :what => 'what') }.to raise_error(ArgumentError, 'Unknown params: what')
|
70
66
|
end
|
@@ -73,12 +69,8 @@ describe Squall::Payment do
|
|
73
69
|
user = @payment.edit(1, 1, :amount => 100)
|
74
70
|
@payment.success.should be_true
|
75
71
|
end
|
76
|
-
|
77
|
-
it "raises an error for an invalid payment id" do
|
78
|
-
expect { @payment.edit(1, 404, @valid) }.to raise_error(Squall::NotFoundError)
|
79
|
-
end
|
80
72
|
end
|
81
|
-
|
73
|
+
|
82
74
|
describe "#delete" do
|
83
75
|
use_vcr_cassette "payment/delete"
|
84
76
|
it "requires an id" do
|
@@ -89,10 +81,5 @@ describe Squall::Payment do
|
|
89
81
|
@payment.delete(1, 1)
|
90
82
|
@payment.success.should be_true
|
91
83
|
end
|
92
|
-
|
93
|
-
it "returns NotFound for missing user" do
|
94
|
-
expect { @payment.delete(1, 404) }.to raise_error(Squall::NotFoundError)
|
95
|
-
end
|
96
84
|
end
|
97
|
-
|
98
85
|
end
|
data/spec/squall/role_spec.rb
CHANGED
@@ -19,10 +19,6 @@ describe Squall::Role do
|
|
19
19
|
expect { @role.show }.to raise_error(ArgumentError)
|
20
20
|
end
|
21
21
|
|
22
|
-
it "returns 404 for invalid id" do
|
23
|
-
expect { @role.show(404) }.to raise_error(Squall::NotFoundError)
|
24
|
-
end
|
25
|
-
|
26
22
|
it "returns a role" do
|
27
23
|
role = @role.show(1)
|
28
24
|
role.should be_a(Hash)
|
@@ -35,10 +31,6 @@ describe Squall::Role do
|
|
35
31
|
expect { @role.edit }.to raise_error(ArgumentError)
|
36
32
|
end
|
37
33
|
|
38
|
-
it "returns 404 for invalid id" do
|
39
|
-
expect { @role.edit(404) }.to raise_error(Squall::NotFoundError)
|
40
|
-
end
|
41
|
-
|
42
34
|
it "allows all optional params" do
|
43
35
|
optional = [:label, :permission_ids]
|
44
36
|
optional.each do |param|
|
@@ -62,10 +54,6 @@ describe Squall::Role do
|
|
62
54
|
expect { @role.delete }.to raise_error(ArgumentError)
|
63
55
|
end
|
64
56
|
|
65
|
-
it "returns not found for invalid user" do
|
66
|
-
expect { @role.delete(5) }.to raise_error(Squall::NotFoundError)
|
67
|
-
end
|
68
|
-
|
69
57
|
it "returns a role" do
|
70
58
|
role = @role.delete(3)
|
71
59
|
@role.success.should be_true
|
@@ -74,17 +62,17 @@ describe Squall::Role do
|
|
74
62
|
|
75
63
|
describe "#permissions" do
|
76
64
|
use_vcr_cassette "role/permissions"
|
77
|
-
|
65
|
+
|
78
66
|
it "returns permissions" do
|
79
67
|
permissions = @role.permissions
|
80
68
|
permissions.should be_an(Array)
|
81
69
|
end
|
82
|
-
|
70
|
+
|
83
71
|
it "contains role data" do
|
84
72
|
permissions = @role.permissions
|
85
73
|
permissions.all?.should be_true
|
86
74
|
end
|
87
|
-
|
75
|
+
|
88
76
|
end
|
89
77
|
|
90
78
|
describe "#create" do
|
@@ -93,7 +81,7 @@ describe Squall::Role do
|
|
93
81
|
it "requires label" do
|
94
82
|
requires_attr(:label) { @role.create }
|
95
83
|
end
|
96
|
-
|
84
|
+
|
97
85
|
it "allows permission_ids" do
|
98
86
|
@role.should_receive(:request).once.and_return Hash.new('role' => [])
|
99
87
|
@role.create(:label => "test", :permission_ids => 1)
|
@@ -23,21 +23,27 @@ describe Squall::Base do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "raises NotFound for 404s" do
|
26
|
-
mock_request(:get, '/404', :status => [404, "NotFound"])
|
27
|
-
|
26
|
+
mock_request(:get, '/404', :status => [404, "NotFound"], :body => "{\"errors\":[\"Resource not found\"]}")
|
27
|
+
@base.request(:get, '/404')
|
28
|
+
|
28
29
|
@base.success.should be_false
|
30
|
+
@base.result.should == { "errors" => ["Resource not found"] }
|
29
31
|
end
|
30
32
|
|
31
33
|
it "raises ServerError on errors" do
|
32
|
-
mock_request(:get, '/500', :status => [500, "Internal Server Error"])
|
33
|
-
|
34
|
+
mock_request(:get, '/500', :status => [500, "Internal Server Error"], :body => "{\"errors\":[\"Internal Server Error\"]}")
|
35
|
+
@base.request(:get, '/500')
|
36
|
+
|
34
37
|
@base.success.should be_false
|
38
|
+
@base.result.should == { "errors" => ["Internal Server Error"] }
|
35
39
|
end
|
36
40
|
|
37
41
|
it "raises RequestError on errors" do
|
38
|
-
mock_request(:get, '/422', :status => [422, "Unprocessable"])
|
39
|
-
|
42
|
+
mock_request(:get, '/422', :status => [422, "Unprocessable"], :body => "{\"errors\":[\"Unprocessable\"]}")
|
43
|
+
@base.request(:get, '/422')
|
44
|
+
|
40
45
|
@base.success.should be_false
|
46
|
+
@base.result.should == { "errors" => ["Unprocessable"] }
|
41
47
|
end
|
42
48
|
|
43
49
|
it "is a sad panda when the config hasn't been specified" do
|
@@ -59,7 +65,7 @@ describe Squall::Base do
|
|
59
65
|
|
60
66
|
it "merges the query in" do
|
61
67
|
expected = {
|
62
|
-
:query => {
|
68
|
+
:query => {
|
63
69
|
:base => {:one => 1, :two => 2}
|
64
70
|
}
|
65
71
|
}
|
@@ -70,7 +76,7 @@ describe Squall::Base do
|
|
70
76
|
base_test = CamelTest.new
|
71
77
|
base_test.default_params.should == {}
|
72
78
|
expected = {
|
73
|
-
:query => {
|
79
|
+
:query => {
|
74
80
|
:camel_test => {:one => 1, :two => 2}
|
75
81
|
}
|
76
82
|
}
|
@@ -92,11 +98,11 @@ describe Squall::Base do
|
|
92
98
|
it "converts Subclass::Test to :test" do
|
93
99
|
sub_class = Subclass::Test.new
|
94
100
|
sub_class.key_for_class.should == :test
|
95
|
-
end
|
101
|
+
end
|
96
102
|
|
97
103
|
it "converts Subclass::CamelTest to :camel_test" do
|
98
104
|
camel_test = Subclass::CamelTest.new
|
99
105
|
camel_test.key_for_class.should == :camel_test
|
100
|
-
end
|
106
|
+
end
|
101
107
|
end
|
102
108
|
end
|
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe Squall::Template do
|
4
4
|
before(:each) do
|
5
5
|
@template = Squall::Template.new
|
6
|
-
@keys = ["label", "operating_system_distro", "operating_system_arch", "created_at",
|
7
|
-
"operating_system_tail", "operating_system", "updated_at", "operating_system_edition",
|
8
|
-
"allowed_swap", "allow_resize_without_reboot", "virtualization", "id", "file_name",
|
6
|
+
@keys = ["label", "operating_system_distro", "operating_system_arch", "created_at",
|
7
|
+
"operating_system_tail", "operating_system", "updated_at", "operating_system_edition",
|
8
|
+
"allowed_swap", "allow_resize_without_reboot", "virtualization", "id", "file_name",
|
9
9
|
"checksum", "version", "user_id", "template_size", "allowed_hot_migrate", "min_disk_size", "state"]
|
10
10
|
end
|
11
11
|
|
@@ -29,11 +29,6 @@ describe Squall::Template do
|
|
29
29
|
@template.success.should be_false
|
30
30
|
end
|
31
31
|
|
32
|
-
it "404s on not found" do
|
33
|
-
expect { @template.make_public(404) }.to raise_error(Squall::NotFoundError)
|
34
|
-
@template.success.should be_false
|
35
|
-
end
|
36
|
-
|
37
32
|
it "makes the template public" do
|
38
33
|
pub = @template.make_public(1)
|
39
34
|
@template.success.should be_true
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Squall::Transaction do
|
4
4
|
before(:each) do
|
5
5
|
@transaction = Squall::Transaction.new
|
6
|
-
@keys = ["pid", "created_at", "updated_at", "actor", "priority",
|
7
|
-
"parent_type", "action", "id", "user_id", "dependent_transaction_id",
|
6
|
+
@keys = ["pid", "created_at", "updated_at", "actor", "priority",
|
7
|
+
"parent_type", "action", "id", "user_id", "dependent_transaction_id",
|
8
8
|
"allowed_cancel", "parent_id", "params", "log_output", "status", "identifier"
|
9
9
|
]
|
10
10
|
end
|
@@ -26,10 +26,6 @@ describe Squall::Transaction do
|
|
26
26
|
expect { @transaction.show }.to raise_error(ArgumentError)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "returns not found for invalid" do
|
30
|
-
expect { @transaction.show(5) }.to raise_error(Squall::NotFoundError)
|
31
|
-
end
|
32
|
-
|
33
29
|
it "returns a transaction" do
|
34
30
|
transaction = @transaction.show(1)
|
35
31
|
transaction.keys.should include(*@keys)
|
@@ -9,7 +9,7 @@ describe Squall::UserGroup do
|
|
9
9
|
|
10
10
|
describe "#list" do
|
11
11
|
use_vcr_cassette "user_group/list"
|
12
|
-
|
12
|
+
|
13
13
|
it "returns a list of user groups" do
|
14
14
|
user_groups = @user_group.list
|
15
15
|
user_groups.should be_an(Array)
|
@@ -20,14 +20,14 @@ describe Squall::UserGroup do
|
|
20
20
|
user_group.should be_a(Hash)
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
describe "#create" do
|
25
25
|
use_vcr_cassette "user_group/create"
|
26
26
|
it "requires label" do
|
27
27
|
invalid = @valid.reject{|k,v| k == :label }
|
28
28
|
requires_attr(:label) { @user_group.create(invalid) }
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "raises error on unknown params" do
|
32
32
|
expect { @user_group.create(@valid.merge(:what => 'what')) }.to raise_error(ArgumentError, 'Unknown params: what')
|
33
33
|
end
|
@@ -37,10 +37,10 @@ describe Squall::UserGroup do
|
|
37
37
|
@user_group.success.should be_true
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
describe "#edit" do
|
42
42
|
use_vcr_cassette "user_group/edit"
|
43
|
-
|
43
|
+
|
44
44
|
it "raises error on unknown params" do
|
45
45
|
expect { @user_group.edit(1, :what => 'what') }.to raise_error(ArgumentError, 'Unknown params: what')
|
46
46
|
end
|
@@ -49,12 +49,8 @@ describe Squall::UserGroup do
|
|
49
49
|
@user_group.edit(1, @valid)
|
50
50
|
@user_group.success.should be_true
|
51
51
|
end
|
52
|
-
|
53
|
-
it "raises an error for an invalid user group id" do
|
54
|
-
expect { @user_group.edit(404, @valid) }.to raise_error(Squall::NotFoundError)
|
55
|
-
end
|
56
52
|
end
|
57
|
-
|
53
|
+
|
58
54
|
describe "#delete" do
|
59
55
|
use_vcr_cassette "user_group/delete"
|
60
56
|
it "requires an id" do
|
@@ -65,10 +61,6 @@ describe Squall::UserGroup do
|
|
65
61
|
@user_group.delete(1)
|
66
62
|
@user_group.success.should be_true
|
67
63
|
end
|
68
|
-
|
69
|
-
it "returns NotFound for missing user" do
|
70
|
-
expect { @user_group.delete(404) }.to raise_error(Squall::NotFoundError)
|
71
|
-
end
|
72
64
|
end
|
73
65
|
|
74
66
|
end
|
data/spec/squall/user_spec.rb
CHANGED
@@ -27,22 +27,22 @@ describe Squall::User do
|
|
27
27
|
invalid = @valid.reject{|k,v| k == :password }
|
28
28
|
requires_attr(:password) { @user.create(invalid) }
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "requires password confirmation" do
|
32
32
|
invalid = @valid.reject{|k,v| k == :password_confirmation }
|
33
33
|
requires_attr(:password_confirmation) { @user.create(invalid) }
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "requires first name" do
|
37
37
|
invalid = @valid.reject{|k,v| k == :first_name }
|
38
38
|
requires_attr(:first_name) { @user.create(invalid) }
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "requires last name" do
|
42
42
|
invalid = @valid.reject{|k,v| k == :last_name }
|
43
43
|
requires_attr(:last_name) { @user.create(invalid) }
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "allows all optional params" do
|
47
47
|
optional = [:role, :time_zone, :locale, :status, :billing_plan_id, :role_ids, :suspend_after_hours, :suspend_at]
|
48
48
|
@user.should_receive(:request).exactly(optional.size).times.and_return Hash.new("user" => {})
|
@@ -50,7 +50,7 @@ describe Squall::User do
|
|
50
50
|
@user.create(@valid.merge(param => "test"))
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "raises error on unknown params" do
|
55
55
|
expect { @user.create(@valid.merge(:what => 'what')) }.to raise_error(ArgumentError, 'Unknown params: what')
|
56
56
|
end
|
@@ -60,10 +60,10 @@ describe Squall::User do
|
|
60
60
|
@user.success.should be_true
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
describe "#edit" do
|
65
65
|
use_vcr_cassette "user/edit"
|
66
|
-
|
66
|
+
|
67
67
|
it "allows select params" do
|
68
68
|
optional = [:email, :password, :password_confirmation, :first_name, :last_name, :user_group_id, :billing_plan_id, :role_ids, :suspend_at]
|
69
69
|
@user.should_receive(:request).exactly(optional.size).times.and_return Hash.new()
|
@@ -71,7 +71,7 @@ describe Squall::User do
|
|
71
71
|
@user.edit(1, param => "test")
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
it "raises error on unknown params" do
|
76
76
|
expect { @user.edit(1, :what => 'what') }.to raise_error(ArgumentError, 'Unknown params: what')
|
77
77
|
end
|
@@ -101,10 +101,6 @@ describe Squall::User do
|
|
101
101
|
expect { @user.show }.to raise_error(ArgumentError)
|
102
102
|
end
|
103
103
|
|
104
|
-
it "returns not found for invalid users" do
|
105
|
-
expect { @user.show(404) }.to raise_error(Squall::NotFoundError)
|
106
|
-
end
|
107
|
-
|
108
104
|
it "returns a user" do
|
109
105
|
user = @user.show(1)
|
110
106
|
user.should be_a(Hash)
|
@@ -161,10 +157,6 @@ describe Squall::User do
|
|
161
157
|
@user.delete(1)
|
162
158
|
@user.success.should be_true
|
163
159
|
end
|
164
|
-
|
165
|
-
it "returns NotFound for missing user" do
|
166
|
-
expect { @user.delete(404) }.to raise_error(Squall::NotFoundError)
|
167
|
-
end
|
168
160
|
end
|
169
161
|
|
170
162
|
describe "#stats" do
|
@@ -178,7 +170,7 @@ describe Squall::User do
|
|
178
170
|
stats.should be_an(Array)
|
179
171
|
end
|
180
172
|
end
|
181
|
-
|
173
|
+
|
182
174
|
describe "#monthly_bills" do
|
183
175
|
use_vcr_cassette "user/monthly_bills"
|
184
176
|
it "requires an id" do
|
@@ -197,44 +189,30 @@ describe Squall::User do
|
|
197
189
|
expect { @user.virtual_machines }.to raise_error(ArgumentError)
|
198
190
|
end
|
199
191
|
|
200
|
-
it "404s on not found" do
|
201
|
-
expect { @user.virtual_machines(404) }.to raise_error(Squall::NotFoundError)
|
202
|
-
end
|
203
|
-
|
204
192
|
it "returns the virtual_machines" do
|
205
193
|
virtual_machines = @user.virtual_machines(1)
|
206
194
|
virtual_machines.should be_an(Array)
|
207
195
|
end
|
208
196
|
end
|
209
|
-
|
197
|
+
|
210
198
|
describe "#hypervisors" do
|
211
199
|
use_vcr_cassette "user/hypervisors"
|
212
200
|
it "requires an id" do
|
213
201
|
expect { @user.hypervisors }.to raise_error(ArgumentError)
|
214
202
|
end
|
215
203
|
|
216
|
-
it "404s on not found" do
|
217
|
-
expect { @user.hypervisors(404) }.to raise_error(Squall::NotFoundError)
|
218
|
-
end
|
219
|
-
|
220
204
|
it "returns the virtual_machines" do
|
221
205
|
hypervisors = @user.hypervisors(1)
|
222
206
|
hypervisors.should be_an(Array)
|
223
207
|
end
|
224
208
|
end
|
225
|
-
|
209
|
+
|
226
210
|
describe "#data_store_zones" do
|
227
211
|
use_vcr_cassette "user/data_store_zones"
|
228
212
|
it "requires an id" do
|
229
213
|
expect { @user.data_store_zones }.to raise_error(ArgumentError)
|
230
214
|
end
|
231
215
|
|
232
|
-
it "404s on not found" do
|
233
|
-
pending "Broken on OnApp: returns success despite non-existent user" do
|
234
|
-
expect { @user.data_store_zones(2532564353245) }.to raise_error(Squall::NotFoundError)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
216
|
it "returns the virtual_machines" do
|
239
217
|
data_store_zones = @user.data_store_zones(1)
|
240
218
|
data_store_zones.should be_an(Array)
|
@@ -247,12 +225,6 @@ describe Squall::User do
|
|
247
225
|
expect { @user.network_zones }.to raise_error(ArgumentError)
|
248
226
|
end
|
249
227
|
|
250
|
-
it "404s on not found" do
|
251
|
-
pending "Broken on OnApp: returns success despite non-existent user" do
|
252
|
-
expect { @user.network_zones(2532564353245) }.to raise_error(Squall::NotFoundError)
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
228
|
it "returns the network_zones" do
|
257
229
|
network_zones = @user.network_zones(1)
|
258
230
|
network_zones.should be_an(Array)
|
@@ -265,14 +237,10 @@ describe Squall::User do
|
|
265
237
|
expect { @user.limits }.to raise_error(ArgumentError)
|
266
238
|
end
|
267
239
|
|
268
|
-
it "404s on not found" do
|
269
|
-
expect { @user.limits(438768534623) }.to raise_error(Squall::NotFoundError)
|
270
|
-
end
|
271
|
-
|
272
240
|
it "returns the limits" do
|
273
241
|
limits = @user.limits(1)
|
274
242
|
limits.should be_a(Hash)
|
275
243
|
end
|
276
244
|
end
|
277
|
-
|
245
|
+
|
278
246
|
end
|