Test failures for Inline Onebox

This commit is contained in:
Robin Ward 2017-07-20 16:01:16 -04:00
parent 3882722195
commit d2490cbbb8
4 changed files with 10 additions and 3 deletions

View File

@ -228,6 +228,8 @@ module Discourse
return Rails.application.routes.recognize_path(path)
end
nil
rescue ActionController::RoutingError
nil
end

View File

@ -22,8 +22,7 @@ class InlineOneboxer
if route = Discourse.route_for(url)
if route[:controller] == "topics" &&
route[:action] == "show" &&
topic = Topic.where(id: route[:topic_id].to_i).first
topic = (Topic.where(id: route[:topic_id].to_i).first rescue nil)
# Only public topics
if Guardian.new.can_see?(topic)

View File

@ -498,7 +498,7 @@ describe Email::Receiver do
it "adds the 'elided' part of the original message when always_show_trimmed_content is enabled" do
SiteSetting.always_show_trimmed_content = true
user = Fabricate(:user, email: "existing@bar.com", trust_level: SiteSetting.email_in_min_trust)
Fabricate(:user, email: "existing@bar.com", trust_level: SiteSetting.email_in_min_trust)
expect { process(:forwarded_email_to_category) }.to change{Topic.count}.by(1) # Topic created
new_post, = Post.last

View File

@ -48,7 +48,13 @@ describe InlineOneboxer do
expect(onebox[:url]).to eq(topic.url)
expect(onebox[:title]).to eq(topic.title)
end
it "returns nothing for unknown links" do
expect(InlineOneboxer.lookup(nil)).to be_nil
expect(InlineOneboxer.lookup("/test")).to be_nil
end
end
end