From 539a79328fc23ba391f93ec8939611e81c0f77a9 Mon Sep 17 00:00:00 2001 From: Jeremy Rudman Date: Tue, 22 Dec 2020 00:53:09 -0500 Subject: [PATCH 1/6] fixed vcs regex to allow upper case added a extra test to vcs links to test upper case links. also made it so portfolio links ands vcs links are stored in lower case --- app/models/questionnaire.rb | 4 +++- test/models/questionnaire_test.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/questionnaire.rb b/app/models/questionnaire.rb index 5407edf57..924911eb6 100644 --- a/app/models/questionnaire.rb +++ b/app/models/questionnaire.rb @@ -43,7 +43,7 @@ class Questionnaire < ApplicationRecord validates :portfolio_url, url: { allow_blank: true } validates :vcs_url, url: { allow_blank: true } - validates_format_of :vcs_url, with: %r{\A(((https?:\/\/)?(www\.)?github\.com\/\w+\/?)|((https?:\/\/)?(www\.)?gitlab\.com\/\w+\/?)|((https?:\/\/)?(www\.)?bitbucket\.org\/\w+\/?))\z}, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" + validates_format_of :vcs_url, with: %r{\A((https?:\/\/)?(www\.)?github\.com\/\w+\/?)|((https?:\/\/)?(www\.)?gitlab\.com\/\w+\/?)|((https?:\/\/)?(www\.)?bitbucket\.org\/\w+\/?)\z}i, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" strip_attributes POSSIBLE_EXPERIENCES = { @@ -129,11 +129,13 @@ def email end def portfolio_url=(value) + value = value.downcase if !value.blank? value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://") super value end def vcs_url=(value) + value = value.downcase if !value.blank? value = "https://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://") super value end diff --git a/test/models/questionnaire_test.rb b/test/models/questionnaire_test.rb index d1ac8764b..25d5abf63 100644 --- a/test/models/questionnaire_test.rb +++ b/test/models/questionnaire_test.rb @@ -103,6 +103,7 @@ class QuestionnaireTest < ActiveSupport::TestCase should allow_value('foo.com').for(:portfolio_url) should allow_value('github.com/foo', 'gitlab.com/bar', 'bitbucket.org/baz').for(:vcs_url) should allow_value('https://github.com/foo', 'https://gitlab.com/bar', 'https://bitbucket.org/baz').for(:vcs_url) + should allow_value('HttPs://gITHub.CoM/foo', 'hTTp://gitLAB.coM/bar').for(:vcs_url) should_not allow_value('http://foo.com', 'https://bar.com').for(:vcs_url) context "#school" do From 93bb9aaa7b9c16f4de5376d2abfcbd5efe35a5ec Mon Sep 17 00:00:00 2001 From: Jeremy Rudman Date: Wed, 23 Dec 2020 00:42:54 -0500 Subject: [PATCH 2/6] fixed houndci complaints --- app/models/questionnaire.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/questionnaire.rb b/app/models/questionnaire.rb index 924911eb6..800db60bf 100644 --- a/app/models/questionnaire.rb +++ b/app/models/questionnaire.rb @@ -129,13 +129,13 @@ def email end def portfolio_url=(value) - value = value.downcase if !value.blank? + value = value.downcase unless value.blank? value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://") super value end def vcs_url=(value) - value = value.downcase if !value.blank? + value = value.downcase unless value.blank? value = "https://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://") super value end From 3a5a54667d6a4978b2380aa46546b58bae993d70 Mon Sep 17 00:00:00 2001 From: Jeremy Rudman Date: Thu, 24 Dec 2020 22:04:49 -0500 Subject: [PATCH 3/6] lossened username regex and add another test --- app/models/questionnaire.rb | 2 +- test/models/questionnaire_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/questionnaire.rb b/app/models/questionnaire.rb index 800db60bf..4d32d86f5 100644 --- a/app/models/questionnaire.rb +++ b/app/models/questionnaire.rb @@ -43,7 +43,7 @@ class Questionnaire < ApplicationRecord validates :portfolio_url, url: { allow_blank: true } validates :vcs_url, url: { allow_blank: true } - validates_format_of :vcs_url, with: %r{\A((https?:\/\/)?(www\.)?github\.com\/\w+\/?)|((https?:\/\/)?(www\.)?gitlab\.com\/\w+\/?)|((https?:\/\/)?(www\.)?bitbucket\.org\/\w+\/?)\z}i, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" + validates_format_of :vcs_url, with: %r{\A((https?:\/\/)?(www\.)?github\.com\/(.*){0,62})|((https?:\/\/)?(www\.)?gitlab\.com\/(.*){0,62})|((https?:\/\/)?(www\.)?bitbucket\.org\/(.*){0,62})\z}i, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" strip_attributes POSSIBLE_EXPERIENCES = { diff --git a/test/models/questionnaire_test.rb b/test/models/questionnaire_test.rb index 25d5abf63..7cf590185 100644 --- a/test/models/questionnaire_test.rb +++ b/test/models/questionnaire_test.rb @@ -104,6 +104,7 @@ class QuestionnaireTest < ActiveSupport::TestCase should allow_value('github.com/foo', 'gitlab.com/bar', 'bitbucket.org/baz').for(:vcs_url) should allow_value('https://github.com/foo', 'https://gitlab.com/bar', 'https://bitbucket.org/baz').for(:vcs_url) should allow_value('HttPs://gITHub.CoM/foo', 'hTTp://gitLAB.coM/bar').for(:vcs_url) + should allow_value('wWw.gITHub.CoM/fOo', 'hTTp://wWw.gitLAB.coM/f-fc-vx').for(:vcs_url) should_not allow_value('http://foo.com', 'https://bar.com').for(:vcs_url) context "#school" do From 838057f91150b5e04f3952d0a81a3b9fc3c22257 Mon Sep 17 00:00:00 2001 From: Jeremy Rudman Date: Thu, 24 Dec 2020 23:04:20 -0500 Subject: [PATCH 4/6] made regex more pleasing to read --- app/models/questionnaire.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/questionnaire.rb b/app/models/questionnaire.rb index 4d32d86f5..d02b47d56 100644 --- a/app/models/questionnaire.rb +++ b/app/models/questionnaire.rb @@ -43,7 +43,11 @@ class Questionnaire < ApplicationRecord validates :portfolio_url, url: { allow_blank: true } validates :vcs_url, url: { allow_blank: true } - validates_format_of :vcs_url, with: %r{\A((https?:\/\/)?(www\.)?github\.com\/(.*){0,62})|((https?:\/\/)?(www\.)?gitlab\.com\/(.*){0,62})|((https?:\/\/)?(www\.)?bitbucket\.org\/(.*){0,62})\z}i, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" + validates_format_of :vcs_url, + with: %r{\A((https?:\/\/)?(www\.)?github\.com\/(.*){0,62}) + |((https?:\/\/)?(www\.)?gitlab\.com\/(.*){0,62}) + |((https?:\/\/)?(www\.)?bitbucket\.org\/(.*){0,62})\z}xi, + allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" strip_attributes POSSIBLE_EXPERIENCES = { From 2b31ac2a5e32b6ee661d906c3660aefe6ddca6cb Mon Sep 17 00:00:00 2001 From: Jeremy Rudman Date: Thu, 24 Dec 2020 23:17:01 -0500 Subject: [PATCH 5/6] made regex method more readable --- app/models/questionnaire.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/questionnaire.rb b/app/models/questionnaire.rb index d02b47d56..ad8c2f488 100644 --- a/app/models/questionnaire.rb +++ b/app/models/questionnaire.rb @@ -44,10 +44,9 @@ class Questionnaire < ApplicationRecord validates :portfolio_url, url: { allow_blank: true } validates :vcs_url, url: { allow_blank: true } validates_format_of :vcs_url, - with: %r{\A((https?:\/\/)?(www\.)?github\.com\/(.*){0,62}) - |((https?:\/\/)?(www\.)?gitlab\.com\/(.*){0,62}) - |((https?:\/\/)?(www\.)?bitbucket\.org\/(.*){0,62})\z}xi, - allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url" + with: %r{\A((https?:\/\/)?(www\.)?((github\.com)|(gitlab\.com)|(bitbucket\.org))\/(.*){0,62})\z}i, + allow_blank: true, + message: "Must be a GitHub, GitLab or Bitbucket url" strip_attributes POSSIBLE_EXPERIENCES = { From dbc443a1ab3c1a6acefe14baa738bbab57679f72 Mon Sep 17 00:00:00 2001 From: Jeremy Rudman Date: Thu, 24 Dec 2020 23:25:26 -0500 Subject: [PATCH 6/6] checks now does 300 attempts --- CHECKS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHECKS b/CHECKS index 223e5a175..24d7a521f 100644 --- a/CHECKS +++ b/CHECKS @@ -1,4 +1,4 @@ WAIT=10 -ATTEMPTS=20 +ATTEMPTS=300 /users/sign_in Sign in to