Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/active_record/migrations/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module Tasks
module DatabaseTasks
def each_current_configuration(environment, spec_name = nil)
unless configuration = ActiveRecord::Base.configurations[environment]
raise ArgumentError.new("Cannot find configuration for environment #{environment.inspect} in #{ActiveRecord::Base.configurations.keys}")
raise ArgumentError.new("Cannot find configuration for environment #{environment.inspect} in #{ActiveRecord::Base.configurations.to_h.keys}")
end

# This is a hack because DatabaseTasks functionality uses string for keys.
Expand Down
10 changes: 10 additions & 0 deletions spec/active_record/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,14 @@
expect(File.read('db/schema.rb')).to include("version: 2016_12_08_121932")
end
end

it "should handle non-existent configuration" do
require 'active_record/migrations/tasks'
ActiveRecord::Base.configurations = {
"development" => "null://test",
}
expect do
ActiveRecord::Tasks::DatabaseTasks.send(:each_current_configuration, "foo")
end.to raise_error(ArgumentError, 'Cannot find configuration for environment "foo" in ["development"]')
end
end