diff options
Diffstat (limited to 'spec/controllers/projects/commit_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/commit_controller_spec.rb | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index 36206a88786..44486d0ed41 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -84,22 +84,6 @@ RSpec.describe Projects::CommitController, feature_category: :source_code_manage 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) @@ -459,6 +443,37 @@ RSpec.describe Projects::CommitController, feature_category: :source_code_manage end end + describe 'GET #diff_files' do + subject(:send_request) { get :diff_files, params: params } + + let(:format) { :html } + let(:params) do + { + namespace_id: project.namespace, + project_id: project, + id: commit.id, + format: format + } + end + + it 'renders diff files' do + send_request + + expect(assigns(:diffs)).to be_a(Gitlab::Diff::FileCollection::Commit) + expect(assigns(:environment)).to be_nil + end + + context 'when format is not html' do + let(:format) { :json } + + it 'returns 404 page' do + send_request + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end + describe 'GET diff_for_path' do def diff_for_path(extra_params = {}) params = { |