Skip to content
Snippets Groups Projects
Commit c04fb3d3 authored by Serhii Yarynovskyi's avatar Serhii Yarynovskyi
Browse files

test

parent 9349815c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -267,8 +267,8 @@ def issuable_sort_options(viewing_issues, viewing_merge_requests)
options.concat([title_option])
end
 
def can_sort_by_issue_weight?(viewing_issues)
viewing_issues && (@project || @group)&.licensed_feature_available?(:issue_weights)
def can_sort_by_issue_weight?(_viewing_issues)
false
end
 
def due_date_option
Loading
Loading
Loading
Loading
@@ -47,6 +47,11 @@ def issuable_sort_options(viewing_issues, viewing_merge_requests)
options
end
 
override :can_sort_by_issue_weight?
def can_sort_by_issue_weight?(viewing_issues)
viewing_issues && (@project || @group)&.licensed_feature_available?(:issue_weights)
end
def weight_option
{ value: sort_value_weight, text: sort_title_weight, href: page_filter_path(sort: sort_value_weight) }
end
Loading
Loading
Loading
Loading
@@ -20,4 +20,38 @@
expect(runners_sort_options_hash['contacted_asc']).to eq('Last Contact')
end
end
describe '#can_sort_by_issue_weight?' do
context 'when user is viewing issues' do
before do
instance_variable_set(:@group, build(:group))
end
context 'when issue_weights feature is enabled' do
before do
stub_licensed_features(issue_weights: true)
end
it 'returns true' do
expect(can_sort_by_issue_weight?(true)).to eq(true)
end
end
context 'when issue_weights feature is disabled' do
before do
stub_licensed_features(issue_weights: false)
end
it 'returns false' do
expect(can_sort_by_issue_weight?(true)).to eq(false)
end
end
end
context 'when user is not viewing issues' do
it 'returns false' do
expect(can_sort_by_issue_weight?(false)).to eq(false)
end
end
end
end
Loading
Loading
@@ -29,10 +29,9 @@ def self.helper_method(name); end
let(:issue_weights_available) { true }
 
before do
controller.instance_variable_set(:@group, group)
allow(controller).to receive(:default_sort_order).and_return('updated_desc')
allow(controller).to receive(:action_name).and_return('issues')
allow(group).to receive(:licensed_feature_available?).and_return(issue_weights_available)
allow(controller).to receive(:can_sort_by_issue_weight?).and_return(issue_weights_available)
user.user_preference.update!(issues_sort: sorting_field)
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment