Skip to content

Commit

Permalink
Index on Errs#last_notice_at should allow listing pile of errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Recobra committed Nov 23, 2010
1 parent 55f2636 commit ec51e94
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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']
4 changes: 3 additions & 1 deletion app/models/err.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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,
Expand Down
2 changes: 2 additions & 0 deletions lib/tasks/errbit/bootstrap.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion spec/controllers/errs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

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(
Expand All @@ -22,6 +25,11 @@
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
Expand Down

0 comments on commit ec51e94

Please sign in to comment.