Commit 0c5a386afd98b344e4ca15980307b1f170475160
1 parent
42789f67
Exists in
master
and in
1 other branch
Fixed issue with different deploy environment dates not being separated for different problems
Showing
3 changed files
with
7 additions
and
5 deletions
Show diff stats
app/models/app.rb
app/models/problem.rb
| ... | ... | @@ -109,7 +109,9 @@ class Problem |
| 109 | 109 | def cache_app_attributes |
| 110 | 110 | if app |
| 111 | 111 | self.app_name = app.name |
| 112 | - self.last_deploy_at = app.last_deploy_at | |
| 112 | + self.last_deploy_at = if (last_deploy = app.deploys.where(:environment => self.environment).last) | |
| 113 | + last_deploy.created_at | |
| 114 | + end | |
| 113 | 115 | self.save if persisted? |
| 114 | 116 | end |
| 115 | 117 | end | ... | ... |
spec/models/problem_spec.rb
| ... | ... | @@ -180,16 +180,16 @@ describe Problem do |
| 180 | 180 | before do |
| 181 | 181 | @app = Factory(:app) |
| 182 | 182 | @last_deploy = 10.days.ago.localtime.round(0) |
| 183 | - deploy = Factory(:deploy, :app => @app, :created_at => @last_deploy) | |
| 183 | + deploy = Factory(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") | |
| 184 | 184 | end |
| 185 | 185 | |
| 186 | 186 | it "is set when a problem is created" do |
| 187 | - problem = Factory(:problem, :app => @app) | |
| 187 | + problem = Factory(:problem, :app => @app, :environment => "production") | |
| 188 | 188 | assert_equal @last_deploy, problem.last_deploy_at |
| 189 | 189 | end |
| 190 | 190 | |
| 191 | 191 | it "is updated when a deploy is created" do |
| 192 | - problem = Factory(:problem, :app => @app) | |
| 192 | + problem = Factory(:problem, :app => @app, :environment => "production") | |
| 193 | 193 | next_deploy = 5.minutes.ago.localtime.round(0) |
| 194 | 194 | lambda { |
| 195 | 195 | @deploy = Factory(:deploy, :app => @app, :created_at => next_deploy) | ... | ... |