Added issuable_filters_present
to check for active filters before rendering the reset button
Added tests
This commit is contained in:
parent
49d6ca6267
commit
443619300d
3 changed files with 15 additions and 2 deletions
|
@ -124,6 +124,10 @@ module IssuablesHelper
|
|||
end
|
||||
end
|
||||
|
||||
def issuable_filters_present
|
||||
params[:search] || params[:author_id] || params[:assignee_id] || params[:milestone_title] || params[:label_name]
|
||||
end
|
||||
|
||||
def issuables_count_for_state(issuable_type, state)
|
||||
issuables_finder = public_send("#{issuable_type}_finder")
|
||||
issuables_finder.params[:state] = state
|
||||
|
|
|
@ -29,8 +29,9 @@
|
|||
.filter-item.inline.labels-filter
|
||||
= render "shared/issuable/label_dropdown", selected: finder.labels.select(:title).uniq, use_id: false, selected_toggle: params[:label_name], data_options: { field_name: "label_name[]" }
|
||||
|
||||
.filter-item.inline.reset-filters
|
||||
%a{href: page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search])} Reset filters
|
||||
- if issuable_filters_present
|
||||
.filter-item.inline.reset-filters
|
||||
%a{href: page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search])} Reset filters
|
||||
|
||||
.pull-right
|
||||
- if boards_page
|
||||
|
|
|
@ -75,6 +75,14 @@ feature 'Issues filter reset button', feature: true, js: true do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when no filters have been applied' do
|
||||
it 'the reset link should not be visible' do
|
||||
visit_issues(project)
|
||||
expect(page).to have_css('.issue', count: 2)
|
||||
expect(page).not_to have_css '.reset_filters'
|
||||
end
|
||||
end
|
||||
|
||||
def reset_filters
|
||||
find('.reset-filters').click
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue