Skip to content

Commit

Permalink
Fix missing backticks in errors
Browse files Browse the repository at this point in the history
These weren't consistent. In some errors we were using backticks and
others we weren't. This fixes `connects_to` errors to use backticks
around the method name
  • Loading branch information
eileencodes committed Sep 21, 2020
1 parent 0bce813 commit 36b7655
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/connection_handling.rb
Expand Up @@ -79,10 +79,10 @@ def establish_connection(config_or_env = nil)
#
# Returns an array of database connections.
def connects_to(database: {}, shards: {})
raise NotImplementedError, "connects_to can only be called on ActiveRecord::Base or abstract classes" unless self == Base || abstract_class?
raise NotImplementedError, "`connects_to` can only be called on ActiveRecord::Base or abstract classes" unless self == Base || abstract_class?

if database.present? && shards.present?
raise ArgumentError, "connects_to can only accept a `database` or `shards` argument, but not both arguments."
raise ArgumentError, "`connects_to` can only accept a `database` or `shards` argument, but not both arguments."
end

connections = []
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/base_test.rb
Expand Up @@ -1666,7 +1666,7 @@ def test_protected_environments_are_stored_as_an_array_of_string
Bird.connects_to(database: { writing: :arunit })
end

assert_equal "connects_to can only be called on ActiveRecord::Base or abstract classes", error.message
assert_equal "`connects_to` can only be called on ActiveRecord::Base or abstract classes", error.message
end

test "cannot call connected_to on subclasses of ActiveRecord::Base" do
Expand Down
Expand Up @@ -233,7 +233,7 @@ def test_connects_to_raises_with_a_shard_and_database_key
error = assert_raises(ArgumentError) do
ActiveRecord::Base.connects_to(database: { writing: :arunit }, shards: { shard_one: { writing: :arunit } })
end
assert_equal "connects_to can only accept a `database` or `shards` argument, but not both arguments.", error.message
assert_equal "`connects_to` can only accept a `database` or `shards` argument, but not both arguments.", error.message
end

def test_retrieve_connection_pool_with_invalid_shard
Expand Down

0 comments on commit 36b7655

Please sign in to comment.