From 3295e54c1f6aa14c316e302038d63163e46a7d31 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Thu, 21 Sep 2023 22:25:07 +0200 Subject: [PATCH] elia/menu-items-cleanup: [wip] --- .../backend_configuration/menu_item_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb b/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb index c87f602bd04..27a31553965 100644 --- a/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb +++ b/backend/spec/lib/spree/backend_configuration/menu_item_spec.rb @@ -20,8 +20,8 @@ end it 'matches a proc accepting the request object' do - described_class.new(match_path: ->(request) { request.fullpath.iclude? == '/bar/' }) request = double(ActionDispatch::Request, fullpath: '/foo/bar/baz') + subject = described_class.new(match_path: -> { _1.fullpath.include? '/bar/' }) expect(subject.match_path?(request)).to be true end @@ -63,4 +63,20 @@ it { is_expected.to eq("/admin/friendly_promotions") } end end + + describe "deprecated behavior" do + describe "passing `sections` and `icon` sequentially" do + it "warns about the deprecation" do + expect(Spree::Deprecation).to receive(:warn).with(a_string_matching(/sections/)) + expect(Spree::Deprecation).to receive(:warn).with(a_string_matching(/icon/)) + + described_class.new([:foo, :bar], 'icon') + end + + it "raises ArgumentError when providing the wrong number of sequential arguments" do + expect { described_class.new([:foo, :bar], 'icon', 'baz') }.to raise_error(ArgumentError) + expect { described_class.new([:foo, :bar]) }.to raise_error(ArgumentError) + end + end + end end