Commit a0fc5a94 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '356661-fix-decrement-sidebar-mr-count' into 'master'

Fix bug when decrementing open MR count

See merge request gitlab-org/gitlab!83516
parents 045870d6 34489c5a
...@@ -124,7 +124,7 @@ MergeRequest.prototype.submitNoteForm = function (form, $button) { ...@@ -124,7 +124,7 @@ MergeRequest.prototype.submitNoteForm = function (form, $button) {
MergeRequest.decreaseCounter = function (by = 1) { MergeRequest.decreaseCounter = function (by = 1) {
const $el = $('.js-merge-counter'); const $el = $('.js-merge-counter');
const count = Math.max(parseInt($el.text().replace(/[^\d]/, ''), 10) - by, 0); const count = Math.max(parseInt($el.first().text().replace(/[^\d]/, ''), 10) - by, 0);
$el.text(addDelimiter(count)); $el.text(addDelimiter(count));
}; };
......
...@@ -10,7 +10,7 @@ RSpec.describe "User merges a merge request", :js do ...@@ -10,7 +10,7 @@ RSpec.describe "User merges a merge request", :js do
end end
shared_examples "fast forward merge a merge request" do shared_examples "fast forward merge a merge request" do
it "merges a merge request", :sidekiq_might_not_need_inline do it "merges a merge request", :sidekiq_inline do
expect(page).to have_content("Fast-forward merge without a merge commit").and have_button("Merge") expect(page).to have_content("Fast-forward merge without a merge commit").and have_button("Merge")
page.within(".mr-state-widget") do page.within(".mr-state-widget") do
...@@ -42,4 +42,23 @@ RSpec.describe "User merges a merge request", :js do ...@@ -42,4 +42,23 @@ RSpec.describe "User merges a merge request", :js do
it_behaves_like "fast forward merge a merge request" it_behaves_like "fast forward merge a merge request"
end end
end end
context 'sidebar merge requests counter' do
let(:project) { create(:project, :public, :repository) }
let!(:merge_request) { create(:merge_request, source_project: project) }
it 'decrements the open MR count', :sidekiq_inline do
create(:merge_request, source_project: project, source_branch: 'branch-1')
visit(merge_request_path(merge_request))
expect(page).to have_css('.js-merge-counter', text: '2')
page.within(".mr-state-widget") do
click_button("Merge")
end
expect(page).to have_css('.js-merge-counter', text: '1')
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