summaryrefslogtreecommitdiff
path: root/spec/features/projects/branches_spec.rb
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-06-30 12:31:41 +0100
committerPhil Hughes <me@iamphill.com>2017-06-30 12:37:35 +0100
commit531a4d124b0a17280b4118d7fa7c66f11042917b (patch)
treea2ee668d403ed538d6046f942f31bce2c1224563 /spec/features/projects/branches_spec.rb
parentf5681fb55a762c9b9bb35c80bf87d727d8d8fd06 (diff)
parent81dba76b9d7d120cd22e3619a4058bd4885be9bc (diff)
downloadgitlab-ce-experimental-breadcrumbs.tar.gz
Merge branch 'master' into experimental-breadcrumbsexperimental-breadcrumbs
Diffstat (limited to 'spec/features/projects/branches_spec.rb')
-rw-r--r--spec/features/projects/branches_spec.rb40
1 files changed, 39 insertions, 1 deletions
diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb
index 8694366de35..0050864d305 100644
--- a/spec/features/projects/branches_spec.rb
+++ b/spec/features/projects/branches_spec.rb
@@ -21,10 +21,48 @@ describe 'Branches', feature: true do
it 'shows all the branches' do
visit namespace_project_branches_path(project.namespace, project)
- repository.branches { |branch| expect(page).to have_content("#{branch.name}") }
+ repository.branches_sorted_by(:name).first(20).each do |branch|
+ expect(page).to have_content("#{branch.name}")
+ end
expect(page).to have_content("Protected branches can be managed in project settings")
end
+ it 'sorts the branches by name' do
+ visit namespace_project_branches_path(project.namespace, project)
+
+ click_button "Name" # Open sorting dropdown
+ click_link "Name"
+
+ sorted = repository.branches_sorted_by(:name).first(20).map do |branch|
+ Regexp.escape(branch.name)
+ end
+ expect(page).to have_content(/#{sorted.join(".*")}/)
+ end
+
+ it 'sorts the branches by last updated' do
+ visit namespace_project_branches_path(project.namespace, project)
+
+ click_button "Name" # Open sorting dropdown
+ click_link "Last updated"
+
+ sorted = repository.branches_sorted_by(:updated_desc).first(20).map do |branch|
+ Regexp.escape(branch.name)
+ end
+ expect(page).to have_content(/#{sorted.join(".*")}/)
+ end
+
+ it 'sorts the branches by oldest updated' do
+ visit namespace_project_branches_path(project.namespace, project)
+
+ click_button "Name" # Open sorting dropdown
+ click_link "Oldest updated"
+
+ sorted = repository.branches_sorted_by(:updated_asc).first(20).map do |branch|
+ Regexp.escape(branch.name)
+ end
+ expect(page).to have_content(/#{sorted.join(".*")}/)
+ end
+
it 'avoids a N+1 query in branches index' do
control_count = ActiveRecord::QueryRecorder.new { visit namespace_project_branches_path(project.namespace, project) }.count