mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Inspecting 1480 files
...................................................................................................................................................................C.......C..........C...............................................................................................................................................................................................................C...........................................................................................................C.........C...............................................................................................................................................................................................................................................................C........................................CC...C............................................................................................................................................................................................................................................................................................................................C.....................................................................................................................................................................................................C..............C.........C..CC.......C.....................................................................................................C...............
Offenses:
app/helpers/application_helper.rb:41:32: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def ng_form_for(name, *args, &block)
^^^^^^
app/helpers/application_helper.rb:44:75: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &block)
^^^^^^
app/helpers/application_helper.rb:49:37: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def method_missing(method, *args, &block)
^^^^^^
app/helpers/link_helper.rb:4:57: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def link_to_service(baseurl, name, html_options = {}, &block)
^^^^^^
app/helpers/link_helper.rb:8:51: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
link_to ext_url(baseurl, name), html_options, &block
^^^^^^
app/helpers/spree/admin/base_helper.rb:6:56: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def field_container(model, method, options = {}, &block)
^^^^^^
app/helpers/spree/admin/base_helper.rb:13:29: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
capture(&block),
^^^^^^
app/reflexes/application_reflex.rb:29:19: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def with_locale(&block)
^^^^^^
app/reflexes/application_reflex.rb:30:43: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
I18n.with_locale(current_user.locale, &block)
^^^^^^
app/services/cache_service.rb:8:43: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def self.cache(cache_key, options = {}, &block)
^^^^^^
app/services/cache_service.rb:9:48: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
Rails.cache.fetch cache_key.to_s, options, &block
^^^^^^
app/services/cache_service.rb:14:58: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def self.cached_data_by_class(cache_key, cached_class, &block)
^^^^^^
app/services/cache_service.rb:16:23: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
&block
^^^^^^
app/services/cache_service.rb:25:34: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def self.home_stats(statistic, &block)
^^^^^^
app/services/cache_service.rb:28:47: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
race_condition_ttl: 10, &block)
^^^^^^
app/services/current_order_locker.rb:12:31: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def self.around(controller, &block)
^^^^^^
app/services/current_order_locker.rb:13:55: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
lock_order_and_variants(controller.current_order, &block)
^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:392:28: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def chain_to_scope(&block)
^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:393:41: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
@scope = @scope.instance_eval(&block)
^^^^^^
lib/spree/core/controller_helpers/respond_with.rb:7:34: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def respond_with(*resources, &block)
^^^^^^
lib/spree/core/controller_helpers/respond_with.rb:13:64: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
return unless (collector = retrieve_collector_from_mimes(&block))
^^^^^^
lib/spree/core/delegate_belongs_to.rb:80:39: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def class_def(name, method = nil, &blk)
^^^^
lib/spree/core/delegate_belongs_to.rb:81:54: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
class_eval { method.nil? ? define_method(name, &blk) : define_method(name, method) }
^^^^
lib/spree/core/environment_extension.rb:22:31: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def create_method(name, &block)
^^^^^^
lib/spree/core/environment_extension.rb:23:51: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
self.class.__send__(:define_method, name, &block)
^^^^^^
spec/models/enterprise_caching_spec.rb:144:13: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def later(&block)
^^^^^^
spec/models/enterprise_caching_spec.rb:145:36: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
Timecop.travel(1.day.from_now, &block)
^^^^^^
spec/support/embedded_pages_helper.rb:5:26: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def on_embedded_page(&block)
^^^^^^
spec/support/embedded_pages_helper.rb:6:28: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
within_frame :frame, &block
^^^^^^
spec/support/preferences_helper.rb:11:31: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def reset_spree_preferences(&config_block)
^^^^^^^^^^^^^
spec/support/preferences_helper.rb:16:33: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
configure_spree_preferences(&config_block) if block_given?
^^^^^^^^^^^^^
spec/support/request/shop_workflow.rb:87:37: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def within_variant(variant = nil, &block)
^^^^^^
spec/support/request/shop_workflow.rb:90:22: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
within(selector, &block)
^^^^^^
spec/support/request/ui_component_helper.rb:4:23: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def browse_as_small(&block)
^^^^^^
spec/support/request/ui_component_helper.rb:5:39: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
browse_with_window_size(640, 480, &block)
^^^^^^
spec/support/request/ui_component_helper.rb:8:24: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def browse_as_medium(&block)
^^^^^^
spec/support/request/ui_component_helper.rb:9:40: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
browse_with_window_size(1024, 768, &block)
^^^^^^
spec/support/request/web_helper.rb:52:23: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def within_row(num, &block)
^^^^^^
spec/support/request/web_helper.rb:53:54: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
within("table.index tbody tr:nth-child(#{num})", &block)
^^^^^^
spec/swagger_helper.rb:77:19: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def param(args, &block)
^^^^^^
spec/swagger_helper.rb:78:45: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
public_send(:let, args) { instance_eval(&block) }
^^^^^^
spec/system/support/capybara_setup.rb:20:27: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
def using_session(name, &block)
^^^^^^
1480 files inspected, 42 offenses detected, 42 offenses corrected
148 lines
4.9 KiB
Ruby
148 lines
4.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
describe Enterprise do
|
|
context "key-based caching invalidation" do
|
|
describe "is touched when a(n)" do
|
|
let(:enterprise) { create(:distributor_enterprise) }
|
|
let(:taxon) { create(:taxon) }
|
|
let(:supplier2) { create(:supplier_enterprise) }
|
|
|
|
describe "with a supplied product" do
|
|
let(:product) { create(:simple_product, supplier: enterprise) }
|
|
let!(:classification) { create(:classification, taxon: taxon, product: product) }
|
|
let(:property) { product.product_properties.last }
|
|
let(:producer_property) { enterprise.producer_properties.last }
|
|
|
|
before do
|
|
product.set_property 'Organic', 'NASAA 12345'
|
|
enterprise.set_producer_property 'Biodynamic', 'ASDF 4321'
|
|
end
|
|
|
|
it "touches enterprise when a classification on that product changes" do
|
|
expect {
|
|
later { classification.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when a property on that product changes" do
|
|
expect {
|
|
later { property.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when a producer property on that product changes" do
|
|
expect {
|
|
later { producer_property.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when the supplier of a product changes" do
|
|
expect {
|
|
later { product.update!(supplier: supplier2) }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
end
|
|
|
|
describe "with a distributed product" do
|
|
let(:product) { create(:simple_product) }
|
|
let(:oc) {
|
|
create(:simple_order_cycle, distributors: [enterprise],
|
|
variants: [product.variants.first])
|
|
}
|
|
let(:supplier) { product.supplier }
|
|
let!(:classification) { create(:classification, taxon: taxon, product: product) }
|
|
let(:property) { product.product_properties.last }
|
|
let(:producer_property) { supplier.producer_properties.last }
|
|
|
|
before do
|
|
product.set_property 'Organic', 'NASAA 12345'
|
|
supplier.set_producer_property 'Biodynamic', 'ASDF 4321'
|
|
end
|
|
|
|
context "with an order cycle" do
|
|
before { oc }
|
|
|
|
it "touches enterprise when a classification on that product changes" do
|
|
expect {
|
|
later { classification.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when a property on that product changes" do
|
|
expect {
|
|
later { property.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when a producer property on that product changes" do
|
|
expect {
|
|
later { producer_property.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when the supplier of a product changes" do
|
|
expect {
|
|
later { product.update!(supplier: supplier2) }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when a relevant exchange is updated" do
|
|
expect {
|
|
later { oc.exchanges.first.update!(updated_at: Time.zone.now) }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
end
|
|
|
|
it "touches enterprise when the product's variant is added to order cycle" do
|
|
expect {
|
|
later { oc }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
end
|
|
|
|
describe "with relatives" do
|
|
let(:child_enterprise) { create(:supplier_enterprise) }
|
|
let!(:er) { create(:enterprise_relationship, parent: enterprise, child: child_enterprise) }
|
|
|
|
it "touches enterprise when enterprise relationship is updated" do
|
|
expect {
|
|
later { er.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
end
|
|
|
|
describe "with shipping methods" do
|
|
let(:sm) { create(:shipping_method) }
|
|
|
|
before do
|
|
enterprise.shipping_methods << sm
|
|
end
|
|
|
|
it "touches enterprise when distributor_shipping_method is updated" do
|
|
expect {
|
|
later { enterprise.distributor_shipping_methods.first.touch }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
|
|
it "touches enterprise when shipping method is updated" do
|
|
expect {
|
|
later { sm.save! }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
end
|
|
|
|
it "touches enterprise when address is updated" do
|
|
expect {
|
|
later { enterprise.address.save! }
|
|
}.to change { enterprise.reload.updated_at }
|
|
end
|
|
end
|
|
end
|
|
|
|
def later(&)
|
|
Timecop.travel(1.day.from_now, &)
|
|
end
|
|
end
|