mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Update deprecated #find_or_create_by_* methods
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user