Sha256: 00f237019aecaa2c4815f59231c2471ecd1b80747dbd4e1a8cd68153e248a8ca

Contents?: true

Size: 976 Bytes

Versions: 3

Compression:

Stored size: 976 Bytes

Contents

require "spec_helper"

describe "transaction" do
  before(:all) do
    reload_turntable!(File.join(File.dirname(__FILE__), "../../config/turntable.yml"))
  end

  before(:each) do
    establish_connection_to(:test)
    truncate_shard
  end
  let(:clusters) { ActiveRecord::Base.turntable_clusters }

  describe "all_cluster_transaction" do
    let(:all_clusters) { clusters.values }
    let(:shards) { all_clusters.flat_map { |c| c.shards.values } }

    it "all shards should begin transaction" do
      User.all_cluster_transaction {
        expect(shards.map(&:connection).map(&:open_transactions)).to all(be == 1)
      }
    end
  end

  describe "cluster_transaction" do
    let(:cluster) { clusters[:user_cluster] }
    let(:shards) { cluster.shards.values }

    it "all shards in the cluster should begin transaction" do
      User.user_cluster_transaction {
        expect(shards.map(&:connection).map(&:open_transactions)).to all(be == 1)
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-turntable-3.0.0.alpha3 spec/active_record/turntable/transaction_spec.rb
activerecord-turntable-3.0.0.alpha2 spec/active_record/turntable/transaction_spec.rb
activerecord-turntable-3.0.0.alpha1 spec/active_record/turntable/transaction_spec.rb