Compare commits

...

32 Commits

Author SHA1 Message Date
Rachel Arnould
7a62a95e0b Merge pull request #10103 from binarygit/stop-horizontal-scroll-of-body-in-order-summary-page
[Split Checkout] Stop horizontal scroll on body in order summary page
2022-12-23 10:29:21 +01:00
Jean-Baptiste Bellet
b8e4dcac7c Update all locales with the latest Transifex translations 2022-12-23 10:27:19 +01:00
Filipe
944d552f6b Merge pull request #10156 from ijdershem/idersh/issue-9834-pt3
[OFN-9834-PT3] Add placeholder for new product supplier field
2022-12-22 15:42:38 +00:00
Filipe
c3e4c53a01 Merge pull request #10074 from binarygit/order-cycle-closes-during-split-co
Redirect to shopfront when Order cycle closes during split checkout
2022-12-22 15:09:57 +00:00
Filipe
ae59621341 Merge pull request #10174 from ijdershem/idersh/OFN-9870
[OFN-9870] Correct error message for differing variant_unit_name for same product in import
2022-12-22 11:20:12 +00:00
Filipe
d61affd82b Merge pull request #10093 from vviekk/viv/noneTranslate
Translating text 'None' for tax and shipping categories of the product
2022-12-21 21:45:05 +00:00
jibees
c0364a845d Merge pull request #10172 from filipefurtad0/fix_flaky_invoice_spec_2
Removes line break for displaying product units
2022-12-21 18:37:50 +01:00
Filipe
47e100607c Merge pull request #10041 from abdellani/add_on-hand_and_on-demand_to_product_report
Add 'on hand' and 'on demand' to Products report
2022-12-21 17:31:21 +00:00
filipefurtad0
7f17bfaa9a Separates assertions to account for line breaks
Rubocop corrections
2022-12-21 17:25:30 +00:00
jibees
e9f92d39aa Merge pull request #10184 from abdellani/fix-zeitwork-load-exception
prevent loading the reporting module if already loaded [dev environment]
2022-12-21 11:26:19 +01:00
Mohamed ABDELLANI
23462e9965 avoid loading reporting lib if it's already loaded 2022-12-21 10:58:48 +01:00
Mohamed ABDELLANI
0d0c568b10 overwrite the default fields_to_hide to [] on OrderCycleSupplierTotals tests 2022-12-21 07:33:05 +01:00
Mohamed ABDELLANI
155b8ed725 subtract fields_to_hide when the fields_to_show are calculated 2022-12-21 07:32:18 +01:00
Mohamed ABDELLANI
11ea6b39cf test if All products report returns on_hand and on_demand 2022-12-21 07:23:32 +01:00
ijdershem-jf
18e9aba6b8 [OFN-9870] Display accurate error message for differing variant_unit_name for same product in import 2022-12-20 08:19:47 -07:00
Filipe
561458ce43 Merge pull request #9933 from Laurel16/instagram
Admin, Enterprise Settings, Social: Add instagram handler validator
2022-12-20 12:40:57 +00:00
Filipe
6f3d27b99b Merge pull request #10089 from abdellani/fix-payment-non-3d-need-to-be-manually-captured-in-BO
Fix Payments with non-3D cards need to be manually captured in the BO (Split checkout)
2022-12-20 10:09:45 +00:00
dependabot[bot]
8e5495c34d Merge pull request #10176 from openfoodfoundation/dependabot/bundler/rubocop-1.41.0 2022-12-20 09:18:06 +00:00
dependabot[bot]
59b727aa95 Bump rubocop from 1.40.0 to 1.41.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.40.0 to 1.41.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.40.0...v1.41.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-20 09:04:30 +00:00
binarygit
3b179e75a4 Stop horizontal scroll on body in cart page 2022-12-19 21:30:31 +05:45
dependabot[bot]
33896a73f3 Merge pull request #10171 from openfoodfoundation/dependabot/bundler/shoulda-matchers-5.3.0 2022-12-19 09:33:32 +00:00
dependabot[bot]
d97f49d1d4 Bump shoulda-matchers from 5.2.0 to 5.3.0
Bumps [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers) from 5.2.0 to 5.3.0.
- [Release notes](https://github.com/thoughtbot/shoulda-matchers/releases)
- [Changelog](https://github.com/thoughtbot/shoulda-matchers/blob/main/CHANGELOG.md)
- [Commits](https://github.com/thoughtbot/shoulda-matchers/compare/v5.2.0...v5.3.0)

---
updated-dependencies:
- dependency-name: shoulda-matchers
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 09:03:57 +00:00
dependabot[bot]
1ca305ab7c Merge pull request #10166 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.0.12 2022-12-16 10:33:18 +00:00
dependabot[bot]
ea07795304 Bump @floating-ui/dom from 1.0.10 to 1.0.12
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.0.10 to 1.0.12.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.0.12/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-16 09:01:18 +00:00
ijdershem-jf
741dc0e29c [9834-PT3] Add en translation for new product supplier select placeholder 2022-12-14 20:35:19 -07:00
ijdershem-jf
ea45462e50 [9834-PT3] Add placeholder/default select option for new product supplier field 2022-12-13 18:17:49 -07:00
Laurel16
bfd396e644 Add instagram handler validator
update entreprise model to match the correct pattern for instagram attribute & add migration to correct wrong links in db + test
2022-12-08 15:22:05 +01:00
Mohamed ABDELLANI
84aedaa1a1 run process_payments before order confirmation 2022-12-08 11:13:54 +01:00
Mohamed ABDELLANI
86c25e1d48 add on_demand/on_hand columns to all products_and_inventory/all_products report 2022-12-06 08:42:42 +01:00
binarygit
368cd76611 [Split Checkout] Stop horizontal scroll on body in order summary page 2022-12-06 12:12:38 +05:45
vviekk
ccddb7ad65 Transalting text 'None' for tax and shipping categories of the product 2022-12-03 18:36:46 +05:30
binarygit
764c8d7d27 Redirect to shopfront when OC closes during split checkout 2022-12-01 15:13:36 +05:45
25 changed files with 343 additions and 19 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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 {

View File

@@ -306,3 +306,8 @@
}
}
}
#line-items {
display: block;
overflow-x: auto;
}

View File

@@ -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

View File

@@ -1363,6 +1363,13 @@ cy:
formatted_data: Data wedii 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"

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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

View File

@@ -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: "")

View File

@@ -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

View File

@@ -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"

View File

@@ -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"