Commit d69719a028f26ebb8dfd420da368842cbd05edde

Authored by Nathan Broadbent
1 parent c84a9925
Exists in master and in 1 other branch production

Updated mongoid to 2.4.10, renamed :klass fields to :error_class (including migration)

@@ -3,7 +3,7 @@ source 'http://rubygems.org' @@ -3,7 +3,7 @@ source 'http://rubygems.org'
3 gem 'rails', '~> 3.2.0' 3 gem 'rails', '~> 3.2.0'
4 4
5 gem 'nokogiri' 5 gem 'nokogiri'
6 -gem 'mongoid', '~> 2.2.2' 6 +gem 'mongoid', '~> 2.4.10'
7 7
8 gem 'haml' 8 gem 'haml'
9 gem 'htmlentities', "~> 4.3.0" 9 gem 'htmlentities', "~> 4.3.0"
@@ -105,8 +105,8 @@ GEM @@ -105,8 +105,8 @@ GEM
105 mime-types (1.18) 105 mime-types (1.18)
106 mongo (1.3.1) 106 mongo (1.3.1)
107 bson (>= 1.3.1) 107 bson (>= 1.3.1)
108 - mongoid (2.2.5)  
109 - activemodel (~> 3.0) 108 + mongoid (2.4.10)
  109 + activemodel (~> 3.1)
110 mongo (~> 1.3) 110 mongo (~> 1.3)
111 tzinfo (~> 0.3.22) 111 tzinfo (~> 0.3.22)
112 mongoid_rails_migrations (0.0.14) 112 mongoid_rails_migrations (0.0.14)
@@ -242,7 +242,7 @@ DEPENDENCIES @@ -242,7 +242,7 @@ DEPENDENCIES
242 kaminari 242 kaminari
243 lighthouse-api 243 lighthouse-api
244 mongo (= 1.3.1) 244 mongo (= 1.3.1)
245 - mongoid (~> 2.2.2) 245 + mongoid (~> 2.4.10)
246 mongoid_rails_migrations 246 mongoid_rails_migrations
247 nokogiri 247 nokogiri
248 octokit (= 0.6.4) 248 octokit (= 0.6.4)
app/models/app.rb
@@ -47,7 +47,7 @@ class App @@ -47,7 +47,7 @@ class App
47 # 47 #
48 # Accepts either XML or a hash with the following attributes: 48 # Accepts either XML or a hash with the following attributes:
49 # 49 #
50 - # * <tt>:klass</tt> - the class of error 50 + # * <tt>:error_class</tt> - the class of error
51 # * <tt>:message</tt> - the error message 51 # * <tt>:message</tt> - the error message
52 # * <tt>:backtrace</tt> - an array of stack trace lines 52 # * <tt>:backtrace</tt> - an array of stack trace lines
53 # 53 #
@@ -67,7 +67,7 @@ class App @@ -67,7 +67,7 @@ class App
67 # 67 #
68 # Accepts a hash with the following attributes: 68 # Accepts a hash with the following attributes:
69 # 69 #
70 - # * <tt>:klass</tt> - the class of error 70 + # * <tt>:error_class</tt> - the class of error
71 # * <tt>:message</tt> - the error message 71 # * <tt>:message</tt> - the error message
72 # * <tt>:backtrace</tt> - an array of stack trace lines 72 # * <tt>:backtrace</tt> - an array of stack trace lines
73 # 73 #
app/models/err.rb
@@ -6,7 +6,7 @@ class Err @@ -6,7 +6,7 @@ class Err
6 include Mongoid::Document 6 include Mongoid::Document
7 include Mongoid::Timestamps 7 include Mongoid::Timestamps
8 8
9 - field :klass 9 + field :error_class
10 field :component 10 field :component
11 field :action 11 field :action
12 field :environment 12 field :environment
@@ -14,11 +14,11 @@ class Err @@ -14,11 +14,11 @@ class Err
14 14
15 belongs_to :problem 15 belongs_to :problem
16 index :problem_id 16 index :problem_id
17 - index :klass 17 + index :error_class
18 18
19 has_many :notices, :inverse_of => :err, :dependent => :destroy 19 has_many :notices, :inverse_of => :err, :dependent => :destroy
20 20
21 - validates_presence_of :klass, :environment 21 + validates_presence_of :error_class, :environment
22 22
23 delegate :app, :resolved?, :to => :problem 23 delegate :app, :resolved?, :to => :problem
24 24
app/models/error_report.rb
@@ -2,7 +2,7 @@ require &#39;digest/md5&#39; @@ -2,7 +2,7 @@ require &#39;digest/md5&#39;
2 require 'hoptoad_notifier' 2 require 'hoptoad_notifier'
3 3
4 class ErrorReport 4 class ErrorReport
5 - attr_reader :klass, :message, :backtrace, :request, :server_environment, :api_key, :notifier, :user_attributes 5 + attr_reader :error_class, :message, :backtrace, :request, :server_environment, :api_key, :notifier, :user_attributes
6 6
7 def initialize(xml_or_attributes) 7 def initialize(xml_or_attributes)
8 @attributes = (xml_or_attributes.is_a?(String) ? Hoptoad.parse_xml!(xml_or_attributes) : xml_or_attributes).with_indifferent_access 8 @attributes = (xml_or_attributes.is_a?(String) ? Hoptoad.parse_xml!(xml_or_attributes) : xml_or_attributes).with_indifferent_access
@@ -36,6 +36,7 @@ class ErrorReport @@ -36,6 +36,7 @@ class ErrorReport
36 def generate_notice! 36 def generate_notice!
37 notice = Notice.new( 37 notice = Notice.new(
38 :message => message, 38 :message => message,
  39 + :error_class => error_class,
39 :backtrace => backtrace, 40 :backtrace => backtrace,
40 :request => request, 41 :request => request,
41 :server_environment => server_environment, 42 :server_environment => server_environment,
@@ -43,7 +44,7 @@ class ErrorReport @@ -43,7 +44,7 @@ class ErrorReport
43 :user_attributes => user_attributes) 44 :user_attributes => user_attributes)
44 45
45 err = app.find_or_create_err!( 46 err = app.find_or_create_err!(
46 - :klass => klass, 47 + :error_class => error_class,
47 :component => component, 48 :component => component,
48 :action => action, 49 :action => action,
49 :environment => rails_env, 50 :environment => rails_env,
app/models/notice.rb
@@ -11,7 +11,7 @@ class Notice @@ -11,7 +11,7 @@ class Notice
11 field :request, :type => Hash 11 field :request, :type => Hash
12 field :notifier, :type => Hash 12 field :notifier, :type => Hash
13 field :user_attributes, :type => Hash 13 field :user_attributes, :type => Hash
14 - field :klass 14 + field :error_class
15 15
16 belongs_to :err 16 belongs_to :err
17 index :created_at 17 index :created_at
app/models/problem.rb
@@ -16,7 +16,7 @@ class Problem @@ -16,7 +16,7 @@ class Problem
16 field :notices_count, :type => Integer, :default => 0 16 field :notices_count, :type => Integer, :default => 0
17 field :message 17 field :message
18 field :environment 18 field :environment
19 - field :klass 19 + field :error_class
20 field :where 20 field :where
21 field :user_agents, :type => Hash, :default => {} 21 field :user_agents, :type => Hash, :default => {}
22 field :messages, :type => Hash, :default => {} 22 field :messages, :type => Hash, :default => {}
@@ -128,7 +128,7 @@ class Problem @@ -128,7 +128,7 @@ class Problem
128 attrs.merge!( 128 attrs.merge!(
129 :message => notice.message, 129 :message => notice.message,
130 :environment => notice.environment_name, 130 :environment => notice.environment_name,
131 - :klass => notice.klass, 131 + :error_class => notice.error_class,
132 :where => notice.where, 132 :where => notice.where,
133 :messages => attribute_count_increase(:messages, notice.message), 133 :messages => attribute_count_increase(:messages, notice.message),
134 :hosts => attribute_count_increase(:hosts, notice.host), 134 :hosts => attribute_count_increase(:hosts, notice.host),
app/views/errs/show.html.haml
1 - content_for :page_title, @problem.message 1 - content_for :page_title, @problem.message
2 -- content_for :title, @problem.klass 2 +- content_for :title, @problem.error_class
3 - content_for :meta do 3 - content_for :meta do
4 %strong App: 4 %strong App:
5 = link_to @app.name, app_path(@app) 5 = link_to @app.name, app_path(@app)
app/views/notices/_summary.html.haml
@@ -3,6 +3,9 @@ @@ -3,6 +3,9 @@
3 %tr 3 %tr
4 %th Message 4 %th Message
5 %td.main.nowrap= message_graph(problem) 5 %td.main.nowrap= message_graph(problem)
  6 + %tr
  7 + %th Error Class
  8 + %td= notice.error_class
6 - if notice.request['url'].present? 9 - if notice.request['url'].present?
7 %tr 10 %tr
8 %th URL 11 %th URL
db/migrate/20120530005915_rename_klass_to_error_class.rb 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +class RenameKlassToErrorClass < Mongoid::Migration
  2 + def self.up
  3 + [Problem, Err, Notice].each do |model|
  4 + model.collection.update({}, {'$rename' => {'klass' => 'error_class'}}, multi: true, safe: true)
  5 + end
  6 + end
  7 +
  8 + def self.down
  9 + [Problem, Err, Notice].each do |model|
  10 + model.collection.update({}, {'$rename' => {'error_class' => 'klass'}}, multi: true, safe: true)
  11 + end
  12 + end
  13 +end
lib/hoptoad/v2.rb
@@ -50,7 +50,7 @@ module Hoptoad @@ -50,7 +50,7 @@ module Hoptoad
50 50
51 def self.for_errbit_api(notice) 51 def self.for_errbit_api(notice)
52 { 52 {
53 - :klass => notice['error']['class'] || notice['error']['key'], 53 + :error_class => notice['error']['class'] || notice['error']['key'],
54 :message => notice['error']['message'], 54 :message => notice['error']['message'],
55 :backtrace => notice['error']['backtrace']['line'], 55 :backtrace => notice['error']['backtrace']['line'],
56 56
lib/tasks/errbit/demo.rake
@@ -9,22 +9,22 @@ namespace :errbit do @@ -9,22 +9,22 @@ namespace :errbit do
9 app.problems.delete_all 9 app.problems.delete_all
10 10
11 errors = [{ 11 errors = [{
12 - :klass => "ArgumentError", 12 + :error_class => "ArgumentError",
13 :message => "wrong number of arguments (3 for 0)" 13 :message => "wrong number of arguments (3 for 0)"
14 }, { 14 }, {
15 - :klass => "RuntimeError", 15 + :error_class => "RuntimeError",
16 :message => "Could not find Red October" 16 :message => "Could not find Red October"
17 }, { 17 }, {
18 - :klass => "TypeError", 18 + :error_class => "TypeError",
19 :message => "can't convert Symbol into Integer" 19 :message => "can't convert Symbol into Integer"
20 }, { 20 }, {
21 - :klass => "ActiveRecord::RecordNotFound", 21 + :error_class => "ActiveRecord::RecordNotFound",
22 :message => "could not find a record with the id 5" 22 :message => "could not find a record with the id 5"
23 }, { 23 }, {
24 - :klass => "NameError", 24 + :error_class => "NameError",
25 :message => "uninitialized constant Tag" 25 :message => "uninitialized constant Tag"
26 }, { 26 }, {
27 - :klass => "SyntaxError", 27 + :error_class => "SyntaxError",
28 :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" 28 :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('"
29 }] 29 }]
30 30
@@ -44,7 +44,7 @@ namespace :errbit do @@ -44,7 +44,7 @@ namespace :errbit do
44 rand(34).times do 44 rand(34).times do
45 45
46 error_report = error_template.reverse_merge({ 46 error_report = error_template.reverse_merge({
47 - :klass => "StandardError", 47 + :error_class => "StandardError",
48 :message => "Oops. Something went wrong!", 48 :message => "Oops. Something went wrong!",
49 :backtrace => random_backtrace, 49 :backtrace => random_backtrace,
50 :request => { 50 :request => {
spec/fabricators/err_fabricator.rb
1 Fabricator :err do 1 Fabricator :err do
2 problem! 2 problem!
3 - klass! { 'FooError' } 3 + error_class! { 'FooError' }
4 component 'foo' 4 component 'foo'
5 action 'bar' 5 action 'bar'
6 environment 'production' 6 environment 'production'
spec/models/app_spec.rb
@@ -117,7 +117,7 @@ describe App do @@ -117,7 +117,7 @@ describe App do
117 before do 117 before do
118 @app = Fabricate(:app) 118 @app = Fabricate(:app)
119 @conditions = { 119 @conditions = {
120 - :klass => 'Whoops', 120 + :error_class => 'Whoops',
121 :component => 'Foo', 121 :component => 'Foo',
122 :action => 'bar', 122 :action => 'bar',
123 :environment => 'production' 123 :environment => 'production'
@@ -158,7 +158,7 @@ describe App do @@ -158,7 +158,7 @@ describe App do
158 it 'finds the correct err for the notice' do 158 it 'finds the correct err for the notice' do
159 App.should_receive(:find_by_api_key!).and_return(@app) 159 App.should_receive(:find_by_api_key!).and_return(@app)
160 @app.should_receive(:find_or_create_err!).with({ 160 @app.should_receive(:find_or_create_err!).with({
161 - :klass => 'HoptoadTestingException', 161 + :error_class => 'HoptoadTestingException',
162 :component => 'application', 162 :component => 'application',
163 :action => 'verify', 163 :action => 'verify',
164 :environment => 'development', 164 :environment => 'development',
@@ -171,7 +171,7 @@ describe App do @@ -171,7 +171,7 @@ describe App do
171 it 'marks the err as unresolved if it was previously resolved' do 171 it 'marks the err as unresolved if it was previously resolved' do
172 App.should_receive(:find_by_api_key!).and_return(@app) 172 App.should_receive(:find_by_api_key!).and_return(@app)
173 @app.should_receive(:find_or_create_err!).with({ 173 @app.should_receive(:find_or_create_err!).with({
174 - :klass => 'HoptoadTestingException', 174 + :error_class => 'HoptoadTestingException',
175 :component => 'application', 175 :component => 'application',
176 :action => 'verify', 176 :action => 'verify',
177 :environment => 'development', 177 :environment => 'development',
spec/models/err_spec.rb
@@ -3,10 +3,10 @@ require &#39;spec_helper&#39; @@ -3,10 +3,10 @@ require &#39;spec_helper&#39;
3 describe Err do 3 describe Err do
4 4
5 context 'validations' do 5 context 'validations' do
6 - it 'requires a klass' do  
7 - err = Fabricate.build(:err, :klass => nil) 6 + it 'requires a error_class' do
  7 + err = Fabricate.build(:err, :error_class => nil)
8 err.should_not be_valid 8 err.should_not be_valid
9 - err.errors[:klass].should include("can't be blank") 9 + err.errors[:error_class].should include("can't be blank")
10 end 10 end
11 11
12 it 'requires an environment' do 12 it 'requires an environment' do