test_track_rails_client 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -7
- data/Rakefile +8 -4
- data/app/models/test_track/analytics/mixpanel_client.rb +2 -5
- data/app/models/test_track/analytics/safe_wrapper.rb +4 -4
- data/app/models/test_track/config_updater.rb +2 -2
- data/app/models/test_track/fake/split_registry.rb +2 -2
- data/app/models/test_track/notify_assignment_job.rb +3 -4
- data/app/models/test_track/offline_session.rb +6 -4
- data/app/models/test_track/remote/split_registry.rb +2 -2
- data/app/models/test_track/remote/visitor.rb +2 -2
- data/app/models/test_track/session.rb +12 -73
- data/app/models/test_track/unsynced_assignments_notifier.rb +2 -4
- data/app/models/test_track/vary_dsl.rb +5 -1
- data/app/models/test_track/visitor.rb +0 -11
- data/lib/test_track_rails_client/version.rb +1 -1
- data/vendor/gems/fakeable_her/fakeable_her.gemspec +2 -3
- data/vendor/gems/her/her.gemspec +4 -5
- data/vendor/gems/her/lib/her/api.rb +1 -1
- data/vendor/gems/her/lib/her/model/associations/association_proxy.rb +1 -2
- data/vendor/gems/her/lib/her/model/orm.rb +41 -29
- data/vendor/gems/her/lib/her/model/parse.rb +1 -0
- data/vendor/gems/her/lib/her/model/relation.rb +21 -6
- data/vendor/gems/her/lib/her/version.rb +1 -1
- metadata +52 -139
- data/app/models/test_track/create_alias_job.rb +0 -18
- data/vendor/gems/her/CONTRIBUTING.md +0 -26
- data/vendor/gems/her/Gemfile +0 -10
- data/vendor/gems/her/README.md +0 -1023
- data/vendor/gems/her/Rakefile +0 -11
- data/vendor/gems/her/UPGRADE.md +0 -101
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-3.2.x +0 -7
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.0 +0 -7
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.1 +0 -7
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.2 +0 -7
- data/vendor/gems/her/spec/api_spec.rb +0 -114
- data/vendor/gems/her/spec/collection_spec.rb +0 -26
- data/vendor/gems/her/spec/error_collection_spec.rb +0 -33
- data/vendor/gems/her/spec/json_api/model_spec.rb +0 -168
- data/vendor/gems/her/spec/middleware/accept_json_spec.rb +0 -10
- data/vendor/gems/her/spec/middleware/first_level_parse_json_spec.rb +0 -62
- data/vendor/gems/her/spec/middleware/json_api_parser_spec.rb +0 -32
- data/vendor/gems/her/spec/middleware/second_level_parse_json_spec.rb +0 -35
- data/vendor/gems/her/spec/model/associations/association_proxy_spec.rb +0 -31
- data/vendor/gems/her/spec/model/associations_spec.rb +0 -504
- data/vendor/gems/her/spec/model/attributes_spec.rb +0 -404
- data/vendor/gems/her/spec/model/callbacks_spec.rb +0 -145
- data/vendor/gems/her/spec/model/dirty_spec.rb +0 -110
- data/vendor/gems/her/spec/model/http_spec.rb +0 -165
- data/vendor/gems/her/spec/model/introspection_spec.rb +0 -76
- data/vendor/gems/her/spec/model/nested_attributes_spec.rb +0 -134
- data/vendor/gems/her/spec/model/orm_spec.rb +0 -791
- data/vendor/gems/her/spec/model/parse_spec.rb +0 -372
- data/vendor/gems/her/spec/model/paths_spec.rb +0 -347
- data/vendor/gems/her/spec/model/relation_spec.rb +0 -226
- data/vendor/gems/her/spec/model/validations_spec.rb +0 -42
- data/vendor/gems/her/spec/model_spec.rb +0 -31
- data/vendor/gems/her/spec/spec_helper.rb +0 -27
- data/vendor/gems/her/spec/support/extensions/array.rb +0 -5
- data/vendor/gems/her/spec/support/extensions/hash.rb +0 -5
- data/vendor/gems/her/spec/support/macros/her_macros.rb +0 -17
- data/vendor/gems/her/spec/support/macros/model_macros.rb +0 -36
- data/vendor/gems/her/spec/support/macros/request_macros.rb +0 -27
- data/vendor/gems/publicsuffix-ruby/CHANGELOG.md +0 -236
- data/vendor/gems/publicsuffix-ruby/Gemfile +0 -3
- data/vendor/gems/publicsuffix-ruby/LICENSE.txt +0 -22
- data/vendor/gems/publicsuffix-ruby/README.md +0 -151
- data/vendor/gems/publicsuffix-ruby/Rakefile +0 -109
- data/vendor/gems/publicsuffix-ruby/lib/definitions.txt +0 -11467
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/domain.rb +0 -387
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/errors.rb +0 -53
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/list.rb +0 -302
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/rule.rb +0 -373
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/version.rb +0 -23
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix.rb +0 -131
- data/vendor/gems/publicsuffix-ruby/public_suffix.gemspec +0 -39
- data/vendor/gems/publicsuffix-ruby/test/acceptance_test.rb +0 -42
- data/vendor/gems/publicsuffix-ruby/test/test_helper.rb +0 -6
- data/vendor/gems/publicsuffix-ruby/test/unit/domain_test.rb +0 -170
- data/vendor/gems/publicsuffix-ruby/test/unit/errors_test.rb +0 -23
- data/vendor/gems/publicsuffix-ruby/test/unit/list_test.rb +0 -179
- data/vendor/gems/publicsuffix-ruby/test/unit/public_suffix_test.rb +0 -115
- data/vendor/gems/publicsuffix-ruby/test/unit/rule_test.rb +0 -307
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/capybara_configuration.rb +0 -98
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/matchers.rb +0 -151
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rspec_configuration.rb +0 -34
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/html_safe.rb +0 -15
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/raw.rb +0 -15
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/safe_concat.rb +0 -15
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop.rb +0 -3
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples/betterment_application_examples.rb +0 -43
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples.rb +0 -1
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_configuration.rb +0 -42
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_dropdown.rb +0 -17
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/version.rb +0 -3
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/webmock_configuration.rb +0 -8
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers.rb +0 -2
- data/vendor/gems/ruby_spec_helpers/ruby_spec_helpers.gemspec +0 -25
@@ -1,372 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.join(File.dirname(__FILE__), "../spec_helper.rb")
|
3
|
-
|
4
|
-
describe Her::Model::Parse do
|
5
|
-
context "when include_root_in_json is set" do
|
6
|
-
before do
|
7
|
-
Her::API.setup :url => "https://api.example.com" do |builder|
|
8
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
9
|
-
builder.use Faraday::Request::UrlEncoded
|
10
|
-
end
|
11
|
-
|
12
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
13
|
-
stub.post("/users") { |env| [200, {}, { :user => { :id => 1, :fullname => params(env)[:user][:fullname] } }.to_json] }
|
14
|
-
stub.post("/users/admins") { |env| [200, {}, { :user => { :id => 1, :fullname => params(env)[:user][:fullname] } }.to_json] }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "to true" do
|
19
|
-
before do
|
20
|
-
spawn_model "Foo::User" do
|
21
|
-
include_root_in_json true
|
22
|
-
parse_root_in_json true
|
23
|
-
custom_post :admins
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "wraps params in the element name in `to_params`" do
|
28
|
-
@new_user = Foo::User.new(:fullname => "Tobias Fünke")
|
29
|
-
@new_user.to_params.should == { :user => { :fullname => "Tobias Fünke" } }
|
30
|
-
end
|
31
|
-
|
32
|
-
it "wraps params in the element name in `.create`" do
|
33
|
-
@new_user = Foo::User.admins(:fullname => "Tobias Fünke")
|
34
|
-
@new_user.fullname.should == "Tobias Fünke"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "to a symbol" do
|
39
|
-
before do
|
40
|
-
spawn_model "Foo::User" do
|
41
|
-
include_root_in_json :person
|
42
|
-
parse_root_in_json :person
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "wraps params in the specified value" do
|
47
|
-
@new_user = Foo::User.new(:fullname => "Tobias Fünke")
|
48
|
-
@new_user.to_params.should == { :person => { :fullname => "Tobias Fünke" } }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "in the parent class" do
|
53
|
-
before do
|
54
|
-
spawn_model("Foo::Model") { include_root_in_json true }
|
55
|
-
|
56
|
-
class User < Foo::Model; end
|
57
|
-
@spawned_models << :User
|
58
|
-
end
|
59
|
-
|
60
|
-
it "wraps params with the class name" do
|
61
|
-
@new_user = User.new(:fullname => "Tobias Fünke")
|
62
|
-
@new_user.to_params.should == { :user => { :fullname => "Tobias Fünke" } }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when parse_root_in_json is set" do
|
68
|
-
before do
|
69
|
-
Her::API.setup :url => "https://api.example.com" do |builder|
|
70
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
71
|
-
builder.use Faraday::Request::UrlEncoded
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "to true" do
|
76
|
-
before do
|
77
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
78
|
-
stub.post("/users") { |env| [200, {}, { :user => { :id => 1, :fullname => "Lindsay Fünke" } }.to_json] }
|
79
|
-
stub.get("/users") { |env| [200, {}, [{ :user => { :id => 1, :fullname => "Lindsay Fünke" } }].to_json] }
|
80
|
-
stub.get("/users/admins") { |env| [200, {}, [{ :user => { :id => 1, :fullname => "Lindsay Fünke" } }].to_json] }
|
81
|
-
stub.get("/users/1") { |env| [200, {}, { :user => { :id => 1, :fullname => "Lindsay Fünke" } }.to_json] }
|
82
|
-
stub.put("/users/1") { |env| [200, {}, { :user => { :id => 1, :fullname => "Tobias Fünke Jr." } }.to_json] }
|
83
|
-
end
|
84
|
-
|
85
|
-
spawn_model("Foo::User") do
|
86
|
-
parse_root_in_json true
|
87
|
-
custom_get :admins
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it "parse the data from the JSON root element after .create" do
|
92
|
-
@new_user = Foo::User.create(:fullname => "Lindsay Fünke")
|
93
|
-
@new_user.fullname.should == "Lindsay Fünke"
|
94
|
-
end
|
95
|
-
|
96
|
-
it "parse the data from the JSON root element after an arbitrary HTTP request" do
|
97
|
-
@new_user = Foo::User.admins
|
98
|
-
@new_user.first.fullname.should == "Lindsay Fünke"
|
99
|
-
end
|
100
|
-
|
101
|
-
it "parse the data from the JSON root element after .all" do
|
102
|
-
@users = Foo::User.all
|
103
|
-
@users.first.fullname.should == "Lindsay Fünke"
|
104
|
-
end
|
105
|
-
|
106
|
-
it "parse the data from the JSON root element after .find" do
|
107
|
-
@user = Foo::User.find(1)
|
108
|
-
@user.fullname.should == "Lindsay Fünke"
|
109
|
-
end
|
110
|
-
|
111
|
-
it "parse the data from the JSON root element after .save" do
|
112
|
-
@user = Foo::User.find(1)
|
113
|
-
@user.fullname = "Tobias Fünke"
|
114
|
-
@user.save
|
115
|
-
@user.fullname.should == "Tobias Fünke Jr."
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context "to a symbol" do
|
120
|
-
before do
|
121
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
122
|
-
stub.post("/users") { |env| [200, {}, { :person => { :id => 1, :fullname => "Lindsay Fünke" } }.to_json] }
|
123
|
-
end
|
124
|
-
|
125
|
-
spawn_model("Foo::User") { parse_root_in_json :person }
|
126
|
-
end
|
127
|
-
|
128
|
-
it "parse the data with the symbol" do
|
129
|
-
@new_user = Foo::User.create(:fullname => "Lindsay Fünke")
|
130
|
-
@new_user.fullname.should == "Lindsay Fünke"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
context "in the parent class" do
|
135
|
-
before do
|
136
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
137
|
-
stub.post("/users") { |env| [200, {}, { :user => { :id => 1, :fullname => "Lindsay Fünke" } }.to_json] }
|
138
|
-
stub.get("/users") { |env| [200, {}, { :users => [ { :id => 1, :fullname => "Lindsay Fünke" } ] }.to_json] }
|
139
|
-
end
|
140
|
-
|
141
|
-
spawn_model("Foo::Model") { parse_root_in_json true, format: :active_model_serializers }
|
142
|
-
class User < Foo::Model
|
143
|
-
collection_path "/users"
|
144
|
-
end
|
145
|
-
|
146
|
-
@spawned_models << :User
|
147
|
-
end
|
148
|
-
|
149
|
-
it "parse the data with the symbol" do
|
150
|
-
@new_user = User.create(:fullname => "Lindsay Fünke")
|
151
|
-
@new_user.fullname.should == "Lindsay Fünke"
|
152
|
-
end
|
153
|
-
|
154
|
-
it "parses the collection of data" do
|
155
|
-
@users = User.all
|
156
|
-
@users.first.fullname.should == "Lindsay Fünke"
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context "to true with :format => :active_model_serializers" do
|
161
|
-
before do
|
162
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
163
|
-
stub.post("/users") { |env| [200, {}, { :user => { :id => 1, :fullname => "Lindsay Fünke" } }.to_json] }
|
164
|
-
stub.get("/users") { |env| [200, {}, { :users => [ { :id => 1, :fullname => "Lindsay Fünke" } ] }.to_json] }
|
165
|
-
stub.get("/users/admins") { |env| [200, {}, { :users => [ { :id => 1, :fullname => "Lindsay Fünke" } ] }.to_json] }
|
166
|
-
stub.get("/users/1") { |env| [200, {}, { :user => { :id => 1, :fullname => "Lindsay Fünke" } }.to_json] }
|
167
|
-
stub.put("/users/1") { |env| [200, {}, { :user => { :id => 1, :fullname => "Tobias Fünke Jr." } }.to_json] }
|
168
|
-
end
|
169
|
-
|
170
|
-
spawn_model("Foo::User") do
|
171
|
-
parse_root_in_json true, :format => :active_model_serializers
|
172
|
-
custom_get :admins
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
it "parse the data from the JSON root element after .create" do
|
177
|
-
@new_user = Foo::User.create(:fullname => "Lindsay Fünke")
|
178
|
-
@new_user.fullname.should == "Lindsay Fünke"
|
179
|
-
end
|
180
|
-
|
181
|
-
it "parse the data from the JSON root element after an arbitrary HTTP request" do
|
182
|
-
@users = Foo::User.admins
|
183
|
-
@users.first.fullname.should == "Lindsay Fünke"
|
184
|
-
end
|
185
|
-
|
186
|
-
it "parse the data from the JSON root element after .all" do
|
187
|
-
@users = Foo::User.all
|
188
|
-
@users.first.fullname.should == "Lindsay Fünke"
|
189
|
-
end
|
190
|
-
|
191
|
-
it "parse the data from the JSON root element after .find" do
|
192
|
-
@user = Foo::User.find(1)
|
193
|
-
@user.fullname.should == "Lindsay Fünke"
|
194
|
-
end
|
195
|
-
|
196
|
-
it "parse the data from the JSON root element after .save" do
|
197
|
-
@user = Foo::User.find(1)
|
198
|
-
@user.fullname = "Tobias Fünke"
|
199
|
-
@user.save
|
200
|
-
@user.fullname.should == "Tobias Fünke Jr."
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context "when to_params is set" do
|
206
|
-
before do
|
207
|
-
Her::API.setup :url => "https://api.example.com" do |builder|
|
208
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
209
|
-
builder.use Faraday::Request::UrlEncoded
|
210
|
-
builder.adapter :test do |stub|
|
211
|
-
stub.post("/users") { |env| ok! :id => 1, :fullname => params(env)['fullname'] }
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
spawn_model "Foo::User" do
|
216
|
-
def to_params
|
217
|
-
{ :fullname => "Lindsay Fünke" }
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
it "changes the request parameters for one-line resource creation" do
|
223
|
-
@user = Foo::User.create(:fullname => "Tobias Fünke")
|
224
|
-
@user.fullname.should == "Lindsay Fünke"
|
225
|
-
end
|
226
|
-
|
227
|
-
it "changes the request parameters for Model.new + #save" do
|
228
|
-
@user = Foo::User.new(:fullname => "Tobias Fünke")
|
229
|
-
@user.save
|
230
|
-
@user.fullname.should == "Lindsay Fünke"
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
context "when parse_root_in_json set json_api to true" do
|
235
|
-
before do
|
236
|
-
Her::API.setup :url => "https://api.example.com" do |builder|
|
237
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
238
|
-
builder.use Faraday::Request::UrlEncoded
|
239
|
-
builder.adapter :test do |stub|
|
240
|
-
stub.get("/users") { |env| [200, {}, { :users => [{ :id => 1, :fullname => "Lindsay Fünke" }] }.to_json] }
|
241
|
-
stub.get("/users/admins") { |env| [200, {}, { :users => [{ :id => 1, :fullname => "Lindsay Fünke" }] }.to_json] }
|
242
|
-
stub.get("/users/1") { |env| [200, {}, { :users => [{ :id => 1, :fullname => "Lindsay Fünke" }] }.to_json] }
|
243
|
-
stub.post("/users") { |env| [200, {}, { :users => [{ :fullname => "Lindsay Fünke" }] }.to_json] }
|
244
|
-
stub.put("/users/1") { |env| [200, {}, { :users => [{ :id => 1, :fullname => "Tobias Fünke Jr." }] }.to_json] }
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
spawn_model("Foo::User") do
|
249
|
-
parse_root_in_json true, :format => :json_api
|
250
|
-
include_root_in_json true
|
251
|
-
custom_get :admins
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
it "parse the data from the JSON root element after .create" do
|
256
|
-
@new_user = Foo::User.create(:fullname => "Lindsay Fünke")
|
257
|
-
@new_user.fullname.should == "Lindsay Fünke"
|
258
|
-
end
|
259
|
-
|
260
|
-
it "parse the data from the JSON root element after an arbitrary HTTP request" do
|
261
|
-
@new_user = Foo::User.admins
|
262
|
-
@new_user.first.fullname.should == "Lindsay Fünke"
|
263
|
-
end
|
264
|
-
|
265
|
-
it "parse the data from the JSON root element after .all" do
|
266
|
-
@users = Foo::User.all
|
267
|
-
@users.first.fullname.should == "Lindsay Fünke"
|
268
|
-
end
|
269
|
-
|
270
|
-
it "parse the data from the JSON root element after .find" do
|
271
|
-
@user = Foo::User.find(1)
|
272
|
-
@user.fullname.should == "Lindsay Fünke"
|
273
|
-
end
|
274
|
-
|
275
|
-
it "parse the data from the JSON root element after .save" do
|
276
|
-
@user = Foo::User.find(1)
|
277
|
-
@user.fullname = "Tobias Fünke"
|
278
|
-
@user.save
|
279
|
-
@user.fullname.should == "Tobias Fünke Jr."
|
280
|
-
end
|
281
|
-
|
282
|
-
it "parse the data from the JSON root element after new/save" do
|
283
|
-
@user = Foo::User.new
|
284
|
-
@user.fullname = "Lindsay Fünke (before save)"
|
285
|
-
@user.save
|
286
|
-
@user.fullname.should == "Lindsay Fünke"
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context "when include_root_in_json set json_api" do
|
291
|
-
before do
|
292
|
-
Her::API.setup :url => "https://api.example.com" do |builder|
|
293
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
294
|
-
builder.use Faraday::Request::UrlEncoded
|
295
|
-
end
|
296
|
-
|
297
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
298
|
-
stub.post("/users") { |env| [200, {}, { :users => [{ :id => 1, :fullname => params(env)[:users][:fullname] }] }.to_json] }
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
context "to true" do
|
303
|
-
before do
|
304
|
-
spawn_model "Foo::User" do
|
305
|
-
include_root_in_json true
|
306
|
-
parse_root_in_json true, format: :json_api
|
307
|
-
custom_post :admins
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
it "wraps params in the element name in `to_params`" do
|
312
|
-
@new_user = Foo::User.new(:fullname => "Tobias Fünke")
|
313
|
-
@new_user.to_params.should == { :users => [{ :fullname => "Tobias Fünke" }] }
|
314
|
-
end
|
315
|
-
|
316
|
-
it "wraps params in the element name in `.where`" do
|
317
|
-
@new_user = Foo::User.where(:fullname => "Tobias Fünke").build
|
318
|
-
@new_user.fullname.should == "Tobias Fünke"
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
context 'when send_only_modified_attributes is set' do
|
324
|
-
before do
|
325
|
-
Her::API.setup :url => "https://api.example.com", :send_only_modified_attributes => true do |builder|
|
326
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
327
|
-
builder.use Faraday::Request::UrlEncoded
|
328
|
-
end
|
329
|
-
|
330
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
331
|
-
stub.get("/users/1") { |env| [200, {}, { :id => 1, :first_name => "Gooby", :last_name => "Pls" }.to_json] }
|
332
|
-
end
|
333
|
-
|
334
|
-
spawn_model "Foo::User" do
|
335
|
-
include_root_in_json true
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
it 'only sends the attributes that were modified' do
|
340
|
-
user = Foo::User.find 1
|
341
|
-
user.first_name = 'Someone'
|
342
|
-
expect(user.to_params).to eql(:user => {:first_name => 'Someone'})
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
context 'when eagerly loaded association is empty' do
|
347
|
-
before do
|
348
|
-
Her::API.setup :url => "https://api.example.com", :send_only_modified_attributes => false do |builder|
|
349
|
-
builder.use Her::Middleware::FirstLevelParseJSON
|
350
|
-
builder.use Faraday::Request::UrlEncoded
|
351
|
-
end
|
352
|
-
|
353
|
-
Her::API.default_api.connection.adapter :test do |stub|
|
354
|
-
stub.get("/users/1") { |env| [200, {}, { :id => 1, :bars => [], :foos => [ { :id => 3 } ] }.to_json] }
|
355
|
-
end
|
356
|
-
|
357
|
-
spawn_model "Foo::Bar"
|
358
|
-
|
359
|
-
spawn_model "Foo::User" do
|
360
|
-
include_root_in_json true
|
361
|
-
|
362
|
-
has_many :bars, class_name: 'Foo::Bar'
|
363
|
-
has_many :foos, class_name: 'Foo::Bar'
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
it 'properly calls to_params on an empty collection' do
|
368
|
-
user = Foo::User.find 1
|
369
|
-
expect(user.to_params).to eql(:user => { :id => 1, :bars => [], :foos => [{:id=>3}] })
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|