From c1890c1a4a6775c848d267a7586e92ac46b4b19c Mon Sep 17 00:00:00 2001 From: Jared Pace Date: Fri, 6 Aug 2010 19:22:12 -0400 Subject: [PATCH] Add errs#all to display resolved + unresolved errs --- app/controllers/errs_controller.rb | 4 ++++ app/views/errs/all.html.haml | 5 +++++ app/views/errs/index.html.haml | 4 +++- config/routes.rb | 6 +++++- spec/controllers/errs_controller_spec.rb | 13 +++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 app/views/errs/all.html.haml diff --git a/app/controllers/errs_controller.rb b/app/controllers/errs_controller.rb index 8322e2e..2e08dfa 100644 --- a/app/controllers/errs_controller.rb +++ b/app/controllers/errs_controller.rb @@ -4,6 +4,10 @@ class ErrsController < ApplicationController @errs = Err.unresolved.ordered.paginate(:page => params[:page]) end + def all + @errs = Err.ordered.paginate(:page => params[:page]) + end + def show @project = Project.find(params[:project_id]) @err = @project.errs.find(params[:id]) diff --git a/app/views/errs/all.html.haml b/app/views/errs/all.html.haml new file mode 100644 index 0000000..a3600fe --- /dev/null +++ b/app/views/errs/all.html.haml @@ -0,0 +1,5 @@ +- content_for :title, 'All Errors' +- content_for :action_bar do + = will_paginate(@errs) + = link_to 'hide resolved', errs_path += render 'table', :errs => @errs \ No newline at end of file diff --git a/app/views/errs/index.html.haml b/app/views/errs/index.html.haml index 58b6f57..77acc82 100644 --- a/app/views/errs/index.html.haml +++ b/app/views/errs/index.html.haml @@ -1,3 +1,5 @@ - content_for :title, 'Unresolved Errors' - +- content_for :action_bar do + = will_paginate(@errs) + = link_to 'show resolved', all_errs_path = render 'table', :errs => @errs \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 33815a2..5249fb3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,11 @@ Hypnotoad::Application.routes.draw do match '/notifier_api/v2/notices' => 'notices#create' match '/deploys.txt' => 'deploys#create' - resources :errs, :only => [:index] + resources :errs, :only => [:index] do + collection do + get :all + end + end resources :notices, :only => [:show] resources :deploys, :only => [:show] diff --git a/spec/controllers/errs_controller_spec.rb b/spec/controllers/errs_controller_spec.rb index 1107f38..16e992e 100644 --- a/spec/controllers/errs_controller_spec.rb +++ b/spec/controllers/errs_controller_spec.rb @@ -17,6 +17,19 @@ describe ErrsController do end end + describe "GET /errs/all" do + it "gets a paginated list of all errors" do + errors = WillPaginate::Collection.new(1,30) + 3.times { errors << Factory(:err) } + 3.times { errors << Factory(:err, :resolved => true)} + Err.should_receive(:ordered).and_return( + mock('proxy', :paginate => errors) + ) + get :index + assigns(:errs).should == errors + end + end + describe "GET /projects/:project_id/errs/:id" do before do 3.times { Factory(:notice, :err => err)} -- libgit2 0.21.2