Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixme: use minitest skip instead of return nil #6298

Merged
merged 1 commit into from
May 13, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions activerecord/test/cases/bind_parameter_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ def setup
@listener = LogListener.new @listener = LogListener.new
@pk = Topic.columns.find { |c| c.primary } @pk = Topic.columns.find { |c| c.primary }
ActiveSupport::Notifications.subscribe('sql.active_record', @listener) ActiveSupport::Notifications.subscribe('sql.active_record', @listener)

skip_if_prepared_statement_caching_is_not_supported
end end


def teardown def teardown
ActiveSupport::Notifications.unsubscribe(@listener) ActiveSupport::Notifications.unsubscribe(@listener)
end end


def test_binds_are_logged def test_binds_are_logged
# FIXME: use skip with minitest
return unless @connection.supports_statement_cache?

sub = @connection.substitute_at(@pk, 0) sub = @connection.substitute_at(@pk, 0)
binds = [[@pk, 1]] binds = [[@pk, 1]]
sql = "select * from topics where id = #{sub}" sql = "select * from topics where id = #{sub}"
Expand All @@ -44,19 +43,13 @@ def test_binds_are_logged
end end


def test_find_one_uses_binds def test_find_one_uses_binds
# FIXME: use skip with minitest
return unless @connection.supports_statement_cache?

Topic.find(1) Topic.find(1)
binds = [[@pk, 1]] binds = [[@pk, 1]]
message = @listener.calls.find { |args| args[4][:binds] == binds } message = @listener.calls.find { |args| args[4][:binds] == binds }
assert message, 'expected a message with binds' assert message, 'expected a message with binds'
end end


def test_logs_bind_vars def test_logs_bind_vars
# FIXME: use skip with minitest
return unless @connection.supports_statement_cache?

pk = Topic.columns.find { |x| x.primary } pk = Topic.columns.find { |x| x.primary }


payload = { payload = {
Expand Down Expand Up @@ -86,5 +79,11 @@ def debug str
logger.sql event logger.sql event
assert_match([[pk.name, 10]].inspect, logger.debugs.first) assert_match([[pk.name, 10]].inspect, logger.debugs.first)
end end

private

def skip_if_prepared_statement_caching_is_not_supported
skip('prepared statement caching is not supported') unless @connection.supports_statement_cache?
end
end end
end end