I have a simple test to execute. Below is the following code:
it 'should validate that email is lowercase' do
account = build(:account, email: 'IRONMAN@gmail.com')
lowercase_account = build(:account, email: 'warmachine@gmail.com')
account.wont_be :valid?
lowercase_account.must_be :valid?
end
According to my test, IRONMAN@gmail.com
should fail and warmachine@gmail.com
should pass. However when I run the test, both emails pass.
Here is my validation code for my Account
model.
validates :email, presence: :true, length: { in: 3..100 }, uniqueness: true,
confirmation: true, email_format: true, allow_blank: false
validates :email_confirmation, email_format: true, presence: true, allow_blank: false, on: :create
What could be the error here? I've referenced this link on SO as a starting point Rails 4 validation case insensitivity test. It had some good information but I am using Postgresql and not MySQL to perform the account insertion. To my knowledge, Postgresql does not do a case insensitive search so I should be good. Has anyone experienced this problem?