Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 52 lines (42 sloc) 2.163 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
require 'rubygems'
require 'rake'
require 'rake/testtask'


desc 'Create the SQL Server test databases'
task :create_databases do
  # Define a user named 'rails' in SQL Server with all privileges granted
  # Use an empty password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
  # which allows you to set a default password for the current session.
  %x( osql -S localhost -U rails -Q "create database activerecord_unittest" -P )
  %x( osql -S localhost -U rails -Q "create database activerecord_unittest2" -P )
  %x( osql -S localhost -U rails -d activerecord_unittest -Q "exec sp_grantdbaccess 'rails'" -P )
  %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "exec sp_grantdbaccess 'rails'" -P )
  %x( osql -S localhost -U rails -d activerecord_unittest -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
  %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
end

desc 'Drop the SQL Server test databases'
task :drop_databases do
  %x( osql -S localhost -U rails -Q "drop database activerecord_unittest" -P )
  %x( osql -S localhost -U rails -Q "drop database activerecord_unittest2" -P )
end

desc 'Recreate the SQL Server test databases'
task :recreate_databases => [:drop_databases, :create_databases]


for adapter in %w( sqlserver sqlserver_odbc )
  
  Rake::TestTask.new("test_#{adapter}") { |t|
    t.libs << "test"
    t.libs << "test/connections/native_#{adapter}"
    t.libs << "../../../rails/activerecord/test/"
    t.test_files = (
      Dir.glob("test/cases/**/*_test_sqlserver.rb").sort +
      Dir.glob("../../../rails/activerecord/test/**/*_test.rb").sort )
    t.verbose = true
  }

  namespace adapter do
    task :test => "test_#{adapter}"
  end
  
end

desc 'Test with unicode types enabled.'
Rake::TestTask.new(:test_unicode_types) do |t|
  ENV['ENABLE_DEFAULT_UNICODE_TYPES'] = 'true'
  test = Rake::Task['test_sqlserver_odbc']
  test.invoke
end
Something went wrong with that request. Please try again.