Skip to content

Commit 4a08f1b

Browse files
committed
Change test/cases/offset_and_limit_test_sqlserver.rb so that it actually runs properly.
NOTE: this was a 2-stage commit because renaming and changing in one commit may mean that git will lose history. The rename commit was 197c598.
1 parent 197c598 commit 4a08f1b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/cases/offset_and_limit_test_sqlserver.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'cases/sqlserver_helper'
2+
require 'models/book'
23

34
class 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

0 commit comments

Comments
 (0)