-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow mutations on configuration_hash
We want to introduce an object-based DSL for building and modifying configuration objects. As part of that we want to make sure that users don't think they can modify configuration_hash values and have them change the configuration. For that reason we're going to freeze the Hash here, and have modified places in tests where we were modifying these hashes. The commit here also adds a test for the Test Databases and in that work we found that we were calling `Rails.env` and Active Record doesn't load Rails. Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
- Loading branch information
1 parent
fe3db2a
commit 154abca
Showing
6 changed files
with
54 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cases/helper" | ||
|
||
class TestDatabasesTest < ActiveRecord::TestCase | ||
unless in_memory_db? | ||
def test_databases_are_created | ||
previous_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "arunit" | ||
|
||
base_db_config = ActiveRecord::Base.configurations.configs_for(env_name: "arunit", spec_name: "primary") | ||
expected_database = "#{base_db_config.database}-2" | ||
|
||
ActiveRecord::Tasks::DatabaseTasks.stub(:reconstruct_from_schema, ->(db_config, _, _) { | ||
assert_equal expected_database, db_config.database | ||
}) do | ||
ActiveRecord::TestDatabases.create_and_load_schema(2, env_name: "arunit") | ||
end | ||
ensure | ||
ENV["RAILS_ENV"] = previous_env | ||
end | ||
end | ||
end |