From 264171f72d4ef3e5dfafaf32d3d267ab279469e1 Mon Sep 17 00:00:00 2001 From: Francisco Lopez Date: Mon, 4 Dec 2017 12:33:19 +0100 Subject: Fixed bug --- app/services/projects/count_service.rb | 7 +++++++ spec/services/projects/count_service_spec.rb | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/services/projects/count_service.rb b/app/services/projects/count_service.rb index 42ebb38f676..933829b557b 100644 --- a/app/services/projects/count_service.rb +++ b/app/services/projects/count_service.rb @@ -25,5 +25,12 @@ module Projects def cache_key ['projects', 'count_service', VERSION, @project.id, cache_key_name] end + + def self.query(project_ids) + raise( + NotImplementedError, + '"query" must be implemented and return an ActiveRecord::Relation' + ) + end end end diff --git a/spec/services/projects/count_service_spec.rb b/spec/services/projects/count_service_spec.rb index cc496501bad..183f6128c7b 100644 --- a/spec/services/projects/count_service_spec.rb +++ b/spec/services/projects/count_service_spec.rb @@ -4,9 +4,17 @@ describe Projects::CountService do let(:project) { build(:project, id: 1) } let(:service) { described_class.new(project) } - describe '#relation_for_count' do + describe '.query' do it 'raises NotImplementedError' do - expect { service.relation_for_count }.to raise_error(NotImplementedError) + expect { described_class.query(project.id) }.to raise_error(NotImplementedError) + end + end + + describe '#relation_for_count' do + it 'calls the class method query with the project id' do + expect(described_class).to receive(:query).with(project.id) + + service.relation_for_count end end -- cgit v1.2.1