diff --git a/lib/gitlab/email_validator.rb b/lib/email_validator.rb similarity index 100% rename from lib/gitlab/email_validator.rb rename to lib/email_validator.rb diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 34a5bcfb4a5..4e0ebb584d1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -83,11 +83,17 @@ describe User 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 "accepts o'reilly@example.com" do + user = build(:user, email: "o'reilly@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 @@ -97,6 +103,11 @@ describe User do user = build(:user, email: 'mailto:test@example.com') expect(user).to be_invalid end + + it "rejects lol!'+=?><#$%^&*()@gmail.com" do + user = build(:user, email: "lol!'+=?><#$%^&*()@gmail.com") + expect(user).to be_invalid + end end end