Commit 6aec6f2e2186ab83af8ee832ea3d5c70f110a48b
1 parent
25a79373
Exists in
master
and in
1 other branch
Add a flag that will cause deploys to resolve all errs for the given project
Showing
5 changed files
with
33 additions
and
0 deletions
Show diff stats
app/models/deploy.rb
| ... | ... | @@ -10,6 +10,7 @@ class Deploy |
| 10 | 10 | embedded_in :project, :inverse_of => :deploys |
| 11 | 11 | |
| 12 | 12 | after_create :deliver_notification, :if => :should_notify? |
| 13 | + after_create :resolve_project_errs, :if => :should_resolve_project_errs? | |
| 13 | 14 | |
| 14 | 15 | validates_presence_of :username, :environment |
| 15 | 16 | |
| ... | ... | @@ -17,10 +18,18 @@ class Deploy |
| 17 | 18 | Mailer.deploy_notification(self).deliver |
| 18 | 19 | end |
| 19 | 20 | |
| 21 | + def resolve_project_errs | |
| 22 | + project.errs.unresolved.each {|err| err.resolve!} | |
| 23 | + end | |
| 24 | + | |
| 20 | 25 | protected |
| 21 | 26 | |
| 22 | 27 | def should_notify? |
| 23 | 28 | project.watchers.any? |
| 24 | 29 | end |
| 30 | + | |
| 31 | + def should_resolve_project_errs? | |
| 32 | + project.resolve_errs_on_deploy? | |
| 33 | + end | |
| 25 | 34 | |
| 26 | 35 | end | ... | ... |
app/models/project.rb
app/views/projects/_fields.html.haml
public/stylesheets/application.css
| ... | ... | @@ -122,6 +122,7 @@ form label { |
| 122 | 122 | display: block; |
| 123 | 123 | } |
| 124 | 124 | form label.inline { display: inline; } |
| 125 | +form .checkbox label { display: inline; } | |
| 125 | 126 | form .required label { color: #BF3838;} |
| 126 | 127 | form input[type=text], form input[type=password] { |
| 127 | 128 | width: 96%; padding: 0.8em; | ... | ... |
spec/models/deploy_spec.rb
| ... | ... | @@ -22,6 +22,24 @@ describe Deploy do |
| 22 | 22 | and_return(mock('email', :deliver => true)) |
| 23 | 23 | Factory(:deploy, :project => Factory(:project_with_watcher)) |
| 24 | 24 | end |
| 25 | + | |
| 26 | + context 'when the project has resolve_errs_on_deploy set to false' do | |
| 27 | + it 'should not resolve the projects errs' do | |
| 28 | + project = Factory(:project, :resolve_errs_on_deploy => false) | |
| 29 | + @errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :project => project)} | |
| 30 | + Factory(:deploy, :project => project) | |
| 31 | + project.reload.errs.none?{|err| err.resolved?}.should == true | |
| 32 | + end | |
| 33 | + end | |
| 34 | + | |
| 35 | + context 'when the project has resolve_errs_on_deploy set to true' do | |
| 36 | + it 'should not resolve the projects errs' do | |
| 37 | + project = Factory(:project, :resolve_errs_on_deploy => true) | |
| 38 | + @errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :project => project)} | |
| 39 | + Factory(:deploy, :project => project) | |
| 40 | + project.reload.errs.all?{|err| err.resolved?}.should == true | |
| 41 | + end | |
| 42 | + end | |
| 25 | 43 | end |
| 26 | 44 | |
| 27 | 45 | end | ... | ... |