summaryrefslogtreecommitdiff
path: root/spec/models/ci/build_trace_chunk_spec.rb
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-04-30 15:27:05 +0900
committerShinya Maeda <shinya@gitlab.com>2018-04-30 15:27:05 +0900
commitd5344617a8b57e4d6d15f22ad3d09d5af82100fe (patch)
treef55cab09b09a85ace936f3a647e5e41e3d03867f /spec/models/ci/build_trace_chunk_spec.rb
parent23c8e198463d566d2e8d2351c315741903035a64 (diff)
downloadgitlab-ce-d5344617a8b57e4d6d15f22ad3d09d5af82100fe.tar.gz
Fix spec when parent record is destroyed
Diffstat (limited to 'spec/models/ci/build_trace_chunk_spec.rb')
-rw-r--r--spec/models/ci/build_trace_chunk_spec.rb25
1 files changed, 8 insertions, 17 deletions
diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb
index a122ee84b3c..cab5db9ca06 100644
--- a/spec/models/ci/build_trace_chunk_spec.rb
+++ b/spec/models/ci/build_trace_chunk_spec.rb
@@ -332,25 +332,20 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- describe 'deletes data in redis after chunk record destroyed' do
+ describe 'deletes data in redis after a parent record destroyed' do
let(:project) { create(:project) }
before do
pipeline = create(:ci_pipeline, project: project)
- @build_ids = []
- @build_ids << create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project).id
- @build_ids << create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project).id
- @build_ids << create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project).id
+ create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project)
+ create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project)
+ create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project)
end
shared_examples_for 'deletes all build_trace_chunk and data in redis' do
it do
- @build_ids.each do |build_id|
- Gitlab::Redis::SharedState.with do |redis|
- redis.scan_each(match: "gitlab:ci:trace:#{build_id}:chunks:?") do |key|
- expect(redis.exists(key)).to be_truthy
- end
- end
+ Gitlab::Redis::SharedState.with do |redis|
+ expect(redis.scan_each(match: "gitlab:ci:trace:?:chunks:?").to_a.count).to eq(3)
end
expect(described_class.count).to eq(3)
@@ -359,12 +354,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
expect(described_class.count).to eq(0)
- @build_ids.each do |build_id|
- Gitlab::Redis::SharedState.with do |redis|
- redis.scan_each(match: "gitlab:ci:trace:#{build_id}:chunks:?") do |key|
- expect(redis.exists(key)).to be_falsey
- end
- end
+ Gitlab::Redis::SharedState.with do |redis|
+ expect(redis.scan_each(match: "gitlab:ci:trace:?:chunks:?").to_a.count).to eq(0)
end
end
end