Sha256: 46729c064ea0948128194e5b0e5d976e7fdbef8f1947245c3bff4038bbb9a665

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe "Dynamoid::Associations::HasAndBelongsToMany" do

  before do
    @subscription = Subscription.create
  end
  
  it 'determines equality from its records' do
    @user = @subscription.users.create
    
    @subscription.users.size.should == 1
    @subscription.users.should include @user
  end

  it 'determines target association correctly' do
    @subscription.users.send(:target_association).should == :subscriptions
  end
  
  it 'determines target attribute' do
    @subscription.users.send(:target_attribute).should == :subscriptions_ids
  end
  
  it 'associates has_and_belongs_to_many automatically' do
    @user = @subscription.users.create
    
    @user.subscriptions.size.should == 1
    @user.subscriptions.should include @subscription
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dynamoid-0.0.2 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb