Sha256: d8d7f7c9ed7d99d7ccdf65e8765cb412ac11619a474e3e46038772c2682f4c6a
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true require "cases/helper" require "models/book" module ActiveRecord class StatementInvalidTest < ActiveRecord::TestCase fixtures :books class MockDatabaseError < StandardError def result 0 end def error_number 0 end end test "message contains no sql" do sql = Book.where(author_id: 96, cover: "hard").to_sql error = assert_raises(ActiveRecord::StatementInvalid) do Book.connection.send(:log, sql, Book.name) do raise MockDatabaseError end end assert_not error.message.include?("SELECT") end test "statement and binds are set on select" do sql = Book.where(author_id: 96, cover: "hard").to_sql binds = [Minitest::Mock.new, Minitest::Mock.new] error = assert_raises(ActiveRecord::StatementInvalid) do Book.connection.send(:log, sql, Book.name, binds) do raise MockDatabaseError end end assert_equal error.sql, sql assert_equal error.binds, binds end end end
Version data entries
4 entries across 4 versions & 1 rubygems