api_client 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,8 @@ module ApiClient
49
49
  end
50
50
 
51
51
  def remote_update
52
- self.class.update(self.id, payload)
52
+ scope = original_scope || self.class
53
+ scope.update(self.id, payload)
53
54
  end
54
55
 
55
56
  def remote_create
@@ -1,3 +1,3 @@
1
1
  module ApiClient
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -41,7 +41,7 @@ describe ApiClient::Connection::Basic do
41
41
  it "can perform GET requests" do
42
42
  @instance.handler.should_receive(:get) do |path, headers|
43
43
  headers.should == @headers
44
- Faraday::Utils.parse_nested_query(path.split("?").last).should == @params
44
+ Faraday::Utils.send(:parse_nested_query, path.split("?").last).should == @params
45
45
  @response
46
46
  end
47
47
  @instance.get "/home", @params, @headers
@@ -60,7 +60,7 @@ describe ApiClient::Connection::Basic do
60
60
  it "can perform DELETE requests" do
61
61
  @instance.handler.should_receive(:delete) do |path, headers|
62
62
  headers.should == @headers
63
- Faraday::Utils.parse_nested_query(path.split("?").last).should == @params
63
+ Faraday::Utils.send(:parse_nested_query, path.split("?").last).should == @params
64
64
  @response
65
65
  end
66
66
  @instance.delete "/home", @params, @headers
@@ -62,6 +62,13 @@ describe ApiClient::Resource::Base do
62
62
  @instance.remote_update
63
63
  end
64
64
 
65
+ it "retains the original scope" do
66
+ ApiClient::Resource::Base.stub(:update)
67
+ @instance.original_scope = stub
68
+ @instance.original_scope.should_receive(:update).with(42, "name" => "Mike")
69
+ @instance.remote_update
70
+ end
71
+
65
72
  end
66
73
 
67
74
  describe "#remote_create" do
@@ -102,7 +102,7 @@ describe ApiClient::Resource::Scope do
102
102
  end
103
103
 
104
104
  it "performs a update to update an existing record skipping the namespace if it is not present" do
105
- @instance = ApiClient::Resource::Scope.new(Restful2)
105
+ @instance = ApiClient::Resource::Scope.new(Restful2)
106
106
  response = { "id" => 42, "name" => "Foo" }
107
107
  @instance.should_receive(:put).with('/restful2s/42.json', {:name => "Foo"} ).and_return(response)
108
108
  result = @instance.update(42, :name => "Foo")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: