-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11df93a
commit 5b6fc74
Showing
5 changed files
with
52 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,6 @@ class Address < ActiveRecord::Base | |
end | ||
|
||
class ActiveRecordTest < Minitest::Test | ||
|
||
def setup | ||
drop_all_tables | ||
create_tables | ||
|
@@ -221,6 +220,32 @@ def test_attribute_was_works_when_options_for_old_encrypted_value_are_different_ | |
assert_equal pw.reverse, account.password | ||
end | ||
|
||
# ActiveRecord 5.2 specific methods | ||
if ::ActiveRecord::VERSION::STRING >= "5.2" | ||
def test_should_create_will_save_change_to_predicate | ||
person = Person.create!(email: '[email protected]') | ||
refute person.will_save_change_to_email? | ||
person.email = '[email protected]' | ||
refute person.will_save_change_to_email? | ||
person.email = nil | ||
assert person.will_save_change_to_email? | ||
person.email = '[email protected]' | ||
assert person.will_save_change_to_email? | ||
end | ||
|
||
def test_should_create_saved_change_to_predicate | ||
person = Person.create!(email: '[email protected]') | ||
assert person.saved_change_to_email? | ||
person.reload | ||
person.email = '[email protected]' | ||
refute person.saved_change_to_email? | ||
person.email = nil | ||
refute person.saved_change_to_email? | ||
person.email = '[email protected]' | ||
refute person.saved_change_to_email? | ||
end | ||
end | ||
|
||
if ::ActiveRecord::VERSION::STRING > "4.0" | ||
def test_should_assign_attributes | ||
@user = UserWithProtectedAttribute.new(login: 'login', is_admin: false) | ||
|
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