Sha256: f87db4ae023b34adc192c9525cde43c7bb7f2f6468019afd2c3fc137bc540fe5

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require 'spec_helper'

describe 'ColumnDefaultDuck' do

	it "should raise an error if we try to initialise ranked_model on a column with a default value" do
		expect {
			class ColumnDefaultDuck < ActiveRecord::Base
			  include RankedModel
			  ranks :size, :with_same => :pond
			end
		}.to raise_error(RankedModel::NonNilColumnDefault, 'Your ranked model column "size" must not have a default value in the database.')
	end

	it "should not raise an error if we don't have a database connection when checking for default value" do
		begin
			ActiveRecord::Base.remove_connection

			expect {
				class ColumnDefaultDuck < ActiveRecord::Base
				  include RankedModel
				  ranks :size, :with_same => :pond
				end
			}.not_to raise_error
		ensure
			ActiveRecord::Base.establish_connection(DB_CONFIG.to_sym)
		end
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ranked-model-0.4.4 spec/duck-model/column_default_ducks_spec.rb