Commit 3db48ca393916651102d0205ebed00f244354597
1 parent
533a7572
Exists in
master
and in
1 other branch
Replaced err validations for error_class and environment with default values ('U…
…nknownError' and 'unknown')
Showing
2 changed files
with
6 additions
and
18 deletions
Show diff stats
app/models/err.rb
| ... | ... | @@ -6,10 +6,10 @@ class Err |
| 6 | 6 | include Mongoid::Document |
| 7 | 7 | include Mongoid::Timestamps |
| 8 | 8 | |
| 9 | - field :error_class | |
| 9 | + field :error_class, :default => "UnknownError" | |
| 10 | 10 | field :component |
| 11 | 11 | field :action |
| 12 | - field :environment | |
| 12 | + field :environment, :default => "unknown" | |
| 13 | 13 | field :fingerprint |
| 14 | 14 | |
| 15 | 15 | belongs_to :problem |
| ... | ... | @@ -19,8 +19,6 @@ class Err |
| 19 | 19 | |
| 20 | 20 | has_many :notices, :inverse_of => :err, :dependent => :destroy |
| 21 | 21 | |
| 22 | - validates_presence_of :error_class, :environment | |
| 23 | - | |
| 24 | 22 | delegate :app, :resolved?, :to => :problem |
| 25 | 23 | |
| 26 | 24 | end | ... | ... |
spec/models/err_spec.rb
| 1 | 1 | require 'spec_helper' |
| 2 | 2 | |
| 3 | 3 | describe Err do |
| 4 | - | |
| 5 | - context 'validations' do | |
| 6 | - it 'requires a error_class' do | |
| 7 | - err = Fabricate.build(:err, :error_class => nil) | |
| 8 | - err.should_not be_valid | |
| 9 | - err.errors[:error_class].should include("can't be blank") | |
| 10 | - end | |
| 11 | - | |
| 12 | - it 'requires an environment' do | |
| 13 | - err = Fabricate.build(:err, :environment => nil) | |
| 14 | - err.should_not be_valid | |
| 15 | - err.errors[:environment].should include("can't be blank") | |
| 16 | - end | |
| 4 | + it 'sets a default error_class and environment' do | |
| 5 | + err = Err.new | |
| 6 | + err.error_class.should == "UnknownError" | |
| 7 | + err.environment.should == "unknown" | |
| 17 | 8 | end |
| 18 | - | |
| 19 | 9 | end |
| 20 | 10 | ... | ... |