mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fixes specs and update code respectively
This commit is contained in:
@@ -109,7 +109,7 @@ module Spree
|
||||
}
|
||||
|
||||
scope :editable_by_producers, ->(enterprises_ids) {
|
||||
joins(:variant, order: :distributor).where(
|
||||
joins(variant: :supplier, order: :distributor).where(
|
||||
distributor: { enable_producers_to_edit_orders: true },
|
||||
spree_variants: { supplier_id: enterprises_ids }
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ module Reporting
|
||||
|
||||
def list(line_item_includes = [variant: [:supplier, :product]])
|
||||
line_items = order_permissions.visible_line_items.in_orders(orders.result)
|
||||
.order("supplier.name", "product.name", "variant.display_name", "variant.unit_description")
|
||||
.order("supplier.name", "product.name", "spree_variants.display_name", "spree_variants.unit_description")
|
||||
|
||||
if @params[:supplier_id_in].present?
|
||||
line_items = line_items.supplied_by_any(@params[:supplier_id_in])
|
||||
|
||||
@@ -70,8 +70,6 @@ RSpec.describe OpenFoodNetwork::ScopeVariantsForSearch do
|
||||
"Enterprise Load",
|
||||
"VariantOverride Load",
|
||||
"SQL",
|
||||
"Enterprise Pluck",
|
||||
"Enterprise Load"
|
||||
]
|
||||
|
||||
expect(result).to include v4
|
||||
|
||||
@@ -151,7 +151,6 @@ RSpec.describe Reporting::Reports::OrdersAndDistributors::Base do
|
||||
subject # build context first
|
||||
|
||||
expect { subject.table_rows }.to query_database [
|
||||
"Enterprise Pluck",
|
||||
"SQL",
|
||||
"Spree::LineItem Load",
|
||||
"Spree::PaymentMethod Load",
|
||||
|
||||
@@ -19,7 +19,7 @@ RSpec.describe 'As a producer who have the ability to update orders' do
|
||||
o = create(
|
||||
:completed_order_with_totals,
|
||||
distributor:, order_cycle:,
|
||||
user: supplier1_ent_user, line_items_count: 1
|
||||
line_items_count: 1
|
||||
)
|
||||
o.line_items.first.update_columns(variant_id: supplier1_v1.id)
|
||||
o
|
||||
@@ -28,7 +28,7 @@ RSpec.describe 'As a producer who have the ability to update orders' do
|
||||
o = create(
|
||||
:completed_order_with_totals,
|
||||
distributor:, order_cycle:,
|
||||
user: supplier2_ent_user, line_items_count: 1
|
||||
line_items_count: 1
|
||||
)
|
||||
o.line_items.first.update_columns(variant_id: supplier2_v1.id)
|
||||
o
|
||||
@@ -14,14 +14,19 @@ RSpec.describe "spree/admin/orders/edit.html.haml" do
|
||||
Spree::Config[:enable_invoices?] = original_config
|
||||
end
|
||||
|
||||
let(:current_test_user) { create(:admin_user) }
|
||||
|
||||
before do
|
||||
controller.singleton_class.class_eval do
|
||||
attr_accessor :current_test_user
|
||||
|
||||
def current_ability
|
||||
Spree::Ability.new(Spree::User.new)
|
||||
Spree::Ability.new(current_test_user)
|
||||
end
|
||||
end
|
||||
|
||||
allow(view).to receive_messages spree_current_user: create(:admin_user)
|
||||
controller.current_test_user = current_test_user
|
||||
allow(view).to receive_messages spree_current_user: current_test_user
|
||||
end
|
||||
|
||||
context "when order is complete" do
|
||||
@@ -54,7 +59,6 @@ RSpec.describe "spree/admin/orders/edit.html.haml" do
|
||||
it "doesn't display a table of out of stock line items" do
|
||||
render
|
||||
|
||||
expect(rendered).not_to have_content "Out of Stock"
|
||||
expect(rendered).not_to have_selector ".insufficient-stock-items",
|
||||
text: out_of_stock_line_item.variant.display_name
|
||||
end
|
||||
@@ -96,7 +100,7 @@ RSpec.describe "spree/admin/orders/edit.html.haml" do
|
||||
it "doesn't display a table of out of stock line items" do
|
||||
render
|
||||
|
||||
expect(rendered).not_to have_content "Out of Stock"
|
||||
expect(rendered).not_to have_selector ".insufficient-stock-items"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user