remotable 0.2.5.beta1 → 0.2.5.beta2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/remotable/adapters/active_resource.rb +19 -1
- data/lib/remotable/version.rb +1 -1
- data/test/active_resource_test.rb +42 -0
- data/test/support/active_resource.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bafa573e3a1665e4e5e26c14d06326d953de1232
|
4
|
+
data.tar.gz: 13cf353936b00ab92a8a1d1fd2dfc9d35098288f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df144f380b385f74558f8c5a8003a0b74962ac948fd72c23f4b97b5b0a459f3c1eddb6bf529c0c1b42f5dd915de7998fac23f46948b6efefc9b9d9b3cf09a3f
|
7
|
+
data.tar.gz: 8f8585e47f6dade2c263787546ff5ab0f7a95a291df5066d246d827296ed9b83d9b5255039d2ef10ca33dfdaecf70eaff7ab935767ba3c2bbfd9849cc5c38ac9
|
data/Gemfile.lock
CHANGED
@@ -24,6 +24,22 @@ module Remotable
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
# If we use `remote_key` to explicitly set the path where
|
28
|
+
# this resource ought to be found, then we should use the
|
29
|
+
# same path when updating or destroying this resource.
|
30
|
+
#
|
31
|
+
# To accomplish this, we need to override ActiveResource's
|
32
|
+
# element_path to return the canonical path for this resource.
|
33
|
+
|
34
|
+
attr_accessor :remote_key_path
|
35
|
+
|
36
|
+
def element_path(*args)
|
37
|
+
return remote_key_path if remote_key_path
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
27
43
|
module ClassMethods
|
28
44
|
|
29
45
|
IF_MODIFIED_SINCE = "If-Modified-Since".freeze
|
@@ -63,7 +79,9 @@ module Remotable
|
|
63
79
|
def find_by!(path)
|
64
80
|
expanded_path = expanded_path_for(path)
|
65
81
|
Remotable.logger.info "[remotable:#{name.underscore}] GET #{expanded_path} (timeout: #{timeout})"
|
66
|
-
find(:one, :from => expanded_path)
|
82
|
+
find(:one, :from => expanded_path).tap do |resource|
|
83
|
+
resource.remote_key_path = expanded_path if resource
|
84
|
+
end
|
67
85
|
rescue ::ActiveResource::TimeoutError
|
68
86
|
$!.extend Remotable::TimeoutError
|
69
87
|
raise
|
data/lib/remotable/version.rb
CHANGED
@@ -211,6 +211,29 @@ class ActiveResourceTest < ActiveSupport::TestCase
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
+
test "should be able to update resources by different attributes" do
|
215
|
+
tenant = RemoteWithKey.where(id: Factory(:tenant).id).first
|
216
|
+
new_name = "Totally Wonky"
|
217
|
+
|
218
|
+
RemoteTenant.run_simulation do |s|
|
219
|
+
s.show(nil, {
|
220
|
+
:id => tenant.id,
|
221
|
+
:slug => tenant.slug,
|
222
|
+
:church_name => tenant.name
|
223
|
+
}, :path => "/api/accounts/by_slug/#{tenant.slug}.json", :headers => if_modified_since(tenant))
|
224
|
+
|
225
|
+
s.update(nil, :path => "/api/accounts/by_slug/#{tenant.slug}.json")
|
226
|
+
|
227
|
+
tenant.nosync = false
|
228
|
+
tenant.name = new_name
|
229
|
+
assert_equal true, tenant.any_remote_changes?
|
230
|
+
|
231
|
+
tenant.save!
|
232
|
+
|
233
|
+
# pending "Not sure how to test that an update happened"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
214
237
|
test "should fail to update a record locally when failing to update one remotely" do
|
215
238
|
tenant = Factory(:tenant)
|
216
239
|
new_name = "Totally Wonky"
|
@@ -327,6 +350,25 @@ class ActiveResourceTest < ActiveSupport::TestCase
|
|
327
350
|
end
|
328
351
|
end
|
329
352
|
|
353
|
+
|
354
|
+
test "should destroy resources by different attributes" do
|
355
|
+
tenant = RemoteWithKey.where(id: Factory(:tenant).id).first
|
356
|
+
new_name = "Totally Wonky"
|
357
|
+
|
358
|
+
RemoteTenant.run_simulation do |s|
|
359
|
+
s.show(nil, {
|
360
|
+
:id => tenant.id,
|
361
|
+
:slug => tenant.slug,
|
362
|
+
:church_name => tenant.name
|
363
|
+
}, :path => "/api/accounts/by_slug/#{tenant.slug}.json", :headers => if_modified_since(tenant))
|
364
|
+
|
365
|
+
s.destroy(nil, :path => "/api/accounts/by_slug/#{tenant.slug}.json")
|
366
|
+
|
367
|
+
tenant.nosync = false
|
368
|
+
tenant.destroy
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
330
372
|
test "should fail to destroy a record locally when failing to destroy one remotely" do
|
331
373
|
tenant = Factory(:tenant)
|
332
374
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remotable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.5.
|
4
|
+
version: 0.2.5.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|