restful_resource 0.8.26 → 0.8.27

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 497d9ea8fabfad7bf1476db40238c550d76b07d8
4
- data.tar.gz: a2a22720cda6d80f92722dbbf916819ddadf5242
3
+ metadata.gz: 97ee3bdc58923601c58f73bfdc73b9c9dae0f919
4
+ data.tar.gz: 9639fff43755fe48221473be09e234d79884abb0
5
5
  SHA512:
6
- metadata.gz: 49421e9608e455840b389b53cda68b67c18b5257414cba27cec065663e8ff8064df2f5c8c99505e17c088f34fa398fb53220131a1ffbc04a023cdc71e5579cae
7
- data.tar.gz: 2bd91a065fba45e08843ce1e0bbd381526cbcc362847e81e32ee84b7c5b0516c0d28a3d76c1be5d57547b88da8821ae8e6cead8a88dfd99d6831ceb110245d8b
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: [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: [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? || @inner_object.errors.count == 0
40
+ @inner_object.errors.nil?
45
41
  end
46
42
  end
47
43
  end
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = "0.8.26"
2
+ VERSION = "0.8.27"
3
3
  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.errors.count).to eq 1
71
- expect(@object.errors.first).to eq @error
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.errors.count).to eq 1
137
- expect(@object.errors.first).to eq @error
116
+ expect(@object.valid?).to be_falsey
117
+ expect(@object.errors).to eq @error
138
118
  end
139
119
  end
140
120
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.26
4
+ version: 0.8.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro