Commit 3a38cdda authored by Phil Hughes's avatar Phil Hughes

Fixed issue when assigning no weight

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/18374
parent 15191864
......@@ -13,7 +13,7 @@ class @WeightSelect
updateWeight = (selected) ->
data = {}
data[abilityName] = {}
data[abilityName].weight = selected
data[abilityName].weight = if selected? then selected else null
$loading
.fadeIn()
$dropdown.trigger('loading.gl.dropdown')
......@@ -27,7 +27,10 @@ class @WeightSelect
$loading.fadeOut()
$selectbox.hide()
$value.html(data.weight)
if data.weight?
$value.html(data.weight)
else
$value.html('None')
$sidebarCollapsedValue.html(data.weight)
$dropdown.glDropdown(
......@@ -38,7 +41,8 @@ class @WeightSelect
# display:block overrides the hide-collapse rule
$value.css('display', '')
id: (obj, el) ->
$(el).data "id"
if not $(el).data("none")?
$(el).data "id"
clicked: (selected) ->
if $(dropdown).is ".js-filter-submit"
$(dropdown).parents('form').submit()
......
......@@ -151,7 +151,7 @@
%ul
- Issue.weight_options.select{|weight| weight != "Everything" && weight != "Any Weight"}.each do |weight|
%li
%a{href: "#", data: { id: weight }, class: ("is-active" if params[:weight] == weight.to_s)}
%a{href: "#", data: { id: weight, none: ("true" if weight == Issue::WEIGHT_NONE) }, class: ("is-active" if params[:weight] == weight.to_s)}
= weight
= render "shared/issuable/participants", participants: issuable.participants(current_user)
......
......@@ -73,6 +73,35 @@ feature 'Issue Sidebar', feature: true do
end
end
context 'updating weight', js: true do
before do
project.team << [user, :master]
visit_issue(project, issue)
end
it 'should update weight in sidebar to 1' do
page.within '.weight' do
click_link 'Edit'
click_link '1'
page.within '.value' do
expect(page).to have_content '1'
end
end
end
it 'should update weight in sidebar to no weight' do
page.within '.weight' do
click_link 'Edit'
click_link 'No Weight'
page.within '.value' do
expect(page).to have_content 'None'
end
end
end
end
def visit_issue(project, issue)
visit namespace_project_issue_path(project.namespace, project, issue)
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