This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
DRAFT toward fixing after_post_process is run even if validations fail #2204
Closed
jrochkind
wants to merge
8
commits into
thoughtbot:master
from
jrochkind:failed_validation_cancel_after_post_process
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41adcc7
work toward fixing after_post_process is run even if validations fail
jrochkind dc63b13
Cancelled attribute-specific callbacks will prevent general callbacks…
jrochkind cac2921
shut up hound
jrochkind f8b849c
really, hound?
jrochkind a99fb94
good spec for after callbacks not called on validation fail
jrochkind e6fa5ba
make after callbacks actually not called on paperclip validation error
jrochkind 23d2ecb
remove tentative specs that never worked, replaced with separate file
jrochkind dc60245
clean up throw conditions
jrochkind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,37 @@ | |
|
||
attachment.assign(invalid_assignment) | ||
end | ||
|
||
context "with custom post-processing" do | ||
before do | ||
Dummy.class_eval do | ||
validates_attachment_content_type :avatar, content_type: "image/png" | ||
before_avatar_post_process :do_before_avatar | ||
after_avatar_post_process :do_after_avatar | ||
before_post_process :do_before_all | ||
after_post_process :do_after_all | ||
def do_before_avatar; end | ||
def do_after_avatar; end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use empty lines between method definitions. |
||
def do_before_all; end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use empty lines between method definitions. |
||
def do_after_all; end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use empty lines between method definitions. |
||
end | ||
end | ||
## FALSE POSITIVE: This passes even before our change in callbacks.rb, | ||
# even though we know it had a problem with this. This passes | ||
# even if we don't trigger a validation error, we haven't succesfully | ||
# set up our callbacks at all somehow. | ||
it 'does not run custom post-processing if validation fails' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
file = File.new(fixture_file("5k.png")) | ||
|
||
instance = Dummy.new | ||
attachment = instance.avatar | ||
|
||
attachment.expects(:do_after_avatar).never | ||
attachment.expects(:do_after_all).never | ||
|
||
attachment.assign(file) | ||
end | ||
end | ||
end | ||
|
||
context 'using validates_attachment' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [125/80]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can write this as: