Render only issues/mr in subnav depends on context

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2016-06-10 18:33:44 +03:00
parent 1976a44649
commit d4b2f5d0f3
5 changed files with 21 additions and 17 deletions

View File

@ -63,7 +63,7 @@
Graphs
- if project_nav_tab? :issues
= nav_link(controller: :issues) do
= nav_link(controller: [:issues, :labels, :milestones]) do
= link_to url_for_project_issues(@project, only_path: true), title: 'Issues', class: 'shortcuts-issues' do
= navbar_icon('issues')
%span

View File

@ -1,12 +1,12 @@
%ul.nav-links.sub-nav
%div{ class: (container_class) }
- if project_nav_tab?(:issues)
- if project_nav_tab?(:issues) && current_controller?(:issues)
= nav_link(controller: :issues) do
= link_to url_for_project_issues(@project, only_path: true), title: 'Issues' do
%span
Issues
- if project_nav_tab?(:merge_requests)
- if project_nav_tab?(:merge_requests) && current_controller?(:merge_requests)
= nav_link(controller: :merge_requests) do
= link_to namespace_project_merge_requests_path(@project.namespace, @project), title: 'Merge Requests' do
%span

View File

@ -107,12 +107,16 @@ Feature: Project Active Tab
Scenario: On Project Issues/Milestones
Given I visit my project's issues page
And I click the "Milestones" tab
Then the active main tab should be Milestones
And I click the "Milestones" sub tab
Then the active main tab should be Issues
Then the active sub tab should be Milestones
And no other main tabs should be active
And no other sub tabs should be active
Scenario: On Project Issues/Labels
Given I visit my project's issues page
And I click the "Labels" tab
Then the active main tab should be Labels
And I click the "Labels" sub tab
Then the active main tab should be Issues
Then the active sub tab should be Labels
And no other main tabs should be active
And no other sub tabs should be active

View File

@ -77,14 +77,14 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
# Sub Tabs: Issues
step 'I click the "Milestones" tab' do
page.within('.layout-nav') do
step 'I click the "Milestones" sub tab' do
page.within('.sub-nav') do
click_link('Milestones')
end
end
step 'I click the "Labels" tab' do
page.within('.layout-nav') do
step 'I click the "Labels" sub tab' do
page.within('.sub-nav') do
click_link('Labels')
end
end
@ -93,11 +93,11 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
ensure_active_sub_tab('Issues')
end
step 'the active main tab should be Milestones' do
ensure_active_main_tab('Milestones')
step 'the active sub tab should be Milestones' do
ensure_active_sub_tab('Milestones')
end
step 'the active main tab should be Labels' do
ensure_active_main_tab('Labels')
step 'the active sub tab should be Labels' do
ensure_active_sub_tab('Labels')
end
end

View File

@ -6,7 +6,7 @@ module SharedActiveTab
end
def ensure_active_sub_tab(content)
expect(find('div.content ul.nav-links li.active')).to have_content(content)
expect(find('.sub-nav li.active')).to have_content(content)
end
def ensure_active_sub_nav(content)
@ -18,7 +18,7 @@ module SharedActiveTab
end
step 'no other sub tabs should be active' do
expect(page).to have_selector('div.content ul.nav-links li.active', count: 1)
expect(page).to have_selector('.sub-nav li.active', count: 1)
end
step 'no other sub navs should be active' do