spec for change
This commit is contained in:
parent
f3ac84d41f
commit
9afea0ed07
|
@ -3,7 +3,6 @@ class IncomingLink < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
validates :url, presence: true
|
validates :url, presence: true
|
||||||
|
|
||||||
validate :referer_valid
|
validate :referer_valid
|
||||||
|
|
||||||
before_validation :extract_domain
|
before_validation :extract_domain
|
||||||
|
@ -51,6 +50,7 @@ class IncomingLink < ActiveRecord::Base
|
||||||
parsed = URI.parse(url)
|
parsed = URI.parse(url)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
# TODO achieve same thing with no exception
|
||||||
params = Rails.application.routes.recognize_path(parsed.path)
|
params = Rails.application.routes.recognize_path(parsed.path)
|
||||||
self.topic_id = params[:topic_id]
|
self.topic_id = params[:topic_id]
|
||||||
self.post_number = params[:post_number]
|
self.post_number = params[:post_number]
|
||||||
|
|
|
@ -48,6 +48,10 @@ describe IncomingLink do
|
||||||
TestRequest.new(env)
|
TestRequest.new(env)
|
||||||
end
|
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
|
it "does nothing if referer is empty" do
|
||||||
IncomingLink.expects(:create).never
|
IncomingLink.expects(:create).never
|
||||||
IncomingLink.add(req('http://somesite.com'))
|
IncomingLink.add(req('http://somesite.com'))
|
||||||
|
|
Loading…
Reference in New Issue