diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 21:10:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 21:10:32 +0300 |
commit | 21db5294d4ba402f9d44a1f59e8344daef0911a2 (patch) | |
tree | d888dbe0a42ce86efe9e235602fe5209b196ada7 /spec/lib/gitlab/github_import/issuable_finder_spec.rb | |
parent | 155f106fd5b5214c387e9b9143e9fa5725daed54 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/github_import/issuable_finder_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/issuable_finder_spec.rb | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/spec/lib/gitlab/github_import/issuable_finder_spec.rb b/spec/lib/gitlab/github_import/issuable_finder_spec.rb index f009b61ad89..3afd006109b 100644 --- a/spec/lib/gitlab/github_import/issuable_finder_spec.rb +++ b/spec/lib/gitlab/github_import/issuable_finder_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::IssuableFinder, :clean_gitlab_redis_cache do - let(:project) { double(:project, id: 4) } + let(:project) { double(:project, id: 4, group: nil) } let(:issue) do double(:issue, issuable_type: MergeRequest, iid: 1) end @@ -26,15 +26,77 @@ RSpec.describe Gitlab::GithubImport::IssuableFinder, :clean_gitlab_redis_cache d expect { finder.database_id }.to raise_error(TypeError) end + + context 'when group is present' do + context 'when github_importer_single_endpoint_notes_import feature flag is enabled' do + it 'reads cache value with longer timeout' do + project = create(:project, import_url: 'http://t0ken@github.com/user/repo.git') + group = create(:group, projects: [project]) + + stub_feature_flags(github_importer_single_endpoint_notes_import: group) + + expect(Gitlab::Cache::Import::Caching) + .to receive(:read) + .with(anything, timeout: Gitlab::Cache::Import::Caching::LONGER_TIMEOUT) + + described_class.new(project, issue).database_id + end + end + + context 'when github_importer_single_endpoint_notes_import feature flag is disabled' do + it 'reads cache value with default timeout' do + project = double(:project, id: 4, group: create(:group)) + + stub_feature_flags(github_importer_single_endpoint_notes_import: false) + + expect(Gitlab::Cache::Import::Caching) + .to receive(:read) + .with(anything, timeout: Gitlab::Cache::Import::Caching::TIMEOUT) + + described_class.new(project, issue).database_id + end + end + end end describe '#cache_database_id' do it 'caches the ID of a database row' do expect(Gitlab::Cache::Import::Caching) .to receive(:write) - .with('github-import/issuable-finder/4/MergeRequest/1', 10) + .with('github-import/issuable-finder/4/MergeRequest/1', 10, timeout: 86400) finder.cache_database_id(10) end + + context 'when group is present' do + context 'when github_importer_single_endpoint_notes_import feature flag is enabled' do + it 'caches value with longer timeout' do + project = create(:project, import_url: 'http://t0ken@github.com/user/repo.git') + group = create(:group, projects: [project]) + + stub_feature_flags(github_importer_single_endpoint_notes_import: group) + + expect(Gitlab::Cache::Import::Caching) + .to receive(:write) + .with(anything, anything, timeout: Gitlab::Cache::Import::Caching::LONGER_TIMEOUT) + + described_class.new(project, issue).cache_database_id(10) + end + end + + context 'when github_importer_single_endpoint_notes_import feature flag is disabled' do + it 'caches value with default timeout' do + project = double(:project, id: 4, group: create(:group)) + + stub_feature_flags(github_importer_single_endpoint_notes_import: false) + + expect(Gitlab::Cache::Import::Caching) + .to receive(:write) + .with(anything, anything, timeout: Gitlab::Cache::Import::Caching::TIMEOUT) + + described_class.new(project, issue).cache_database_id(10) + end + end + end end end |