Sha256: c3958a3bdc2f28b43c8db935e6ac1fe98d9b8ab16309d1fb5a2ff11d99a9347c
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require "rails_helper" module Sortability module ActiveRecord RSpec.describe Migration do let(:migration) { ::ActiveRecord::Migration.new } let(:table) { :test } context 'without some options' do let(:options) { { something: :else } } it '#add_sortable_column can add a sortable column, adding defaults' do expect(migration).to receive(:method_missing).with( :add_column, table, :sort_position, :integer, options.merge(null: false) ) migration.add_sortable_column table, options end it '#add_sortable_index can add a sortable index, adding defaults' do expect(migration).to receive(:method_missing).with( :add_index, table, [ :sort_position ], options.merge(unique: true) ) migration.add_sortable_index table, options end end context 'with all options' do let(:options) do { something: :else, on: :pos, null: true, unique: false, scope: :container_id } end it '#add_sortable_column can add a sortable column with the given options' do expect(migration).to receive(:method_missing).with( :add_column, table, :pos, :integer, options.except(:on) ) migration.add_sortable_column table, options end it '#add_sortable_index can add a sortable index with the given options' do expect(migration).to receive(:method_missing).with( :add_index, table, [ :container_id, :pos ], options.except(:on, :scope) ) migration.add_sortable_index table, options end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sortability-1.1.0 | spec/lib/sortability/active_record/migration_spec.rb |
sortability-1.0.0 | spec/lib/sortability/active_record/migration_spec.rb |