From f54e5781d1ead0869977ee988a91750010e10d0f Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Thu, 7 Nov 2024 10:01:48 -0800 Subject: [PATCH] Remove unused RFC gem (#4068) * the RFC gem doesn't support ruby 3.3, but we don't seem to use it anyway --- Gemfile | 1 - Gemfile.lock | 2 - lib/sequel_plugins/vcap_validations.rb | 7 ---- lib/vcap/rest_api/message.rb | 2 - ...validation_error_message_overrides_spec.rb | 9 ---- .../sequel_plugins/vcap_validations_spec.rb | 41 ------------------- 6 files changed, 62 deletions(-) diff --git a/Gemfile b/Gemfile index eafacc4cb90..dc8cf838fed 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,6 @@ gem 'public_suffix' gem 'puma' gem 'rake' gem 'redis' -gem 'rfc822' gem 'rubyzip', '>= 1.3.0' gem 'sequel', '~> 5.86' gem 'sequel_pg', require: 'sequel' diff --git a/Gemfile.lock b/Gemfile.lock index b285f5205b0..7bcaca87322 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -435,7 +435,6 @@ GEM reverse_markdown (2.1.1) nokogiri rexml (3.3.9) - rfc822 (0.1.5) roodi (5.0.0) ruby_parser (~> 3.2, >= 3.2.2) rspec (3.13.0) @@ -651,7 +650,6 @@ DEPENDENCIES railties (~> 7.2.1) rake redis - rfc822 roodi rspec (~> 3.13.0) rspec-collection_matchers diff --git a/lib/sequel_plugins/vcap_validations.rb b/lib/sequel_plugins/vcap_validations.rb index 79e64f14b81..7be89e97f60 100644 --- a/lib/sequel_plugins/vcap_validations.rb +++ b/lib/sequel_plugins/vcap_validations.rb @@ -8,12 +8,5 @@ def validates_url(attr, opts={}) validates_format(URI::DEFAULT_PARSER.make_regexp(%w[http https]), attr, message: opts.fetch(:message, :url)) end - - # Validates that an attribute is a valid email address - # - # @param [Symbol] The attribute to validate - def validates_email(attr) - validates_format(RFC822::EMAIL_REGEXP_WHOLE, attr, message: :email) if send(attr) - end end end diff --git a/lib/vcap/rest_api/message.rb b/lib/vcap/rest_api/message.rb index 2897b48aad8..bdd26401109 100644 --- a/lib/vcap/rest_api/message.rb +++ b/lib/vcap/rest_api/message.rb @@ -1,5 +1,4 @@ require 'vcap/json_message' -require 'rfc822' module VCAP module RestAPI @@ -58,7 +57,6 @@ def self.schema_doc(schema) URL = UrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https])) HTTPS_URL = HttpsUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp('https')) - EMAIL = EmailDecorator.new(RFC822::EMAIL_REGEXP_WHOLE) GIT_URL = GitUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https git])) # The block will be evaluated in the context of the schema validator used diff --git a/spec/unit/lib/ext/validation_error_message_overrides_spec.rb b/spec/unit/lib/ext/validation_error_message_overrides_spec.rb index f877381269d..0a4a5c810c6 100644 --- a/spec/unit/lib/ext/validation_error_message_overrides_spec.rb +++ b/spec/unit/lib/ext/validation_error_message_overrides_spec.rb @@ -35,15 +35,6 @@ end end - context 'with a custom readable_regexp for an email' do - let(:regexp) { VCAP::RestAPI::Message::EMAIL } - - it 'generates a readable message' do - expected_emsg = 'must be a valid email' - expect { subject.fail!(regexp, object) }.to raise_error(Membrane::SchemaValidationError, /#{expected_emsg}/) - end - end - context 'with a custom readable_regexp for a git URL' do let(:regexp) { VCAP::RestAPI::Message::GIT_URL } diff --git a/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb b/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb index 533c030bed5..a1ef2a6a890 100644 --- a/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb +++ b/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb @@ -63,45 +63,4 @@ def self.define_validations(&) end end end - - describe 'validates_email' do - before do - @c.define_validations { validates_email(:val) } - end - - it 'allows a valid email' do - @m.val = 'some_guy@foo.com' - expect(@m).to be_valid - end - - it 'does not allow an email with no domain' do - @m.val = 'some_guy' - expect(@m).not_to be_valid - end - - it 'does not allow an email with no user' do - @m.val = '@somedomain.com' - expect(@m).not_to be_valid - end - - it 'does not allow a malformed email with multiple @' do - @m.val = 'foo@some@domain.com' - expect(@m).not_to be_valid - end - - it 'allows a nil email' do - @m.val = nil - expect(@m).to be_valid - end - - it 'does not allow an empty email' do - @m.val = '' - expect(@m).not_to be_valid - end - - it 'does not allow an email with only spaces' do - @m.val = ' ' - expect(@m).not_to be_valid - end - end end