smooth_operator 1.2.9 → 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.
Files changed (52) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +78 -22
  3. data/console.rb +2 -0
  4. data/lib/smooth_operator/array_with_meta_data.rb +20 -8
  5. data/lib/smooth_operator/{relation → associations}/association_reflection.rb +8 -8
  6. data/lib/smooth_operator/{relation/array_relation.rb → associations/has_many_relation.rb} +3 -13
  7. data/lib/smooth_operator/{relation → associations}/reflection.rb +2 -2
  8. data/lib/smooth_operator/associations.rb +110 -0
  9. data/lib/smooth_operator/attribute_assignment.rb +52 -60
  10. data/lib/smooth_operator/cookie_jar.rb +21 -0
  11. data/lib/smooth_operator/delegation.rb +13 -34
  12. data/lib/smooth_operator/finder_methods.rb +26 -17
  13. data/lib/smooth_operator/helpers.rb +14 -8
  14. data/lib/smooth_operator/http_methods.rb +17 -0
  15. data/lib/smooth_operator/internal_data.rb +45 -0
  16. data/lib/smooth_operator/open_struct.rb +11 -26
  17. data/lib/smooth_operator/operator.rb +65 -59
  18. data/lib/smooth_operator/operators/connection_wrapper.rb +15 -0
  19. data/lib/smooth_operator/operators/faraday.rb +6 -6
  20. data/lib/smooth_operator/operators/typhoeus.rb +22 -12
  21. data/lib/smooth_operator/options.rb +30 -0
  22. data/lib/smooth_operator/persistence.rb +64 -61
  23. data/lib/smooth_operator/remote_call/base.rb +7 -6
  24. data/lib/smooth_operator/resource_name.rb +46 -0
  25. data/lib/smooth_operator/schema.rb +21 -0
  26. data/lib/smooth_operator/serialization.rb +80 -36
  27. data/lib/smooth_operator/translation.rb +21 -12
  28. data/lib/smooth_operator/type_casting.rb +127 -0
  29. data/lib/smooth_operator/validations.rb +25 -3
  30. data/lib/smooth_operator/version.rb +1 -1
  31. data/lib/smooth_operator.rb +55 -5
  32. data/smooth_operator.gemspec +5 -5
  33. data/spec/smooth_operator/attribute_assignment_spec.rb +5 -14
  34. data/spec/smooth_operator/finder_methods_spec.rb +4 -9
  35. data/spec/smooth_operator/persistence_spec.rb +27 -19
  36. data/spec/smooth_operator/remote_call_spec.rb +104 -84
  37. data/spec/smooth_operator/{model_schema_spec.rb → resource_name_spec.rb} +1 -1
  38. data/spec/support/models/address.rb +8 -10
  39. data/spec/support/models/comment.rb +2 -0
  40. data/spec/support/models/post.rb +7 -7
  41. data/spec/support/models/user.rb +10 -13
  42. data/spec/support/models/user_with_address_and_posts.rb +9 -17
  43. data/spec/support/test_server.rb +7 -7
  44. metadata +25 -25
  45. data/lib/smooth_operator/attribute_methods.rb +0 -78
  46. data/lib/smooth_operator/attributes/base.rb +0 -107
  47. data/lib/smooth_operator/attributes/dirty.rb +0 -29
  48. data/lib/smooth_operator/attributes/normal.rb +0 -15
  49. data/lib/smooth_operator/blank_slate.rb +0 -7
  50. data/lib/smooth_operator/model_schema.rb +0 -81
  51. data/lib/smooth_operator/relation/associations.rb +0 -102
  52. data/spec/smooth_operator/attributes_dirty_spec.rb +0 -53
@@ -1,289 +1,305 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe SmoothOperator::RemoteCall do
4
- subject { UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts)) }
5
4
 
6
5
  context "when the server response has a http code in the 200 range" do
7
- before { subject.save(nil, { status: 200 }) }
6
+ before(:all) do
7
+ @subject = UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts))
8
+ @subject.save(nil, { status: 200 })
9
+ end
8
10
 
9
11
  it "#ok? should return true" do
10
- expect(subject.last_remote_call.ok?).to be true
12
+ expect(@subject.last_remote_call.ok?).to be true
11
13
  end
12
14
 
13
15
  it "#not_processed? should return false" do
14
- expect(subject.last_remote_call.not_processed?).to be false
16
+ expect(@subject.last_remote_call.not_processed?).to be false
15
17
  end
16
18
 
17
19
  it "#client_error? should return false" do
18
- expect(subject.last_remote_call.client_error?).to be false
20
+ expect(@subject.last_remote_call.client_error?).to be false
19
21
  end
20
22
 
21
23
  it "#server_error? should return false" do
22
- expect(subject.last_remote_call.server_error?).to be false
24
+ expect(@subject.last_remote_call.server_error?).to be false
23
25
  end
24
26
 
25
27
  it "#error? should return false" do
26
- expect(subject.last_remote_call.error?).to be false
28
+ expect(@subject.last_remote_call.error?).to be false
27
29
  end
28
30
 
29
31
  it "#not_found? should return false" do
30
- expect(subject.last_remote_call.not_found?).to be false
32
+ expect(@subject.last_remote_call.not_found?).to be false
31
33
  end
32
34
 
33
35
  it "#timeout? should return false" do
34
- expect(subject.last_remote_call.timeout?).to be false
36
+ expect(@subject.last_remote_call.timeout?).to be false
35
37
  end
36
38
 
37
39
  it "#connection_failed? should return false" do
38
- expect(subject.last_remote_call.connection_failed?).to be false
40
+ expect(@subject.last_remote_call.connection_failed?).to be false
39
41
  end
40
42
 
41
43
  it "#status should return true" do
42
- expect(subject.last_remote_call.status).to be true
44
+ expect(@subject.last_remote_call.status).to be true
43
45
  end
44
46
  end
45
47
 
46
48
  context "when the server response has a http code in the 400 range (not 422, 404)" do
47
- before { subject.save(nil, { status: 400 }) }
49
+ before(:all) do
50
+ @subject = UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts))
51
+ @subject.save(nil, { status: 400 })
52
+ end
48
53
 
49
54
  it "#ok? should return false" do
50
- expect(subject.last_remote_call.ok?).to be false
55
+ expect(@subject.last_remote_call.ok?).to be false
51
56
  end
52
57
 
53
58
  it "#not_processed? should return false" do
54
- expect(subject.last_remote_call.not_processed?).to be false
59
+ expect(@subject.last_remote_call.not_processed?).to be false
55
60
  end
56
61
 
57
62
  it "#client_error? should return true" do
58
- expect(subject.last_remote_call.client_error?).to be true
63
+ expect(@subject.last_remote_call.client_error?).to be true
59
64
  end
60
65
 
61
66
  it "#server_error? should return false" do
62
- expect(subject.last_remote_call.server_error?).to be false
67
+ expect(@subject.last_remote_call.server_error?).to be false
63
68
  end
64
69
 
65
70
  it "#error? should return true" do
66
- expect(subject.last_remote_call.error?).to be true
71
+ expect(@subject.last_remote_call.error?).to be true
67
72
  end
68
73
 
69
74
  it "#not_found? should return false" do
70
- expect(subject.last_remote_call.not_found?).to be false
75
+ expect(@subject.last_remote_call.not_found?).to be false
71
76
  end
72
77
 
73
78
  it "#timeout? should return false" do
74
- expect(subject.last_remote_call.timeout?).to be false
79
+ expect(@subject.last_remote_call.timeout?).to be false
75
80
  end
76
81
 
77
82
  it "#connection_failed? should return false" do
78
- expect(subject.last_remote_call.connection_failed?).to be false
83
+ expect(@subject.last_remote_call.connection_failed?).to be false
79
84
  end
80
85
 
81
86
  it "#status should return nil" do
82
- expect(subject.last_remote_call.status).to be nil
87
+ expect(@subject.last_remote_call.status).to be nil
83
88
  end
84
89
  end
85
90
 
86
91
  context "when the server response has a http is 404" do
87
- before { subject.save(nil, { status: 404 }) }
92
+ before(:all) do
93
+ @subject = UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts))
94
+ @subject.save(nil, { status: 404 })
95
+ end
88
96
 
89
97
  it "#ok? should return false" do
90
- expect(subject.last_remote_call.ok?).to be false
98
+ expect(@subject.last_remote_call.ok?).to be false
91
99
  end
92
100
 
93
101
  it "#not_processed? should return false" do
94
- expect(subject.last_remote_call.not_processed?).to be false
102
+ expect(@subject.last_remote_call.not_processed?).to be false
95
103
  end
96
104
 
97
105
  it "#client_error? should return true" do
98
- expect(subject.last_remote_call.client_error?).to be true
106
+ expect(@subject.last_remote_call.client_error?).to be true
99
107
  end
100
108
 
101
109
  it "#server_error? should return false" do
102
- expect(subject.last_remote_call.server_error?).to be false
110
+ expect(@subject.last_remote_call.server_error?).to be false
103
111
  end
104
112
 
105
113
  it "#error? should return true" do
106
- expect(subject.last_remote_call.error?).to be true
114
+ expect(@subject.last_remote_call.error?).to be true
107
115
  end
108
116
 
109
117
  it "#not_found? should return true" do
110
- expect(subject.last_remote_call.not_found?).to be true
118
+ expect(@subject.last_remote_call.not_found?).to be true
111
119
  end
112
120
 
113
121
  it "#timeout? should return false" do
114
- expect(subject.last_remote_call.timeout?).to be false
122
+ expect(@subject.last_remote_call.timeout?).to be false
115
123
  end
116
124
 
117
125
  it "#connection_failed? should return false" do
118
- expect(subject.last_remote_call.connection_failed?).to be false
126
+ expect(@subject.last_remote_call.connection_failed?).to be false
119
127
  end
120
128
 
121
129
  it "#status should return nil" do
122
- expect(subject.last_remote_call.status).to be nil
130
+ expect(@subject.last_remote_call.status).to be nil
123
131
  end
124
132
  end
125
133
 
126
134
  context "when the server response has a http is 422" do
127
- before { subject.save(nil, { status: 422 }) }
135
+ before(:all) do
136
+ @subject = UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts))
137
+ @subject.save(nil, { status: 422 })
138
+ end
128
139
 
129
140
  it "#ok? should return false" do
130
- expect(subject.last_remote_call.ok?).to be false
141
+ expect(@subject.last_remote_call.ok?).to be false
131
142
  end
132
143
 
133
144
  it "#not_processed? should return true" do
134
- expect(subject.last_remote_call.not_processed?).to be true
145
+ expect(@subject.last_remote_call.not_processed?).to be true
135
146
  end
136
147
 
137
148
  it "#client_error? should return true" do
138
- expect(subject.last_remote_call.client_error?).to be true
149
+ expect(@subject.last_remote_call.client_error?).to be true
139
150
  end
140
151
 
141
152
  it "#server_error? should return false" do
142
- expect(subject.last_remote_call.server_error?).to be false
153
+ expect(@subject.last_remote_call.server_error?).to be false
143
154
  end
144
155
 
145
156
  it "#error? should return false" do
146
- expect(subject.last_remote_call.error?).to be false
157
+ expect(@subject.last_remote_call.error?).to be false
147
158
  end
148
159
 
149
160
  it "#not_found? should return false" do
150
- expect(subject.last_remote_call.not_found?).to be false
161
+ expect(@subject.last_remote_call.not_found?).to be false
151
162
  end
152
163
 
153
164
  it "#timeout? should return false" do
154
- expect(subject.last_remote_call.timeout?).to be false
165
+ expect(@subject.last_remote_call.timeout?).to be false
155
166
  end
156
167
 
157
168
  it "#connection_failed? should return false" do
158
- expect(subject.last_remote_call.connection_failed?).to be false
169
+ expect(@subject.last_remote_call.connection_failed?).to be false
159
170
  end
160
171
 
161
172
  it "#status should return false" do
162
- expect(subject.last_remote_call.status).to be false
173
+ expect(@subject.last_remote_call.status).to be false
163
174
  end
164
175
  end
165
176
 
166
177
  context "when the server response has a http code in the 500 range" do
167
- before { subject.save(nil, { status: 500 }) }
178
+ before(:all) do
179
+ @subject = UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts))
180
+ @subject.save(nil, { status: 500 })
181
+ end
168
182
 
169
183
  it "#ok? should return false" do
170
- expect(subject.last_remote_call.ok?).to be false
184
+ expect(@subject.last_remote_call.ok?).to be false
171
185
  end
172
186
 
173
187
  it "#not_processed? should return false" do
174
- expect(subject.last_remote_call.not_processed?).to be false
188
+ expect(@subject.last_remote_call.not_processed?).to be false
175
189
  end
176
190
 
177
191
  it "#client_error? should return false" do
178
- expect(subject.last_remote_call.client_error?).to be false
192
+ expect(@subject.last_remote_call.client_error?).to be false
179
193
  end
180
194
 
181
195
  it "#server_error? should return true" do
182
- expect(subject.last_remote_call.server_error?).to be true
196
+ expect(@subject.last_remote_call.server_error?).to be true
183
197
  end
184
198
 
185
199
  it "#error? should return true" do
186
- expect(subject.last_remote_call.error?).to be true
200
+ expect(@subject.last_remote_call.error?).to be true
187
201
  end
188
202
 
189
203
  it "#not_found? should return false" do
190
- expect(subject.last_remote_call.not_found?).to be false
204
+ expect(@subject.last_remote_call.not_found?).to be false
191
205
  end
192
206
 
193
207
  it "#timeout? should return false" do
194
- expect(subject.last_remote_call.timeout?).to be false
208
+ expect(@subject.last_remote_call.timeout?).to be false
195
209
  end
196
210
 
197
211
  it "#connection_failed? should return false" do
198
- expect(subject.last_remote_call.connection_failed?).to be false
212
+ expect(@subject.last_remote_call.connection_failed?).to be false
199
213
  end
200
214
 
201
215
  it "#status should return nil" do
202
- expect(subject.last_remote_call.status).to be nil
216
+ expect(@subject.last_remote_call.status).to be nil
203
217
  end
204
218
  end
205
219
 
206
220
  context "when the connection is broken" do
207
- subject { User::BrokenConnection.new }
208
-
209
- before { subject.save }
221
+ before(:all) do
222
+ @subject = User::BrokenConnection.new
223
+ @subject.save
224
+ end
210
225
 
211
226
  it "#ok? should return false" do
212
- expect(subject.last_remote_call.ok?).to be false
227
+ expect(@subject.last_remote_call.ok?).to be false
213
228
  end
214
229
 
215
230
  it "#not_processed? should return false" do
216
- expect(subject.last_remote_call.not_processed?).to be false
231
+ expect(@subject.last_remote_call.not_processed?).to be false
217
232
  end
218
233
 
219
234
  it "#client_error? should return false" do
220
- expect(subject.last_remote_call.client_error?).to be false
235
+ expect(@subject.last_remote_call.client_error?).to be false
221
236
  end
222
237
 
223
238
  it "#server_error? should return true" do
224
- expect(subject.last_remote_call.server_error?).to be true
239
+ expect(@subject.last_remote_call.server_error?).to be true
225
240
  end
226
241
 
227
242
  it "#error? should return true" do
228
- expect(subject.last_remote_call.error?).to be true
243
+ expect(@subject.last_remote_call.error?).to be true
229
244
  end
230
245
 
231
246
  it "#not_found? should return false" do
232
- expect(subject.last_remote_call.not_found?).to be false
247
+ expect(@subject.last_remote_call.not_found?).to be false
233
248
  end
234
249
 
235
250
  it "#timeout? should return false" do
236
- expect(subject.last_remote_call.timeout?).to be false
251
+ expect(@subject.last_remote_call.timeout?).to be false
237
252
  end
238
253
 
239
254
  it "#connection_failed? should return true" do
240
- expect(subject.last_remote_call.connection_failed?).to be true
255
+ expect(@subject.last_remote_call.connection_failed?).to be true
241
256
  end
242
257
 
243
258
  it "#status should return nil" do
244
- expect(subject.last_remote_call.status).to be nil
259
+ expect(@subject.last_remote_call.status).to be nil
245
260
  end
246
261
  end
247
262
 
248
- context "when the connection exceeds the timeout" do
249
- subject { User::TimeoutConnection.new }
250
-
251
- before { subject.save('/timeout') }
263
+ context "when the connection exceeds the timeout", current: true do
264
+ before(:all) do
265
+ @subject = User::TimeoutConnection.new
266
+ @subject.save('/timeout')
267
+ end
252
268
 
253
269
  it "#ok? should return false" do
254
- expect(subject.last_remote_call.ok?).to be false
270
+ expect(@subject.last_remote_call.ok?).to be false
255
271
  end
256
272
 
257
273
  it "#not_processed? should return false" do
258
- expect(subject.last_remote_call.not_processed?).to be false
274
+ expect(@subject.last_remote_call.not_processed?).to be false
259
275
  end
260
276
 
261
277
  it "#client_error? should return false" do
262
- expect(subject.last_remote_call.client_error?).to be false
278
+ expect(@subject.last_remote_call.client_error?).to be false
263
279
  end
264
280
 
265
281
  it "#server_error? should return true" do
266
- expect(subject.last_remote_call.server_error?).to be true
282
+ expect(@subject.last_remote_call.server_error?).to be true
267
283
  end
268
284
 
269
285
  it "#error? should return true" do
270
- expect(subject.last_remote_call.error?).to be true
286
+ expect(@subject.last_remote_call.error?).to be true
271
287
  end
272
288
 
273
289
  it "#not_found? should return false" do
274
- expect(subject.last_remote_call.not_found?).to be false
290
+ expect(@subject.last_remote_call.not_found?).to be false
275
291
  end
276
292
 
277
293
  it "#timeout? should return true" do
278
- expect(subject.last_remote_call.timeout?).to be true
294
+ expect(@subject.last_remote_call.timeout?).to be true
279
295
  end
280
296
 
281
297
  it "#connection_failed? should return false" do
282
- expect(subject.last_remote_call.connection_failed?).to be false
298
+ expect(@subject.last_remote_call.connection_failed?).to be false
283
299
  end
284
300
 
285
301
  it "#status should return nil" do
286
- expect(subject.last_remote_call.status).to be nil
302
+ expect(@subject.last_remote_call.status).to be nil
287
303
  end
288
304
  end
289
305
 
@@ -291,28 +307,32 @@ describe SmoothOperator::RemoteCall do
291
307
  context "when the server response's body does not contains valid json data" do
292
308
  let(:remote_call) { User::Base.find('bad_json') }
293
309
 
294
- it "should return nil" do
295
- expect(remote_call.data).to be nil
310
+ it "it should return what the server has returned" do
311
+ expect(remote_call.data).to eq('ok')
296
312
  end
297
313
  end
298
314
  end
299
315
 
300
316
  describe "#http_status" do
301
317
  context "when a server connection is established" do
302
- before { subject.save(nil, { status: 422 }) }
318
+ before do
319
+ @subject = UserWithAddressAndPosts::Son.new(attributes_for(:user_with_address_and_posts))
320
+ @subject.save(nil, { status: 422 })
321
+ end
303
322
 
304
323
  it "it should return the server's http response code" do
305
- expect(subject.last_remote_call.http_status).to be 422
324
+ expect(@subject.last_remote_call.http_status).to be 422
306
325
  end
307
326
  end
308
327
 
309
328
  context "when a server connection fails" do
310
- subject { User::TimeoutConnection.new }
311
-
312
- before { subject.save('/timeout') }
329
+ before do
330
+ @subject = User::TimeoutConnection.new
331
+ @subject.save('/timeout')
332
+ end
313
333
 
314
334
  it "should return 0" do
315
- expect(subject.last_remote_call.http_status).to be 0
335
+ expect(@subject.last_remote_call.http_status).to be 0
316
336
  end
317
337
  end
318
338
  end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe SmoothOperator::ModelSchema do
3
+ describe SmoothOperator::ResourceName do
4
4
 
5
5
  describe "#known_attributes" do
6
6
  let(:initial_attributes_keys) { attributes_for(:user).keys.map(&:to_s) }
@@ -1,14 +1,12 @@
1
1
  class Address < SmoothOperator::Base
2
2
 
3
- self.dirty_attributes
4
-
5
- self.resource_name = ''
6
-
7
- self.endpoint_user = 'admin'
8
- self.endpoint_pass = 'admin'
9
-
10
- self.endpoint = 'http://localhost:4567/'
11
-
12
- self.headers = { "X-APPTOKEN" => "joaquim_app_token", "X-LAYERTOKEN" => "joaquim_layer_token" }
3
+ options resource_name: '',
4
+ endpoint_user: 'admin',
5
+ endpoint_pass: 'admin',
6
+ endpoint: 'http://localhost:4567/',
7
+ headers: {
8
+ "X-APPTOKEN" => "app_token",
9
+ "X-LAYERTOKEN" => "layer_token"
10
+ }
13
11
 
14
12
  end
@@ -1,3 +1,5 @@
1
1
  class Comment < SmoothOperator::Base
2
2
 
3
+ options unknown_hash_class: SmoothOperator::OpenStruct
4
+
3
5
  end
@@ -1,13 +1,13 @@
1
1
  class Post < SmoothOperator::Base
2
2
 
3
- self.endpoint_user = 'admin'
3
+ options endpoint_user: 'admin',
4
+ endpoint_pass: 'admin',
5
+ rails_serialization: true,
6
+ endpoint: 'http://localhost:4567/',
7
+ unknown_hash_class: SmoothOperator::OpenStruct
4
8
 
5
- self.endpoint_pass = 'admin'
9
+ has_many :comments#, rails_serialization: true
6
10
 
7
- self.endpoint = 'http://localhost:4567/'
8
-
9
- has_many :comments
10
-
11
- belongs_to :address
11
+ belongs_to :address#, rails_serialization: true
12
12
 
13
13
  end
@@ -1,14 +1,11 @@
1
1
  module User
2
-
3
- class Base < SmoothOperator::Base
4
-
5
- self.resource_name = 'user'
6
-
7
- self.endpoint_user = 'admin'
8
2
 
9
- self.endpoint_pass = 'admin'
3
+ class Base < SmoothOperator::Base
10
4
 
11
- self.endpoint = 'http://localhost:4567/'
5
+ options resource_name: 'user',
6
+ endpoint_user: 'admin',
7
+ endpoint_pass: 'admin',
8
+ endpoint: 'http://localhost:4567/'
12
9
 
13
10
  def self.query_string(params)
14
11
  params['query_string_param'] = true
@@ -19,23 +16,23 @@ module User
19
16
  end
20
17
 
21
18
  module UnknownHashClass
22
-
19
+
23
20
  class OpenStructBase < User::Base
24
- self.unknown_hash_class = SmoothOperator::OpenStruct::Base
21
+ options unknown_hash_class: SmoothOperator::OpenStruct
25
22
  end
26
23
 
27
24
  class None < User::Base
28
- self.unknown_hash_class = :none
25
+ options unknown_hash_class: nil
29
26
  end
30
27
 
31
28
  end
32
29
 
33
30
  class BrokenConnection < SmoothOperator::Base
34
- self.endpoint = 'http://localhost:1234/'
31
+ options endpoint: 'http://localhost:1234/'
35
32
  end
36
33
 
37
34
  class TimeoutConnection < Base
38
- self.timeout = 1
35
+ options timeout: 1
39
36
  end
40
37
 
41
38
  end
@@ -1,8 +1,8 @@
1
1
  module UserWithAddressAndPosts
2
-
2
+
3
3
  class Father < User::Base
4
-
5
- self.resource_name = 'user'
4
+
5
+ options resource_name: 'user'
6
6
 
7
7
  schema(
8
8
  posts: Post,
@@ -27,19 +27,19 @@ module UserWithAddressAndPosts
27
27
 
28
28
  class SoftBehaviour < Son
29
29
 
30
- self.strict_behaviour = false
30
+ options strict_behaviour: false
31
31
 
32
32
  end
33
33
 
34
34
  class WithPatch < Son
35
35
 
36
- self.update_http_verb = :patch
36
+ options update_http_verb: 'patch'
37
37
 
38
38
  end
39
-
39
+
40
40
 
41
41
  module UserBlackListed
42
-
42
+
43
43
  class Father < ::UserWithAddressAndPosts::Son
44
44
 
45
45
  attributes_black_list_add "last_name"
@@ -55,7 +55,7 @@ module UserWithAddressAndPosts
55
55
  end
56
56
 
57
57
  module UserWhiteListed
58
-
58
+
59
59
  class Father < ::UserWithAddressAndPosts::Son
60
60
 
61
61
  attributes_white_list_add "id"
@@ -69,7 +69,7 @@ module UserWithAddressAndPosts
69
69
  end
70
70
 
71
71
  end
72
-
72
+
73
73
  class UserWithMyMethod < UserWithAddressAndPosts::Son
74
74
 
75
75
  def my_method
@@ -78,12 +78,4 @@ module UserWithAddressAndPosts
78
78
 
79
79
  end
80
80
 
81
- class DirtyAttributes < UserWithAddressAndPosts::Son
82
-
83
- self.dirty_attributes
84
-
85
- self.unknown_hash_class = SmoothOperator::OpenStruct::Dirty
86
-
87
- end
88
-
89
81
  end
@@ -38,7 +38,7 @@ class TestServer < Sinatra::Base
38
38
 
39
39
  get '/users' do
40
40
  users = [FactoryGirl.attributes_for(:user_with_address_and_posts), FactoryGirl.attributes_for(:user_with_address_and_posts)]
41
-
41
+
42
42
  users[0][:id] = 1
43
43
  users[1][:id] = 2
44
44
 
@@ -63,10 +63,10 @@ class TestServer < Sinatra::Base
63
63
  users = [{ id: 1, users: nested_users}, { id: 2, users: nested_users}]
64
64
 
65
65
  data = { page: 1, total: 6, users: users }
66
-
66
+
67
67
  json data
68
68
  end
69
-
69
+
70
70
  get '/users/bad_json' do
71
71
  'ok'
72
72
  end
@@ -79,7 +79,7 @@ class TestServer < Sinatra::Base
79
79
  user_data = { user: FactoryGirl.attributes_for(:user_with_address_and_posts), status: 1 }
80
80
  json user_data
81
81
  end
82
-
82
+
83
83
 
84
84
  put '/users/:id/send_error' do
85
85
  data_with_error = { id: 1, errors: [{ first_name: ["can't be blank"] }] }
@@ -90,7 +90,7 @@ class TestServer < Sinatra::Base
90
90
  post '/users' do
91
91
  common_response
92
92
  end
93
-
93
+
94
94
  post '/users/timeout' do
95
95
  # sleep 2 # for typhoeus tests
96
96
  sleep 1
@@ -100,7 +100,7 @@ class TestServer < Sinatra::Base
100
100
  put '/users/:id' do
101
101
  common_response
102
102
  end
103
-
103
+
104
104
  patch '/users/:id' do
105
105
  common_response
106
106
  end
@@ -123,7 +123,7 @@ class TestServer < Sinatra::Base
123
123
  data.delete('id')
124
124
 
125
125
  query_params = (params[:query_string_param] == 'true')
126
-
126
+
127
127
  internal_data_match = params[:user] ? (params[:user] == data) : true
128
128
 
129
129
  json({ user: { server_response: true }, http_verb: env["REQUEST_METHOD"].downcase, internal_data_match: internal_data_match, query_params: query_params })