mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-18 19:36:48 +00:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a62a95e0b | ||
|
|
b8e4dcac7c | ||
|
|
944d552f6b | ||
|
|
c3e4c53a01 | ||
|
|
ae59621341 | ||
|
|
d61affd82b | ||
|
|
c0364a845d | ||
|
|
47e100607c | ||
|
|
7f17bfaa9a | ||
|
|
e9f92d39aa | ||
|
|
23462e9965 | ||
|
|
0d0c568b10 | ||
|
|
155b8ed725 | ||
|
|
11ea6b39cf | ||
|
|
18e9aba6b8 | ||
|
|
561458ce43 | ||
|
|
6f3d27b99b | ||
|
|
8e5495c34d | ||
|
|
59b727aa95 | ||
|
|
3b179e75a4 | ||
|
|
33896a73f3 | ||
|
|
d97f49d1d4 | ||
|
|
1ca305ab7c | ||
|
|
ea07795304 | ||
|
|
741dc0e29c | ||
|
|
ea45462e50 | ||
|
|
bfd396e644 | ||
|
|
84aedaa1a1 | ||
|
|
86c25e1d48 | ||
|
|
368cd76611 | ||
|
|
ccddb7ad65 | ||
|
|
764c8d7d27 |
@@ -599,7 +599,7 @@ GEM
|
||||
rswag-ui (2.8.0)
|
||||
actionpack (>= 3.1, < 7.1)
|
||||
railties (>= 3.1, < 7.1)
|
||||
rubocop (1.40.0)
|
||||
rubocop (1.41.0)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.1.2.1)
|
||||
@@ -634,7 +634,7 @@ GEM
|
||||
tilt (>= 1.1, < 3)
|
||||
sd_notify (0.1.1)
|
||||
semantic_range (3.0.0)
|
||||
shoulda-matchers (5.2.0)
|
||||
shoulda-matchers (5.3.0)
|
||||
activesupport (>= 5.2.0)
|
||||
sidekiq (6.5.8)
|
||||
connection_pool (>= 2.2.5, < 3)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module OrderStockCheck
|
||||
include CablecarResponses
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def valid_order_line_items?
|
||||
@@ -29,6 +30,9 @@ module OrderStockCheck
|
||||
|
||||
flash[:info] = I18n.t('order_cycle_closed')
|
||||
respond_to do |format|
|
||||
format.cable_ready {
|
||||
render status: :see_other, operations: cable_car.redirect_to(url: main_app.shop_path)
|
||||
}
|
||||
format.json { render json: { path: main_app.shop_path }, status: :see_other }
|
||||
format.html { redirect_to main_app.shop_path, status: :see_other }
|
||||
end
|
||||
|
||||
@@ -31,6 +31,7 @@ class SplitCheckoutController < ::BaseController
|
||||
if confirm_order || update_order
|
||||
return if performed?
|
||||
|
||||
check_payments_adjustments
|
||||
clear_invalid_payments
|
||||
advance_order_state
|
||||
redirect_to_step
|
||||
@@ -53,6 +54,10 @@ class SplitCheckoutController < ::BaseController
|
||||
flash[:error] = I18n.t('split_checkout.errors.no_shipping_methods_available')
|
||||
end
|
||||
|
||||
def check_payments_adjustments
|
||||
@order.payments.each(&:ensure_correct_adjustment)
|
||||
end
|
||||
|
||||
def clear_invalid_payments
|
||||
@order.payments.with_state(:invalid).delete_all
|
||||
end
|
||||
@@ -65,6 +70,7 @@ class SplitCheckoutController < ::BaseController
|
||||
|
||||
return true if redirect_to_payment_gateway
|
||||
|
||||
@order.process_payments!
|
||||
@order.confirm!
|
||||
order_completion_reset @order
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@ class Enterprise < ApplicationRecord
|
||||
medium: { resize_to_fill: [720, 156] },
|
||||
large: { resize_to_fill: [1200, 260] },
|
||||
}.freeze
|
||||
VALID_INSTAGRAM_REGEX = %r{\A[a-zA-Z0-9._]{1,30}([^/-]*)\z}
|
||||
|
||||
searchable_attributes :sells, :is_primary_producer
|
||||
searchable_associations :properties
|
||||
@@ -99,6 +100,7 @@ class Enterprise < ApplicationRecord
|
||||
validate :shopfront_taxons
|
||||
validate :shopfront_producers
|
||||
validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? }
|
||||
validates :instagram, format: { with: VALID_INSTAGRAM_REGEX, message: Spree.t('errors.messages.invalid_instagram_url') }, allow_blank: true
|
||||
|
||||
before_validation :initialize_permalink, if: lambda { permalink.nil? }
|
||||
before_validation :set_unused_address_fields
|
||||
@@ -456,7 +458,7 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def correct_instagram_url(url)
|
||||
url && strip_url(url).sub(%r{www.instagram.com/}, '').delete("@")
|
||||
url && strip_url(url.downcase).sub(%r{www.instagram.com/}, '').sub(%r{instagram.com/}, '').delete("@")
|
||||
end
|
||||
|
||||
def correct_twitter_url(url)
|
||||
|
||||
@@ -211,7 +211,7 @@ module ProductImport
|
||||
reference_entry = all_entries_for_product(entry).first
|
||||
return if entry.variant_unit_name.to_s == reference_entry.variant_unit_name.to_s
|
||||
|
||||
mark_as_not_updatable(entry, "variant_unit_name")
|
||||
mark_as_values_must_be_same(entry, "variant_unit_name")
|
||||
end
|
||||
|
||||
def producer_validation(entry)
|
||||
@@ -425,6 +425,11 @@ module ProductImport
|
||||
error: I18n.t("admin.product_import.model.not_updatable"))
|
||||
end
|
||||
|
||||
def mark_as_values_must_be_same(entry, attribute)
|
||||
mark_as_invalid(entry, attribute: attribute,
|
||||
error: I18n.t("admin.product_import.model.values_must_be_same"))
|
||||
end
|
||||
|
||||
def import_into_inventory?
|
||||
@import_settings.dig(:settings, 'import_into') == 'inventories'
|
||||
end
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
|
||||
= f.field_container :shipping_categories do
|
||||
= f.label :shipping_category_id, t(:shipping_categories)
|
||||
= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { :include_blank => 'None' }, { :class => 'select2' })
|
||||
= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { :include_blank => t(:none) }, { :class => 'select2' })
|
||||
= f.error_message_on :shipping_category
|
||||
|
||||
= f.field_container :tax_category do
|
||||
= f.label :tax_category_id, t(:tax_category)
|
||||
= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { :include_blank => 'None' }, { :class => 'select2' })
|
||||
= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { :include_blank => t(:none) }, { :class => 'select2' })
|
||||
= f.error_message_on :tax_category
|
||||
|
||||
.clear
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
.sixteen.columns.alpha
|
||||
.eight.columns.alpha
|
||||
= f.field_container :supplier do
|
||||
= f.label :supplier_id, t(".supplier")
|
||||
= f.select :supplier_id, options_from_collection_for_select(@producers, :id, :name, @product.supplier_id), {}, { "data-controller": "tom-select", class: "primary" }
|
||||
= f.label :supplier, t(".supplier")
|
||||
%span.required *
|
||||
= f.select :supplier_id, options_from_collection_for_select(@producers, :id, :name, @product.supplier_id), { include_blank: t("spree.admin.products.new.supplier_select_placeholder") }, { "data-controller": "tom-select", class: "primary" }
|
||||
= f.error_message_on :supplier
|
||||
.eight.columns.omega
|
||||
= f.field_container :name do
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
.sub-header.show-for-medium-down
|
||||
= render partial: "shopping_shared/order_cycles"
|
||||
|
||||
%fieldset.footer-pad
|
||||
#cart-container
|
||||
- if @order.line_items.empty?
|
||||
%div.row{"data-hook" => "empty_cart"}
|
||||
%p= t(:your_cart_is_empty)
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#cart-container {
|
||||
padding: 25px;
|
||||
padding-bottom: 100px;
|
||||
}
|
||||
|
||||
#update-cart {
|
||||
#errorExplanation {
|
||||
display: none;
|
||||
@@ -6,6 +11,8 @@
|
||||
|
||||
#cart-detail {
|
||||
width: 100%;
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
|
||||
.cart-item-delete,
|
||||
.bought-item-delete {
|
||||
|
||||
@@ -306,3 +306,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#line-items {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ module Openfoodnetwork
|
||||
initializer "ofn.reports" do |app|
|
||||
module ::Reporting; end
|
||||
Rails.application.reloader.to_prepare do
|
||||
next if defined?(::Reporting) && defined?(::Reporting::Errors)
|
||||
loader = Zeitwerk::Loader.new
|
||||
loader.push_dir("#{Rails.root}/lib/reporting", namespace: ::Reporting)
|
||||
loader.enable_reloading
|
||||
|
||||
@@ -1363,6 +1363,13 @@ cy:
|
||||
formatted_data: Data wedi’i Fformatio
|
||||
packing:
|
||||
name: "Adroddiadau Pacio"
|
||||
oidc_settings:
|
||||
index:
|
||||
title: "OIDC Settings"
|
||||
already_connected: "Your account is already linked to this DFC authorization account:"
|
||||
les_communs_link: "Les Communs Open ID server"
|
||||
link_your_account: "You need first to link your account with the authorization provider used by DFC (Les Communs Open ID Connect)."
|
||||
link_account_button: "Link your Les Communs OIDC Account"
|
||||
subscriptions:
|
||||
index:
|
||||
title: "Tanysgrifiadau"
|
||||
|
||||
@@ -730,6 +730,7 @@ en:
|
||||
not_found: not found in database
|
||||
category_not_found: doesn't match allowed categories. See the correct categories to choose from on the product import page, or check that there's no misspelling.
|
||||
not_updatable: cannot be updated on existing products via product import
|
||||
values_must_be_same: must be the same for products with the same name
|
||||
blank: can't be blank
|
||||
products_no_permission: you do not have permission to manage products for this enterprise
|
||||
inventory_no_permission: you do not have permission to create inventory for this producer
|
||||
@@ -3804,6 +3805,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
messages:
|
||||
included_price_validation: "cannot be selected unless you have set a Default Tax Zone"
|
||||
blank: "can't be blank"
|
||||
invalid_instagram_url: "Must be user name only eg. the_prof"
|
||||
layouts:
|
||||
admin:
|
||||
login_nav:
|
||||
@@ -4059,6 +4061,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
title: "New Product"
|
||||
new_product: "New Product"
|
||||
supplier: "Supplier"
|
||||
supplier_select_placeholder: "Select a supplier"
|
||||
product_name: "Product Name"
|
||||
units: "Unit Size"
|
||||
value: "Value"
|
||||
@@ -4104,6 +4107,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
select_and_search: "Select filters and click on %{option} to access your data."
|
||||
customer_names_message:
|
||||
customer_names_tip: "If customer names are hidden for orders you have supplied, you can contact the distributor and ask if they can update their shop preferences to allow their suppliers to view customer names."
|
||||
products_and_inventory:
|
||||
all_products:
|
||||
message: "Note that stock levels reported are from supplier product lists only. If you are using Inventory to manage your stock quantities these values will be ignored in this report."
|
||||
users:
|
||||
index:
|
||||
listing_users: "Listing Users"
|
||||
|
||||
@@ -30,6 +30,7 @@ en_GB:
|
||||
shipping_category_id: "Shipping Category"
|
||||
variant_unit: "Variant Unit"
|
||||
variant_unit_name: "Variant Unit Name"
|
||||
unit_value: "Unit value"
|
||||
spree/credit_card:
|
||||
base: "Credit Card"
|
||||
number: "Number"
|
||||
@@ -180,6 +181,8 @@ en_GB:
|
||||
updated_not_active: "Your password has been reset, but your email has not been confirmed yet."
|
||||
updated: "Your password was changed successfully. You are now signed in."
|
||||
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
|
||||
oidc:
|
||||
failure: "Could not sign in: %{error}"
|
||||
home_page_alert_html: "Home page alert HTML"
|
||||
hub_signup_case_studies_html: "Hub signup case studies HTML"
|
||||
hub_signup_detail_html: "Hub signup detail HTML"
|
||||
@@ -401,8 +404,11 @@ en_GB:
|
||||
filters:
|
||||
categories:
|
||||
title: Categories
|
||||
selected_categories: "%{count} categories selected"
|
||||
producers:
|
||||
title: Producers
|
||||
selected_producers: "%{count} producers selected"
|
||||
per_page: "%{count} items per page"
|
||||
colums: Columns
|
||||
columns:
|
||||
name: Name
|
||||
@@ -643,6 +649,7 @@ en_GB:
|
||||
conditional_blank: can't be blank if unit_type is blank
|
||||
no_product: did not match any products in the database
|
||||
not_found: not found in database
|
||||
category_not_found: doesn't match allowed categories. See the correct categories to choose from on the product import page, or check that there's no misspelling.
|
||||
not_updatable: cannot be updated on existing products via product import
|
||||
blank: can't be blank
|
||||
products_no_permission: you do not have permission to manage products for this enterprise
|
||||
@@ -1363,6 +1370,15 @@ en_GB:
|
||||
formatted_data: Formatted Data
|
||||
packing:
|
||||
name: "Packing Reports"
|
||||
oidc_settings:
|
||||
index:
|
||||
title: "OIDC Settings"
|
||||
connect: "Connect Your Account"
|
||||
already_connected: "Your account is already linked to this DFC authorisation account:"
|
||||
les_communs_link: "Les Communs Open ID server"
|
||||
link_your_account: "You need first to link your account with the authorisation provider used by DFC (Les Communs Open ID Connect)."
|
||||
link_account_button: "Link your Les Communs OIDC Account"
|
||||
view_account: "To view your account, see:"
|
||||
subscriptions:
|
||||
index:
|
||||
title: "Subscriptions"
|
||||
@@ -2607,7 +2623,17 @@ en_GB:
|
||||
report_header_to_hub: To Hub
|
||||
report_header_hub_code: Hub Code
|
||||
report_header_hub_id: Hub ID
|
||||
report_header_hub_business_number: "Hub Business Number"
|
||||
report_header_hub_legal_name: "Hub Legal Name"
|
||||
report_header_hub_contact_name: "Hub Contact Name"
|
||||
report_header_hub_email: "Hub Public Email"
|
||||
report_header_hub_owner_email: Hub Owner Email
|
||||
report_header_hub_phone: "Hub Phone Number"
|
||||
report_header_hub_address_line1: "Hub Address Line 1"
|
||||
report_header_hub_address_line2: "Hub Address Line 2"
|
||||
report_header_hub_address_city: "Hub Town"
|
||||
report_header_hub_address_zipcode: "Hub Postcode"
|
||||
report_header_hub_address_state_name: "Hub County"
|
||||
report_header_code: Code
|
||||
report_header_paid: Paid?
|
||||
report_header_delivery: Delivery?
|
||||
@@ -2642,11 +2668,13 @@ en_GB:
|
||||
report_header_total_tax: "Total Tax (%{currency_symbol})"
|
||||
report_header_total_excl_tax: "Total excl. tax (%{currency_symbol})"
|
||||
report_header_total_incl_tax: "Total incl. tax (%{currency_symbol})"
|
||||
report_header_total_orders: "Total Number of Orders"
|
||||
report_header_enterprise: Enterprise
|
||||
report_header_customer: Customer
|
||||
report_header_customer_code: Customer Code
|
||||
report_header_product: Product
|
||||
report_header_product_properties: Product Properties
|
||||
report_header_product_tax_category: Product Tax Category
|
||||
report_header_quantity: Quantity
|
||||
report_header_max_quantity: Max Quantity
|
||||
report_header_variant: Variant
|
||||
@@ -2659,6 +2687,7 @@ en_GB:
|
||||
report_header_supplier: Supplier
|
||||
report_header_producer: Producer
|
||||
report_header_producer_suburb: Producer Suburb
|
||||
report_header_producer_charges_sales_tax?: GST/VAT Registered
|
||||
report_header_unit: Unit
|
||||
report_header_group_buy_unit_quantity: Group Buy Unit Quantity
|
||||
report_header_cost: Cost
|
||||
@@ -2770,6 +2799,7 @@ en_GB:
|
||||
action_required: "Action required"
|
||||
tag_rules: "Tag Rules"
|
||||
enterprise_fee_whole_order: Whole order
|
||||
enterprise_fee_by_name: "%{name} fee by %{role}%{enterprise_name}"
|
||||
validation_msg_relationship_already_established: "^That relationship is already established."
|
||||
validation_msg_at_least_one_hub: "^At least one hub must be selected"
|
||||
validation_msg_tax_category_cant_be_blank: "^Tax Category can't be blank"
|
||||
@@ -3592,6 +3622,7 @@ en_GB:
|
||||
messages:
|
||||
included_price_validation: "cannot be selected unless you have set a Default Tax Zone"
|
||||
blank: "can't be blank"
|
||||
invalid_instagram_url: "Must be user name only eg. the_prof"
|
||||
layouts:
|
||||
admin:
|
||||
login_nav:
|
||||
@@ -3890,6 +3921,9 @@ en_GB:
|
||||
select_and_search: "Select filters and click on %{option} to access your data."
|
||||
customer_names_message:
|
||||
customer_names_tip: "If customer names are hidden for orders you have supplied, you can contact the distributor and ask if they can update their shop preferences to allow their suppliers to view customer names."
|
||||
products_and_inventory:
|
||||
all_products:
|
||||
message: "Note that stock levels reported are from supplier product lists only. If you are using Inventory to manage your stock quantities these values will be ignored in this report."
|
||||
users:
|
||||
index:
|
||||
listing_users: "Listing Users"
|
||||
@@ -4058,6 +4092,8 @@ en_GB:
|
||||
thanks: "Thank you for your order with us."
|
||||
track_information: "Tracking Information: %{tracking}"
|
||||
track_link: "Tracking Link: %{url}"
|
||||
picked_up_instructions: "Your order from %{distributor} has been picked up"
|
||||
picked_up_subject: "Pick up Notification"
|
||||
test_mailer:
|
||||
test_email:
|
||||
greeting: "Congratulations!"
|
||||
@@ -4233,9 +4269,12 @@ en_GB:
|
||||
title: "The change you wanted was rejected (422)"
|
||||
message_html: "<p>The change you wanted was rejected. Maybe you tried to change something you don't have access to. <br><h3><a href='/' >Return home</a></h3> </p>"
|
||||
components:
|
||||
multiple_checked_select:
|
||||
filter_placeholder: "Filter options"
|
||||
search_input:
|
||||
placeholder: Search
|
||||
selector_with_filter:
|
||||
selected_items: "%{count} selected"
|
||||
search_placeholder: Search
|
||||
pagination:
|
||||
next: Next
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UpdateEnterpriseInstagramLinks < ActiveRecord::Migration[6.1]
|
||||
class Enterprise < ActiveRecord::Base
|
||||
def strip_url(url)
|
||||
url&.sub(%r{(https?://)?}, '')
|
||||
end
|
||||
|
||||
def correct_instagram_url(url)
|
||||
url && strip_url(url.downcase).sub(%r{www.instagram.com/}, '').sub(%r{instagram.com/},
|
||||
'').delete("@")
|
||||
end
|
||||
|
||||
def instagram
|
||||
correct_instagram_url self[:instagram]
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
Enterprise.where.not(instagram: nil).find_each do |enterprise|
|
||||
enterprise.update!(instagram: enterprise.instagram)
|
||||
enterprise.save!
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_11_16_095826) do
|
||||
ActiveRecord::Schema.define(version: 2022_12_08_150521) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -36,7 +36,7 @@ module Reporting
|
||||
else
|
||||
[]
|
||||
end
|
||||
params_fields_to_show - fields_in_headers
|
||||
params_fields_to_show - fields_in_headers - fields_to_hide
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -4,6 +4,30 @@ module Reporting
|
||||
module Reports
|
||||
module ProductsAndInventory
|
||||
class AllProducts < Base
|
||||
def default_params
|
||||
{ fields_to_hide: [:on_demand, :on_hand] }
|
||||
end
|
||||
|
||||
def message
|
||||
I18n.t("spree.admin.reports.products_and_inventory.all_products.message")
|
||||
end
|
||||
|
||||
def custom_headers
|
||||
{
|
||||
on_demand: I18n.t("admin.on_demand?"),
|
||||
on_hand: I18n.t("admin.on_hand")
|
||||
}
|
||||
end
|
||||
|
||||
def columns
|
||||
super.merge(
|
||||
{
|
||||
on_demand: proc{ |variant| variant.on_demand },
|
||||
on_hand: proc{ |variant| variant.on_demand ? I18n.t(:on_demand) : variant.on_hand }
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def filter_on_hand(variants)
|
||||
variants # do not filter
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ module Reporting
|
||||
order.line_items.first.variant.product.supplier
|
||||
end
|
||||
let(:current_user) { distributor.owner }
|
||||
let(:params) { { display_summary_row: false } }
|
||||
let(:params) { { display_summary_row: false, fields_to_hide: [] } }
|
||||
let(:report) do
|
||||
OrderCycleSupplierTotals.new(current_user, params)
|
||||
end
|
||||
|
||||
@@ -266,6 +266,64 @@ module Reporting
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe AllProducts do
|
||||
let(:user) do
|
||||
user = create(:user)
|
||||
user.spree_roles << Spree::Role.find_or_create_by!(name: 'admin')
|
||||
user
|
||||
end
|
||||
let(:report) do
|
||||
AllProducts.new user, { fields_to_hide: [] }
|
||||
end
|
||||
|
||||
it "Should return headers" do
|
||||
expect(report.table_headers).to eq([
|
||||
"Supplier",
|
||||
"Producer Suburb",
|
||||
"Product",
|
||||
"Product Properties",
|
||||
"Taxons",
|
||||
"Variant Value",
|
||||
"Price",
|
||||
"Group Buy Unit Quantity",
|
||||
"Amount",
|
||||
"SKU",
|
||||
"On Demand?",
|
||||
"On Hand"
|
||||
])
|
||||
end
|
||||
|
||||
it "Should render 'On demand' when the product is available on demand" do
|
||||
product = create(:product)
|
||||
variant = product.variants.first
|
||||
variant.on_demand = true
|
||||
variant.on_hand = 15
|
||||
variant.save!
|
||||
|
||||
first_row = report.table_rows.first
|
||||
on_demand_column = first_row[-2]
|
||||
on_hand_column = first_row[-1]
|
||||
|
||||
expect(on_demand_column).to eq("Yes")
|
||||
expect(on_hand_column).to eq("On demand")
|
||||
end
|
||||
|
||||
it "Should render the on hand count when the product is not available on demand" do
|
||||
product = create(:product)
|
||||
variant = product.variants.first
|
||||
variant.on_demand = false
|
||||
variant.on_hand = 22
|
||||
variant.save!
|
||||
|
||||
first_row = report.table_rows.first
|
||||
on_demand_column = first_row[-2]
|
||||
on_hand_column = first_row[-1]
|
||||
|
||||
expect(on_demand_column).to eq("No")
|
||||
expect(on_hand_column).to eq(22)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
39
spec/migrations/update_enterprise_instagram_links_spec.rb
Normal file
39
spec/migrations/update_enterprise_instagram_links_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
require Rails.root.join('db/migrate/20221208150521_update_enterprise_instagram_links.rb')
|
||||
|
||||
describe UpdateEnterpriseInstagramLinks do
|
||||
let!(:enterprise1) { create(:enterprise, instagram: "https://www.instagram.com/happyfarm") }
|
||||
|
||||
let!(:enterprise2) { create(:enterprise, instagram: "@happyfarm") }
|
||||
|
||||
let!(:enterprise3) { create(:enterprise, instagram: "happyfarm") }
|
||||
|
||||
# rubocop:disable Style/NumericLiterals
|
||||
|
||||
let(:current_version) { 20221208150521 }
|
||||
|
||||
# rubocop:enable Style/NumericLiterals
|
||||
|
||||
subject { ActiveRecord::Migrator.new(:up, migrations, current_version).migrate }
|
||||
|
||||
context "when link includes https://www.instagram.com/" do
|
||||
it "removes https://www.instagram.com/" do
|
||||
expect(enterprise1.instagram).to eq("happyfarm")
|
||||
end
|
||||
end
|
||||
|
||||
context "when link includes @" do
|
||||
it "removes @" do
|
||||
expect(enterprise2.instagram).to eq("happyfarm")
|
||||
end
|
||||
end
|
||||
|
||||
context "when link includes only the username" do
|
||||
it "does nothing" do
|
||||
expect(enterprise3.instagram).to eq("happyfarm")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -155,6 +155,94 @@ describe Enterprise do
|
||||
end
|
||||
end
|
||||
|
||||
describe "prevent a wrong instagram link pattern" do
|
||||
it "invalidates the instagram attribute https://facebook.com/user" do
|
||||
e = build(:enterprise, instagram: 'https://facebook.com/user')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute tagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'tagram.com/user')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute https://instagram.com/user/preferences" do
|
||||
e = build(:enterprise, instagram: 'https://instagram.com/user/preferences')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute https://instagram.com/user/" do
|
||||
e = build(:enterprise, instagram: 'https://instagram.com/user/')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
|
||||
it "invalidates the instagram attribute https://instagram.com/user-user" do
|
||||
e = build(:enterprise, instagram: 'https://instagram.com/user-user')
|
||||
expect(e).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe "Verify accepted instagram url pattern" do
|
||||
it "validates empty instagram attribute" do
|
||||
e = build(:enterprise, instagram: '')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq ""
|
||||
end
|
||||
|
||||
it "validates the instagram attribute @my_user" do
|
||||
e = build(:enterprise, instagram: '@my_user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "my_user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute user" do
|
||||
e = build(:enterprise, instagram: 'user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute my_www5.example" do
|
||||
e = build(:enterprise, instagram: 'my_www5.example')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "my_www5.example"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute http://instagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'http://instagram.com/user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute https://www.instagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'https://www.instagram.com/user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute instagram.com/@user" do
|
||||
e = build(:enterprise, instagram: 'instagram.com/@user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute Https://www.Instagram.com/@User" do
|
||||
e = build(:enterprise, instagram: 'Https://www.Instagram.com/@User')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "validates the instagram attribute instagram.com/user" do
|
||||
e = build(:enterprise, instagram: 'instagram.com/user')
|
||||
expect(e).to be_valid
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
|
||||
it "renders the expected pattern" do
|
||||
e = build(:enterprise, instagram: 'instagram.com/user')
|
||||
expect(e.instagram).to eq "user"
|
||||
end
|
||||
end
|
||||
|
||||
describe "preferred_shopfront_taxon_order" do
|
||||
it "empty strings are valid" do
|
||||
enterprise = build(:enterprise, preferred_shopfront_taxon_order: "")
|
||||
|
||||
@@ -223,8 +223,9 @@ describe '
|
||||
# header
|
||||
expect(page).to have_content "Item Qty GST Price"
|
||||
# second line item, included tax
|
||||
expect(page).to have_content "#{Spree::Product.second.name} 3 $250.08 $1,500.45"
|
||||
expect(page).to have_content Spree::Product.second.name.to_s
|
||||
expect(page).to have_content "(1g)" # display as
|
||||
expect(page).to have_content "3 $250.08 $1,500.45"
|
||||
# Enterprise fee
|
||||
expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \
|
||||
"#{user1.enterprises.first.name} 1 $15.65 (included) $120.00"
|
||||
@@ -346,15 +347,17 @@ describe '
|
||||
it "displays $0.0 when a line item has no tax" do
|
||||
pending "iii) for legend see picture on PR #9495"
|
||||
# first line item, no tax - display $0.0
|
||||
expect(page).to have_content "#{Spree::Product.first.name} 1 $0.0 $12.54"
|
||||
expect(page).to have_content Spree::Product.first.name.to_s
|
||||
expect(page).to have_content "(1g)" # display as
|
||||
expect(page).to have_content "1 $0.0 $12.54"
|
||||
end
|
||||
|
||||
it "displays the added tax on the GST colum" do
|
||||
pending "closing #7983, iv) for legend see picture on PR #9495"
|
||||
# second line item, added tax of $300.09
|
||||
expect(page).to have_content "#{Spree::Product.second.name} 3 $300.09 $1,500.45"
|
||||
expect(page).to have_content Spree::Product.second.name.to_s
|
||||
expect(page).to have_content "(1g)" # display as
|
||||
expect(page).to have_content "3 $300.09 $1,500.45"
|
||||
end
|
||||
|
||||
it "displays GST for enterprise fees" do
|
||||
|
||||
@@ -136,7 +136,7 @@ describe "Registration", js: true do
|
||||
expect(e.facebook).to eq "FaCeBoOk"
|
||||
expect(e.linkedin).to eq "LiNkEdIn"
|
||||
expect(e.twitter).to eq "TwItTeR"
|
||||
expect(e.instagram).to eq "InStAgRaM"
|
||||
expect(e.instagram).to eq "instagram"
|
||||
|
||||
click_link "Go to Enterprise Dashboard"
|
||||
expect(page).to have_content "CHOOSE YOUR PACKAGE"
|
||||
|
||||
@@ -1679,9 +1679,9 @@
|
||||
integrity sha512-FPFLbg2b06MIw1dqk2SOEMAMX3xlrreGjcui5OTxfBDtaKTmh0kioOVjT8gcfl58juawL/yF+S+gnq8aUYQx/Q==
|
||||
|
||||
"@floating-ui/dom@^1.0.1":
|
||||
version "1.0.10"
|
||||
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.0.10.tgz#a2299e942a06ca35cfdaeb4d4709805c9bb9c032"
|
||||
integrity sha512-ZRe5ZmtGYCd82zrjWnnMW8hN5H1otedLh0Ur6rRo6f0exbEe6IlkVvo1RO7tgiMvbF0Df8hkhdm50VcVYqwP6g==
|
||||
version "1.0.12"
|
||||
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.0.12.tgz#07c870a05d9b825a6d7657524f48fe6761722800"
|
||||
integrity sha512-HeG/wHoa2laUHlDX3xkzqlUqliAfa+zqV04LaKIwNCmCNaW2p0fQi4/Kd0LB4GdFoJ2UllLFq5gWnXAd67lg7w==
|
||||
dependencies:
|
||||
"@floating-ui/core" "^1.0.4"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user