Sha256: 98c6e532e97a7ff954e129f5444c7377b9b9ee2310f493fd7f28b7e9438a59b0
Contents?: true
Size: 1.43 KB
Versions: 48
Compression:
Stored size: 1.43 KB
Contents
require 'test_helper' class ConnectionAdapterExtensionsTest < ActiveSupport::TestCase TEST_OBJECT_NAME = "test_object_#{SecureRandom.random_number(1<<16).to_s(16).rjust(4, '0')}" def setup @conn = ActiveRecord::Base::connection end test 'should have extension methods' do assert @conn.respond_to?(:object_exists?) assert @conn.respond_to?(:exec_sp) end test 'should be able to determine existence' do assert_not @conn.object_exists?(TEST_OBJECT_NAME) @conn.execute "CREATE TABLE #{TEST_OBJECT_NAME} ( some_value INTEGER NOT NULL )" begin assert @conn.object_exists?(TEST_OBJECT_NAME) ensure @conn.execute "DROP TABLE #{TEST_OBJECT_NAME}" end end test 'should be able to execute a stored proc' do skip if MsSqlTestConn.skip_tests? @conn = MsSqlTestConn.connection assert_not @conn.object_exists?(TEST_OBJECT_NAME) @conn.execute <<-EOS CREATE PROCEDURE #{TEST_OBJECT_NAME} @i_val INTEGER AS BEGIN SET NOCOUNT ON; DECLARE @d_val INTEGER; SELECT @d_val = ISNULL(@i_val, 0) + 55; RETURN @d_val; END EOS begin # It should exist now. assert @conn.object_exists?(TEST_OBJECT_NAME) # And it should retrieve the return value. assert_equal 55, @conn.exec_sp("exec #{TEST_OBJECT_NAME} NULL") assert_equal 100, @conn.exec_sp("exec #{TEST_OBJECT_NAME} 45") ensure @conn.execute "DROP PROCEDURE #{TEST_OBJECT_NAME}" end end end
Version data entries
48 entries across 48 versions & 1 rubygems