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