Skip to content

Commit

Permalink
Merge pull request rails#13485 from schneems/schneems/fix-more-railti…
Browse files Browse the repository at this point in the history
…es-tests

Partial fix of database url tests
  • Loading branch information
guilleiguaran committed Dec 26, 2013
2 parents d80ad96 + 2409c61 commit c99d969
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion activerecord/test/cases/tasks/database_tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
7 changes: 5 additions & 2 deletions railties/test/application/rake/dbs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c99d969

Please sign in to comment.