Commit c2823a4b authored by Jan's avatar Jan Committed by Rémy Coutable

Resolve "Protected branches count is wrong when a wildcard includes several protected branches"

parent 6587a0cd
...@@ -16,6 +16,10 @@ module Projects ...@@ -16,6 +16,10 @@ module Projects
@protected_tags = @project.protected_tags.order(:name).page(params[:page]) @protected_tags = @project.protected_tags.order(:name).page(params[:page])
@protected_branch = @project.protected_branches.new @protected_branch = @project.protected_branches.new
@protected_tag = @project.protected_tags.new @protected_tag = @project.protected_tags.new
@protected_branches_count = @protected_branches.reduce(0) { |sum, branch| sum + branch.matching(@project.repository.branches).size }
@protected_tags_count = @protected_tags.reduce(0) { |sum, tag| sum + tag.matching(@project.repository.tags).size }
load_gon_index load_gon_index
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- if @protected_branches.empty? - if @protected_branches.empty?
.panel-heading .panel-heading
%h3.panel-title %h3.panel-title
Protected branch (#{@protected_branches.size}) Protected branch (#{@protected_branches_count})
%p.settings-message.text-center %p.settings-message.text-center
There are currently no protected branches, protect a branch with the form above. There are currently no protected branches, protect a branch with the form above.
- else - else
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
%col %col
%thead %thead
%tr %tr
%th Protected branch (#{@protected_branches.size}) %th Protected branch (#{@protected_branches_count})
%th Last commit %th Last commit
%th Allowed to merge %th Allowed to merge
%th Allowed to push %th Allowed to push
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- if @protected_tags.empty? - if @protected_tags.empty?
.panel-heading .panel-heading
%h3.panel-title %h3.panel-title
Protected tag (#{@protected_tags.size}) Protected tag (#{@protected_tags_count})
%p.settings-message.text-center %p.settings-message.text-center
There are currently no protected tags, protect a tag with the form above. There are currently no protected tags, protect a tag with the form above.
- else - else
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
%col %col
%thead %thead
%tr %tr
%th Protected tag (#{@protected_tags.size}) %th Protected tag (#{@protected_tags_count})
%th Last commit %th Last commit
%th Allowed to create %th Allowed to create
- if can_admin_project - if can_admin_project
......
---
title: Include matching branches and tags in protected branches / tags count
merge_request:
author: Jan Beckmann
type: fixed
...@@ -142,7 +142,10 @@ feature 'Protected Branches', :js do ...@@ -142,7 +142,10 @@ feature 'Protected Branches', :js do
set_protected_branch_name('*-stable') set_protected_branch_name('*-stable')
click_on "Protect" click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content("2 matching branches") } within(".protected-branches-list") do
expect(page).to have_content("Protected branch (2)")
expect(page).to have_content("2 matching branches")
end
end end
it "displays all the branches matching the wildcard" do it "displays all the branches matching the wildcard" do
......
...@@ -65,7 +65,10 @@ feature 'Protected Tags', :js do ...@@ -65,7 +65,10 @@ feature 'Protected Tags', :js do
set_protected_tag_name('*-stable') set_protected_tag_name('*-stable')
click_on "Protect" click_on "Protect"
within(".protected-tags-list") { expect(page).to have_content("2 matching tags") } within(".protected-tags-list") do
expect(page).to have_content("Protected tag (2)")
expect(page).to have_content("2 matching tags")
end
end end
it "displays all the tags matching the wildcard" do it "displays all the tags matching the wildcard" do
......
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