Commit 35ae77fedcf104120b101fe5bc161cadb1cf6d3a
Exists in
master
and in
1 other branch
Merge branch 'master' into mongoid-3
Conflicts: spec/models/problem_spec.rb
Showing
4 changed files
with
25 additions
and
24 deletions
Show diff stats
CHANGELOG.md
app/models/problem.rb
| ... | ... | @@ -39,7 +39,7 @@ class Problem |
| 39 | 39 | has_many :errs, :inverse_of => :problem, :dependent => :destroy |
| 40 | 40 | has_many :comments, :inverse_of => :err, :dependent => :destroy |
| 41 | 41 | |
| 42 | - validates_presence_of :error_class, :environment | |
| 42 | + validates_presence_of :environment | |
| 43 | 43 | |
| 44 | 44 | before_create :cache_app_attributes |
| 45 | 45 | ... | ... |
spec/models/app_spec.rb
| ... | ... | @@ -165,31 +165,44 @@ describe App do |
| 165 | 165 | end |
| 166 | 166 | |
| 167 | 167 | context '#find_or_create_err!' do |
| 168 | - before do | |
| 169 | - @app = Fabricate(:app) | |
| 170 | - @conditions = { | |
| 168 | + let(:app) { Fabricate(:app) } | |
| 169 | + let(:conditions) { { | |
| 171 | 170 | :error_class => 'Whoops', |
| 172 | 171 | :environment => 'production', |
| 173 | 172 | :fingerprint => 'some-finger-print' |
| 174 | 173 | } |
| 175 | - end | |
| 174 | + } | |
| 176 | 175 | |
| 177 | 176 | it 'returns the correct err if one already exists' do |
| 178 | - existing = Fabricate(:err, @conditions.merge(:problem => Fabricate(:problem, :app => @app))) | |
| 179 | - Err.where(@conditions).first.should == existing | |
| 180 | - @app.find_or_create_err!(@conditions).should == existing | |
| 177 | + existing = Fabricate(:err, conditions.merge(:problem => Fabricate(:problem, :app => app))) | |
| 178 | + Err.where(conditions).first.should == existing | |
| 179 | + app.find_or_create_err!(conditions).should == existing | |
| 181 | 180 | end |
| 182 | 181 | |
| 183 | 182 | it 'assigns the returned err to the given app' do |
| 184 | - @app.find_or_create_err!(@conditions).app.should == @app | |
| 183 | + app.find_or_create_err!(conditions).app.should == app | |
| 185 | 184 | end |
| 186 | 185 | |
| 187 | 186 | it 'creates a new problem if a matching one does not already exist' do |
| 188 | - Err.where(@conditions).first.should be_nil | |
| 187 | + Err.where(conditions).first.should be_nil | |
| 189 | 188 | lambda { |
| 190 | - @app.find_or_create_err!(@conditions) | |
| 189 | + app.find_or_create_err!(conditions) | |
| 191 | 190 | }.should change(Problem,:count).by(1) |
| 192 | 191 | end |
| 192 | + | |
| 193 | + context "without error_class" do | |
| 194 | + let(:conditions) { { | |
| 195 | + :environment => 'production', | |
| 196 | + :fingerprint => 'some-finger-print' | |
| 197 | + } | |
| 198 | + } | |
| 199 | + it 'save the err' do | |
| 200 | + Err.where(conditions).first.should be_nil | |
| 201 | + lambda { | |
| 202 | + app.find_or_create_err!(conditions) | |
| 203 | + }.should change(Problem,:count).by(1) | |
| 204 | + end | |
| 205 | + end | |
| 193 | 206 | end |
| 194 | 207 | |
| 195 | 208 | describe ".find_by_api_key!" do | ... | ... |
spec/models/problem_spec.rb
| ... | ... | @@ -3,12 +3,6 @@ require 'spec_helper' |
| 3 | 3 | describe Problem do |
| 4 | 4 | |
| 5 | 5 | context 'validations' do |
| 6 | - it 'requires a error_class' do | |
| 7 | - err = Fabricate.build(:problem, :error_class => nil) | |
| 8 | - err.should_not be_valid | |
| 9 | - err.errors[:error_class].should include("can't be blank") | |
| 10 | - end | |
| 11 | - | |
| 12 | 6 | it 'requires an environment' do |
| 13 | 7 | err = Fabricate.build(:problem, :environment => nil) |
| 14 | 8 | err.should_not be_valid |
| ... | ... | @@ -70,7 +64,6 @@ describe Problem do |
| 70 | 64 | end |
| 71 | 65 | end |
| 72 | 66 | |
| 73 | - | |
| 74 | 67 | context '#message' do |
| 75 | 68 | it "adding a notice caches its message" do |
| 76 | 69 | err = Fabricate(:err) |
| ... | ... | @@ -81,7 +74,6 @@ describe Problem do |
| 81 | 74 | end |
| 82 | 75 | end |
| 83 | 76 | |
| 84 | - | |
| 85 | 77 | context 'being created' do |
| 86 | 78 | context 'when the app has err notifications set to false' do |
| 87 | 79 | it 'should not send an email notification' do |
| ... | ... | @@ -92,7 +84,6 @@ describe Problem do |
| 92 | 84 | end |
| 93 | 85 | end |
| 94 | 86 | |
| 95 | - | |
| 96 | 87 | context "#resolved?" do |
| 97 | 88 | it "should start out as unresolved" do |
| 98 | 89 | problem = Problem.new |
| ... | ... | @@ -108,7 +99,6 @@ describe Problem do |
| 108 | 99 | end |
| 109 | 100 | end |
| 110 | 101 | |
| 111 | - | |
| 112 | 102 | context "resolve!" do |
| 113 | 103 | it "marks the problem as resolved" do |
| 114 | 104 | problem = Fabricate(:problem) |
| ... | ... | @@ -202,7 +192,6 @@ describe Problem do |
| 202 | 192 | end |
| 203 | 193 | end |
| 204 | 194 | |
| 205 | - | |
| 206 | 195 | context "notice counter cache" do |
| 207 | 196 | before do |
| 208 | 197 | @app = Fabricate(:app) |
| ... | ... | @@ -229,7 +218,6 @@ describe Problem do |
| 229 | 218 | end |
| 230 | 219 | end |
| 231 | 220 | |
| 232 | - | |
| 233 | 221 | context "#app_name" do |
| 234 | 222 | let!(:app) { Fabricate(:app) } |
| 235 | 223 | let!(:problem) { Fabricate(:problem, :app => app) } | ... | ... |