1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #13485 from schneems/schneems/fix-more-railties-tests

Partial fix of database url tests
This commit is contained in:
Guillermo Iguaran 2013-12-25 16:38:49 -08:00
commit c99d969160
2 changed files with 6 additions and 3 deletions

View file

@ -143,7 +143,7 @@ module ActiveRecord
def test_establishes_connection_for_the_given_environment
ActiveRecord::Tasks::DatabaseTasks.stubs(:create).returns true
ActiveRecord::Base.expects(:establish_connection).with('development')
ActiveRecord::Base.expects(:establish_connection).with(:development)
ActiveRecord::Tasks::DatabaseTasks.create_current(
ActiveSupport::StringInquirer.new('development')

View file

@ -20,9 +20,12 @@ module ApplicationTests
end
def set_database_url
ENV['DATABASE_URL'] = File.join("sqlite3://:@localhost", database_url_db_name)
ENV['RAILS_DATABASE_URL'] = File.join("sqlite3://:@localhost", database_url_db_name)
# ensure it's using the DATABASE_URL
FileUtils.rm_rf("#{app_path}/config/database.yml")
File.open("#{app_path}/config/database.yml", 'w') do |f|
f << {ENV['RAILS_ENV'] => %Q{<%= ENV['RAILS_DATABASE_URL'] %>}}.to_yaml
end
end
def expected
@ -126,7 +129,7 @@ module ApplicationTests
bundle exec rake db:migrate db:structure:dump`
structure_dump = File.read("db/structure.sql")
assert_match(/CREATE TABLE \"books\"/, structure_dump)
`bundle exec rake db:drop db:structure:load`
`bundle exec rake environment db:drop db:structure:load`
assert_match(/#{expected[:database]}/,
ActiveRecord::Base.connection_config[:database])
require "#{app_path}/app/models/book"