Sha256: ff8876a18f0731727dc93098e85269bb74cc6bc2b44273f926de6f0b10c4ce37

Contents?: true

Size: 987 Bytes

Versions: 12

Compression:

Stored size: 987 Bytes

Contents

require_relative "../spec_helper"

class SortingExpressionsTest < Lanes::TestCase

    include TestingModels

    def teardown
        TestModel.instance_variable_set(:@sorting_expressions, nil)
    end

    def test_assert_adds_sorting_expression
        refute TestModel.has_sorting_expression?('foo')
        TestModel.export_sort 'foo' do | query, dir |
            query
        end
        assert TestModel.has_sorting_expression?('foo')
    end

    def test_sorting_by_field
        query = TestModel.where(name: 'bar')
        query = TestModel.append_sort_to_query(query, 'name', :asc)
        assert_match 'ORDER BY name ASC', query.to_sql
    end

    def test_sorting_by_block
        query = TestModel.where(name: 'bar')
        TestModel.export_sort :test do | q, dir |
            q.order(:name => 'desc')
        end
        query = TestModel.append_sort_to_query(query, 'test', :asc)
        assert_match 'ORDER BY "test_models"."name" DESC', query.to_sql
    end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lanes-0.8.3 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.8.2 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.8.1 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.8.0 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.7.0 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.6.1 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.6.0 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.5.6 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.5.5 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.5.0 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.4.0 spec/server/concerns/sorting_expressions_spec.rb
lanes-0.3.0 spec/server/concerns/sorting_expressions_spec.rb