spec for change

This commit is contained in:
Sam 2013-07-05 14:23:29 +10:00
parent f3ac84d41f
commit 9afea0ed07
2 changed files with 5 additions and 1 deletions

View file

@ -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]

View file

@ -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'))