diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/tasks/gitlab/external_diffs_rake_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/tasks/gitlab/external_diffs_rake_spec.rb')
-rw-r--r-- | spec/tasks/gitlab/external_diffs_rake_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/external_diffs_rake_spec.rb b/spec/tasks/gitlab/external_diffs_rake_spec.rb new file mode 100644 index 00000000000..66e555734b3 --- /dev/null +++ b/spec/tasks/gitlab/external_diffs_rake_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'gitlab:external_diffs rake tasks' do + before do + Rake.application.rake_require 'tasks/gitlab/external_diffs' + end + + describe 'force_object_storage task' do + it 'forces externally stored merge request diffs to object storage' do + db = create(:merge_request).merge_request_diff + file = create(:merge_request).merge_request_diff.tap { |o| o.update_columns(stored_externally: true, external_diff_store: 1) } + object = create(:merge_request).merge_request_diff.tap { |o| o.update_columns(stored_externally: true, external_diff_store: 2) } + + run_rake_task('gitlab:external_diffs:force_object_storage') + + expect(db.reload).not_to be_stored_externally + expect(file.reload).to be_stored_externally + expect(object.reload).to be_stored_externally + + expect(file.external_diff_store).to eq(2) + expect(object.external_diff_store).to eq(2) + end + + it 'limits batches according to BATCH_SIZE, START_ID, and END_ID' do + stub_env('START_ID' => 'foo', 'END_ID' => 'bar', 'BATCH_SIZE' => 'baz') + + expect(MergeRequestDiff).to receive(:in_batches).with(start: 'foo', finish: 'bar', of: 'baz') + + run_rake_task('gitlab:external_diffs:force_object_storage') + end + end +end |