mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Removes obsolete/failing performance specs
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe InjectionHelper, type: :helper, performance: true do
|
||||
let(:oc) { create(:simple_order_cycle) }
|
||||
let(:relative_supplier) { create(:supplier_enterprise) }
|
||||
let(:relative_distributor) { create(:distributor_enterprise) }
|
||||
|
||||
before do
|
||||
50.times do
|
||||
e = create(:enterprise)
|
||||
oc.distributors << e
|
||||
create(:enterprise_relationship, parent: e, child: relative_supplier)
|
||||
create(:enterprise_relationship, parent: e, child: relative_distributor)
|
||||
end
|
||||
end
|
||||
|
||||
it "is performant in injecting enterprises" do
|
||||
results = []
|
||||
4.times do |i|
|
||||
ActiveRecord::Base.connection.query_cache.clear
|
||||
Rails.cache.delete_matched('api\/cached_enterprise_serializer\/enterprises')
|
||||
result = Benchmark.measure { helper.inject_enterprises }
|
||||
results << result.total if i.positive?
|
||||
puts result
|
||||
end
|
||||
|
||||
avg = (results.sum / results.count * 1000).round(0)
|
||||
puts avg
|
||||
end
|
||||
end
|
||||
@@ -1,39 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::OrdersController, type: :controller, performance: true do
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let(:order_cycle) {
|
||||
create(:simple_order_cycle, distributors: [distributor], variants: products.map { |p|
|
||||
p.variants.first
|
||||
} )
|
||||
}
|
||||
let(:products) { (0...num_products).map { create(:product) } }
|
||||
let(:order) { subject.current_order(true) }
|
||||
let(:num_products) { 20 }
|
||||
|
||||
before do
|
||||
order.set_distribution! distributor, order_cycle
|
||||
controller.stub(:current_order) { order }
|
||||
|
||||
Spree::Config.currency = 'AUD'
|
||||
end
|
||||
|
||||
describe "adding products to cart" do
|
||||
it "adds products to cart" do
|
||||
puts "Pre-populating first product"
|
||||
spree_post :populate, variants: { products[0].variants.first.id => 1 }
|
||||
|
||||
result = Benchmark.measure do
|
||||
(1..num_products).each do |num_products|
|
||||
puts "Populating #{num_products} products"
|
||||
variants = Hash[products.map { |p| [p.variants.first.id, 1] }.first(num_products)]
|
||||
spree_post :populate, variants: variants
|
||||
end
|
||||
end
|
||||
|
||||
puts result
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,50 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe ShopController, type: :controller, performance: true do
|
||||
include FileHelper
|
||||
|
||||
let(:d) { create(:distributor_enterprise) }
|
||||
let(:enterprise_fee) { create(:enterprise_fee) }
|
||||
let(:order_cycle) {
|
||||
create(:simple_order_cycle, distributors: [d], coordinator_fees: [enterprise_fee])
|
||||
}
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:current_distributor) { d }
|
||||
allow(controller).to receive(:current_order_cycle) { order_cycle }
|
||||
Spree::Config.currency = 'AUD'
|
||||
end
|
||||
|
||||
describe "fetching products" do
|
||||
let(:exchange) { order_cycle.exchanges.to_enterprises(d).outgoing.first }
|
||||
let(:image) { white_logo_file }
|
||||
let(:cache_key_patterns) do
|
||||
[
|
||||
'api\/taxon_serializer\/spree\/taxons',
|
||||
'enterprise'
|
||||
]
|
||||
end
|
||||
|
||||
before do
|
||||
11.times do
|
||||
p = create(:simple_product)
|
||||
p.set_property 'Organic Certified', 'NASAA 12345'
|
||||
v1 = create(:variant, product: p)
|
||||
v2 = create(:variant, product: p)
|
||||
Spree::Image.create! viewable_id: p.master.id, viewable_type: 'Spree::Variant',
|
||||
attachment: image
|
||||
|
||||
exchange.variants << [v1, v2]
|
||||
end
|
||||
end
|
||||
|
||||
it "returns products via json" do
|
||||
results = multi_benchmark(3, cache_key_patterns: cache_key_patterns) do
|
||||
get :products, xhr: true
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user