| | 50 | |
|---|
| | 51 | |
|---|
| | 52 | SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions)) |
|---|
| | 53 | |
|---|
| | 54 | desc 'Create the SQL Server test databases' |
|---|
| | 55 | task :create_databases do |
|---|
| | 56 | # Define a user named 'rails' in SQL Server with all privileges granted |
|---|
| | 57 | # Use an empty password for user 'rails', or alternatively use the OSQLPASSWORD environment variable |
|---|
| | 58 | # which allows you to set a default password for the current session. |
|---|
| | 59 | %x( osql -S localhost -U rails -Q "create database activerecord_unittest" -P ) |
|---|
| | 60 | %x( osql -S localhost -U rails -Q "create database activerecord_unittest2" -P ) |
|---|
| | 61 | %x( osql -S localhost -U rails -d activerecord_unittest -Q "exec sp_grantdbaccess 'rails'" -P ) |
|---|
| | 62 | %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "exec sp_grantdbaccess 'rails'" -P ) |
|---|
| | 63 | %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 ) |
|---|
| | 64 | %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 ) |
|---|
| | 65 | end |
|---|
| | 66 | |
|---|
| | 67 | desc 'Drop the SQL Server test databases' |
|---|
| | 68 | task :drop_databases do |
|---|
| | 69 | %x( osql -S localhost -U rails -Q "drop database activerecord_unittest" -P ) |
|---|
| | 70 | %x( osql -S localhost -U rails -Q "drop database activerecord_unittest2" -P ) |
|---|
| | 71 | end |
|---|
| | 72 | |
|---|
| | 73 | desc 'Recreate the SQL Server test databases' |
|---|
| | 74 | task :recreate_databases => [:drop_databases, :create_databases] |
|---|
| | 75 | |
|---|
| | 76 | |
|---|
| | 77 | for adapter in %w( sqlserver sqlserver_odbc ) |
|---|
| | 78 | Rake::TestTask.new("test_#{adapter}") { |t| |
|---|
| | 79 | t.libs << "test" |
|---|
| | 80 | t.libs << "test/connections/native_#{adapter}" |
|---|
| | 81 | t.libs << "../../../rails/activerecord/test/" |
|---|
| | 82 | t.pattern = ["test/**/*_test_sqlserver.rb", "../../../rails/activerecord/test/**/*_test.rb"] |
|---|
| | 83 | t.verbose = true |
|---|
| | 84 | } |
|---|
| | 85 | |
|---|
| | 86 | namespace adapter do |
|---|
| | 87 | task :test => "test_#{adapter}" |
|---|
| | 88 | end |
|---|
| | 89 | end |
|---|