Commit d90e226d authored by Francisco Javier López's avatar Francisco Javier López Committed by Bob Van Landuyt

Fix subgroup url in search drop down

Inside a subgroup scope, when the user clicks on the
search drop down in the header, some options are displayed.

Some of this links direct the user to the issues and merge
requests linked to the subgroup. Nevertheless, the url
was broken because they doesn't include the complete
group namespace
parent b286ac37
- if @group && @group.persisted? && @group.path - if @group && @group.persisted? && @group.path
- group_data_attrs = { group_path: j(@group.path), name: @group.name, issues_path: issues_group_path(j(@group.path)), mr_path: merge_requests_group_path(j(@group.path)) } - group_data_attrs = { group_path: j(@group.path), name: j(@group.name), issues_path: issues_group_path(@group), mr_path: merge_requests_group_path(@group) }
- if @project && @project.persisted? - if @project && @project.persisted?
- project_data_attrs = { project_path: j(@project.path), name: j(@project.name), issues_path: project_issues_path(@project), mr_path: project_merge_requests_path(@project), issues_disabled: !@project.issues_enabled? } - project_data_attrs = { project_path: j(@project.path), name: j(@project.name), issues_path: project_issues_path(@project), mr_path: project_merge_requests_path(@project), issues_disabled: !@project.issues_enabled? }
.search.search-form{ data: { track_label: "navbar_search", track_event: "activate_form_input" } } .search.search-form{ data: { track_label: "navbar_search", track_event: "activate_form_input" } }
......
---
title: Fix subgroup url in search drop down
merge_request: 30457
author:
type: fixed
require 'spec_helper' require 'spec_helper'
describe 'User uses header search field' do describe 'User uses header search field', :js do
include FilteredSearchHelpers include FilteredSearchHelpers
let(:project) { create(:project) } let(:project) { create(:project) }
...@@ -11,57 +11,12 @@ describe 'User uses header search field' do ...@@ -11,57 +11,12 @@ describe 'User uses header search field' do
sign_in(user) sign_in(user)
end end
context 'when user is in a global scope', :js do shared_examples 'search field examples' do
before do before do
visit(root_path) visit(url)
page.find('#search').click
end end
context 'when clicking issues' do it 'starts searching by pressing the enter key' do
it 'shows assigned issues' do
find('.search-input-container .dropdown-menu').click_link('Issues assigned to me')
expect(page).to have_selector('.filtered-search')
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty
end
it 'shows created issues' do
find('.search-input-container .dropdown-menu').click_link("Issues I've created")
expect(page).to have_selector('.filtered-search')
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty
end
end
context 'when clicking merge requests' do
let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignees: [user]) }
it 'shows assigned merge requests' do
find('.search-input-container .dropdown-menu').click_link('Merge requests assigned to me')
expect(page).to have_selector('.filtered-search')
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty
end
it 'shows created merge requests' do
find('.search-input-container .dropdown-menu').click_link("Merge requests I've created")
expect(page).to have_selector('.filtered-search')
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty
end
end
end
context 'when user is in a project scope' do
before do
visit(project_path(project))
end
it 'starts searching by pressing the enter key', :js do
fill_in('search', with: 'gitlab') fill_in('search', with: 'gitlab')
find('#search').native.send_keys(:enter) find('#search').native.send_keys(:enter)
...@@ -70,30 +25,31 @@ describe 'User uses header search field' do ...@@ -70,30 +25,31 @@ describe 'User uses header search field' do
end end
end end
context 'when clicking the search field', :js do context 'when clicking the search field' do
before do before do
page.find('#search').click page.find('#search').click
wait_for_all_requests
end end
it 'shows category search dropdown' do it 'shows category search dropdown' do
expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i) expect(page).to have_selector('.dropdown-header', text: /#{scope_name}/i)
end end
context 'when clicking issues' do context 'when clicking issues' do
let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
it 'shows assigned issues' do it 'shows assigned issues' do
find('.dropdown-menu').click_link('Issues assigned to me') find('.search-input-container .dropdown-menu').click_link('Issues assigned to me')
expect(page).to have_selector('.filtered-search') expect(page).to have_selector('.issues-list .issue')
expect_tokens([assignee_token(user.name)]) expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'shows created issues' do it 'shows created issues' do
find('.dropdown-menu').click_link("Issues I've created") find('.search-input-container .dropdown-menu').click_link("Issues I've created")
expect(page).to have_selector('.filtered-search') expect(page).to have_selector('.issues-list .issue')
expect_tokens([author_token(user.name)]) expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -103,33 +59,77 @@ describe 'User uses header search field' do ...@@ -103,33 +59,77 @@ describe 'User uses header search field' do
let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignees: [user]) } let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignees: [user]) }
it 'shows assigned merge requests' do it 'shows assigned merge requests' do
find('.dropdown-menu').click_link('Merge requests assigned to me') find('.search-input-container .dropdown-menu').click_link('Merge requests assigned to me')
expect(page).to have_selector('.merge-requests-holder') expect(page).to have_selector('.mr-list .merge-request')
expect_tokens([assignee_token(user.name)]) expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
it 'shows created merge requests' do it 'shows created merge requests' do
find('.dropdown-menu').click_link("Merge requests I've created") find('.search-input-container .dropdown-menu').click_link("Merge requests I've created")
expect(page).to have_selector('.merge-requests-holder') expect(page).to have_selector('.mr-list .merge-request')
expect_tokens([author_token(user.name)]) expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
end end
context 'when entering text into the search field', :js do context 'when entering text into the search field' do
before do before do
page.within('.search-input-wrap') do page.within('.search-input-wrap') do
fill_in('search', with: project.name[0..3]) fill_in('search', with: scope_name.first(4))
end end
end end
it 'does not display the category search dropdown' do it 'does not display the category search dropdown' do
expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i) expect(page).not_to have_selector('.dropdown-header', text: /#{scope_name}/i)
end end
end end
end end
context 'when user is in a global scope' do
include_examples 'search field examples' do
let(:url) { root_path }
let(:scope_name) { 'All GitLab' }
end
end
context 'when user is in a project scope' do
include_examples 'search field examples' do
let(:url) { project_path(project) }
let(:scope_name) { project.name }
end
end
context 'when user is in a group scope' do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
before do
group.add_maintainer(user)
end
include_examples 'search field examples' do
let(:url) { group_path(group) }
let(:scope_name) { group.name }
end
end
context 'when user is in a subgroup scope' do
let(:group) { create(:group) }
let(:subgroup) { create(:group, :public, parent: group) }
let(:project) { create(:project, namespace: subgroup) }
before do
group.add_owner(user)
subgroup.add_owner(user)
end
include_examples 'search field examples' do
let(:url) { group_path(subgroup) }
let(:scope_name) { subgroup.name }
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment