Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
d412147d
Unverified
Commit
d412147d
authored
2 years ago
by
Jeong Arm
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Save avatar or header correctly even if other one fails (#18465)
* Save avatar or header correctly if other one fails * Fix test
parent
8f8c0fe8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/account.rb
+9
-3
9 additions, 3 deletions
app/models/account.rb
spec/models/account_spec.rb
+1
-1
1 addition, 1 deletion
spec/models/account_spec.rb
with
10 additions
and
4 deletions
app/models/account.rb
+
9
−
3
View file @
d412147d
...
...
@@ -341,9 +341,15 @@ class Account < ApplicationRecord
def
save_with_optional_media!
save!
rescue
ActiveRecord
::
RecordInvalid
self
.
avatar
=
nil
self
.
header
=
nil
rescue
ActiveRecord
::
RecordInvalid
=>
e
errors
=
e
.
record
.
errors
.
errors
errors
.
each
do
|
err
|
if
err
.
attribute
==
:avatar
self
.
avatar
=
nil
elsif
err
.
attribute
==
:header
self
.
header
=
nil
end
end
save!
end
...
...
This diff is collapsed.
Click to expand it.
spec/models/account_spec.rb
+
1
−
1
View file @
d412147d
...
...
@@ -160,7 +160,7 @@ RSpec.describe Account, type: :model do
expect
(
account
.
avatar_remote_url
).
to
eq
'https://remote.test/invalid_avatar'
expect
(
account
.
header_remote_url
).
to
eq
expectation
.
header_remote_url
expect
(
account
.
avatar_file_name
).
to
eq
nil
expect
(
account
.
header_file_name
).
to
eq
nil
expect
(
account
.
header_file_name
).
to
eq
expectation
.
header_file_name
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment