Update deprecated #find_or_create_by_* methods

This commit is contained in:
Matt-Yorkley
2019-12-20 15:44:10 +01:00
committed by Luis Ramos
parent 6dd982532c
commit 30558485de
20 changed files with 26 additions and 26 deletions

View File

@@ -14,7 +14,7 @@ module Addressing
end
def zone
zone = Spree::Zone.find_or_create_by_name!(ENV.fetch('CHECKOUT_ZONE'))
zone = Spree::Zone.find_or_create_by!(name: ENV.fetch('CHECKOUT_ZONE'))
zone.members.create!(zoneable: country) unless zone.zoneables.include?(country)
zone
end

View File

@@ -11,7 +11,7 @@ class EnterpriseFactory
name = data[:name]
log "- #{name}"
data[:long_description] = data[:long_description].strip_heredoc.tr("\n", " ")
Enterprise.create_with(data).find_or_create_by_name!(name)
Enterprise.create_with(data).find_or_create_by!(name: name)
end
end

View File

@@ -18,7 +18,7 @@ class InventoryFactory
enterprise: shop,
variant: product.variants.first,
visible: true
).find_or_create_by_variant_id!(product.variants.first.id)
).find_or_create_by!(variant_id: product.variants.first.id)
create_override(shop, product)
end
@@ -29,6 +29,6 @@ class InventoryFactory
price: 12,
on_demand: false,
count_on_hand: 5
).find_or_create_by_variant_id!(product.variants.first.id)
).find_or_create_by!(variant_id: product.variants.first.id)
end
end

View File

@@ -75,7 +75,7 @@ class ProductFactory
shipping_category: DefaultShippingCategory.find_or_create,
tax_category_id: find_or_create_tax_category.id
)
product = Spree::Product.create_with(params).find_or_create_by_name!(params[:name])
product = Spree::Product.create_with(params).find_or_create_by!(name: params[:name])
product.variants.first.update_attribute :on_demand, true
product
end

View File

@@ -49,7 +49,7 @@ class ShippingMethodFactory
params[:distributor_ids] = [enterprise.id]
method = enterprise.shipping_methods.new(params)
method.zones << zone
method.shipping_categories << Spree::ShippingCategory.find_or_create_by_name('Default')
method.shipping_categories << Spree::ShippingCategory.find_or_create_by(name: 'Default')
method.save!
method
end

View File

@@ -5,7 +5,7 @@ class TaxonFactory
def create_samples
log "Creating taxonomies:"
taxonomy = Spree::Taxonomy.find_or_create_by_name!('Products')
taxonomy = Spree::Taxonomy.find_or_create_by!(name: 'Products')
taxons = ['Vegetables', 'Fruit', 'Oils', 'Preserves and Sauces', 'Dairy', 'Meat and Fish']
taxons.each do |taxon_name|
create_taxon(taxonomy, taxon_name)

View File

@@ -34,7 +34,7 @@ class UserFactory
password_confirmation: password,
confirmation_sent_at: Time.zone.now,
confirmed_at: Time.zone.now
).find_or_create_by_email!(email)
).find_or_create_by!(email: email)
[name, user]
end
end