Sha256: 02728aea3566fae0dd7f90c0651776669caf6cd2449e675f8a22189cf0d63618

Contents?: true

Size: 902 Bytes

Versions: 13

Compression:

Stored size: 902 Bytes

Contents

require 'spec_helper'

module ApiResource
  module Associations
    
    describe HasManyRemoteObjectProxy do

      before(:all) 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

13 entries across 13 versions & 1 rubygems

Version Path
api_resource-0.6.18 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.17 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.16 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.15 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.14 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.13 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.12 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.11 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.9 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.10 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.8 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.7 spec/lib/associations/has_many_remote_object_proxy_spec.rb
api_resource-0.6.6 spec/lib/associations/has_many_remote_object_proxy_spec.rb