diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index fb26a4e6fc335a3780394b5d8388ee32268999e6..828e55092625d0d3d35110852b6d7718b42a2a5f 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -81,6 +81,7 @@ class GroupsController < Groups::ApplicationController def group @group ||= Group.find_by(path: params[:id]) + render_404 unless @group end def load_projects diff --git a/features/explore/groups.feature b/features/explore/groups.feature index 5fc9b1356010c2433d626b51e83b203656e367cb..7529dcc3d9d77c6f2d404051c6f37b56366323cf 100644 --- a/features/explore/groups.feature +++ b/features/explore/groups.feature @@ -3,6 +3,11 @@ Feature: Explore Groups Background: Given group "TestGroup" has private project "Enterprise" + Scenario: I should not see a group if it does not exist + When I sign in as a user + And I visit group "NonExistentGroup" page + Then page status code should be 404 + Scenario: I should see group with private and internal projects as user Given group "TestGroup" has internal project "Internal" When I sign in as a user diff --git a/features/steps/explore/groups.rb b/features/steps/explore/groups.rb index 87f32e70d59257c2b9365c692451d12ad55848d1..68c473e7b29a1c5f09bc9c63e806af9a21c4774f 100644 --- a/features/steps/explore/groups.rb +++ b/features/steps/explore/groups.rb @@ -26,6 +26,10 @@ class Spinach::Features::ExploreGroups < Spinach::FeatureSteps visit group_path(Group.find_by(name: "TestGroup")) end + step 'I visit group "NonExistentGroup" page' do + visit group_path(-1) + end + step 'I visit group "TestGroup" issues page' do visit issues_group_path(Group.find_by(name: "TestGroup")) end