Sha256: 814f6cf667b3c88fa8ef8582201415f2f350c0c25fec0981054fc1953b4bd957
Contents?: true
Size: 1.97 KB
Versions: 4
Compression:
Stored size: 1.97 KB
Contents
require 'rails_helper' describe TbCore::Mysql2Extensions do let(:adapter){ SpudUser.connection } describe '#create_table' do before(:each){ allow_any_instance_of(ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter).to receive(:create_table) do |abstract_adapter, table_name, arguments| arguments[:options] end } it 'should pass the dynamic option' do options = adapter.create_table(:tests) expect(options).to match('ROW_FORMAT=DYNAMIC') end end describe '#length_options_for_utf8mb4_string_index' do it 'should return a hash with a single value' do options = adapter.length_options_for_utf8mb4_string_index(:spud_users, :first_name) expect(options).to eq({:first_name => 191}) end it 'should return a hash with multiple values' do options = adapter.length_options_for_utf8mb4_string_index(:spud_users, [:first_name, :last_name]) expect(options[:first_name]).to eq(191) expect(options[:last_name]).to eq(191) end it 'should not assign a length for a non-string column' do options = adapter.length_options_for_utf8mb4_string_index(:spud_users, [:first_name, :last_name, :super_admin]) expect(options[:super_admin]).to eq(nil) end end describe '#add_index' do before(:each){ # Mock the add_index method to simply return the options hash rather than adding an index, so that we can inspect the contents of options allow_any_instance_of(ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter).to receive(:add_index) do |abstract_adapter, table_name, column_name, options| options end } it 'should pass a length option' do options = adapter.add_index(:spud_users, :first_name) expect(options[:length]).to eq({:first_name => 191}) end it 'should not override the given length option' do options = adapter.add_index(:spud_users, :first_name, :length => 20) expect(options[:length]).to eq(20) end end end
Version data entries
4 entries across 4 versions & 1 rubygems