restful_resource 0.8.26 → 0.8.27
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97ee3bdc58923601c58f73bfdc73b9c9dae0f919
|
4
|
+
data.tar.gz: 9639fff43755fe48221473be09e234d79884abb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d0329baa0ecd710a706a25e39f639480bca7fca58d1d4add1973726124839e9d96bf6053fd6daa603b178b4ca65d920bbc018be281954fc6979ef4ae5e4f3a
|
7
|
+
data.tar.gz: f6153a1eab7c7040a73b298384d0d208528a7d950ab31f919cb4741dd13c14a0a196d8b10b5140a91b71d9e0e2602b05ad411ac89572ed94a9712652ea55f992
|
@@ -9,10 +9,8 @@ module RestfulResource
|
|
9
9
|
result = nil
|
10
10
|
if errors.is_a?(Hash) && errors.has_key?('errors')
|
11
11
|
result = data.merge(errors)
|
12
|
-
elsif errors.is_a?(Array)
|
13
|
-
result = data.merge(errors: errors)
|
14
12
|
else
|
15
|
-
result = data.merge(errors:
|
13
|
+
result = data.merge(errors: errors)
|
16
14
|
end
|
17
15
|
self.new(result)
|
18
16
|
end
|
@@ -26,10 +24,8 @@ module RestfulResource
|
|
26
24
|
result = nil
|
27
25
|
if errors.is_a?(Hash) && errors.has_key?('errors')
|
28
26
|
result = data.merge(errors)
|
29
|
-
elsif errors.is_a?(Array)
|
30
|
-
result = data.merge(errors: errors)
|
31
27
|
else
|
32
|
-
result = data.merge(errors:
|
28
|
+
result = data.merge(errors: errors)
|
33
29
|
end
|
34
30
|
self.new(result)
|
35
31
|
end
|
@@ -41,7 +37,7 @@ module RestfulResource
|
|
41
37
|
end
|
42
38
|
|
43
39
|
def valid?
|
44
|
-
@inner_object.errors.nil?
|
40
|
+
@inner_object.errors.nil?
|
45
41
|
end
|
46
42
|
end
|
47
43
|
end
|
@@ -51,24 +51,14 @@ describe RestfulResource::RailsValidations do
|
|
51
51
|
expect(@object.valid?).to be_falsey
|
52
52
|
end
|
53
53
|
|
54
|
-
it 'should handle errors returned as root array' do
|
55
|
-
data = {name: 'Michelangelo'}
|
56
|
-
expected_response = RestfulResource::Response.new(body: [@error].to_json)
|
57
|
-
expect_put_with_unprocessable_entity("http://api.carwow.co.uk/dealers/1", expected_response, data: data)
|
58
|
-
|
59
|
-
@object = Dealer.put(1, data: data)
|
60
|
-
expect(@object.errors.count).to eq 1
|
61
|
-
expect(@object.errors.first).to eq @error
|
62
|
-
end
|
63
|
-
|
64
54
|
it 'should handle errors returned as root object' do
|
65
55
|
data = {name: 'Michelangelo'}
|
66
56
|
expected_response = RestfulResource::Response.new(body: @error.to_json)
|
67
57
|
expect_put_with_unprocessable_entity("http://api.carwow.co.uk/dealers/1", expected_response, data: data)
|
68
58
|
|
69
59
|
@object = Dealer.put(1, data: data)
|
70
|
-
expect(@object.
|
71
|
-
expect(@object.errors
|
60
|
+
expect(@object.valid?).to be_falsey
|
61
|
+
expect(@object.errors).to eq @error
|
72
62
|
end
|
73
63
|
|
74
64
|
end
|
@@ -117,24 +107,14 @@ describe RestfulResource::RailsValidations do
|
|
117
107
|
expect(@object.valid?).to be_falsey
|
118
108
|
end
|
119
109
|
|
120
|
-
it 'should handle errors returned as root object' do
|
121
|
-
data = {name: 'Michelangelo'}
|
122
|
-
expected_response = RestfulResource::Response.new(body: [@error].to_json)
|
123
|
-
expect_post_with_unprocessable_entity("http://api.carwow.co.uk/dealers", expected_response, data: data)
|
124
|
-
|
125
|
-
@object = Dealer.post(data: data)
|
126
|
-
expect(@object.errors.count).to eq 1
|
127
|
-
expect(@object.errors.first).to eq @error
|
128
|
-
end
|
129
|
-
|
130
110
|
it 'should handle errors returned as root object' do
|
131
111
|
data = {name: 'Michelangelo'}
|
132
112
|
expected_response = RestfulResource::Response.new(body: @error.to_json)
|
133
113
|
expect_post_with_unprocessable_entity("http://api.carwow.co.uk/dealers", expected_response, data: data)
|
134
114
|
|
135
115
|
@object = Dealer.post(data: data)
|
136
|
-
expect(@object.
|
137
|
-
expect(@object.errors
|
116
|
+
expect(@object.valid?).to be_falsey
|
117
|
+
expect(@object.errors).to eq @error
|
138
118
|
end
|
139
119
|
end
|
140
120
|
end
|