diff --git a/app/models/incoming_link.rb b/app/models/incoming_link.rb index ba996f337..42b6f6a65 100644 --- a/app/models/incoming_link.rb +++ b/app/models/incoming_link.rb @@ -3,7 +3,6 @@ class IncomingLink < ActiveRecord::Base belongs_to :user validates :url, presence: true - validate :referer_valid before_validation :extract_domain @@ -51,6 +50,7 @@ class IncomingLink < ActiveRecord::Base parsed = URI.parse(url) begin + # TODO achieve same thing with no exception params = Rails.application.routes.recognize_path(parsed.path) self.topic_id = params[:topic_id] self.post_number = params[:post_number] diff --git a/spec/models/incoming_link_spec.rb b/spec/models/incoming_link_spec.rb index 16066d636..a6cf4c6b3 100644 --- a/spec/models/incoming_link_spec.rb +++ b/spec/models/incoming_link_spec.rb @@ -48,6 +48,10 @@ describe IncomingLink do TestRequest.new(env) end + it "does not explode with bad referer" do + IncomingLink.add(req('http://sam.com','file:///Applications/Install/75067ABC-C9D1-47B7-8ACE-76AEDE3911B2/Install/')) + end + it "does nothing if referer is empty" do IncomingLink.expects(:create).never IncomingLink.add(req('http://somesite.com'))