diff --git a/Gemfile b/Gemfile index 43864c1..8f3fcf6 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ gem 'libxml-ruby' gem 'bson_ext', :require => nil gem 'mongoid', '2.0.0.beta.15' gem 'haml' +gem 'will_paginate' group :development, :test do gem 'rspec-rails', '>= 2.0.0.beta.19' diff --git a/Gemfile.lock b/Gemfile.lock index 49fd62a..0324d6c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -112,3 +112,4 @@ DEPENDENCIES rails (= 3.0.0.rc) rspec (>= 2.0.0.beta.19) rspec-rails (>= 2.0.0.beta.19) + will_paginate diff --git a/app/controllers/errs_controller.rb b/app/controllers/errs_controller.rb index 9840a5a..eb1d1ee 100644 --- a/app/controllers/errs_controller.rb +++ b/app/controllers/errs_controller.rb @@ -4,4 +4,11 @@ class ErrsController < ApplicationController @errs = Err.unresolved.paginate(:page => params[:page]) end + def show + @project = Project.find(params[:project_id]) + @err = @project.errs.find(params[:id]) + @notices = @err.notices.paginate(:page => (params[:notice] || @err.notices.count), :per_page => 1) + @notice = @notices.first + end + end diff --git a/app/views/errs/show.html.haml b/app/views/errs/show.html.haml new file mode 100644 index 0000000..3273673 --- /dev/null +++ b/app/views/errs/show.html.haml @@ -0,0 +1,19 @@ +- content_for :title, @err.message +- content_for :meta do + %strong Where: + = @err.where + %strong Environment: + = @err.environment.titleize + %strong Type: + = @err.klass + %strong Last Notice: + = @err.last_notice_at.to_s(:micro) +- content_for :action_bar do + = will_paginate @notices, :param_name => :notice, :page_links => false + .float-left viewing occurrence #{@notices.current_page} of #{@notices.total_pages} + = link_to "back to '#{@project.name}'", project_path(@project) + | + = link_to 'resolve', '#' if @err.unresolved? + +%h3#backtrace Backtrace += render 'notices/backtrace', :lines => @notice.backtrace \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0eec155..7e70043 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,7 +18,7 @@ #content-title %h1= yield :title %span.meta= yield :meta - - if action_bar = yield(:action_bar) + - if (action_bar = yield(:action_bar)).present? #action-bar = action_bar #content diff --git a/app/views/notices/_backtrace.html.haml b/app/views/notices/_backtrace.html.haml new file mode 100644 index 0000000..f8c8f3c --- /dev/null +++ b/app/views/notices/_backtrace.html.haml @@ -0,0 +1,14 @@ +.backtrace + %table + %tr + %th + %ul.line-numbers + - lines.each do |line| + %li= line['number'] + %td + %ul.lines + - lines.each do |line| + %li{:class => (line['file'].gsub!('[PROJECT_ROOT]','') ? 'in-project' : nil)} + = line['file'] + → + %strong= line['method'] \ No newline at end of file diff --git a/app/views/shared/_navigation.html.haml b/app/views/shared/_navigation.html.haml index 7e61420..960b68c 100644 --- a/app/views/shared/_navigation.html.haml +++ b/app/views/shared/_navigation.html.haml @@ -2,5 +2,5 @@ %ul //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) %li= link_to 'Projects', projects_path, :class => active_if_here(:projects) - %li= link_to 'Errors', errs_path, :class => active_if_here(:errs => :index) + %li= link_to 'Errors', errs_path, :class => active_if_here(:errs) %div.clear \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3337efd..d3133bf 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -9,6 +9,8 @@ body { } /* Convenience Classes */ +.float-left { float: left; } +.float-right { float: right; } .clear { clear: both; } .clear-left { clear: left; } .clear-right { clear: right; } @@ -171,6 +173,26 @@ pre { .html ul li { margin-bottom: 0.5em; list-style: disc; } .html ol li { margin-bottom: 0.5em; list-style: decimal; } +/* Pagination */ +.pagination { + float: left; + margin-right: 0.8em; + text-align: left; + font-size: 0.9em; +} +.pagination a, .pagination span { + display: inline-block; + padding: 0 0.3em; + background-color: #666666; + border: 1px solid #505050; +} +.pagination a:hover { + text-decoration: none !important; +} +.pagination span { + color: #AAA; +} + /* Projects Table */ table.projects td.name, table.errs td.message { width: 100%; @@ -189,4 +211,33 @@ table.errs td.message a { table.errs td.message em { color: #727272; font-size: 0.9em; +} + +/* Backtrace */ +.backtrace { + width: 100%; + overflow: auto; +} +.backtrace table { + margin: 0; +} +.backtrace td { + width: 100%; + padding: 0; + margin: 0; + color: #A2A2A2; + background-color: #222 !important; +} +.backtrace ul.line-numbers li { + text-align: right; +} +.backtrace ul.lines { + padding: 10px 8px; + overflow: auto; +} +.backtrace li { + white-space: nowrap; +} +.backtrace li.in-project { + color: #2adb2e; } \ No newline at end of file diff --git a/spec/controllers/errs_controller_spec.rb b/spec/controllers/errs_controller_spec.rb index 3543dac..50dc2dd 100644 --- a/spec/controllers/errs_controller_spec.rb +++ b/spec/controllers/errs_controller_spec.rb @@ -3,15 +3,40 @@ require 'spec_helper' describe ErrsController do let(:project) { Factory(:project) } + let(:err) { Factory(:err, :project => project) } describe "GET /errs" do it "gets a paginated list of unresolved errors" do errors = WillPaginate::Collection.new(1,30) - 3.times { errors << Factory(:err, :project => project) } + 3.times { errors << Factory(:err) } Err.should_receive(:unresolved).and_return(mock('proxy', :paginate => errors)) get :index assigns(:errs).should == errors end end + describe "GET /errs/:id" do + before do + 3.times { Factory(:notice, :err => err)} + end + + it "finds the project" do + get :show, :project_id => project.id, :id => err.id + assigns(:project).should == project + end + + it "finds the err" do + get :show, :project_id => project.id, :id => err.id + assigns(:err).should == err + end + + it "paginates the notices, 1 at a time" do + Project.stub(:find).with(project.id).and_return(project) + project.errs.stub(:find).with(err.id).and_return(err) + err.notices.should_receive(:paginate).with(:page => 3, :per_page => 1). + and_return(WillPaginate::Collection.new(1,1) << err.notices.first) + get :show, :project_id => project.id, :id => err.id + end + end + end -- libgit2 0.21.2