Sha256: b4395574ee9fd4c55a2c8340416915e6dfff1728b168f2da8d199fde9508d63d
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
shared_examples_for "basic user operations" do before do ActiveRecord::Base.connection.execute("TRUNCATE TABLE users") transactioner do |trans| 100.times do |count| user = User.new(username: "User #{count}", email: "user#{count}@example.com") trans.save!(user) end end end it "can create a lot of models" do User.count.should eq 100 end it "can both insert and update a lot of records correct" do transactioner do |trans| 200.times do |count| user = User.find_or_initialize_by(email: "user#{count}@example.com") user.username = "User upsert #{count}" trans.save!(user) end end count = 0 User.find_each do |user| user.email.should eq "user#{count}@example.com" count += 1 end User.count.should eq 200 end it "can delete a lot of records" do transactioner do |trans| User.limit(50).each do |user| trans.destroy!(user) end end User.count.should eq 50 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active-record-transactioner-0.0.6 | spec/support/basic_user_operations.rb |