[bbb-greenlight: 16/39] Added validation for name: Should not include a http(s) url (#2114)




commit 75b989240a21449e2941f582ba2d0d933fcefe56
Author: Henning <hng users noreply github com>
Date:   Tue Sep 22 16:46:17 2020 +0200

    Added validation for name: Should not include a http(s) url (#2114)

 app/models/user.rb       | 3 ++-
 spec/models/user_spec.rb | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/app/models/user.rb b/app/models/user.rb
index 71e3c8d..fc5d010 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -35,7 +35,8 @@ class User < ApplicationRecord
 
   belongs_to :role, required: false
 
-  validates :name, length: { maximum: 256 }, presence: true
+  validates :name, length: { maximum: 256 }, presence: true,
+                   format: { without: %r{https?://}i }
   validates :provider, presence: true
   validate :check_if_email_can_be_blank
   validates :email, length: { maximum: 256 }, allow_blank: true,
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9670b99..8c6d652 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -27,6 +27,7 @@ describe User, type: :model do
   context 'validations' do
     it { should validate_presence_of(:name) }
     it { should validate_length_of(:name).is_at_most(256) }
+    it { should_not allow_value("https://www.bigbluebutton.org";).for(:name) }
 
     it { should validate_presence_of(:provider) }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]