Commit 4ef9066c47a1c2082feba39b874edc104e7ba435

Authored by Nathan Broadbent
1 parent c4ef403a
Exists in master and in 1 other branch production

Backtrace link should always default to plain text if in app repos aren't configured

app/helpers/backtrace_line_helper.rb
1 1 module BacktraceLineHelper
2 2 def link_to_source_file(line, &block)
3 3 text = capture_haml(&block)
4   - line.in_app? ? link_to_in_app_source_file(line, text) : link_to_external_source_file(text)
  4 + link_to_in_app_source_file(line, text) || link_to_external_source_file(text)
5 5 end
6 6  
7 7 private
8 8 def link_to_in_app_source_file(line, text)
  9 + return unless line.in_app?
9 10 link_to_repo_source_file(line, text) || link_to_issue_tracker_file(line, text)
10 11 end
11 12  
... ...
spec/helpers/backtrace_line_helper.rb 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +require 'spec_helper'
  2 +
  3 +describe BacktraceLineHelper do
  4 + describe "in app lines" do
  5 + let(:notice) do
  6 + Fabricate.build(:notice, :backtrace =>
  7 + Fabricate.build(:backtrace, :lines => [
  8 + Fabricate.build(:backtrace_line, :file => "[PROJECT_ROOT]/path/to/asset.js")
  9 + ])
  10 + )
  11 + end
  12 +
  13 + describe '#link_to_source_file' do
  14 + it 'still returns text for in app file and line number when no repo is configured' do
  15 + result = link_to_source_file(notice.backtrace.lines.first) { haml_concat "link text" }
  16 + result.strip.should == 'link text'
  17 + end
  18 + end
  19 + end
  20 +end
... ...
spec/spec_helper.rb
... ... @@ -28,6 +28,12 @@ RSpec.configure do |config|
28 28 DatabaseCleaner.clean
29 29 end
30 30 config.include WebMock::API
  31 +
  32 + config.include Haml, :type => :helper
  33 + config.include Haml::Helpers, :type => :helper
  34 + config.before(:each, :type => :helper) do |config|
  35 + init_haml_helpers
  36 + end
31 37 end
32 38  
33 39 OmniAuth.config.test_mode = true
... ...