diff options
Diffstat (limited to 'spec/routing')
-rw-r--r-- | spec/routing/group_routing_spec.rb | 113 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 20 |
2 files changed, 29 insertions, 104 deletions
diff --git a/spec/routing/group_routing_spec.rb b/spec/routing/group_routing_spec.rb index 00ca394a50b..c6b101ae908 100644 --- a/spec/routing/group_routing_spec.rb +++ b/spec/routing/group_routing_spec.rb @@ -41,111 +41,16 @@ describe "Groups", "routing" do expect(get("/groups/#{group_path}/-/milestones")).to route_to('groups/milestones#index', group_id: group_path) end - describe 'legacy redirection' do - describe 'labels' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/labels", "/groups/complex.group-namegit/-/labels" do - let(:resource) { create(:group, parent: group, path: 'labels') } - end - - context 'when requesting JSON' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/labels.json", "/groups/complex.group-namegit/-/labels.json" do - let(:resource) { create(:group, parent: group, path: 'labels') } - end - end - end - - describe 'group_members' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/group_members", "/groups/complex.group-namegit/-/group_members" do - let(:resource) { create(:group, parent: group, path: 'group_members') } - end - end - - describe 'avatar' do - it 'routes to the avatars controller' do - expect(delete("/groups/#{group_path}/-/avatar")) - .to route_to(group_id: group_path, - controller: 'groups/avatars', - action: 'destroy') - end - end - - describe 'milestones' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/milestones", "/groups/complex.group-namegit/-/milestones" do - let(:resource) { create(:group, parent: group, path: 'milestones') } - end - - context 'nested routes' do - include RSpec::Rails::RequestExampleGroup - - let(:milestone) { create(:milestone, group: group) } - - it 'redirects the nested routes' do - request = get("/groups/#{group_path}/milestones/#{milestone.id}/merge_requests") - expect(request).to redirect_to("/groups/#{group_path}/-/milestones/#{milestone.id}/merge_requests") - end - end - - context 'with a query string' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/milestones?hello=world", "/groups/complex.group-namegit/-/milestones?hello=world" do - let(:resource) { create(:group, parent: group, path: 'milestones') } - end - - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/milestones?milestones=/milestones", "/groups/complex.group-namegit/-/milestones?milestones=/milestones" do - let(:resource) { create(:group, parent: group, path: 'milestones') } - end - end - end - - describe 'edit' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/edit", "/groups/complex.group-namegit/-/edit" do - let(:resource) do - pending('still rejected because of the wildcard reserved word') - create(:group, parent: group, path: 'edit') - end - end - end - - describe 'issues' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/issues", "/groups/complex.group-namegit/-/issues" do - let(:resource) { create(:group, parent: group, path: 'issues') } - end - end - - describe 'merge_requests' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/merge_requests", "/groups/complex.group-namegit/-/merge_requests" do - let(:resource) { create(:group, parent: group, path: 'merge_requests') } - end - end - - describe 'projects' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/projects", "/groups/complex.group-namegit/-/projects" do - let(:resource) { create(:group, parent: group, path: 'projects') } - end - end - - describe 'activity' do - it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/activity", "/groups/complex.group-namegit/-/activity" do - let(:resource) { create(:group, parent: group, path: 'activity') } - end - - it_behaves_like 'redirecting a legacy path', "/groups/activity/activity", "/groups/activity/-/activity" do - let!(:parent) { create(:group, path: 'activity') } - let(:resource) { create(:group, parent: parent, path: 'activity') } - end - end - - describe 'subgroup "boards"' do - it 'shows group show page' do - allow(Group).to receive(:find_by_full_path).with('gitlabhq/boards', any_args).and_return(true) - - expect(get('/groups/gitlabhq/boards')).to route_to('groups#show', id: 'gitlabhq/boards') - end + it 'routes to the avatars controller' do + expect(delete("/groups/#{group_path}/-/avatar")) + .to route_to(group_id: group_path, + controller: 'groups/avatars', + action: 'destroy') + end - it 'shows boards index page' do - allow(Group).to receive(:find_by_full_path).with('gitlabhq', any_args).and_return(true) + it 'routes to the boards controller' do + allow(Group).to receive(:find_by_full_path).with('gitlabhq', any_args).and_return(true) - expect(get('/groups/gitlabhq/-/boards')).to route_to('groups/boards#index', group_id: 'gitlabhq') - end - end + expect(get('/groups/gitlabhq/-/boards')).to route_to('groups/boards#index', group_id: 'gitlabhq') end end diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 83775b1040e..6dde40d1cb6 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -693,4 +693,24 @@ describe 'project routing' do it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/settings/repository", "/gitlab/gitlabhq/-/settings/repository" end + + describe Projects::TemplatesController, 'routing' do + describe '#show' do + def show_with_template_type(template_type) + "/gitlab/gitlabhq/templates/#{template_type}/template_name" + end + + it 'routes when :template_type is `merge_request`' do + expect(get(show_with_template_type('merge_request'))).to route_to('projects/templates#show', namespace_id: 'gitlab', project_id: 'gitlabhq', template_type: 'merge_request', key: 'template_name', format: 'json') + end + + it 'routes when :template_type is `issue`' do + expect(get(show_with_template_type('issue'))).to route_to('projects/templates#show', namespace_id: 'gitlab', project_id: 'gitlabhq', template_type: 'issue', key: 'template_name', format: 'json') + end + + it 'routes to application#route_not_found when :template_type is unknown' do + expect(get(show_with_template_type('invalid'))).to route_to('application#route_not_found', unmatched_route: 'gitlab/gitlabhq/templates/invalid/template_name') + end + end + end end |