Commit ec51e940b460618b6c0eebec443292712eda07db

Authored by Nick Recobra
1 parent 55f2636e
Exists in master and in 1 other branch production

Index on Errs#last_notice_at should allow listing pile of errors.

Rakefile
... ... @@ -8,4 +8,18 @@ require 'bundler'
8 8 Errbit::Application.load_tasks
9 9  
10 10 Rake::Task[:default].clear
  11 +
  12 +namespace :spec do
  13 + desc "Preparing test env"
  14 + task :prepare do
  15 + tmp_env = Rails.env
  16 + Rails.env = "test"
  17 + %w( errbit:bootstrap ).each do |task|
  18 + Rake::Task[task].invoke
  19 + end
  20 + Rails.env = tmp_env
  21 + end
  22 +end
  23 +
  24 +Rake::Task["spec"].prerequisites.push("spec:prepare")
11 25 task :default => ['spec']
12 26 \ No newline at end of file
... ...
app/models/err.rb
... ... @@ -9,7 +9,9 @@ class Err
9 9 field :fingerprint
10 10 field :last_notice_at, :type => DateTime
11 11 field :resolved, :type => Boolean, :default => false
12   -
  12 +
  13 + index :last_notice_at
  14 +
13 15 referenced_in :app
14 16 embeds_many :notices
15 17  
... ...
db/seeds.rb
... ... @@ -10,7 +10,7 @@ puts "-- email: #{admin_email}"
10 10 puts "-- password: #{admin_pass}"
11 11 puts ""
12 12 puts "Be sure to change these credentials ASAP!"
13   -user = User.new({
  13 +user = User.where(:email => admin_email).first || User.new({
14 14 :name => 'Errbit Admin',
15 15 :email => admin_email,
16 16 :password => admin_pass,
... ...
lib/tasks/errbit/bootstrap.rake
... ... @@ -26,6 +26,8 @@ namespace :errbit do
26 26 Rake::Task['errbit:copy_configs'].execute
27 27 puts "\n"
28 28 Rake::Task['db:seed'].invoke
  29 + puts "\n"
  30 + Rake::Task['db:mongoid:create_indexes'].invoke
29 31 end
30 32  
31 33 end
32 34 \ No newline at end of file
... ...
spec/controllers/errs_controller_spec.rb
... ... @@ -12,8 +12,11 @@ describe ErrsController do
12 12  
13 13 describe "GET /errs" do
14 14 context 'when logged in as an admin' do
15   - it "gets a paginated list of unresolved errs" do
  15 + before(:each) do
16 16 sign_in Factory(:admin)
  17 + end
  18 +
  19 + it "gets a paginated list of unresolved errs" do
17 20 errs = WillPaginate::Collection.new(1,30)
18 21 3.times { errs << Factory(:err) }
19 22 Err.should_receive(:unresolved).and_return(
... ... @@ -22,6 +25,11 @@ describe ErrsController do
22 25 get :index
23 26 assigns(:errs).should == errs
24 27 end
  28 +
  29 + it "should handle lots of errors" do
  30 + 1000.times { Factory :notice }
  31 + lambda { get :index }.should_not raise_error
  32 + end
25 33 end
26 34  
27 35 context 'when logged in as a user' do
... ...