Permalink
Browse files

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

Partial fix of database url tests
  • Loading branch information...
2 parents d80ad96 + 2409c61 commit c99d969160302a849cfb8d3d6d0604a50b86fadd @guilleiguaran guilleiguaran committed Dec 26, 2013
@@ -143,7 +143,7 @@ def test_creates_test_database_when_environment_is_database
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 @@ def database_url_db_name
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 @@ def db_structure_dump_and_load
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"

0 comments on commit c99d969

Please sign in to comment.