Sha256: b2d2f152b7079827a43683bc94d1017784a7f22a51aab303097b9fd5d0178022

Contents?: true

Size: 891 Bytes

Versions: 7

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'

module ApiResource
  module Associations

    describe HasManyRemoteObjectProxy do

      before(:each) do
        TestResource.reload_resource_definition
      end

      context "#<<" do

        it "implements the shift operator" do
          tr = TestResource.new
          tr.has_many_objects << HasManyObject.new

          tr.has_many_objects.length.should be 1
        end

      end

      context "#load" do

        it "does a find based on its set of ids if present" do
          tr = TestResource.new
          tr.has_many_object_ids = [1,2]

          HasManyObject.connection.expects(:get)
            .with("/has_many_objects.json?ids%5B%5D=1&ids%5B%5D=2")
            .returns([{"name" => "Test"}])

          tr.has_many_objects.length.should be 1
          tr.has_many_objects.first.name.should eql("Test")

        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
api_resource-0.6.25 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.24 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.23 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.22 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.21 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.20 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.19 spec/lib/associations/has_many_remote_object_proxy_spec.rb