diff --git a/app/views/administrate/application/_navigation.html.erb b/app/views/administrate/application/_navigation.html.erb index e4a40a1771..5e955be277 100644 --- a/app/views/administrate/application/_navigation.html.erb +++ b/app/views/administrate/application/_navigation.html.erb @@ -15,6 +15,6 @@ as defined by the routes in the `admin/` namespace display_resource_name(resource), [namespace, resource_index_route_key(resource)], class: "navigation__link navigation__link--#{nav_link_state(resource)}" - ) %> + ) if valid_action? :index, resource %> <% end %> diff --git a/spec/example_app/config/routes.rb b/spec/example_app/config/routes.rb index 8e64fe1e2e..fe4b7cc9ab 100644 --- a/spec/example_app/config/routes.rb +++ b/spec/example_app/config/routes.rb @@ -5,7 +5,7 @@ resources :log_entries resources :orders resources :products - resources :product_meta_tags + resources :product_meta_tags, except: [:index] resources :payments, only: [:index, :show] resources :series diff --git a/spec/features/navigation_spec.rb b/spec/features/navigation_spec.rb index 0358778dea..bc3f3c9262 100644 --- a/spec/features/navigation_spec.rb +++ b/spec/features/navigation_spec.rb @@ -36,4 +36,10 @@ expect(page).to have_header("Users") end end + + it "hides link to resources without index page" do + visit admin_customers_path + navigation = find(".navigation") + expect(navigation).not_to have_link("Product Meta Tags") + end end