Sha256: 6d155a155fc6579cf261dc4bcfd09814e499cfcc87586762f162406729d5e774

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

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
    @subscription.users.size.should == 1
    @subscription.users.should include @user
  end
  
  it 'disassociates has_and_belongs_to_many automatically' do
    @user = @subscription.users.create
    
    @subscription.users.delete(@user)
    @subscription.users.size.should == 0
    @user.subscriptions.size.should == 0
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dynamoid-0.2.0 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.1.2 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.1.1 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.1.0 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.0.7 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.0.6 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.0.5 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.0.4 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb
dynamoid-0.0.3 spec/dynamoid/associations/has_and_belongs_to_many_spec.rb