From 7058205f704ef3ec9d2ac587f5cbcbba35fb460a Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 24 Jul 2018 12:00:23 -0400 Subject: [PATCH] FIX: Broken specs --- lib/final_destination.rb | 2 +- spec/components/final_destination_spec.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/final_destination.rb b/lib/final_destination.rb index ff4ac8396cf..b1360d20734 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -304,7 +304,7 @@ class FinalDestination def self.lookup_ip(host) if Rails.env.test? - "0.0.0.0" + "1.1.1.1" else IPSocket::getaddress(host) end diff --git a/spec/components/final_destination_spec.rb b/spec/components/final_destination_spec.rb index 45fa30fbb85..6a30757a7c3 100644 --- a/spec/components/final_destination_spec.rb +++ b/spec/components/final_destination_spec.rb @@ -338,8 +338,17 @@ describe FinalDestination do end it "returns false for short ip" do - expect(FinalDestination.new('https://0/logo.png').is_dest_valid?).to eq(false) - expect(FinalDestination.new('https://1/logo.png').is_dest_valid?).to eq(false) + lookup = lambda do |host| + # How IPs are looked up for single digits + if host == "0" + "0.0.0.0" + elsif host == "1" + "0.0.0.1" + end + end + + expect(FinalDestination.new('https://0/logo.png', lookup_ip: lookup).is_dest_valid?).to eq(false) + expect(FinalDestination.new('https://1/logo.png', lookup_ip: lookup).is_dest_valid?).to eq(false) end it "returns false for private ipv4" do