Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
test cleanup
- Loading branch information
Showing
3 changed files
with
31 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '/../test_helper')) | ||
|
||
class ValidationsTest < SampleModelsTestCase | ||
def test_validate_uniqueness_with_an_allow_nil_allows_nil_configuration | ||
User.sample | ||
user = User.sample | ||
assert_nil user.external_user | ||
assert_nil user.external_user_id | ||
end | ||
|
||
def test_picks_a_value_given_in_a_validates_inclusion_of | ||
assert_difference('User.count') do | ||
user = User.sample | ||
assert(%(m f).include?(user.gender)) | ||
end | ||
end | ||
|
||
def test_cant_override_validations | ||
assert_no_difference('User.count') do | ||
assert_raise(ActiveRecord::RecordInvalid) do | ||
User.sample(:gender => 'x') | ||
end | ||
end | ||
assert_no_difference('User.count') do | ||
assert_raise(ActiveRecord::RecordInvalid) do | ||
User.sample(:email => 'call.me') | ||
end | ||
end | ||
end | ||
end | ||
|