Sha256: 5fb53b20cc1028fea3f6f9ca974e7b26fbc9c218f8af0e4c5829f0a3895258e1

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

if defined?(JRUBY_VERSION)

  require 'spec_helper'
  require 'apartment/adapters/jdbc_postgresql_adapter'

  describe Apartment::Adapters::JDBCPostgresqlAdapter, database: :postgresql do

    subject { Apartment::Tenant.jdbc_postgresql_adapter config.symbolize_keys }

    context "using schemas" do

      before { Apartment.use_schemas = true }

      # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
      def tenant_names
        ActiveRecord::Base.connection.execute("SELECT nspname FROM pg_namespace;").collect { |row| row['nspname'] }
      end

      let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.schema_search_path.gsub('"', '') } }

      it_should_behave_like "a generic apartment adapter"
      it_should_behave_like "a schema based apartment adapter"
    end

    context "using databases" do

      before { Apartment.use_schemas = false }

      # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
      def tenant_names
        connection.execute("select datname from pg_database;").collect { |row| row['datname'] }
      end

      let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } }

      it_should_behave_like "a generic apartment adapter"
      it_should_behave_like "a connection based apartment adapter"

    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ros-apartment-2.3.0 spec/adapters/jdbc_postgresql_adapter_spec.rb
ros-apartment-2.3.0.alpha2 spec/adapters/jdbc_postgresql_adapter_spec.rb
ros-apartment-2.3.0.alpha1 spec/adapters/jdbc_postgresql_adapter_spec.rb
apartment-2.2.1 spec/adapters/jdbc_postgresql_adapter_spec.rb
apartment-2.2.0 spec/adapters/jdbc_postgresql_adapter_spec.rb
apartment-2.1.0 spec/adapters/jdbc_postgresql_adapter_spec.rb
apartment-2.0.0 spec/adapters/jdbc_postgresql_adapter_spec.rb
apartment-1.2.0 spec/adapters/jdbc_postgresql_adapter_spec.rb
apartment-1.1.0 spec/adapters/jdbc_postgresql_adapter_spec.rb