diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:08:56 +0300 |
commit | 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (patch) | |
tree | 8eb149293eee90ec2750b6ac5e46a111a806424e /spec/models | |
parent | 66d4203791a01fdedf668a78818a229ea2c07aad (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/processable_spec.rb | 24 | ||||
-rw-r--r-- | spec/models/concerns/reactive_caching_spec.rb | 37 | ||||
-rw-r--r-- | spec/models/error_tracking/project_error_tracking_setting_spec.rb | 21 |
3 files changed, 81 insertions, 1 deletions
diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb index 1e0544c14c5..e03f54aa728 100644 --- a/spec/models/ci/processable_spec.rb +++ b/spec/models/ci/processable_spec.rb @@ -145,4 +145,28 @@ describe Ci::Processable do expect(another_build.reload.scheduling_type).to be_nil end end + + describe '#needs_attributes' do + let(:build) { create(:ci_build, :created, project: project, pipeline: pipeline) } + + context 'with needs' do + before do + create(:ci_build_need, build: build, name: 'test1') + create(:ci_build_need, build: build, name: 'test2') + end + + it 'returns all needs attributes' do + expect(build.needs_attributes).to contain_exactly( + { 'artifacts' => true, 'name' => 'test1' }, + { 'artifacts' => true, 'name' => 'test2' } + ) + end + end + + context 'without needs' do + it 'returns all needs attributes' do + expect(build.needs_attributes).to be_empty + end + end + end end diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb index 6d4eeae641f..96a9c317fb8 100644 --- a/spec/models/concerns/reactive_caching_spec.rb +++ b/spec/models/concerns/reactive_caching_spec.rb @@ -112,6 +112,43 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do end end + describe '#with_reactive_cache_set', :use_clean_rails_redis_caching do + subject(:go!) do + instance.with_reactive_cache_set('resource', {}) do |data| + data + end + end + + it 'calls with_reactive_cache' do + expect(instance) + .to receive(:with_reactive_cache) + + go! + end + + context 'data returned' do + let(:resource) { 'resource' } + let(:set_key) { "#{cache_key}:#{resource}" } + let(:set_cache) { Gitlab::ReactiveCacheSetCache.new } + + before do + stub_reactive_cache(instance, true, resource, {}) + end + + it 'saves keys in set' do + expect(set_cache.read(set_key)).to be_empty + + go! + + expect(set_cache.read(set_key)).not_to be_empty + end + + it 'returns the data' do + expect(go!).to eq(true) + end + end + end + describe '.reactive_cache_worker_finder' do context 'with default reactive_cache_worker_finder' do let(:args) { %w(other args) } diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb index e81480ab88f..ef3679da71f 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -8,7 +8,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do let_it_be(:project) { create(:project) } - subject { create(:project_error_tracking_setting, project: project) } + subject(:setting) { create(:project_error_tracking_setting, project: project) } describe 'Associations' do it { is_expected.to belong_to(:project) } @@ -453,4 +453,23 @@ describe ErrorTracking::ProjectErrorTrackingSetting do end end end + + describe '#expire_issues_cache', :use_clean_rails_redis_caching do + let(:issues) { [:some, :issues] } + let(:opt) { 'list_issues' } + let(:params) { { issue_status: 'unresolved', limit: 20, sort: 'last_seen' } } + + before do + start_reactive_cache_lifetime(subject, opt, params.stringify_keys) + stub_reactive_cache(subject, issues, opt, params.stringify_keys) + end + + it 'clears the cache' do + expect(subject.list_sentry_issues(params)).to eq(issues) + + subject.expire_issues_cache + + expect(subject.list_sentry_issues(params)).to eq(nil) + end + end end |