Commit 458f3cf9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Update specs for new upload path

parent c156030e
...@@ -81,7 +81,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -81,7 +81,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'I should see new group "Owned" avatar' do step 'I should see new group "Owned" avatar' do
expect(owned_group.avatar).to be_instance_of AvatarUploader expect(owned_group.avatar).to be_instance_of AvatarUploader
expect(owned_group.avatar.url).to eq "/uploads/system/group/avatar/#{Group.find_by(name: "Owned").id}/banana_sample.gif" expect(owned_group.avatar.url).to eq "/uploads/-/system/group/avatar/#{Group.find_by(name: "Owned").id}/banana_sample.gif"
end end
step 'I should see the "Remove avatar" button' do step 'I should see the "Remove avatar" button' do
......
...@@ -36,7 +36,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps ...@@ -36,7 +36,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps
step 'I should see new avatar' do step 'I should see new avatar' do
expect(@user.avatar).to be_instance_of AvatarUploader expect(@user.avatar).to be_instance_of AvatarUploader
expect(@user.avatar.url).to eq "/uploads/system/user/avatar/#{@user.id}/banana_sample.gif" expect(@user.avatar.url).to eq "/uploads/-/system/user/avatar/#{@user.id}/banana_sample.gif"
end end
step 'I should see the "Remove avatar" button' do step 'I should see the "Remove avatar" button' do
......
...@@ -38,7 +38,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps ...@@ -38,7 +38,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step 'I should see new project avatar' do step 'I should see new project avatar' do
expect(@project.avatar).to be_instance_of AvatarUploader expect(@project.avatar).to be_instance_of AvatarUploader
url = @project.avatar.url url = @project.avatar.url
expect(url).to eq "/uploads/system/project/avatar/#{@project.id}/banana_sample.gif" expect(url).to eq "/uploads/-/system/project/avatar/#{@project.id}/banana_sample.gif"
end end
step 'I should see the "Remove avatar" button' do step 'I should see the "Remove avatar" button' do
......
FactoryGirl.define do FactoryGirl.define do
factory :upload do factory :upload do
model { build(:project) } model { build(:project) }
path { "uploads/system/project/avatar/avatar.jpg" } path { "uploads/-/system/project/avatar/avatar.jpg" }
size 100.kilobytes size 100.kilobytes
uploader "AvatarUploader" uploader "AvatarUploader"
end end
......
...@@ -63,11 +63,11 @@ feature 'Admin Appearance', feature: true do ...@@ -63,11 +63,11 @@ feature 'Admin Appearance', feature: true do
end end
def logo_selector def logo_selector
'//img[@src^="/uploads/system/appearance/logo"]' '//img[@src^="/uploads/-/system/appearance/logo"]'
end end
def header_logo_selector def header_logo_selector
'//img[@src^="/uploads/system/appearance/header_logo"]' '//img[@src^="/uploads/-/system/appearance/header_logo"]'
end end
def logo_fixture def logo_fixture
......
...@@ -18,7 +18,7 @@ feature 'User uploads avatar to group', feature: true do ...@@ -18,7 +18,7 @@ feature 'User uploads avatar to group', feature: true do
visit group_path(group) visit group_path(group)
expect(page).to have_selector(%Q(img[src$="/uploads/system/group/avatar/#{group.id}/dk.png"])) expect(page).to have_selector(%Q(img[src$="/uploads/-/system/group/avatar/#{group.id}/dk.png"]))
# Cheating here to verify something that isn't user-facing, but is important # Cheating here to verify something that isn't user-facing, but is important
expect(group.reload.avatar.file).to exist expect(group.reload.avatar.file).to exist
......
...@@ -16,7 +16,7 @@ feature 'User uploads avatar to profile', feature: true do ...@@ -16,7 +16,7 @@ feature 'User uploads avatar to profile', feature: true do
visit user_path(user) visit user_path(user)
expect(page).to have_selector(%Q(img[src$="/uploads/system/user/avatar/#{user.id}/dk.png"])) expect(page).to have_selector(%Q(img[src$="/uploads/-/system/user/avatar/#{user.id}/dk.png"]))
# Cheating here to verify something that isn't user-facing, but is important # Cheating here to verify something that isn't user-facing, but is important
expect(user.reload.avatar.file).to exist expect(user.reload.avatar.file).to exist
......
...@@ -59,13 +59,13 @@ describe ApplicationHelper do ...@@ -59,13 +59,13 @@ describe ApplicationHelper do
describe 'project_icon' do describe 'project_icon' do
it 'returns an url for the avatar' do it 'returns an url for the avatar' do
project = create(:empty_project, avatar: File.open(uploaded_image_temp_path)) project = create(:empty_project, avatar: File.open(uploaded_image_temp_path))
avatar_url = "/uploads/system/project/avatar/#{project.id}/banana_sample.gif" avatar_url = "/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
expect(helper.project_icon(project.full_path).to_s) expect(helper.project_icon(project.full_path).to_s)
.to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" .to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />"
allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host) allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host)
avatar_url = "#{gitlab_host}/uploads/system/project/avatar/#{project.id}/banana_sample.gif" avatar_url = "#{gitlab_host}/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
expect(helper.project_icon(project.full_path).to_s) expect(helper.project_icon(project.full_path).to_s)
.to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" .to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />"
...@@ -88,7 +88,7 @@ describe ApplicationHelper do ...@@ -88,7 +88,7 @@ describe ApplicationHelper do
context 'when there is a matching user' do context 'when there is a matching user' do
it 'returns a relative URL for the avatar' do it 'returns a relative URL for the avatar' do
expect(helper.avatar_icon(user.email).to_s) expect(helper.avatar_icon(user.email).to_s)
.to eq("/uploads/system/user/avatar/#{user.id}/banana_sample.gif") .to eq("/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif")
end end
context 'when an asset_host is set in the config' do context 'when an asset_host is set in the config' do
...@@ -100,14 +100,14 @@ describe ApplicationHelper do ...@@ -100,14 +100,14 @@ describe ApplicationHelper do
it 'returns an absolute URL on that asset host' do it 'returns an absolute URL on that asset host' do
expect(helper.avatar_icon(user.email, only_path: false).to_s) expect(helper.avatar_icon(user.email, only_path: false).to_s)
.to eq("#{asset_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif") .to eq("#{asset_host}/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif")
end end
end end
context 'when only_path is set to false' do context 'when only_path is set to false' do
it 'returns an absolute URL for the avatar' do it 'returns an absolute URL for the avatar' do
expect(helper.avatar_icon(user.email, only_path: false).to_s) expect(helper.avatar_icon(user.email, only_path: false).to_s)
.to eq("#{gitlab_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif") .to eq("#{gitlab_host}/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif")
end end
end end
...@@ -120,7 +120,7 @@ describe ApplicationHelper do ...@@ -120,7 +120,7 @@ describe ApplicationHelper do
it 'returns a relative URL with the correct prefix' do it 'returns a relative URL with the correct prefix' do
expect(helper.avatar_icon(user.email).to_s) expect(helper.avatar_icon(user.email).to_s)
.to eq("/gitlab/uploads/system/user/avatar/#{user.id}/banana_sample.gif") .to eq("/gitlab/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif")
end end
end end
end end
...@@ -138,14 +138,14 @@ describe ApplicationHelper do ...@@ -138,14 +138,14 @@ describe ApplicationHelper do
context 'when only_path is true' do context 'when only_path is true' do
it 'returns a relative URL for the avatar' do it 'returns a relative URL for the avatar' do
expect(helper.avatar_icon(user, only_path: true).to_s) expect(helper.avatar_icon(user, only_path: true).to_s)
.to eq("/uploads/system/user/avatar/#{user.id}/banana_sample.gif") .to eq("/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif")
end end
end end
context 'when only_path is false' do context 'when only_path is false' do
it 'returns an absolute URL for the avatar' do it 'returns an absolute URL for the avatar' do
expect(helper.avatar_icon(user, only_path: false).to_s) expect(helper.avatar_icon(user, only_path: false).to_s)
.to eq("#{gitlab_host}/uploads/system/user/avatar/#{user.id}/banana_sample.gif") .to eq("#{gitlab_host}/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif")
end end
end end
end end
......
...@@ -52,7 +52,7 @@ describe EmailsHelper do ...@@ -52,7 +52,7 @@ describe EmailsHelper do
) )
expect(header_logo).to eq( expect(header_logo).to eq(
%{<img style="height: 50px" src="/uploads/system/appearance/header_logo/#{appearance.id}/dk.png" alt="Dk" />} %{<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" alt="Dk" />}
) )
end end
end end
......
...@@ -11,7 +11,7 @@ describe GroupsHelper do ...@@ -11,7 +11,7 @@ describe GroupsHelper do
group.avatar = fixture_file_upload(avatar_file_path) group.avatar = fixture_file_upload(avatar_file_path)
group.save! group.save!
expect(group_icon(group.path).to_s) expect(group_icon(group.path).to_s)
.to match("/uploads/system/group/avatar/#{group.id}/banana_sample.gif") .to match("/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif")
end end
it 'gives default avatar_icon when no avatar is present' do it 'gives default avatar_icon when no avatar is present' do
......
...@@ -60,7 +60,7 @@ describe PageLayoutHelper do ...@@ -60,7 +60,7 @@ describe PageLayoutHelper do
%w(project user group).each do |type| %w(project user group).each do |type|
context "with @#{type} assigned" do context "with @#{type} assigned" do
it "uses #{type.titlecase} avatar if available" do it "uses #{type.titlecase} avatar if available" do
object = double(avatar_url: 'http://example.com/uploads/system/avatar.png') object = double(avatar_url: 'http://example.com/uploads/-/system/avatar.png')
assign(type, object) assign(type, object)
expect(helper.page_image).to eq object.avatar_url expect(helper.page_image).to eq object.avatar_url
......
...@@ -22,7 +22,7 @@ describe('Commit component', () => { ...@@ -22,7 +22,7 @@ describe('Commit component', () => {
shortSha: 'b7836edd', shortSha: 'b7836edd',
title: 'Commit message', title: 'Commit message',
author: { author: {
avatar_url: 'https://gitlab.com/uploads/system/user/avatar/300478/avatar.png', avatar_url: 'https://gitlab.com/uploads/-/system/user/avatar/300478/avatar.png',
web_url: 'https://gitlab.com/jschatz1', web_url: 'https://gitlab.com/jschatz1',
path: '/jschatz1', path: '/jschatz1',
username: 'jschatz1', username: 'jschatz1',
...@@ -45,7 +45,7 @@ describe('Commit component', () => { ...@@ -45,7 +45,7 @@ describe('Commit component', () => {
shortSha: 'b7836edd', shortSha: 'b7836edd',
title: 'Commit message', title: 'Commit message',
author: { author: {
avatar_url: 'https://gitlab.com/uploads/system/user/avatar/300478/avatar.png', avatar_url: 'https://gitlab.com/uploads/-/system/user/avatar/300478/avatar.png',
web_url: 'https://gitlab.com/jschatz1', web_url: 'https://gitlab.com/jschatz1',
path: '/jschatz1', path: '/jschatz1',
username: 'jschatz1', username: 'jschatz1',
......
...@@ -189,7 +189,7 @@ describe Group, models: true do ...@@ -189,7 +189,7 @@ describe Group, models: true do
let!(:group) { create(:group, :access_requestable, :with_avatar) } let!(:group) { create(:group, :access_requestable, :with_avatar) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" } let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" }
let(:avatar_path) { "/uploads/system/group/avatar/#{group.id}/dk.png" } let(:avatar_path) { "/uploads/-/system/group/avatar/#{group.id}/dk.png" }
context 'when avatar file is uploaded' do context 'when avatar file is uploaded' do
before do before do
......
...@@ -807,7 +807,7 @@ describe Project, models: true do ...@@ -807,7 +807,7 @@ describe Project, models: true do
context 'when avatar file is uploaded' do context 'when avatar file is uploaded' do
let(:project) { create(:empty_project, :with_avatar) } let(:project) { create(:empty_project, :with_avatar) }
let(:avatar_path) { "/uploads/system/project/avatar/#{project.id}/dk.png" } let(:avatar_path) { "/uploads/-/system/project/avatar/#{project.id}/dk.png" }
let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" } let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" }
it 'shows correct url' do it 'shows correct url' do
......
...@@ -1028,7 +1028,7 @@ describe User, models: true do ...@@ -1028,7 +1028,7 @@ describe User, models: true do
context 'when avatar file is uploaded' do context 'when avatar file is uploaded' do
let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" } let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" }
let(:avatar_path) { "/uploads/system/user/avatar/#{user.id}/dk.png" } let(:avatar_path) { "/uploads/-/system/user/avatar/#{user.id}/dk.png" }
it 'shows correct avatar url' do it 'shows correct avatar url' do
expect(user.avatar_url).to eq(avatar_path) expect(user.avatar_url).to eq(avatar_path)
......
...@@ -442,7 +442,7 @@ describe API::Projects do ...@@ -442,7 +442,7 @@ describe API::Projects do
post api('/projects', user), project post api('/projects', user), project
project_id = json_response['id'] project_id = json_response['id']
expect(json_response['avatar_url']).to eq("http://localhost/uploads/system/project/avatar/#{project_id}/banana_sample.gif") expect(json_response['avatar_url']).to eq("http://localhost/uploads/-/system/project/avatar/#{project_id}/banana_sample.gif")
end end
it 'sets a project as allowing merge even if build fails' do it 'sets a project as allowing merge even if build fails' do
......
...@@ -79,7 +79,7 @@ describe 'OpenID Connect requests' do ...@@ -79,7 +79,7 @@ describe 'OpenID Connect requests' do
'email_verified' => true, 'email_verified' => true,
'website' => 'https://example.com', 'website' => 'https://example.com',
'profile' => 'http://localhost/alice', 'profile' => 'http://localhost/alice',
'picture' => "http://localhost/uploads/system/user/avatar/#{user.id}/dk.png" 'picture' => "http://localhost/uploads/-/system/user/avatar/#{user.id}/dk.png"
}) })
end end
end end
......
...@@ -13,7 +13,7 @@ describe Projects::ParticipantsService, services: true do ...@@ -13,7 +13,7 @@ describe Projects::ParticipantsService, services: true do
groups = participants.groups groups = participants.groups
expect(groups.size).to eq 1 expect(groups.size).to eq 1
expect(groups.first[:avatar_url]).to eq("/uploads/system/group/avatar/#{group.id}/dk.png") expect(groups.first[:avatar_url]).to eq("/uploads/-/system/group/avatar/#{group.id}/dk.png")
end end
it 'should return an url for the avatar with relative url' do it 'should return an url for the avatar with relative url' do
...@@ -24,7 +24,7 @@ describe Projects::ParticipantsService, services: true do ...@@ -24,7 +24,7 @@ describe Projects::ParticipantsService, services: true do
groups = participants.groups groups = participants.groups
expect(groups.size).to eq 1 expect(groups.size).to eq 1
expect(groups.first[:avatar_url]).to eq("/gitlab/uploads/system/group/avatar/#{group.id}/dk.png") expect(groups.first[:avatar_url]).to eq("/gitlab/uploads/-/system/group/avatar/#{group.id}/dk.png")
end end
end end
end end
......
...@@ -5,7 +5,7 @@ describe AttachmentUploader do ...@@ -5,7 +5,7 @@ describe AttachmentUploader do
describe "#store_dir" do describe "#store_dir" do
it "stores in the system dir" do it "stores in the system dir" do
expect(uploader.store_dir).to start_with("uploads/system/user") expect(uploader.store_dir).to start_with("uploads/-/system/user")
end end
it "uses the old path when using object storage" do it "uses the old path when using object storage" do
......
...@@ -5,7 +5,7 @@ describe AvatarUploader do ...@@ -5,7 +5,7 @@ describe AvatarUploader do
describe "#store_dir" do describe "#store_dir" do
it "stores in the system dir" do it "stores in the system dir" do
expect(uploader.store_dir).to start_with("uploads/system/user") expect(uploader.store_dir).to start_with("uploads/-/system/user")
end end
it "uses the old path when using object storage" do it "uses the old path when using object storage" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment