Commit d69719a028f26ebb8dfd420da368842cbd05edde
1 parent
c84a9925
Exists in
master
and in
1 other branch
Updated mongoid to 2.4.10, renamed :klass fields to :error_class (including migration)
Showing
15 changed files
with
47 additions
and
30 deletions
Show diff stats
Gemfile
Gemfile.lock
| ... | ... | @@ -105,8 +105,8 @@ GEM |
| 105 | 105 | mime-types (1.18) |
| 106 | 106 | mongo (1.3.1) |
| 107 | 107 | bson (>= 1.3.1) |
| 108 | - mongoid (2.2.5) | |
| 109 | - activemodel (~> 3.0) | |
| 108 | + mongoid (2.4.10) | |
| 109 | + activemodel (~> 3.1) | |
| 110 | 110 | mongo (~> 1.3) |
| 111 | 111 | tzinfo (~> 0.3.22) |
| 112 | 112 | mongoid_rails_migrations (0.0.14) |
| ... | ... | @@ -242,7 +242,7 @@ DEPENDENCIES |
| 242 | 242 | kaminari |
| 243 | 243 | lighthouse-api |
| 244 | 244 | mongo (= 1.3.1) |
| 245 | - mongoid (~> 2.2.2) | |
| 245 | + mongoid (~> 2.4.10) | |
| 246 | 246 | mongoid_rails_migrations |
| 247 | 247 | nokogiri |
| 248 | 248 | octokit (= 0.6.4) | ... | ... |
app/models/app.rb
| ... | ... | @@ -47,7 +47,7 @@ class App |
| 47 | 47 | # |
| 48 | 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 | 51 | # * <tt>:message</tt> - the error message |
| 52 | 52 | # * <tt>:backtrace</tt> - an array of stack trace lines |
| 53 | 53 | # |
| ... | ... | @@ -67,7 +67,7 @@ class App |
| 67 | 67 | # |
| 68 | 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 | 71 | # * <tt>:message</tt> - the error message |
| 72 | 72 | # * <tt>:backtrace</tt> - an array of stack trace lines |
| 73 | 73 | # | ... | ... |
app/models/err.rb
| ... | ... | @@ -6,7 +6,7 @@ class Err |
| 6 | 6 | include Mongoid::Document |
| 7 | 7 | include Mongoid::Timestamps |
| 8 | 8 | |
| 9 | - field :klass | |
| 9 | + field :error_class | |
| 10 | 10 | field :component |
| 11 | 11 | field :action |
| 12 | 12 | field :environment |
| ... | ... | @@ -14,11 +14,11 @@ class Err |
| 14 | 14 | |
| 15 | 15 | belongs_to :problem |
| 16 | 16 | index :problem_id |
| 17 | - index :klass | |
| 17 | + index :error_class | |
| 18 | 18 | |
| 19 | 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 | 23 | delegate :app, :resolved?, :to => :problem |
| 24 | 24 | ... | ... |
app/models/error_report.rb
| ... | ... | @@ -2,7 +2,7 @@ require 'digest/md5' |
| 2 | 2 | require 'hoptoad_notifier' |
| 3 | 3 | |
| 4 | 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 | 7 | def initialize(xml_or_attributes) |
| 8 | 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 | 36 | def generate_notice! |
| 37 | 37 | notice = Notice.new( |
| 38 | 38 | :message => message, |
| 39 | + :error_class => error_class, | |
| 39 | 40 | :backtrace => backtrace, |
| 40 | 41 | :request => request, |
| 41 | 42 | :server_environment => server_environment, |
| ... | ... | @@ -43,7 +44,7 @@ class ErrorReport |
| 43 | 44 | :user_attributes => user_attributes) |
| 44 | 45 | |
| 45 | 46 | err = app.find_or_create_err!( |
| 46 | - :klass => klass, | |
| 47 | + :error_class => error_class, | |
| 47 | 48 | :component => component, |
| 48 | 49 | :action => action, |
| 49 | 50 | :environment => rails_env, | ... | ... |
app/models/notice.rb
app/models/problem.rb
| ... | ... | @@ -16,7 +16,7 @@ class Problem |
| 16 | 16 | field :notices_count, :type => Integer, :default => 0 |
| 17 | 17 | field :message |
| 18 | 18 | field :environment |
| 19 | - field :klass | |
| 19 | + field :error_class | |
| 20 | 20 | field :where |
| 21 | 21 | field :user_agents, :type => Hash, :default => {} |
| 22 | 22 | field :messages, :type => Hash, :default => {} |
| ... | ... | @@ -128,7 +128,7 @@ class Problem |
| 128 | 128 | attrs.merge!( |
| 129 | 129 | :message => notice.message, |
| 130 | 130 | :environment => notice.environment_name, |
| 131 | - :klass => notice.klass, | |
| 131 | + :error_class => notice.error_class, | |
| 132 | 132 | :where => notice.where, |
| 133 | 133 | :messages => attribute_count_increase(:messages, notice.message), |
| 134 | 134 | :hosts => attribute_count_increase(:hosts, notice.host), | ... | ... |
app/views/errs/show.html.haml
app/views/notices/_summary.html.haml
db/migrate/20120530005915_rename_klass_to_error_class.rb
0 → 100644
| ... | ... | @@ -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 | 50 | |
| 51 | 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 | 54 | :message => notice['error']['message'], |
| 55 | 55 | :backtrace => notice['error']['backtrace']['line'], |
| 56 | 56 | ... | ... |
lib/tasks/errbit/demo.rake
| ... | ... | @@ -9,22 +9,22 @@ namespace :errbit do |
| 9 | 9 | app.problems.delete_all |
| 10 | 10 | |
| 11 | 11 | errors = [{ |
| 12 | - :klass => "ArgumentError", | |
| 12 | + :error_class => "ArgumentError", | |
| 13 | 13 | :message => "wrong number of arguments (3 for 0)" |
| 14 | 14 | }, { |
| 15 | - :klass => "RuntimeError", | |
| 15 | + :error_class => "RuntimeError", | |
| 16 | 16 | :message => "Could not find Red October" |
| 17 | 17 | }, { |
| 18 | - :klass => "TypeError", | |
| 18 | + :error_class => "TypeError", | |
| 19 | 19 | :message => "can't convert Symbol into Integer" |
| 20 | 20 | }, { |
| 21 | - :klass => "ActiveRecord::RecordNotFound", | |
| 21 | + :error_class => "ActiveRecord::RecordNotFound", | |
| 22 | 22 | :message => "could not find a record with the id 5" |
| 23 | 23 | }, { |
| 24 | - :klass => "NameError", | |
| 24 | + :error_class => "NameError", | |
| 25 | 25 | :message => "uninitialized constant Tag" |
| 26 | 26 | }, { |
| 27 | - :klass => "SyntaxError", | |
| 27 | + :error_class => "SyntaxError", | |
| 28 | 28 | :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" |
| 29 | 29 | }] |
| 30 | 30 | |
| ... | ... | @@ -44,7 +44,7 @@ namespace :errbit do |
| 44 | 44 | rand(34).times do |
| 45 | 45 | |
| 46 | 46 | error_report = error_template.reverse_merge({ |
| 47 | - :klass => "StandardError", | |
| 47 | + :error_class => "StandardError", | |
| 48 | 48 | :message => "Oops. Something went wrong!", |
| 49 | 49 | :backtrace => random_backtrace, |
| 50 | 50 | :request => { | ... | ... |
spec/fabricators/err_fabricator.rb
spec/models/app_spec.rb
| ... | ... | @@ -117,7 +117,7 @@ describe App do |
| 117 | 117 | before do |
| 118 | 118 | @app = Fabricate(:app) |
| 119 | 119 | @conditions = { |
| 120 | - :klass => 'Whoops', | |
| 120 | + :error_class => 'Whoops', | |
| 121 | 121 | :component => 'Foo', |
| 122 | 122 | :action => 'bar', |
| 123 | 123 | :environment => 'production' |
| ... | ... | @@ -158,7 +158,7 @@ describe App do |
| 158 | 158 | it 'finds the correct err for the notice' do |
| 159 | 159 | App.should_receive(:find_by_api_key!).and_return(@app) |
| 160 | 160 | @app.should_receive(:find_or_create_err!).with({ |
| 161 | - :klass => 'HoptoadTestingException', | |
| 161 | + :error_class => 'HoptoadTestingException', | |
| 162 | 162 | :component => 'application', |
| 163 | 163 | :action => 'verify', |
| 164 | 164 | :environment => 'development', |
| ... | ... | @@ -171,7 +171,7 @@ describe App do |
| 171 | 171 | it 'marks the err as unresolved if it was previously resolved' do |
| 172 | 172 | App.should_receive(:find_by_api_key!).and_return(@app) |
| 173 | 173 | @app.should_receive(:find_or_create_err!).with({ |
| 174 | - :klass => 'HoptoadTestingException', | |
| 174 | + :error_class => 'HoptoadTestingException', | |
| 175 | 175 | :component => 'application', |
| 176 | 176 | :action => 'verify', |
| 177 | 177 | :environment => 'development', | ... | ... |
spec/models/err_spec.rb
| ... | ... | @@ -3,10 +3,10 @@ require 'spec_helper' |
| 3 | 3 | describe Err do |
| 4 | 4 | |
| 5 | 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 | 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 | 10 | end |
| 11 | 11 | |
| 12 | 12 | it 'requires an environment' do | ... | ... |