Sha256: c8597648d3d3a89c378767cc36d36be9657313530f1137a24d59e4818161ceec
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
require File.dirname(__FILE__) + '/test_helper' require 'clevic/order_attribute.rb' class Dummy < Sequel::Model end # need to set up a test DB, and test data for this class TestOrderAttribute < Test::Unit::TestCase def setup end def teardown end def test_reverse oa = OrderAttribute.new Dummy, 'id' assert_equal :asc, oa.reverse( :desc ) assert_equal :desc, oa.reverse( :asc ) assert_raise( RuntimeError ) { oa.reverse( :something_wrong ) } end # Test that initialisation was OK def test_equal oa1 = OrderAttribute.new Dummy, 'id' oa2 = OrderAttribute.new Dummy, 'id' assert_equal oa1, oa2 assert_equal oa1.to_sql, 'dummies.id asc' assert_equal oa1.to_reverse_sql, 'dummies.id desc' assert_equal oa1.attribute.to_sym, oa1.to_sym assert_equal oa2.to_sql, 'dummies.id asc' assert_equal oa2.to_reverse_sql, 'dummies.id desc' end def test_parse_default oa_asc = OrderAttribute.new Dummy, "name" assert_equal 'name', oa_asc.attribute assert_equal :asc, oa_asc.direction end def test_parse_desc oa_desc = OrderAttribute.new Dummy, "name desc" assert_equal 'name', oa_desc.attribute assert_equal 'name', oa_desc.to_s assert_equal :desc, oa_desc.direction assert_equal oa_desc.to_sql, 'dummies.name desc' assert_equal 'dummies.name asc', oa_desc.to_reverse_sql oa_desc = OrderAttribute.new Dummy, "dummies.name desc" assert_equal 'name', oa_desc.attribute assert_equal :desc, oa_desc.direction assert_equal oa_desc.to_sql, 'dummies.name desc' end def test_parse_table oa_with_table = OrderAttribute.new Dummy, 'dummies.name asc' assert_equal 'name', oa_with_table.attribute assert_equal :asc, oa_with_table.direction assert_equal oa_with_table.to_sql, 'dummies.name asc' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clevic-0.13.0.b3 | test/test_order_attribute.rb |
clevic-0.13.0.b2 | test/test_order_attribute.rb |
clevic-0.13.0.b1 | test/test_order_attribute.rb |