Commit a0a423fe authored by Arinde Eniola's avatar Arinde Eniola

fix failing tests

parent d0ad5669
......@@ -36,19 +36,37 @@
$(".selected_issue").bind "change", Issues.checkChanged
getLabelsQueryString: ->
pageURL = decodeURIComponent(window.location.search.substring(1))
urlVariables = pageURL.split('&')
labelParams = (
variables for variables in urlVariables when variables.indexOf('label_name[]') > -1
).join('&')
removeLabelsQueryString: (url) ->
pageURL = decodeURIComponent(url)
urlVariables = pageURL.split('&')
Params = (
variables for variables in urlVariables when variables.indexOf('label_name[]') is -1
).join('&')
# Update state filters if present in page
updateStateFilters: ->
stateFilters = $('.issues-state-filters')
newParams = {}
paramKeys = ['author_id', 'label_name', 'milestone_title', 'assignee_id', 'issue_search']
paramKeys = ['author_id', 'milestone_title', 'assignee_id', 'issue_search']
for paramKey in paramKeys
newParams[paramKey] = gl.utils.getUrlParameter(paramKey) or ''
if stateFilters.length
stateFilters.find('a').each ->
initialUrl = $(this).attr 'href'
$(this).attr 'href', gl.utils.mergeUrlParams(newParams, initialUrl)
initialUrl = Issues.removeLabelsQueryString($(this).attr 'href')
if Issues.getLabelsQueryString()
newUrl = "#{gl.utils.mergeUrlParams(newParams, initialUrl)}&#{Issues.getLabelsQueryString()}"
else
newUrl = gl.utils.mergeUrlParams(newParams, initialUrl)
$(this).attr 'href', newUrl
# Make sure we trigger ajax request only after user stop typing
initSearch: ->
......@@ -91,7 +109,8 @@
opacity: 0
}
}).then( ->
$filteredLabels.html(Issue.labelRow(data))
if typeof Issue.labelRow is 'function'
$filteredLabels.html(Issue.labelRow(data))
$spans = $filteredLabels.find('span')
$spans.css('opacity',0)
return gl.animate.animateEach($spans, 'fadeInUp', 20, {
......
......@@ -254,11 +254,11 @@ module ApplicationHelper
def page_filter_path(options = {})
without = options.delete(:without)
add_label = options.delete(:label)
exist_opts = {
state: params[:state],
scope: params[:scope],
label_name: params[:label_name],
milestone_title: params[:milestone_title],
assignee_id: params[:assignee_id],
author_id: params[:author_id],
......@@ -275,6 +275,13 @@ module ApplicationHelper
path = request.path
path << "?#{options.to_param}"
if add_label
if params[:label_name].present? and params[:label_name].respond_to?('any?')
params[:label_name].each do |label|
path << "&label_name[]=#{label}"
end
end
end
path
end
......
......@@ -4,22 +4,22 @@
- else
- page_context_word = 'issues'
%li{class: ("active" if params[:state] == 'opened')}
= link_to page_filter_path(state: 'opened'), title: "Filter by #{page_context_word} that are currently opened." do
= link_to page_filter_path(state: 'opened', label: true), title: "Filter by #{page_context_word} that are currently opened." do
#{state_filters_text_for(:opened, @project)}
- if defined?(type) && type == :merge_requests
%li{class: ("active" if params[:state] == 'merged')}
= link_to page_filter_path(state: 'merged'), title: 'Filter by merge requests that are currently merged.' do
= link_to page_filter_path(state: 'merged', label: true), title: 'Filter by merge requests that are currently merged.' do
#{state_filters_text_for(:merged, @project)}
%li{class: ("active" if params[:state] == 'closed')}
= link_to page_filter_path(state: 'closed'), title: 'Filter by merge requests that are currently closed and unmerged.' do
= link_to page_filter_path(state: 'closed', label: true), title: 'Filter by merge requests that are currently closed and unmerged.' do
#{state_filters_text_for(:closed, @project)}
- else
%li{class: ("active" if params[:state] == 'closed')}
= link_to page_filter_path(state: 'closed'), title: 'Filter by issues that are currently closed.' do
= link_to page_filter_path(state: 'closed', label: true), title: 'Filter by issues that are currently closed.' do
#{state_filters_text_for(:closed, @project)}
%li{class: ("active" if params[:state] == 'all')}
= link_to page_filter_path(state: 'all'), title: "Show all #{page_context_word}." do
= link_to page_filter_path(state: 'all', label: true), title: "Show all #{page_context_word}." do
#{state_filters_text_for(:all, @project)}
......@@ -84,14 +84,20 @@ describe 'Filter issues', feature: true do
it 'should filter by any label' do
find('.dropdown-menu-labels a', text: 'Any Label').click
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
sleep 2
page.within '.labels-filter' do
expect(page).to have_content 'Any Label'
end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Label')
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Any Label')
end
it 'should filter by no label' do
find('.dropdown-menu-labels a', text: 'No Label').click
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
sleep 2
page.within '.labels-filter' do
expect(page).to have_content 'No Label'
end
......@@ -121,6 +127,7 @@ describe 'Filter issues', feature: true do
find('.js-label-select').click
find('.dropdown-menu-labels .dropdown-content a', text: label.title).click
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
sleep 2
end
......
......@@ -2,8 +2,14 @@ require 'rails_helper'
feature 'Merge Request filtering by Milestone', feature: true do
let(:project) { create(:project, :public) }
let!(:user) { create(:user)}
let(:milestone) { create(:milestone, project: project) }
before do
project.team << [user, :master]
login_as(user)
end
scenario 'filters by no Milestone', js: true do
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
......
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