her 1.0.1 → 1.0.2

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +19 -1279
  3. data/.rubocop_todo.yml +232 -0
  4. data/README.md +16 -0
  5. data/her.gemspec +3 -2
  6. data/lib/her/api.rb +8 -7
  7. data/lib/her/collection.rb +2 -1
  8. data/lib/her/errors.rb +3 -1
  9. data/lib/her/json_api/model.rb +8 -12
  10. data/lib/her/middleware.rb +1 -1
  11. data/lib/her/middleware/accept_json.rb +1 -0
  12. data/lib/her/middleware/first_level_parse_json.rb +6 -5
  13. data/lib/her/middleware/json_api_parser.rb +6 -5
  14. data/lib/her/middleware/parse_json.rb +2 -1
  15. data/lib/her/middleware/second_level_parse_json.rb +6 -5
  16. data/lib/her/model/associations.rb +6 -6
  17. data/lib/her/model/associations/association.rb +7 -9
  18. data/lib/her/model/associations/association_proxy.rb +2 -3
  19. data/lib/her/model/associations/belongs_to_association.rb +1 -1
  20. data/lib/her/model/attributes.rb +6 -6
  21. data/lib/her/model/base.rb +2 -2
  22. data/lib/her/model/http.rb +1 -1
  23. data/lib/her/model/introspection.rb +5 -3
  24. data/lib/her/model/nested_attributes.rb +1 -1
  25. data/lib/her/model/orm.rb +9 -8
  26. data/lib/her/model/parse.rb +9 -12
  27. data/lib/her/model/paths.rb +3 -4
  28. data/lib/her/model/relation.rb +5 -4
  29. data/lib/her/version.rb +1 -1
  30. data/spec/api_spec.rb +3 -0
  31. data/spec/middleware/accept_json_spec.rb +1 -0
  32. data/spec/middleware/first_level_parse_json_spec.rb +2 -1
  33. data/spec/middleware/json_api_parser_spec.rb +1 -0
  34. data/spec/middleware/second_level_parse_json_spec.rb +1 -0
  35. data/spec/model/associations/association_proxy_spec.rb +1 -0
  36. data/spec/model/associations_spec.rb +4 -3
  37. data/spec/model/attributes_spec.rb +5 -3
  38. data/spec/model/callbacks_spec.rb +14 -15
  39. data/spec/model/dirty_spec.rb +1 -0
  40. data/spec/model/http_spec.rb +1 -0
  41. data/spec/model/introspection_spec.rb +3 -2
  42. data/spec/model/nested_attributes_spec.rb +1 -0
  43. data/spec/model/orm_spec.rb +22 -16
  44. data/spec/model/parse_spec.rb +3 -0
  45. data/spec/model/paths_spec.rb +1 -0
  46. data/spec/model/relation_spec.rb +3 -2
  47. data/spec/model/validations_spec.rb +1 -0
  48. data/spec/model_spec.rb +1 -0
  49. data/spec/support/extensions/array.rb +1 -0
  50. data/spec/support/extensions/hash.rb +1 -0
  51. metadata +12 -11
@@ -1,6 +1,7 @@
1
1
  module Her
2
2
  module Model
3
3
  class Relation
4
+
4
5
  # @private
5
6
  attr_accessor :params
6
7
  attr_writer :parent
@@ -32,7 +33,7 @@ module Her
32
33
  # # Fetched via GET "/users?approved=1"
33
34
  def where(params = {})
34
35
  return self if params.blank? && !@_fetch.nil?
35
- self.clone.tap do |r|
36
+ clone.tap do |r|
36
37
  r.params = r.params.merge(params)
37
38
  r.clear_fetch_cache!
38
39
  end
@@ -58,7 +59,7 @@ module Her
58
59
 
59
60
  # @private
60
61
  def kind_of?(thing)
61
- fetch.kind_of?(thing)
62
+ fetch.is_a?(thing)
62
63
  end
63
64
 
64
65
  # Fetch a collection of resources
@@ -68,7 +69,7 @@ module Her
68
69
  @_fetch ||= begin
69
70
  path = @parent.build_request_path(@parent.collection_path, @params)
70
71
  method = @parent.method_for(:find)
71
- @parent.request(@params.merge(:_method => method, :_path => path)) do |parsed_data, response|
72
+ @parent.request(@params.merge(:_method => method, :_path => path)) do |parsed_data, _|
72
73
  @parent.new_collection(parsed_data)
73
74
  end
74
75
  end
@@ -106,7 +107,7 @@ module Her
106
107
  resource
107
108
  end
108
109
 
109
- ids.length > 1 || ids.first.kind_of?(Array) ? results : results.first
110
+ ids.length > 1 || ids.first.is_a?(Array) ? results : results.first
110
111
  end
111
112
 
112
113
  # Fetch first resource with the given attributes.
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "spec_helper.rb")
3
4
 
4
5
  describe Her::API do
@@ -32,6 +33,7 @@ describe Her::API do
32
33
  describe "#request" do
33
34
  before do
34
35
  class SimpleParser < Faraday::Response::Middleware
36
+
35
37
  def on_complete(env)
36
38
  env[:body] = { data: env[:body] }
37
39
  end
@@ -85,6 +87,7 @@ describe Her::API do
85
87
  let(:parsed_data) { subject.request(_method: :get, _path: "users/1")[:parsed_data] }
86
88
  before do
87
89
  class CustomParser < Faraday::Response::Middleware
90
+
88
91
  def on_complete(env)
89
92
  json = MultiJson.load(env[:body], symbolize_keys: true)
90
93
  errors = json.delete(:errors) || []
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::AcceptJSON do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::FirstLevelParseJSON do
@@ -31,7 +32,7 @@ describe Her::Middleware::FirstLevelParseJSON do
31
32
  end
32
33
 
33
34
  it "ensures the errors are a hash if there are no errors" do
34
- expect(subject.parse(body_with_errors)[:errors]).to eq(name: %w(not_valid should_be_present))
35
+ expect(subject.parse(body_with_errors)[:errors]).to eq(name: %w[not_valid should_be_present])
35
36
  end
36
37
 
37
38
  it "ensures that malformed JSON throws an exception" do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::JsonApiParser do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::SecondLevelParseJSON do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Model::Associations::AssociationProxy do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Associations do
@@ -296,7 +297,7 @@ describe Her::Model::Associations do
296
297
  stub.get("/users/1/comments") { [200, {}, [{ comment: { id: 4, body: "They're having a FIRESALE?" } }].to_json] }
297
298
  stub.get("/users/1/role") { [200, {}, { id: 3, body: "User" }.to_json] }
298
299
  stub.get("/users/1/posts") { [200, {}, [{ id: 1, body: "blogging stuff", admin_id: 1 }].to_json] }
299
- stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
300
+ stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
300
301
  end
301
302
  end
302
303
  end
@@ -558,7 +559,7 @@ describe Her::Model::Associations do
558
559
  builder.adapter :test do |stub|
559
560
  stub.get("/users/1") { [200, {}, { user: { id: 1, name: "Tobias Fünke", comments: [{ id: 2, body: "Tobias, you blow hard!", user_id: 1 }, { id: 3, body: "I wouldn't mind kissing that man between the cheeks, so to speak", user_id: 1 }], role: { id: 1, body: "Admin" }, organization: { id: 1, name: "Bluth Company" }, organization_id: 1 } }.to_json] }
560
561
  stub.get("/users/1/comments") { [200, {}, { comments: [{ id: 4, body: "They're having a FIRESALE?" }] }.to_json] }
561
- stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
562
+ stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
562
563
  end
563
564
  end
564
565
  end
@@ -616,7 +617,7 @@ describe Her::Model::Associations do
616
617
  stub.get("/users/2") { [200, {}, { user: { id: 2, name: "Lindsay Fünke", organization_id: 1 } }.to_json] }
617
618
  stub.get("/users/2/comments") { [200, {}, { comments: [{ id: 4, body: "They're having a FIRESALE?" }, { id: 5, body: "Is this the tiny town from Footloose?" }] }.to_json] }
618
619
  stub.get("/users/2/comments/5") { [200, {}, { comment: { id: 5, body: "Is this the tiny town from Footloose?" } }.to_json] }
619
- stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
620
+ stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
620
621
  end
621
622
  end
622
623
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Attributes do
@@ -164,11 +165,11 @@ describe Her::Model::Attributes do
164
165
  store_metadata :my_data
165
166
  end
166
167
 
167
- @user = Foo::User.new(_errors: %w(Foo Bar), _metadata: { secret: true })
168
+ @user = Foo::User.new(_errors: %w[Foo Bar], _metadata: { secret: true })
168
169
  end
169
170
 
170
171
  it "should return response_errors stored in the method provided by `store_response_errors`" do
171
- expect(@user.errors).to eq(%w(Foo Bar))
172
+ expect(@user.errors).to eq(%w[Foo Bar])
172
173
  end
173
174
 
174
175
  it "should remove the default method for errors" do
@@ -204,7 +205,7 @@ describe Her::Model::Attributes do
204
205
 
205
206
  spawn_model "Foo::User" do
206
207
  def document
207
- self.attributes[:document][:url]
208
+ attributes[:document][:url]
208
209
  end
209
210
  end
210
211
  end
@@ -310,6 +311,7 @@ describe Her::Model::Attributes do
310
311
  context "when attribute methods are already defined" do
311
312
  before do
312
313
  class AbstractUser
314
+
313
315
  def fullname
314
316
  raise NotImplementedError
315
317
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe "Her::Model and ActiveModel::Callbacks" do
@@ -6,12 +7,10 @@ describe "Her::Model and ActiveModel::Callbacks" do
6
7
  Her::API.setup url: "https://api.example.com" do |builder|
7
8
  builder.use Her::Middleware::FirstLevelParseJSON
8
9
  end
9
-
10
- spawn_model "Foo::User"
11
10
  end
12
11
 
13
12
  context :before_save do
14
- subject { Foo::User.create(name: "Tobias Funke") }
13
+ subject { User.create(name: "Tobias Funke") }
15
14
  before do
16
15
  Her::API.default_api.connection.adapter :test do |stub|
17
16
  stub.post("/users") { |env| [200, {}, { id: 1, name: env[:body][:name] }.to_json] }
@@ -21,7 +20,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
21
20
 
22
21
  context "when using a symbol callback" do
23
22
  before do
24
- class Foo::User
23
+ spawn_model "User" do
25
24
  before_save :alter_name
26
25
  def alter_name
27
26
  name.upcase!
@@ -37,7 +36,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
37
36
 
38
37
  context "when using a block callback" do
39
38
  before do
40
- class Foo::User
39
+ spawn_model "User" do
41
40
  before_save -> { name.upcase! }
42
41
  end
43
42
  end
@@ -50,7 +49,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
50
49
 
51
50
  context "when changing a value of an existing resource in a callback" do
52
51
  before do
53
- class Foo::User
52
+ spawn_model "User" do
54
53
  before_save :alter_name
55
54
  def alter_name
56
55
  self.name = "Lumberjack" if persisted?
@@ -67,7 +66,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
67
66
  end
68
67
 
69
68
  context :before_create do
70
- subject { Foo::User.create(name: "Tobias Funke") }
69
+ subject { User.create(name: "Tobias Funke") }
71
70
  before do
72
71
  Her::API.default_api.connection.adapter :test do |stub|
73
72
  stub.post("/users") { |env| [200, {}, { id: 1, name: env[:body][:name] }.to_json] }
@@ -76,7 +75,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
76
75
 
77
76
  context "when using a symbol callback" do
78
77
  before do
79
- class Foo::User
78
+ spawn_model "User" do
80
79
  before_create :alter_name
81
80
  def alter_name
82
81
  name.upcase!
@@ -92,7 +91,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
92
91
 
93
92
  context "when using a block callback" do
94
93
  before do
95
- class Foo::User
94
+ spawn_model "User" do
96
95
  before_create -> { name.upcase! }
97
96
  end
98
97
  end
@@ -105,7 +104,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
105
104
  end
106
105
 
107
106
  context :after_find do
108
- subject { Foo::User.find(1) }
107
+ subject { User.find(1) }
109
108
  before do
110
109
  Her::API.default_api.connection.adapter :test do |stub|
111
110
  stub.get("/users/1") { [200, {}, { id: 1, name: "Tobias Funke" }.to_json] }
@@ -114,7 +113,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
114
113
 
115
114
  context "when using a symbol callback" do
116
115
  before do
117
- class Foo::User
116
+ spawn_model "User" do
118
117
  after_find :alter_name
119
118
  def alter_name
120
119
  name.upcase!
@@ -130,7 +129,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
130
129
 
131
130
  context "when using a block callback" do
132
131
  before do
133
- class Foo::User
132
+ spawn_model "User" do
134
133
  after_find -> { name.upcase! }
135
134
  end
136
135
  end
@@ -143,11 +142,11 @@ describe "Her::Model and ActiveModel::Callbacks" do
143
142
  end
144
143
 
145
144
  context :after_initialize do
146
- subject { Foo::User.new(name: "Tobias Funke") }
145
+ subject { User.new(name: "Tobias Funke") }
147
146
 
148
147
  context "when using a symbol callback" do
149
148
  before do
150
- class Foo::User
149
+ spawn_model "User" do
151
150
  after_initialize :alter_name
152
151
  def alter_name
153
152
  name.upcase!
@@ -163,7 +162,7 @@ describe "Her::Model and ActiveModel::Callbacks" do
163
162
 
164
163
  context "when using a block callback" do
165
164
  before do
166
- class Foo::User
165
+ spawn_model "User" do
167
166
  after_initialize -> { name.upcase! }
168
167
  end
169
168
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe "Her::Model and ActiveModel::Dirty" do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::HTTP do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Introspection do
@@ -38,7 +39,7 @@ describe Her::Model::Introspection do
38
39
  @user.instance_eval do
39
40
  def password
40
41
  "filtered"
41
- end
42
+ end
42
43
  end
43
44
  expect(@user.inspect).to include("name=\"Tobias Funke\"")
44
45
  expect(@user.inspect).to include("password=\"filtered\"")
@@ -73,7 +74,7 @@ describe Her::Model::Introspection do
73
74
  expect(Foo::User.her_nearby_class("AccessRecord")).to eq(Foo::AccessRecord)
74
75
  expect(AccessRecord.her_nearby_class("Log")).to eq(Log)
75
76
  expect(Foo::User.her_nearby_class("Log")).to eq(Log)
76
- expect{Foo::User.her_nearby_class("X")}.to raise_error(NameError)
77
+ expect { Foo::User.her_nearby_class("X") }.to raise_error(NameError)
77
78
  end
78
79
  end
79
80
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::NestedAttributes do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::ORM do
@@ -73,10 +74,10 @@ describe Her::Model::ORM do
73
74
  builder.use Her::Middleware::SecondLevelParseJSON
74
75
  builder.use Faraday::Request::UrlEncoded
75
76
  builder.adapter :test do |stub|
76
- stub.get("/users") { [200, {}, { data: [{ id: 1, name: "Tobias Fünke" }, { id: 2, name: "Lindsay Fünke" }], metadata: { total_pages: 10, next_page: 2 }, errors: %w(Oh My God) }.to_json] }
77
- stub.get("/users") { |env| [200, {}, { :data => [{ :id => 1, :name => "Tobias Fünke" }, { :id => 2, :name => "Lindsay Fünke" }], :metadata => { :total_pages => 10, :next_page => 2 }, :errors => ["Oh", "My", "God"] }.to_json] }
78
- stub.post("/users") { |env| [200, {}, { :data => { :name => "George Michael Bluth" }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
79
- stub.delete("/users/1") { |env| [200, {}, { :data => { :id => 1 }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
77
+ stub.get("/users") { [200, {}, { data: [{ id: 1, name: "Tobias Fünke" }, { id: 2, name: "Lindsay Fünke" }], metadata: { total_pages: 10, next_page: 2 }, errors: %w[Oh My God] }.to_json] }
78
+ stub.get("/users") { [200, {}, { :data => [{ :id => 1, :name => "Tobias Fünke" }, { :id => 2, :name => "Lindsay Fünke" }], :metadata => { :total_pages => 10, :next_page => 2 }, :errors => ["Oh", "My", "God"] }.to_json] }
79
+ stub.post("/users") { [200, {}, { :data => { :name => "George Michael Bluth" }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
80
+ stub.delete("/users/1") { [200, {}, { :data => { :id => 1 }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
80
81
  end
81
82
  end
82
83
 
@@ -102,7 +103,7 @@ describe Her::Model::ORM do
102
103
 
103
104
  it "handles error data on a resource" do
104
105
  @user = User.create(name: "George Michael Bluth")
105
- expect(@user.response_errors).to eq(%w(Yes Sir))
106
+ expect(@user.response_errors).to eq(%w[Yes Sir])
106
107
  end
107
108
 
108
109
  it "handles metadata on a destroyed resource" do
@@ -112,7 +113,7 @@ describe Her::Model::ORM do
112
113
 
113
114
  it "handles error data on a destroyed resource" do
114
115
  @user = User.destroy_existing(1)
115
- expect(@user.response_errors).to eq(%w(Yes Sir))
116
+ expect(@user.response_errors).to eq(%w[Yes Sir])
116
117
  end
117
118
  end
118
119
 
@@ -123,8 +124,8 @@ describe Her::Model::ORM do
123
124
  builder.use Her::Middleware::SecondLevelParseJSON
124
125
  builder.use Faraday::Request::UrlEncoded
125
126
  builder.adapter :test do |stub|
126
- stub.get("/users") { [200, {}, { data: [{ id: 1, name: "Tobias Fünke" }, { id: 2, name: "Lindsay Fünke" }], metadata: { total_pages: 10, next_page: 2 }, errors: %w(Oh My God) }.to_json] }
127
- stub.post("/users") { [200, {}, { data: { name: "George Michael Bluth" }, metadata: { foo: "bar" }, errors: %w(Yes Sir) }.to_json] }
127
+ stub.get("/users") { [200, {}, { data: [{ id: 1, name: "Tobias Fünke" }, { id: 2, name: "Lindsay Fünke" }], metadata: { total_pages: 10, next_page: 2 }, errors: %w[Oh My God] }.to_json] }
128
+ stub.post("/users") { [200, {}, { data: { name: "George Michael Bluth" }, metadata: { foo: "bar" }, errors: %w[Yes Sir] }.to_json] }
128
129
  end
129
130
  end
130
131
 
@@ -150,7 +151,7 @@ describe Her::Model::ORM do
150
151
 
151
152
  it "handles error data on a resource" do
152
153
  @user = User.create(name: "George Michael Bluth")
153
- expect(@user.response_errors).to eq(%w(Yes Sir))
154
+ expect(@user.response_errors).to eq(%w[Yes Sir])
154
155
  end
155
156
  end
156
157
 
@@ -161,7 +162,7 @@ describe Her::Model::ORM do
161
162
  builder.use Her::Middleware::FirstLevelParseJSON
162
163
  builder.use Faraday::Request::UrlEncoded
163
164
  builder.adapter :test do |stub|
164
- stub.get("/users/1") { [200, {}, { id: 1, friends: %w(Maeby GOB Anne) }.to_json] }
165
+ stub.get("/users/1") { [200, {}, { id: 1, friends: %w[Maeby GOB Anne] }.to_json] }
165
166
  stub.get("/users/2") { [200, {}, { id: 1 }.to_json] }
166
167
  end
167
168
  end
@@ -185,7 +186,7 @@ describe Her::Model::ORM do
185
186
  @user = User.find(1)
186
187
  expect(@user.friends).to eq("* Maeby\n* GOB\n* Anne")
187
188
  @user.instance_eval do
188
- @_her_attributes[:friends] = %w(Maeby GOB Anne)
189
+ @_her_attributes[:friends] = %w[Maeby GOB Anne]
189
190
  end
190
191
  end
191
192
 
@@ -194,7 +195,7 @@ describe Her::Model::ORM do
194
195
  @user.friends = "* George\n* Oscar\n* Lucille"
195
196
  expect(@user.friends).to eq("* George\n* Oscar\n* Lucille")
196
197
  @user.instance_eval do
197
- @_her_attributes[:friends] = %w(George Oscar Lucille)
198
+ @_her_attributes[:friends] = %w[George Oscar Lucille]
198
199
  end
199
200
  end
200
201
  end
@@ -492,10 +493,10 @@ describe Her::Model::ORM do
492
493
  stub.get("/users/1") { [200, {}, { id: 1, fullname: "Tobias Fünke", active: true }.to_json] }
493
494
  stub.delete("/users/1") { [status, {}, { id: 1, fullname: "Lindsay Fünke", active: false }.to_json] }
494
495
 
495
- stub.get("/child_users") { [200, {}, { data: [{ id: 1, name: "Tobias Fünke" }, { id: 2, name: "Lindsay Fünke" }], metadata: { total_pages: 10, next_page: 2 }, errors: %w(Oh My God) }.to_json] }
496
- stub.get("/child_users") { |env| [200, {}, { :data => [{ :id => 1, :name => "Tobias Fünke" }, { :id => 2, :name => "Lindsay Fünke" }], :metadata => { :total_pages => 10, :next_page => 2 }, :errors => ["Oh", "My", "God"] }.to_json] }
497
- stub.post("/child_users") { |env| [200, {}, { :data => { :name => "George Michael Bluth" }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
498
- stub.delete("/child_users/1") { |env| [200, {}, { :data => { :id => 1 }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
496
+ stub.get("/child_users") { [200, {}, { data: [{ id: 1, name: "Tobias Fünke" }, { id: 2, name: "Lindsay Fünke" }], metadata: { total_pages: 10, next_page: 2 }, errors: %w[Oh My God] }.to_json] }
497
+ stub.get("/child_users") { [200, {}, { :data => [{ :id => 1, :name => "Tobias Fünke" }, { :id => 2, :name => "Lindsay Fünke" }], :metadata => { :total_pages => 10, :next_page => 2 }, :errors => ["Oh", "My", "God"] }.to_json] }
498
+ stub.post("/child_users") { [200, {}, { :data => { :name => "George Michael Bluth" }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
499
+ stub.delete("/child_users/1") { [200, {}, { :data => { :id => 1 }, :metadata => { :foo => "bar" }, :errors => ["Yes", "Sir"] }.to_json] }
499
500
  end
500
501
  end
501
502
 
@@ -652,10 +653,15 @@ describe Her::Model::ORM do
652
653
  after_create :after_create_callback
653
654
  after_save :after_save_callback
654
655
  def before_save_callback; end
656
+
655
657
  def before_create_callback; end
658
+
656
659
  def before_update_callback; end
660
+
657
661
  def after_update_callback; end
662
+
658
663
  def after_create_callback; end
664
+
659
665
  def after_save_callback; end
660
666
  end
661
667
  end