diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-01-23 20:42:56 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-01-23 20:42:56 +0000 |
commit | 8d90f81731ccc10f3239fecfd232f84bdae23665 (patch) | |
tree | 2b65991c6761a8fc528176dbd362203913a8ee0c | |
parent | f40e769211ea708ede1c581d999e5b0d92586c0b (diff) | |
parent | 19f9d998700592be0d40d6727d6e990ef39ada68 (diff) | |
download | gitlab-ce-8d90f81731ccc10f3239fecfd232f84bdae23665.tar.gz |
Merge branch 'sh-fix-issue-9357' into 'master'
Fix 500 errors with legacy appearance logos
Closes gitlab-ee#9357
See merge request gitlab-org/gitlab-ce!24615
-rw-r--r-- | app/models/appearance.rb | 6 | ||||
-rw-r--r-- | changelogs/unreleased/sh-fix-issue-9357.yml | 5 | ||||
-rw-r--r-- | spec/models/appearance_spec.rb | 7 |
3 files changed, 17 insertions, 1 deletions
diff --git a/app/models/appearance.rb b/app/models/appearance.rb index e114c435b67..ff1ecfda684 100644 --- a/app/models/appearance.rb +++ b/app/models/appearance.rb @@ -44,7 +44,11 @@ class Appearance < ActiveRecord::Base private def logo_system_path(logo, mount_type) - return unless logo&.upload + # Legacy attachments may not have have an associated Upload record, + # so fallback to the AttachmentUploader#url if this is the + # case. AttachmentUploader#path doesn't work because for a local + # file, this is an absolute path to the file. + return logo&.url unless logo&.upload # If we're using a CDN, we need to use the full URL asset_host = ActionController::Base.asset_host diff --git a/changelogs/unreleased/sh-fix-issue-9357.yml b/changelogs/unreleased/sh-fix-issue-9357.yml new file mode 100644 index 00000000000..756cd6047b8 --- /dev/null +++ b/changelogs/unreleased/sh-fix-issue-9357.yml @@ -0,0 +1,5 @@ +--- +title: Fix 500 errors with legacy appearance logos +merge_request: 24615 +author: +type: fixed diff --git a/spec/models/appearance_spec.rb b/spec/models/appearance_spec.rb index ec2e7d672f0..cc76a2019ec 100644 --- a/spec/models/appearance_spec.rb +++ b/spec/models/appearance_spec.rb @@ -36,6 +36,13 @@ describe Appearance do expect(subject.send("#{logo_type}_path")).to be_nil end + it 'returns the path when the upload has been orphaned' do + appearance.send(logo_type).upload.destroy + appearance.reload + + expect(appearance.send("#{logo_type}_path")).to eq(expected_path) + end + it 'returns a local path using the system route' do expect(appearance.send("#{logo_type}_path")).to eq(expected_path) end |