Sha256: 1b9eefe6dc50bf488f7b2a2dce178420f33dde0f21e58be9ac5ed6070b141629

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

describe "Transaction" do
  it "01" do
    param = mock.blank? {true}
    User.each_with_transaction(param).should == :empty
  end

  it '02' do
    5.times { Factory(:user) }
    ids = User.all.map(&:id)
    ids << (ids.last + 10)

    User.each_with_transaction(ids).should == :error
    
  end

  it '03' do
    5.times { Factory(:user) }
    ids = User.all.map(&:id)

    User.each_with_transaction(ids) do |user|
      user.update_attributes(:name => "cool")
    end.should == :success

    User.all.map(&:name).all? {|name| name == "cool"}.should be_true
  end



  it '04' do
    user = Factory(:user, :name => "i" * 100)
    user.should be_persisted

    params = {:name => "cool"}
    mock.instance_of(User).update_attributes(params) { false }
    

    User.each_with_transaction([user.id]) do |user|
      user.update_attributes(params)
    end.should == :error
  end



end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
induction_cannon_01-0.0.5 spec/models/base/transaction_spec.rb
induction_cannon_01-0.0.3 spec/models/base/transaction_spec.rb