Commit c894b04b authored by Thong Kuah's avatar Thong Kuah

Merge branch 'frozen-string-enable-spec-models' into 'master'

Enable frozen string for spec/models

See merge request gitlab-org/gitlab!18994
parents 0805006e e8bad184
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191017045817_schedule_fix_gitlab_com_pages_access_level.rb') require Rails.root.join('db', 'post_migrate', '20191017045817_schedule_fix_gitlab_com_pages_access_level.rb')
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...@@ -63,7 +65,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -63,7 +65,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :redis } let(:data_store) { :redis }
before do before do
build_trace_chunk.send(:unsafe_set_data!, 'Sample data in redis') build_trace_chunk.send(:unsafe_set_data!, +'Sample data in redis')
end end
it { is_expected.to eq('Sample data in redis') } it { is_expected.to eq('Sample data in redis') }
...@@ -71,7 +73,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -71,7 +73,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context 'when data_store is database' do context 'when data_store is database' do
let(:data_store) { :database } let(:data_store) { :database }
let(:raw_data) { 'Sample data in database' } let(:raw_data) { +'Sample data in database' }
it { is_expected.to eq('Sample data in database') } it { is_expected.to eq('Sample data in database') }
end end
...@@ -80,7 +82,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -80,7 +82,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :fog } let(:data_store) { :fog }
before do before do
build_trace_chunk.send(:unsafe_set_data!, 'Sample data in fog') build_trace_chunk.send(:unsafe_set_data!, +'Sample data in fog')
end end
it { is_expected.to eq('Sample data in fog') } it { is_expected.to eq('Sample data in fog') }
...@@ -90,7 +92,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -90,7 +92,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
describe '#append' do describe '#append' do
subject { build_trace_chunk.append(new_data, offset) } subject { build_trace_chunk.append(new_data, offset) }
let(:new_data) { 'Sample new data' } let(:new_data) { +'Sample new data' }
let(:offset) { 0 } let(:offset) { 0 }
let(:merged_data) { data + new_data.to_s } let(:merged_data) { data + new_data.to_s }
...@@ -143,7 +145,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -143,7 +145,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when new_data is empty' do context 'when new_data is empty' do
let(:new_data) { '' } let(:new_data) { +'' }
it 'does not append' do it 'does not append' do
subject subject
...@@ -172,7 +174,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -172,7 +174,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
shared_examples_for 'Scheduling sidekiq worker to flush data to persist store' do shared_examples_for 'Scheduling sidekiq worker to flush data to persist store' do
context 'when new data fulfilled chunk size' do context 'when new data fulfilled chunk size' do
let(:new_data) { 'a' * described_class::CHUNK_SIZE } let(:new_data) { +'a' * described_class::CHUNK_SIZE }
it 'schedules trace chunk flush worker' do it 'schedules trace chunk flush worker' do
expect(Ci::BuildTraceChunkFlushWorker).to receive(:perform_async).once expect(Ci::BuildTraceChunkFlushWorker).to receive(:perform_async).once
...@@ -194,7 +196,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -194,7 +196,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
shared_examples_for 'Scheduling no sidekiq worker' do shared_examples_for 'Scheduling no sidekiq worker' do
context 'when new data fulfilled chunk size' do context 'when new data fulfilled chunk size' do
let(:new_data) { 'a' * described_class::CHUNK_SIZE } let(:new_data) { +'a' * described_class::CHUNK_SIZE }
it 'does not schedule trace chunk flush worker' do it 'does not schedule trace chunk flush worker' do
expect(Ci::BuildTraceChunkFlushWorker).not_to receive(:perform_async) expect(Ci::BuildTraceChunkFlushWorker).not_to receive(:perform_async)
...@@ -219,7 +221,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -219,7 +221,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :redis } let(:data_store) { :redis }
context 'when there are no data' do context 'when there are no data' do
let(:data) { '' } let(:data) { +'' }
it 'has no data' do it 'has no data' do
expect(build_trace_chunk.data).to be_empty expect(build_trace_chunk.data).to be_empty
...@@ -230,7 +232,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -230,7 +232,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when there are some data' do context 'when there are some data' do
let(:data) { 'Sample data in redis' } let(:data) { +'Sample data in redis' }
before do before do
build_trace_chunk.send(:unsafe_set_data!, data) build_trace_chunk.send(:unsafe_set_data!, data)
...@@ -249,7 +251,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -249,7 +251,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :database } let(:data_store) { :database }
context 'when there are no data' do context 'when there are no data' do
let(:data) { '' } let(:data) { +'' }
it 'has no data' do it 'has no data' do
expect(build_trace_chunk.data).to be_empty expect(build_trace_chunk.data).to be_empty
...@@ -260,7 +262,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -260,7 +262,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when there are some data' do context 'when there are some data' do
let(:raw_data) { 'Sample data in database' } let(:raw_data) { +'Sample data in database' }
let(:data) { raw_data } let(:data) { raw_data }
it 'has data' do it 'has data' do
...@@ -276,7 +278,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -276,7 +278,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :fog } let(:data_store) { :fog }
context 'when there are no data' do context 'when there are no data' do
let(:data) { '' } let(:data) { +'' }
it 'has no data' do it 'has no data' do
expect(build_trace_chunk.data).to be_empty expect(build_trace_chunk.data).to be_empty
...@@ -287,7 +289,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -287,7 +289,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when there are some data' do context 'when there are some data' do
let(:data) { 'Sample data in fog' } let(:data) { +'Sample data in fog' }
before do before do
build_trace_chunk.send(:unsafe_set_data!, data) build_trace_chunk.send(:unsafe_set_data!, data)
...@@ -332,7 +334,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -332,7 +334,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context 'when data_store is redis' do context 'when data_store is redis' do
let(:data_store) { :redis } let(:data_store) { :redis }
let(:data) { 'Sample data in redis' } let(:data) { +'Sample data in redis' }
before do before do
build_trace_chunk.send(:unsafe_set_data!, data) build_trace_chunk.send(:unsafe_set_data!, data)
...@@ -343,7 +345,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -343,7 +345,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context 'when data_store is database' do context 'when data_store is database' do
let(:data_store) { :database } let(:data_store) { :database }
let(:raw_data) { 'Sample data in database' } let(:raw_data) { +'Sample data in database' }
let(:data) { raw_data } let(:data) { raw_data }
it_behaves_like 'truncates' it_behaves_like 'truncates'
...@@ -351,7 +353,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -351,7 +353,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context 'when data_store is fog' do context 'when data_store is fog' do
let(:data_store) { :fog } let(:data_store) { :fog }
let(:data) { 'Sample data in fog' } let(:data) { +'Sample data in fog' }
before do before do
build_trace_chunk.send(:unsafe_set_data!, data) build_trace_chunk.send(:unsafe_set_data!, data)
...@@ -368,7 +370,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -368,7 +370,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :redis } let(:data_store) { :redis }
context 'when data exists' do context 'when data exists' do
let(:data) { 'Sample data in redis' } let(:data) { +'Sample data in redis' }
before do before do
build_trace_chunk.send(:unsafe_set_data!, data) build_trace_chunk.send(:unsafe_set_data!, data)
...@@ -386,7 +388,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -386,7 +388,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :database } let(:data_store) { :database }
context 'when data exists' do context 'when data exists' do
let(:raw_data) { 'Sample data in database' } let(:raw_data) { +'Sample data in database' }
let(:data) { raw_data } let(:data) { raw_data }
it { is_expected.to eq(data.bytesize) } it { is_expected.to eq(data.bytesize) }
...@@ -401,7 +403,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -401,7 +403,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:data_store) { :fog } let(:data_store) { :fog }
context 'when data exists' do context 'when data exists' do
let(:data) { 'Sample data in fog' } let(:data) { +'Sample data in fog' }
let(:key) { "tmp/builds/#{build.id}/chunks/#{chunk_index}.log" } let(:key) { "tmp/builds/#{build.id}/chunks/#{chunk_index}.log" }
before do before do
...@@ -443,7 +445,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -443,7 +445,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when data size reached CHUNK_SIZE' do context 'when data size reached CHUNK_SIZE' do
let(:data) { 'a' * described_class::CHUNK_SIZE } let(:data) { +'a' * described_class::CHUNK_SIZE }
it 'persists the data' do it 'persists the data' do
expect(build_trace_chunk.redis?).to be_truthy expect(build_trace_chunk.redis?).to be_truthy
...@@ -463,7 +465,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -463,7 +465,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when data size has not reached CHUNK_SIZE' do context 'when data size has not reached CHUNK_SIZE' do
let(:data) { 'Sample data in redis' } let(:data) { +'Sample data in redis' }
it 'does not persist the data and the orignal data is intact' do it 'does not persist the data and the orignal data is intact' do
expect { subject }.to raise_error(described_class::FailedToPersistDataError) expect { subject }.to raise_error(described_class::FailedToPersistDataError)
...@@ -492,7 +494,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -492,7 +494,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when data size reached CHUNK_SIZE' do context 'when data size reached CHUNK_SIZE' do
let(:data) { 'a' * described_class::CHUNK_SIZE } let(:data) { +'a' * described_class::CHUNK_SIZE }
it 'persists the data' do it 'persists the data' do
expect(build_trace_chunk.database?).to be_truthy expect(build_trace_chunk.database?).to be_truthy
...@@ -512,7 +514,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -512,7 +514,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when data size has not reached CHUNK_SIZE' do context 'when data size has not reached CHUNK_SIZE' do
let(:data) { 'Sample data in database' } let(:data) { +'Sample data in database' }
it 'does not persist the data and the orignal data is intact' do it 'does not persist the data and the orignal data is intact' do
expect { subject }.to raise_error(described_class::FailedToPersistDataError) expect { subject }.to raise_error(described_class::FailedToPersistDataError)
...@@ -561,7 +563,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -561,7 +563,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end end
context 'when data size has not reached CHUNK_SIZE' do context 'when data size has not reached CHUNK_SIZE' do
let(:data) { 'Sample data in fog' } let(:data) { +'Sample data in fog' }
it 'does not raise error' do it 'does not raise error' do
expect { subject }.not_to raise_error expect { subject }.not_to raise_error
......
# frozen_string_literals: true # frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe Shard do describe Shard do
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe Sidekiq::Cron::Job do describe Sidekiq::Cron::Job do
......
# frozen_string_literal: true
module SmimeHelper module SmimeHelper
include OpenSSL include OpenSSL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment