Sha256: 44a3b9824a09676e1f14421419a6efab2cfbd517b5cf1b3a61ecfd9066335da1

Contents?: true

Size: 826 Bytes

Versions: 7

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(ENV['DB'].to_sym)
		end
	end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ranked-model-0.4.11 spec/duck-model/column_default_ducks_spec.rb
ranked-model-0.4.10 spec/duck-model/column_default_ducks_spec.rb
ranked-model-0.4.9 spec/duck-model/column_default_ducks_spec.rb
ranked-model-0.4.8 spec/duck-model/column_default_ducks_spec.rb
ranked-model-0.4.7 spec/duck-model/column_default_ducks_spec.rb
ranked-model-0.4.6 spec/duck-model/column_default_ducks_spec.rb
ranked-model-0.4.5 spec/duck-model/column_default_ducks_spec.rb