File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 11require 'cases/sqlserver_helper'
2+ require 'models/book'
23
34class WhenSelectingWithLimitOffsetAndLimitTest < ActiveRecord ::TestCase
45 def setup
@@ -31,13 +32,14 @@ class WhenSelectingWithLimitAndOffsetOffsetAndLimitTest < ActiveRecord::TestCase
3132 def setup
3233 @connection = ActiveRecord ::Base . connection
3334 # we have to use a real table as we need the counts
34- @select_sql = 'SELECT * FROM accounts'
35- class Account < ActiveRecord ::Base ; end
36-
37- # create 10 Accounts
38- ( 1 ..10 ) . each { |i | Account . create! }
35+ @select_sql = 'SELECT * FROM books'
36+ @books = ( 1 ..10 ) . map { |i | Book . create! }
3937 end
40-
38+
39+ def teardown
40+ @books . each { |b | b . destroy }
41+ end
42+
4143 def test_should_have_limit_if_offset_is_passed
4244 options = { :offset => 1 }
4345 assert_raise ( ArgumentError ) { @connection . add_limit_offset! ( @select_sql , options ) }
@@ -55,7 +57,7 @@ def test_should_convert_strings_which_look_like_integers_to_integers
5557
5658 def test_should_alter_SQL_to_limit_number_of_records_returned_offset_by_specified_amount
5759 options = { :limit => 3 , :offset => 5 }
58- expected_sql = %&SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 8 * FROM accounts ) AS tmp1) AS tmp2&
60+ expected_sql = %&SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 8 * FROM books ) AS tmp1) AS tmp2&
5961 assert_equal ( expected_sql , @connection . add_limit_offset! ( @select_sql , options ) )
6062 end
6163
You can’t perform that action at this time.
0 commit comments