diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-08-30 12:34:41 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-30 12:34:41 +0000 |
commit | edb5759caf8c328803fdc04e3ae520d234edfcfc (patch) | |
tree | e73ba9b241027664a1e27d5778cbd18c0e5a9434 /spec/controllers/projects/avatars_controller_spec.rb | |
parent | b8856d662942f54d7353e69505be08deb9b1d575 (diff) | |
download | gitlab-ce-edb5759caf8c328803fdc04e3ae520d234edfcfc.tar.gz |
Fixed project logo when it is LFS tracked
Diffstat (limited to 'spec/controllers/projects/avatars_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/avatars_controller_spec.rb | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/spec/controllers/projects/avatars_controller_spec.rb b/spec/controllers/projects/avatars_controller_spec.rb index 17c9a61f339..14059cff74c 100644 --- a/spec/controllers/projects/avatars_controller_spec.rb +++ b/spec/controllers/projects/avatars_controller_spec.rb @@ -1,24 +1,55 @@ require 'spec_helper' describe Projects::AvatarsController do - let(:project) { create(:project, :repository, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) } - let(:user) { create(:user) } + let(:project) { create(:project, :repository) } before do - sign_in(user) - project.add_maintainer(user) controller.instance_variable_set(:@project, project) end - it 'GET #show' do - get :show, namespace_id: project.namespace.id, project_id: project.id + describe 'GET #show' do + subject { get :show, namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(404) + context 'when repository has no avatar' do + it 'shows 404' do + subject + + expect(response).to have_gitlab_http_status(404) + end + end + + context 'when repository has an avatar' do + before do + allow(project).to receive(:avatar_in_git).and_return(filepath) + end + + context 'when the avatar is stored in the repository' do + let(:filepath) { 'files/images/logo-white.png' } + + it 'sends the avatar' do + subject + + expect(response).to have_gitlab_http_status(200) + expect(response.header['Content-Type']).to eq('image/png') + expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') + end + end + + context 'when the avatar is stored in lfs' do + it_behaves_like 'repository lfs file load' do + let(:filename) { 'lfs_object.iso' } + let(:filepath) { "files/lfs/#{filename}" } + end + end + end end - it 'removes avatar from DB by calling destroy' do - delete :destroy, namespace_id: project.namespace.id, project_id: project.id - expect(project.avatar.present?).to be_falsey - expect(project).to be_valid + describe 'DELETE #destroy' do + it 'removes avatar from DB by calling destroy' do + delete :destroy, namespace_id: project.namespace.id, project_id: project.id + + expect(project.avatar.present?).to be_falsey + expect(project).to be_valid + end end end |