Style numeric predicate use with Rubocop

This commit is contained in:
Maikel Linke
2021-03-25 18:07:11 +11:00
parent 852147bf45
commit ffb4ba5ef5
7 changed files with 7 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ FactoryBot.define do
shipping_category { DefaultShippingCategory.find_or_create }
# ensure stock item will be created for this products master
before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 }
before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? }
factory :product do
transient do

View File

@@ -15,7 +15,7 @@ FactoryBot.define do
option_values { [create(:option_value)] }
# ensure stock item will be created for this variant
before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 }
before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? }
factory :variant do
transient do

View File

@@ -75,7 +75,7 @@ feature '
def adjustments_in_print_data
checkout_adjustments_for(order, exclude: [:line_item]).
reject { |a| a.amount == 0 }.
reject { |a| a.amount.zero? }.
map do |adjustment|
[raw(adjustment.label),
display_adjustment_amount(adjustment).format(symbol: false, with_currency: false)]

View File

@@ -186,7 +186,7 @@ module Spree
end
it "has tax included" do
expect(adjustment.amount).to be > 0
expect(adjustment.amount).to be_positive
expect(adjustment.included).to be true
end

View File

@@ -22,7 +22,7 @@ describe InjectionHelper, type: :helper, performance: true do
ActiveRecord::Base.connection.query_cache.clear
Rails.cache.delete_matched('api\/cached_enterprise_serializer\/enterprises')
result = Benchmark.measure { helper.inject_enterprises }
results << result.total if i > 0
results << result.total if i.positive?
puts result
end

View File

@@ -78,7 +78,7 @@ module UIComponentHelper
def wait_for_ajax
counter = 0
while page.execute_script("return $.active").to_i > 0
while page.execute_script("return $.active").to_i.positive?
counter += 1
sleep(0.1)
raise "AJAX request took longer than 5 seconds." if counter >= 50

View File

@@ -157,6 +157,6 @@ module WebHelper
end
def wait_for_ajax
wait_until { page.evaluate_script("$.active") == 0 }
wait_until { page.evaluate_script("$.active").zero? }
end
end