From 3c25e8734f137d5e32d0cce4ec4cd95e90a39d07 Mon Sep 17 00:00:00 2001 From: Aleksei Lipniagov Date: Fri, 9 Aug 2019 17:46:55 +0300 Subject: Fix :wiki_can_not_be_created_total counter --- app/services/projects/update_service.rb | 2 +- .../alipniagov-fix-wiki_can_not_be_created_total-counter.yml | 5 +++++ spec/services/projects/update_service_spec.rb | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/alipniagov-fix-wiki_can_not_be_created_total-counter.yml diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index 2bc04470342..caab946174d 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -122,7 +122,7 @@ module Projects ProjectWiki.new(project, project.owner).wiki rescue ProjectWiki::CouldNotCreateWikiError log_error("Could not create wiki for #{project.full_name}") - Gitlab::Metrics.counter(:wiki_can_not_be_created_total, 'Counts the times we failed to create a wiki') + Gitlab::Metrics.counter(:wiki_can_not_be_created_total, 'Counts the times we failed to create a wiki').increment end def update_pages_config diff --git a/changelogs/unreleased/alipniagov-fix-wiki_can_not_be_created_total-counter.yml b/changelogs/unreleased/alipniagov-fix-wiki_can_not_be_created_total-counter.yml new file mode 100644 index 00000000000..58f969ed742 --- /dev/null +++ b/changelogs/unreleased/alipniagov-fix-wiki_can_not_be_created_total-counter.yml @@ -0,0 +1,5 @@ +--- +title: Fix :wiki_can_not_be_created_total counter +merge_request: 31673 +author: +type: fixed diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index 6bbaa410d56..82010dd283c 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -186,7 +186,10 @@ describe Projects::UpdateService do expect_any_instance_of(ProjectWiki).to receive(:wiki).and_raise(ProjectWiki::CouldNotCreateWikiError) expect_any_instance_of(described_class).to receive(:log_error).with("Could not create wiki for #{project.full_name}") - expect(Gitlab::Metrics).to receive(:counter) + + counter = double(:counter) + expect(Gitlab::Metrics).to receive(:counter).with(:wiki_can_not_be_created_total, 'Counts the times we failed to create a wiki').and_return(counter) + expect(counter).to receive(:increment) update_project(project, user, project_feature_attributes: { wiki_access_level: ProjectFeature::ENABLED }) end -- cgit v1.2.1