Commit d777b87b authored by Robert Speicher's avatar Robert Speicher

Merge branch 'disable-mr-sort-by-weight' into 'master'

Fix Error 500 when attempting to sort merge requests by weight

Fixes #673

See merge request !477
parents 23520789 6ac89382
...@@ -295,7 +295,8 @@ class IssuableFinder ...@@ -295,7 +295,8 @@ class IssuableFinder
end end
def weights? def weights?
params[:weight].present? && params[:weight] != Issue::WEIGHT_ALL params[:weight].present? && params[:weight] != Issue::WEIGHT_ALL &&
klass.column_names.include?('weight')
end end
def filter_by_no_weight? def filter_by_no_weight?
......
...@@ -34,6 +34,22 @@ describe IssuesFinder do ...@@ -34,6 +34,22 @@ describe IssuesFinder do
expect(issues).to contain_exactly(issue1, issue2, issue3) expect(issues).to contain_exactly(issue1, issue2, issue3)
end end
context 'sort by issues with no weight' do
let(:params) { { weight: Issue::WEIGHT_NONE } }
it 'returns all issues' do
expect(issues).to contain_exactly(issue1, issue2, issue3)
end
end
context 'sort by issues with any weight' do
let(:params) { { weight: Issue::WEIGHT_ANY } }
it 'returns all issues' do
expect(issues).to be_empty
end
end
context 'filtering by assignee ID' do context 'filtering by assignee ID' do
let(:params) { { assignee_id: user.id } } let(:params) { { assignee_id: user.id } }
......
...@@ -29,5 +29,11 @@ describe MergeRequestsFinder do ...@@ -29,5 +29,11 @@ describe MergeRequestsFinder do
merge_requests = MergeRequestsFinder.new(user, params).execute merge_requests = MergeRequestsFinder.new(user, params).execute
expect(merge_requests.size).to eq(1) expect(merge_requests.size).to eq(1)
end end
it 'should ignore sorting by weight' do
params = { project_id: project1.id, scope: 'authored', state: 'opened', weight: Issue::WEIGHT_ANY }
merge_requests = MergeRequestsFinder.new(user, params).execute
expect(merge_requests.size).to eq(1)
end
end end
end 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