Sha256: 29115f93c487bd9f33f6874d6a678267cb93a2b2d6402fa445d67a2ee45d54f1

Contents?: true

Size: 1010 Bytes

Versions: 16

Compression:

Stored size: 1010 Bytes

Contents

require 'spec_helper'

describe ActiveRecord::Turntable::Migration 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

  describe ".target_shards" do
    subject { migration_class.new.target_shards }

    context "With clusters definitions" do
      let(:migration_class) {
        klass = Class.new(ActiveRecord::Migration) {
        clusters :user_cluster
        }
      }
      let(:cluster_config) { ActiveRecord::Base.turntable_config["clusters"]["user_cluster"] }
      let(:user_cluster_shards) { cluster_config["shards"].map { |s| s["connection"] } }

      it { is_expected.to eq(user_cluster_shards) }
    end

    context "With shards definitions" do
      let(:migration_class) {
        klass = Class.new(ActiveRecord::Migration) {
          shards :user_shard_01
        }
      }

      it { is_expected.to eq([:user_shard_01]) }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
activerecord-turntable-2.5.0 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.4.0 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.3.3 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.3.2 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.3.1 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.3.0 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.2.2 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.2.1 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.2.0 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.1.1 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.1.0 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.1.0.rc2 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.1.0.rc1 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.1.0.beta2 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.1.0.beta1 spec/active_record/turntable/active_record_ext/migration_spec.rb
activerecord-turntable-2.0.6 spec/active_record/turntable/active_record_ext/migration_spec.rb