diff options
| author | Jeroen van Baarsen <jeroenvanbaarsen@gmail.com> | 2014-01-16 12:14:47 +0100 |
|---|---|---|
| committer | Jeroen van Baarsen <jeroenvanbaarsen@gmail.com> | 2014-01-16 12:14:47 +0100 |
| commit | 05e4af5b4c7709ab08194d109ddec8e19f44758d (patch) | |
| tree | c052438b48fbc6f6c8e75c6f79bf41b2d8397596 /spec/models | |
| parent | dba982403b7b894d2096ea61b89a247060eefe57 (diff) | |
| download | gitlab-ce-05e4af5b4c7709ab08194d109ddec8e19f44758d.tar.gz | |
Better check on the validity of emails
At this moment it was possible to enter emails like:
mailto:info@example.com. This was causing some issue in the frontend,
since those links became html mailto: links.
Fixes: #3516
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/user_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 94bd19f5900..cd025c204f4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -74,6 +74,27 @@ describe User do it { should_not allow_value(-1).for(:projects_limit) } it { should ensure_length_of(:bio).is_within(0..255) } + + describe 'email' do + it 'accepts info@example.com' do + user = build(:user, email: 'info@example.com') + expect(user).to be_valid + end + it 'accepts info+test@example.com' do + user = build(:user, email: 'info+test@example.com') + expect(user).to be_valid + end + + it 'rejects test@test@example.com' do + user = build(:user, email: 'test@test@example.com') + expect(user).to be_invalid + end + + it 'rejects mailto:test@example.com' do + user = build(:user, email: 'mailto:test@example.com') + expect(user).to be_invalid + end + end end describe "Respond to" do |
