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:
commit
c99d969160
2 changed files with 6 additions and 3 deletions
|
@ -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')
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue