Commit ec51e940b460618b6c0eebec443292712eda07db
1 parent
55f2636e
Exists in
master
and in
1 other branch
Index on Errs#last_notice_at should allow listing pile of errors.
Showing
5 changed files
with
29 additions
and
3 deletions
Show diff stats
Rakefile
| @@ -8,4 +8,18 @@ require 'bundler' | @@ -8,4 +8,18 @@ require 'bundler' | ||
| 8 | Errbit::Application.load_tasks | 8 | Errbit::Application.load_tasks |
| 9 | 9 | ||
| 10 | Rake::Task[:default].clear | 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 | task :default => ['spec'] | 25 | task :default => ['spec'] |
| 12 | \ No newline at end of file | 26 | \ No newline at end of file |
app/models/err.rb
| @@ -9,7 +9,9 @@ class Err | @@ -9,7 +9,9 @@ class Err | ||
| 9 | field :fingerprint | 9 | field :fingerprint |
| 10 | field :last_notice_at, :type => DateTime | 10 | field :last_notice_at, :type => DateTime |
| 11 | field :resolved, :type => Boolean, :default => false | 11 | field :resolved, :type => Boolean, :default => false |
| 12 | - | 12 | + |
| 13 | + index :last_notice_at | ||
| 14 | + | ||
| 13 | referenced_in :app | 15 | referenced_in :app |
| 14 | embeds_many :notices | 16 | embeds_many :notices |
| 15 | 17 |
db/seeds.rb
| @@ -10,7 +10,7 @@ puts "-- email: #{admin_email}" | @@ -10,7 +10,7 @@ puts "-- email: #{admin_email}" | ||
| 10 | puts "-- password: #{admin_pass}" | 10 | puts "-- password: #{admin_pass}" |
| 11 | puts "" | 11 | puts "" |
| 12 | puts "Be sure to change these credentials ASAP!" | 12 | puts "Be sure to change these credentials ASAP!" |
| 13 | -user = User.new({ | 13 | +user = User.where(:email => admin_email).first || User.new({ |
| 14 | :name => 'Errbit Admin', | 14 | :name => 'Errbit Admin', |
| 15 | :email => admin_email, | 15 | :email => admin_email, |
| 16 | :password => admin_pass, | 16 | :password => admin_pass, |
lib/tasks/errbit/bootstrap.rake
| @@ -26,6 +26,8 @@ namespace :errbit do | @@ -26,6 +26,8 @@ namespace :errbit do | ||
| 26 | Rake::Task['errbit:copy_configs'].execute | 26 | Rake::Task['errbit:copy_configs'].execute |
| 27 | puts "\n" | 27 | puts "\n" |
| 28 | Rake::Task['db:seed'].invoke | 28 | Rake::Task['db:seed'].invoke |
| 29 | + puts "\n" | ||
| 30 | + Rake::Task['db:mongoid:create_indexes'].invoke | ||
| 29 | end | 31 | end |
| 30 | 32 | ||
| 31 | end | 33 | end |
| 32 | \ No newline at end of file | 34 | \ No newline at end of file |
spec/controllers/errs_controller_spec.rb
| @@ -12,8 +12,11 @@ describe ErrsController do | @@ -12,8 +12,11 @@ describe ErrsController do | ||
| 12 | 12 | ||
| 13 | describe "GET /errs" do | 13 | describe "GET /errs" do |
| 14 | context 'when logged in as an admin' do | 14 | context 'when logged in as an admin' do |
| 15 | - it "gets a paginated list of unresolved errs" do | 15 | + before(:each) do |
| 16 | sign_in Factory(:admin) | 16 | sign_in Factory(:admin) |
| 17 | + end | ||
| 18 | + | ||
| 19 | + it "gets a paginated list of unresolved errs" do | ||
| 17 | errs = WillPaginate::Collection.new(1,30) | 20 | errs = WillPaginate::Collection.new(1,30) |
| 18 | 3.times { errs << Factory(:err) } | 21 | 3.times { errs << Factory(:err) } |
| 19 | Err.should_receive(:unresolved).and_return( | 22 | Err.should_receive(:unresolved).and_return( |
| @@ -22,6 +25,11 @@ describe ErrsController do | @@ -22,6 +25,11 @@ describe ErrsController do | ||
| 22 | get :index | 25 | get :index |
| 23 | assigns(:errs).should == errs | 26 | assigns(:errs).should == errs |
| 24 | end | 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 | end | 33 | end |
| 26 | 34 | ||
| 27 | context 'when logged in as a user' do | 35 | context 'when logged in as a user' do |