diff options
author | Rémy Coutable <remy@rymai.me> | 2016-10-24 13:58:03 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-10-24 13:58:03 +0300 |
commit | 5bd4bee00fd1c5bd0bbccd330bf10fd9edc5e742 (patch) | |
tree | fb1acc7062e342d075fb9888d787202f15d9e878 /spec/models | |
parent | ed256037427f1a9b92fabe430e392e600720a29f (diff) | |
parent | b1ce2eb1e5f6a4a5b413381489fbb7e63ff3e1e5 (diff) |
Merge branch 'remove-callback' into 'master'
This MR removes AR before_validation callback in favor setter.
## Why was this MR needed?
Because setters is good practice to normalize model attributes instead AR callbacks. Because new object should be valid right after initialization.
If it MR interested I can try to find other places where we can use setters.
See merge request !6763
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/email_spec.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb index d9df9e0f907..fe4de1b2afb 100644 --- a/spec/models/email_spec.rb +++ b/spec/models/email_spec.rb @@ -6,4 +6,9 @@ describe Email, models: true do subject { build(:email) } end end + + it 'normalize email value' do + expect(described_class.new(email: ' inFO@exAMPLe.com ').email) + .to eq 'info@example.com' + end end |