Permalink
Browse files

Merge pull request #13443 from schneems/schneems/fix-master-tests

Fix DB Console tests
  • Loading branch information...
2 parents 6d255b7 + dd93a5f commit 6f4a556bf51f70090000a18b82ee4fe60730c6b2 @guilleiguaran guilleiguaran committed Dec 22, 2013
View
2 railties/test/application/initializers/frameworks_test.rb
@@ -216,7 +216,7 @@ def from_bar_helper
require "#{app_path}/config/environment"
orig_database_url = ENV.delete("DATABASE_URL")
orig_rails_env, Rails.env = Rails.env, 'development'
- database_url_db_name = "db/database_url_db.sqlite3"
+ database_url_db_name = File.join(app_path, "db/database_url_db.sqlite3")
ENV["DATABASE_URL"] = "sqlite3://:@localhost/#{database_url_db_name}"
ActiveRecord::Base.establish_connection
assert ActiveRecord::Base.connection
View
6 railties/test/application/rake/dbs_test.rb
@@ -16,11 +16,11 @@ def teardown
end
def database_url_db_name
- "db/database_url_db.sqlite3"
+ File.join(app_path, "db/database_url_db.sqlite3")
end
def set_database_url
- ENV['DATABASE_URL'] = "sqlite3://:@localhost/#{database_url_db_name}"
+ ENV['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")
end
@@ -60,7 +60,7 @@ def db_migrate_and_status
`rails generate model book title:string;
bundle exec rake db:migrate`
output = `bundle exec rake db:migrate:status`
- assert_match(/database:\s+\S+#{expected[:database]}/, output)
+ assert_match(%r{database:\s+\S*#{Regexp.escape(expected[:database])}}, output)
assert_match(/up\s+\d{14}\s+Create books/, output)
end
end
View
42 railties/test/commands/dbconsole_test.rb
@@ -38,36 +38,38 @@ def test_config_with_no_db_config
end
def test_config_with_database_url_only
- ENV['DATABASE_URL'] = 'sqlite3://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
+ ENV['DATABASE_URL'] = 'postgresql://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
app_db_config(nil)
- assert_equal Rails::DBConsole.new.config.sort, {
- "adapter"=> "sqlite3",
- "host"=> "localhost",
- "port"=> 9000,
- "database"=> "foo_test",
- "username"=> "foo",
- "password"=> "bar",
- "pool"=> "5",
- "timeout"=> "3000"
+ expected = {
+ "adapter" => "postgresql",
+ "host" => "localhost",
+ "port" => 9000,
+ "database" => "foo_test",
+ "username" => "foo",
+ "password" => "bar",
+ "pool" => "5",
+ "timeout" => "3000"
}.sort
+ assert_equal expected, Rails::DBConsole.new.config.sort
end
def test_config_choose_database_url_if_exists
- ENV['DATABASE_URL'] = 'sqlite3://foo:bar@dburl:9000/foo_test?pool=5&timeout=3000'
+ host = "database-url-host.com"
+ ENV['DATABASE_URL'] = "postgresql://foo:bar@#{host}:9000/foo_test?pool=5&timeout=3000"
sample_config = {
"test" => {
- "adapter"=> "sqlite3",
- "host"=> "localhost",
- "port"=> 9000,
- "database"=> "foo_test",
- "username"=> "foo",
- "password"=> "bar",
- "pool"=> "5",
- "timeout"=> "3000"
+ "adapter" => "postgresql",
+ "host" => "not-the-#{host}",
+ "port" => 9000,
+ "database" => "foo_test",
+ "username" => "foo",
+ "password" => "bar",
+ "pool" => "5",
+ "timeout" => "3000"
}
}
app_db_config(sample_config)
- assert_equal Rails::DBConsole.new.config["host"], "dburl"
+ assert_equal host, Rails::DBConsole.new.config["host"]
end
def test_env

0 comments on commit 6f4a556

Please sign in to comment.