Commit 31e6766991bd05ff040b128830cb897e0869cf29

Authored by Jared Pace
1 parent 52b9cafb
Exists in master and in 1 other branch production

Only resolve errs on deploy which are in the same environment

app/models/deploy.rb
... ... @@ -19,7 +19,7 @@ class Deploy
19 19 end
20 20  
21 21 def resolve_app_errs
22   - app.errs.unresolved.each {|err| err.resolve!}
  22 + app.errs.unresolved.in_env(environment).each {|err| err.resolve!}
23 23 end
24 24  
25 25 protected
... ...
app/models/err.rb
... ... @@ -18,6 +18,7 @@ class Err
18 18 scope :resolved, where(:resolved => true)
19 19 scope :unresolved, where(:resolved => false)
20 20 scope :ordered, order_by(:last_notice_at.desc)
  21 + scope :in_env, lambda {|env| where(:environment => env)}
21 22  
22 23 def self.for(attrs)
23 24 app = attrs.delete(:app)
... ...
spec/models/deploy_spec.rb
... ... @@ -33,11 +33,13 @@ describe Deploy do
33 33 end
34 34  
35 35 context 'when the app has resolve_errs_on_deploy set to true' do
36   - it 'should not resolve the apps errs' do
  36 + it 'should resolve the apps errs that were in the same environment' do
37 37 app = Factory(:app, :resolve_errs_on_deploy => true)
38   - @errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :app => app)}
39   - Factory(:deploy, :app => app)
40   - app.reload.errs.all?{|err| err.resolved?}.should == true
  38 + @prod_errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :app => app, :environment => 'production')}
  39 + @staging_errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :app => app, :environment => 'staging')}
  40 + Factory(:deploy, :app => app, :environment => 'production')
  41 + @prod_errs.all?{|err| err.reload.resolved?}.should == true
  42 + @staging_errs.all?{|err| err.reload.resolved?}.should == false
41 43 end
42 44 end
43 45 end
... ...