diff --git a/app/decorators/backtrace_line_decorator.rb b/app/decorators/backtrace_line_decorator.rb
index e13edf1..85a0239 100644
--- a/app/decorators/backtrace_line_decorator.rb
+++ b/app/decorators/backtrace_line_decorator.rb
@@ -44,7 +44,9 @@ class BacktraceLineDecorator < Draper::Decorator
end
def decorated_path
- file_relative.sub(Backtrace::GEMS_PATH, "\\1")
+ path
+ .sub(Backtrace::IN_APP_PATH, '')
+ .sub(Backtrace::GEMS_PATH, "\\1")
end
private
diff --git a/spec/decorators/backtrace_line_decorator_spec.rb b/spec/decorators/backtrace_line_decorator_spec.rb
new file mode 100644
index 0000000..32dde29
--- /dev/null
+++ b/spec/decorators/backtrace_line_decorator_spec.rb
@@ -0,0 +1,30 @@
+describe BacktraceLineDecorator, type: :decorator do
+ let(:backtrace_line) do
+ described_class.new(
+ number: 884,
+ file: '/path/to/file/ea315ea4.rb',
+ method: :instance_eval)
+ end
+ let(:backtrace_line_in_app) do
+ described_class.new(
+ number: 884,
+ file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb',
+ method: :instance_eval)
+ end
+ let(:app) { Fabricate(:app, github_repo: 'foo/bar') }
+
+ describe '#to_s' do
+ it 'returns a nice string representation of the first line' do
+ expect(backtrace_line.to_s).to eq('/path/to/file/ea315ea4.rb:884')
+ end
+ end
+
+ describe '#link_to_source_file' do
+ it 'adds a link to the source file' do
+ link = backtrace_line_in_app.link_to_source_file(app) { 'mytext' }
+ expect(link).to eq(
+ 'mytext')
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 3fe6063..1bac201 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -50,6 +50,11 @@ RSpec.configure do |config|
init_haml_helpers
end
+ config.before(:each, type: :decorator) do |_|
+ Draper::ViewContext.current.class_eval { include Haml::Helpers }
+ Draper::ViewContext.current.instance_eval { init_haml_helpers }
+ end
+
config.infer_spec_type_from_file_location!
end
--
libgit2 0.21.2