diff options
author | Francisco Lopez <fjlopez@gitlab.com> | 2017-12-04 12:33:19 +0100 |
---|---|---|
committer | Francisco Lopez <fjlopez@gitlab.com> | 2017-12-04 12:33:19 +0100 |
commit | 264171f72d4ef3e5dfafaf32d3d267ab279469e1 (patch) | |
tree | a00d4974e201663a3f3ce3446510e7a64335d104 | |
parent | 7f2b6b11bd7aaeab73f6f1b5431e9d8f3f034cb6 (diff) | |
download | gitlab-ce-sh-optimize-groups-api.tar.gz |
Fixed bugsh-optimize-groups-api
-rw-r--r-- | app/services/projects/count_service.rb | 7 | ||||
-rw-r--r-- | 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 |