From 025c89ad11cf5b354bdee6976e2c62d3c6a0f529 Mon Sep 17 00:00:00 2001 From: Stephen Crosby Date: Tue, 14 Jul 2015 22:37:09 -0700 Subject: [PATCH] fix Problems#show action after mongoid5 refactor --- app/controllers/problems_controller.rb | 4 ++-- app/decorators/backtrace_line_decorator.rb | 12 ++++++++++++ app/models/backtrace.rb | 1 + app/views/problems/show.html.haml | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index 12c68a4..866bb34 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -50,9 +50,9 @@ class ProblemsController < ApplicationController def index; end def show - @notices = problem.object.notices.reverse_ordered + @notices = problem.object.notices.reverse_ordered .page(params[:notice]).per(1) - @notice = @notices.first + @notice = NoticeDecorator.new @notices.first @comment = Comment.new end diff --git a/app/decorators/backtrace_line_decorator.rb b/app/decorators/backtrace_line_decorator.rb index 2b62da7..e13edf1 100644 --- a/app/decorators/backtrace_line_decorator.rb +++ b/app/decorators/backtrace_line_decorator.rb @@ -9,6 +9,10 @@ class BacktraceLineDecorator < Draper::Decorator object[:number] end + def column + object[:column] + end + def file object[:file] end @@ -35,6 +39,14 @@ class BacktraceLineDecorator < Draper::Decorator link_to_in_app_source_file(app, text) || text end + def path + File.dirname(object[:file]).gsub(/^\.$/, '') + "/" + end + + def decorated_path + file_relative.sub(Backtrace::GEMS_PATH, "\\1") + end + private def link_to_in_app_source_file(app, text) return unless in_app? diff --git a/app/models/backtrace.rb b/app/models/backtrace.rb index f0596e0..560e0b4 100644 --- a/app/models/backtrace.rb +++ b/app/models/backtrace.rb @@ -3,6 +3,7 @@ class Backtrace include Mongoid::Timestamps IN_APP_PATH = %r{^\[PROJECT_ROOT\](?!(\/vendor))/?} + GEMS_PATH = %r{\[GEM_ROOT\]\/gems\/([^\/]+)} field :fingerprint field :lines diff --git a/app/views/problems/show.html.haml b/app/views/problems/show.html.haml index e9a47f2..cbca417 100644 --- a/app/views/problems/show.html.haml +++ b/app/views/problems/show.html.haml @@ -68,7 +68,7 @@ #backtrace %h3 Backtrace - = render 'notices/backtrace', :lines => @notice.backtrace_lines + = render 'notices/backtrace', :lines => @notice.backtrace.lines - if @notice.user_attributes.present? #user_attributes -- libgit2 0.21.2