Sha256: 74ac0a9cff4d01b788d499f6f739a18369a31fede7fd14b6455f0bdacfdeb335

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

require 'spec_helper'

shared_examples_for "an apartment elevator" do

  context "single request" do
    it "should switch the db" do
      ActiveRecord::Base.connection.schema_search_path.should_not == %{"#{db1}"}

      visit(domain1)
      ActiveRecord::Base.connection.schema_search_path.should == %{"#{db1}"}
    end
  end

  context "simultaneous requests" do

    let!(:c1_user_count) { api.process(db1){ (2 + rand(2)).times{ User.create } } }
    let!(:c2_user_count) { api.process(db2){ (c1_user_count + 2).times{ User.create } } }

    it "should fetch the correct user count for each session based on the elevator processor" do
      visit(domain1)

      in_new_session do |session|
        session.visit(domain2)
        User.count.should == c2_user_count
      end

      visit(domain1)
      User.count.should == c1_user_count
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apartment-0.23.0 spec/examples/elevator_examples.rb