Commit cb196194 authored by Igor Drozdov's avatar Igor Drozdov

Display stale branches oldest at the top

Currently, branches#index (overview and stale) displays the most
recent stale branch (updated 3 months ago). It's more reasonable
to display the stalest branches there instead.
parent 2f219efa
......@@ -18,8 +18,8 @@ class Projects::BranchesController < Projects::ApplicationController
def index
respond_to do |format|
format.html do
@sort = params[:sort].presence || sort_value_recently_updated
@mode = params[:state].presence || 'overview'
@sort = sort_value_for_mode
@overview_max_branches = 5
# Fetch branches for the specified mode
......@@ -125,6 +125,12 @@ class Projects::BranchesController < Projects::ApplicationController
private
def sort_value_for_mode
return params[:sort] if params[:sort].present?
'stale' == @mode ? sort_value_oldest_updated : sort_value_recently_updated
end
# It can be expensive to calculate the diverging counts for each
# branch. Normally the frontend should be specifying a set of branch
# names, but prior to
......
......@@ -512,7 +512,8 @@ RSpec.describe Projects::BranchesController do
state: 'all'
}
expect(controller.instance_variable_get(:@branch_pipeline_statuses)["master"].group).to eq("success")
expect(assigns[:branch_pipeline_statuses]["master"].group).to eq("success")
expect(assigns[:sort]).to eq('updated_desc')
end
end
......@@ -543,8 +544,8 @@ RSpec.describe Projects::BranchesController do
state: 'all'
}
expect(controller.instance_variable_get(:@branch_pipeline_statuses)["master"].group).to eq("running")
expect(controller.instance_variable_get(:@branch_pipeline_statuses)["test"].group).to eq("success")
expect(assigns[:branch_pipeline_statuses]["master"].group).to eq("running")
expect(assigns[:branch_pipeline_statuses]["test"].group).to eq("success")
end
end
......@@ -555,10 +556,11 @@ RSpec.describe Projects::BranchesController do
params: {
namespace_id: project.namespace,
project_id: project,
state: 'all'
state: 'stale'
}
expect(controller.instance_variable_get(:@branch_pipeline_statuses)).to be_blank
expect(assigns[:branch_pipeline_statuses]).to be_blank
expect(assigns[:sort]).to eq('updated_asc')
end
end
......@@ -573,10 +575,12 @@ RSpec.describe Projects::BranchesController do
params: {
namespace_id: project.namespace,
project_id: project,
sort: 'name_asc',
state: 'all'
}
expect(response).to have_gitlab_http_status(:ok)
expect(assigns[:sort]).to eq('name_asc')
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