-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from igorkasyanchuk/234-problem-with-conditio…
…nal-validations [Matcher] Bugfix when several validator are used on the same attribute (#234)
- Loading branch information
Showing
17 changed files
with
198 additions
and
42 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Validatable | ||
extend ActiveSupport::Concern | ||
|
||
private | ||
|
||
def title_is_quo_vadis? | ||
return false if self.title.blank? | ||
|
||
self.title == "Quo vadis" | ||
end | ||
|
||
def title_is_american_psycho? | ||
return false if self.title.blank? | ||
|
||
self.title == "American Psycho" | ||
end | ||
end |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module ChecksIfIsValid | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
describe 'Edge cases' do | ||
describe 'when the validator is used several times on the same attributes' do | ||
describe 'and is provided with different error messages' do | ||
before do | ||
case validator_sym | ||
when :aspect_ratio then matcher.allowing(:square) | ||
when :attached then matcher | ||
when :content_type then matcher.rejecting('image/jpg') | ||
when :dimension then matcher.width(150) | ||
when :size then matcher.less_than(10.megabytes) | ||
end | ||
end | ||
|
||
subject { matcher } | ||
|
||
let(:model_attribute) { :validatable_different_error_messages } | ||
let(:instance) { klass.new(title: "American Psycho") } | ||
|
||
it { is_expected_to_match_for(instance) } | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.