diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/commit_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/controllers/projects/compare_controller_spec.rb | 19 |
2 files changed, 33 insertions, 2 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index 59b2168c41a..edb07bbdce6 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -82,6 +82,22 @@ RSpec.describe Projects::CommitController do expect(response).to be_successful end + it 'only loads blobs in the current page' do + stub_feature_flags(async_commit_diff_files: false) + stub_const('Projects::CommitController::COMMIT_DIFFS_PER_PAGE', 1) + + commit = project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') + + expect_next_instance_of(Repository) do |repository| + # This commit contains 3 changed files but we expect only the blobs for the first one to be loaded + expect(repository).to receive(:blobs_at).with([[commit.id, '.gitignore']], anything).and_call_original + end + + go(id: commit.id) + + expect(response).to be_ok + end + shared_examples "export as" do |format| it "does generally work" do go(id: commit.id, format: format) diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index e6e0307d0ca..6ed6f7017e3 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -226,8 +226,8 @@ RSpec.describe Projects::CompareController do context 'when page is valid' do let(:from_project_id) { nil } - let(:from_ref) { '08f22f25' } - let(:to_ref) { '66eceea0' } + let(:from_ref) { '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' } + let(:to_ref) { '5937ac0a7beb003549fc5fd26fc247adbce4a52e' } let(:page) { 1 } it 'shows the diff' do @@ -237,6 +237,21 @@ RSpec.describe Projects::CompareController do expect(assigns(:diffs).diff_files.first).to be_present expect(assigns(:commits).length).to be >= 1 end + + it 'only loads blobs in the current page' do + stub_const('Projects::CompareController::COMMIT_DIFFS_PER_PAGE', 1) + + expect_next_instance_of(Repository) do |repository| + # This comparison contains 4 changed files but we expect only the blobs for the first one to be loaded + expect(repository).to receive(:blobs_at).with( + contain_exactly([from_ref, '.gitmodules'], [to_ref, '.gitmodules']), anything + ).and_call_original + end + + show_request + + expect(response).to be_successful + end end context 'when page is not valid' do |