Skip to content

Commit

Permalink
Set match_path on stock items MenuItem
Browse files Browse the repository at this point in the history
Without setting match_path the tab helper uses the current controller
name as criteria to activate the tab in the menu. Since the stock items
controller can be accessed for a single product or all products we need
to make sure it only matches the /stock_items path for the Stock menu
tab.

Closes #2950
  • Loading branch information
tvdeyen committed Nov 23, 2018
1 parent 04f4214 commit bc5825f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/app/models/spree/backend_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def menu_items
condition: -> { can?(:admin, Spree::StockItem) },
label: :stock,
url: :admin_stock_items_path,
match_path: '/stock_items',
position: 3
),
MenuItem.new(
Expand Down
22 changes: 22 additions & 0 deletions backend/spec/models/spree/backend_configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::BackendConfiguration do
describe '#menu_items' do
subject do
described_class.new.menu_items
end

describe 'menu tab for stock items' do
let(:stock_menu_item) do
subject.detect { |item| item.label == :stock }
end

# Regression for https://github.com/solidusio/solidus/issues/2950
it 'has match_path set to /stock_items' do
expect(stock_menu_item.match_path).to eq('/stock_items')
end
end
end
end

0 comments on commit bc5825f

Please sign in to comment.