Skip to content

Commit

Permalink
Merge pull request #4 from ccarruitero/admin_menu
Browse files Browse the repository at this point in the history
add conditional to show reports menu tab
  • Loading branch information
spaghetticode authored Oct 16, 2019
2 parents 1cf562e + caee0b4 commit d973af5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/solidus_reports/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module SolidusReports
class Configuration < Spree::Preferences::Configuration
REPORT_TABS ||= [:reports]

new_item = Spree::BackendConfiguration::MenuItem.new(REPORT_TABS, 'file')
new_item = Spree::BackendConfiguration::MenuItem.new(
REPORT_TABS,
'file',
condition: -> { can?(:admin, REPORT_TABS) }
)
Spree::Backend::Config.menu_items << new_item
end
end
2 changes: 1 addition & 1 deletion spec/features/admin/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
it 'should only display tabs fakedispatch has access to' do
visit spree.admin_path
expect(page).to have_link('Orders')
expect(page).to have_link('Reports')
expect(page).not_to have_link('Reports')
expect(page).not_to have_link('Products')
expect(page).not_to have_link('Promotions')
expect(page).not_to have_link('Settings')
Expand Down

0 comments on commit d973af5

Please sign in to comment.