mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
use assert_not
instead of refute
as mentioned in our guides.
As described in the "Follow Coding Conventions" section in our contribution guide (http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) we favor `assert_not` over `refute`. While we don't usually make stylistic changes on it's own I opted to do it in this case. The reason being that test cases are usually copied as a starting point for new tests. This results in a spread of `refute` in files that have been using it already.
This commit is contained in:
parent
3b0e1e49e0
commit
48a183ecb9
7 changed files with 23 additions and 24 deletions
|
@ -59,14 +59,13 @@ class QueuingTest < ActiveSupport::TestCase
|
|||
test 'should supply a provider_job_id when available for immediate jobs' do
|
||||
skip unless adapter_is?(:delayed_job, :sidekiq, :qu, :que)
|
||||
test_job = TestJob.perform_later @id
|
||||
refute test_job.provider_job_id.nil?, 'Provider job id should be set by provider'
|
||||
assert test_job.provider_job_id, 'Provider job id should be set by provider'
|
||||
end
|
||||
|
||||
test 'should supply a provider_job_id when available for delayed jobs' do
|
||||
skip unless adapter_is?(:delayed_job, :sidekiq, :que)
|
||||
delayed_test_job = TestJob.set(wait: 1.minute).perform_later @id
|
||||
refute delayed_test_job.provider_job_id.nil?,
|
||||
'Provider job id should by set for delayed jobs by provider'
|
||||
assert delayed_test_job.provider_job_id, 'Provider job id should by set for delayed jobs by provider'
|
||||
end
|
||||
|
||||
test 'current locale is kept while running perform_later' do
|
||||
|
|
|
@ -24,6 +24,6 @@ class MysqlQuotingTest < ActiveRecord::MysqlTestCase
|
|||
@conn.stubs(:full_version).returns('5.6.3')
|
||||
@conn.remove_instance_variable(:@version) if @conn.instance_variable_defined?(:@version)
|
||||
t = Time.now.change(usec: 1)
|
||||
refute_match(/\.000001\z/, @conn.quoted_date(t))
|
||||
assert_no_match(/\.000001\z/, @conn.quoted_date(t))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,6 @@ class Mysql2QuotingTest < ActiveRecord::Mysql2TestCase
|
|||
@connection.stubs(:full_version).returns('5.6.3')
|
||||
@connection.remove_instance_variable(:@version) if @connection.instance_variable_defined?(:@version)
|
||||
t = Time.now.change(usec: 1)
|
||||
refute_match(/\.000001\z/, @connection.quoted_date(t))
|
||||
assert_no_match(/\.000001\z/, @connection.quoted_date(t))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,7 +91,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
account = model.new
|
||||
refute account.valid?
|
||||
assert_not account.valid?
|
||||
assert_equal [{error: :blank}], account.errors.details[:company]
|
||||
ensure
|
||||
ActiveRecord::Base.belongs_to_required_by_default = original_value
|
||||
|
@ -108,7 +108,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
account = model.new
|
||||
refute account.valid?
|
||||
assert_not account.valid?
|
||||
assert_equal [{error: :blank}], account.errors.details[:company]
|
||||
ensure
|
||||
ActiveRecord::Base.belongs_to_required_by_default = original_value
|
||||
|
|
|
@ -152,7 +152,7 @@ module ActiveRecord
|
|||
Type::String.new(limit: 50))
|
||||
int_array = ConnectionAdapters::PostgreSQL::OID::Array.new(
|
||||
Type::Integer.new)
|
||||
refute_equal string_array, int_array
|
||||
assert_not_equal string_array, int_array
|
||||
assert_equal string_array, klass.type_for_attribute("my_array")
|
||||
assert_equal int_array, klass.type_for_attribute("my_int_array")
|
||||
end
|
||||
|
@ -167,7 +167,7 @@ module ActiveRecord
|
|||
Type::String.new(limit: 50))
|
||||
int_range = ConnectionAdapters::PostgreSQL::OID::Range.new(
|
||||
Type::Integer.new)
|
||||
refute_equal string_range, int_range
|
||||
assert_not_equal string_range, int_range
|
||||
assert_equal string_range, klass.type_for_attribute("my_range")
|
||||
assert_equal int_range, klass.type_for_attribute("my_int_range")
|
||||
end
|
||||
|
|
|
@ -40,43 +40,43 @@ class EnumTest < ActiveRecord::TestCase
|
|||
published, written = Book.statuses[:published], Book.statuses[:written]
|
||||
|
||||
assert_equal @book, Book.where(status: published).first
|
||||
refute_equal @book, Book.where(status: written).first
|
||||
assert_not_equal @book, Book.where(status: written).first
|
||||
assert_equal @book, Book.where(status: [published]).first
|
||||
refute_equal @book, Book.where(status: [written]).first
|
||||
refute_equal @book, Book.where("status <> ?", published).first
|
||||
assert_not_equal @book, Book.where(status: [written]).first
|
||||
assert_not_equal @book, Book.where("status <> ?", published).first
|
||||
assert_equal @book, Book.where("status <> ?", written).first
|
||||
end
|
||||
|
||||
test "find via where with symbols" do
|
||||
assert_equal @book, Book.where(status: :published).first
|
||||
refute_equal @book, Book.where(status: :written).first
|
||||
assert_not_equal @book, Book.where(status: :written).first
|
||||
assert_equal @book, Book.where(status: [:published]).first
|
||||
refute_equal @book, Book.where(status: [:written]).first
|
||||
refute_equal @book, Book.where.not(status: :published).first
|
||||
assert_not_equal @book, Book.where(status: [:written]).first
|
||||
assert_not_equal @book, Book.where.not(status: :published).first
|
||||
assert_equal @book, Book.where.not(status: :written).first
|
||||
end
|
||||
|
||||
test "find via where with strings" do
|
||||
assert_equal @book, Book.where(status: "published").first
|
||||
refute_equal @book, Book.where(status: "written").first
|
||||
assert_not_equal @book, Book.where(status: "written").first
|
||||
assert_equal @book, Book.where(status: ["published"]).first
|
||||
refute_equal @book, Book.where(status: ["written"]).first
|
||||
refute_equal @book, Book.where.not(status: "published").first
|
||||
assert_not_equal @book, Book.where(status: ["written"]).first
|
||||
assert_not_equal @book, Book.where.not(status: "published").first
|
||||
assert_equal @book, Book.where.not(status: "written").first
|
||||
end
|
||||
|
||||
test "build from scope" do
|
||||
assert Book.written.build.written?
|
||||
refute Book.written.build.proposed?
|
||||
assert_not Book.written.build.proposed?
|
||||
end
|
||||
|
||||
test "build from where" do
|
||||
assert Book.where(status: Book.statuses[:written]).build.written?
|
||||
refute Book.where(status: Book.statuses[:written]).build.proposed?
|
||||
assert_not Book.where(status: Book.statuses[:written]).build.proposed?
|
||||
assert Book.where(status: :written).build.written?
|
||||
refute Book.where(status: :written).build.proposed?
|
||||
assert_not Book.where(status: :written).build.proposed?
|
||||
assert Book.where(status: "written").build.written?
|
||||
refute Book.where(status: "written").build.proposed?
|
||||
assert_not Book.where(status: "written").build.proposed?
|
||||
end
|
||||
|
||||
test "update by declaration" do
|
||||
|
|
|
@ -11,7 +11,7 @@ class TouchLaterTest < ActiveRecord::TestCase
|
|||
def test_touch_laster_raise_if_non_persisted
|
||||
invoice = Invoice.new
|
||||
Invoice.transaction do
|
||||
refute invoice.persisted?
|
||||
assert_not invoice.persisted?
|
||||
assert_raises(ActiveRecord::ActiveRecordError) do
|
||||
invoice.touch_later
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ class TouchLaterTest < ActiveRecord::TestCase
|
|||
def test_touch_later_dont_set_dirty_attributes
|
||||
invoice = Invoice.create!
|
||||
invoice.touch_later
|
||||
refute invoice.changed?
|
||||
assert_not invoice.changed?
|
||||
end
|
||||
|
||||
def test_touch_later_update_the_attributes
|
||||
|
|
Loading…
Reference in a new issue