diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/models/merge_request_diff_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/models/merge_request_diff_spec.rb')
-rw-r--r-- | spec/models/merge_request_diff_spec.rb | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 3741e01e99a..e0e25031589 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -9,10 +9,6 @@ RSpec.describe MergeRequestDiff do let(:diff_with_commits) { create(:merge_request).merge_request_diff } - before do - stub_feature_flags(diffs_gradual_load: false) - end - describe 'validations' do subject { diff_with_commits } @@ -115,6 +111,7 @@ RSpec.describe MergeRequestDiff do let(:closed_recently) { recently_closed_mr.merge_request_diff } let_it_be(:recently_merged_mr) { create(:merge_request, :merged) } + let(:merged_recently) { recently_merged_mr.merge_request_diff } before do @@ -436,9 +433,7 @@ RSpec.describe MergeRequestDiff do it 'returns empty pagination data' do diffs = diff_with_commits.diffs_in_batch(1, 10, diff_options: diff_options) - expect(diffs.pagination_data).to eq(current_page: nil, - next_page: nil, - total_pages: nil) + expect(diffs.pagination_data).to eq(total_pages: nil) end end @@ -460,19 +455,17 @@ RSpec.describe MergeRequestDiff do context 'when persisted files available' do it 'returns paginated diffs' do - diffs = diff_with_commits.diffs_in_batch(1, 10, diff_options: diff_options) + diffs = diff_with_commits.diffs_in_batch(0, 10, diff_options: diff_options) expect(diffs).to be_a(Gitlab::Diff::FileCollection::MergeRequestDiffBatch) expect(diffs.diff_files.size).to eq(10) - expect(diffs.pagination_data).to eq(current_page: 1, - next_page: 2, - total_pages: 2) + expect(diffs.pagination_data).to eq(total_pages: 20) end it 'sorts diff files directory first' do diff_with_commits.update!(sorted: false) # Mark as unsorted so it'll re-order - expect(diff_with_commits.diffs_in_batch(1, 10, diff_options: diff_options).diff_file_paths).to eq([ + expect(diff_with_commits.diffs_in_batch(0, 10, diff_options: diff_options).diff_file_paths).to eq([ 'bar/branch-test.txt', 'custom-highlighting/test.gitlab-custom', 'encoding/iso8859.txt', @@ -491,43 +484,21 @@ RSpec.describe MergeRequestDiff do { ignore_whitespace_change: true } end - it 'returns a Gitlab::Diff::FileCollection::Compare with paginated diffs' do + it 'returns pagination data from MergeRequestDiffBatch' do diffs = diff_with_commits.diffs_in_batch(1, 10, diff_options: diff_options) + file_count = diff_with_commits.merge_request_diff_files.count expect(diffs).to be_a(Gitlab::Diff::FileCollection::Compare) expect(diffs.diff_files.size).to eq 10 - expect(diffs.pagination_data).to eq(current_page: 1, next_page: 2, total_pages: 2) + expect(diffs.pagination_data).to eq(total_pages: file_count) end it 'returns an empty MergeRequestBatch with empty pagination data when the batch is empty' do - diffs = diff_with_commits.diffs_in_batch(3, 10, diff_options: diff_options) + diffs = diff_with_commits.diffs_in_batch(30, 10, diff_options: diff_options) expect(diffs).to be_a(Gitlab::Diff::FileCollection::MergeRequestDiffBatch) expect(diffs.diff_files.size).to eq 0 - expect(diffs.pagination_data).to eq(current_page: nil, next_page: nil, total_pages: nil) - end - - context 'with gradual load enabled' do - before do - stub_feature_flags(diffs_gradual_load: true) - end - - it 'returns pagination data from MergeRequestDiffBatch' do - diffs = diff_with_commits.diffs_in_batch(1, 10, diff_options: diff_options) - file_count = diff_with_commits.merge_request_diff_files.count - - expect(diffs).to be_a(Gitlab::Diff::FileCollection::Compare) - expect(diffs.diff_files.size).to eq 10 - expect(diffs.pagination_data).to eq(current_page: nil, next_page: nil, total_pages: file_count) - end - - it 'returns an empty MergeRequestBatch with empty pagination data when the batch is empty' do - diffs = diff_with_commits.diffs_in_batch(30, 10, diff_options: diff_options) - - expect(diffs).to be_a(Gitlab::Diff::FileCollection::MergeRequestDiffBatch) - expect(diffs.diff_files.size).to eq 0 - expect(diffs.pagination_data).to eq(current_page: nil, next_page: nil, total_pages: nil) - end + expect(diffs.pagination_data).to eq(total_pages: nil) end end end |