Commit e175e183bac04daf67ca476ae4ae7ba60a898b49
1 parent
79514294
Exists in
master
and in
1 other branch
Fix spec/model/deploy with fabrication gem
Showing
1 changed file
with
11 additions
and
11 deletions
Show diff stats
spec/models/deploy_spec.rb
@@ -4,13 +4,13 @@ describe Deploy do | @@ -4,13 +4,13 @@ describe Deploy do | ||
4 | 4 | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires a username' do | 6 | it 'requires a username' do |
7 | - deploy = Factory.build(:deploy, :username => nil) | 7 | + deploy = Fabricate.build(:deploy, :username => nil) |
8 | deploy.should_not be_valid | 8 | deploy.should_not be_valid |
9 | deploy.errors[:username].should include("can't be blank") | 9 | deploy.errors[:username].should include("can't be blank") |
10 | end | 10 | end |
11 | 11 | ||
12 | it 'requires an environment' do | 12 | it 'requires an environment' do |
13 | - deploy = Factory.build(:deploy, :environment => nil) | 13 | + deploy = Fabricate.build(:deploy, :environment => nil) |
14 | deploy.should_not be_valid | 14 | deploy.should_not be_valid |
15 | deploy.errors[:environment].should include("can't be blank") | 15 | deploy.errors[:environment].should include("can't be blank") |
16 | end | 16 | end |
@@ -20,24 +20,24 @@ describe Deploy do | @@ -20,24 +20,24 @@ describe Deploy do | ||
20 | it 'should send an email notification' do | 20 | it 'should send an email notification' do |
21 | Mailer.should_receive(:deploy_notification). | 21 | Mailer.should_receive(:deploy_notification). |
22 | and_return(mock('email', :deliver => true)) | 22 | and_return(mock('email', :deliver => true)) |
23 | - Factory(:deploy, :app => Factory(:app_with_watcher, :notify_on_deploys => true)) | 23 | + Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) |
24 | end | 24 | end |
25 | 25 | ||
26 | context 'when the app has resolve_errs_on_deploy set to false' do | 26 | context 'when the app has resolve_errs_on_deploy set to false' do |
27 | it 'should not resolve the apps errs' do | 27 | it 'should not resolve the apps errs' do |
28 | - app = Factory(:app, :resolve_errs_on_deploy => false) | ||
29 | - @problems = 3.times.map{Factory(:err, :problem => Factory(:problem, :resolved => false, :app => app))} | ||
30 | - Factory(:deploy, :app => app) | 28 | + app = Fabricate(:app, :resolve_errs_on_deploy => false) |
29 | + @problems = 3.times.map{Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app))} | ||
30 | + Fabricate(:deploy, :app => app) | ||
31 | app.reload.problems.none?{|problem| problem.resolved?}.should == true | 31 | app.reload.problems.none?{|problem| problem.resolved?}.should == true |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | context 'when the app has resolve_errs_on_deploy set to true' do | 35 | context 'when the app has resolve_errs_on_deploy set to true' do |
36 | it 'should resolve the apps errs that were in the same environment' do | 36 | it 'should resolve the apps errs that were in the same environment' do |
37 | - app = Factory(:app, :resolve_errs_on_deploy => true) | ||
38 | - @prod_errs = 3.times.map{Factory(:problem, :resolved => false, :app => app, :environment => 'production')} | ||
39 | - @staging_errs = 3.times.map{Factory(:problem, :resolved => false, :app => app, :environment => 'staging')} | ||
40 | - Factory(:deploy, :app => app, :environment => 'production') | 37 | + app = Fabricate(:app, :resolve_errs_on_deploy => true) |
38 | + @prod_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'production')} | ||
39 | + @staging_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging')} | ||
40 | + Fabricate(:deploy, :app => app, :environment => 'production') | ||
41 | @prod_errs.all?{|problem| problem.reload.resolved?}.should == true | 41 | @prod_errs.all?{|problem| problem.reload.resolved?}.should == true |
42 | @staging_errs.all?{|problem| problem.reload.resolved?}.should == false | 42 | @staging_errs.all?{|problem| problem.reload.resolved?}.should == false |
43 | end | 43 | end |
@@ -46,7 +46,7 @@ describe Deploy do | @@ -46,7 +46,7 @@ describe Deploy do | ||
46 | context 'when the app has deploy notifications set to false' do | 46 | context 'when the app has deploy notifications set to false' do |
47 | it 'should not send an email notification' do | 47 | it 'should not send an email notification' do |
48 | Mailer.should_not_receive(:deploy_notification) | 48 | Mailer.should_not_receive(:deploy_notification) |
49 | - Factory(:deploy, :app => Factory(:app_with_watcher, :notify_on_deploys => false)) | 49 | + Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false)) |
50 | end | 50 | end |
51 | end | 51 | end |
52 | end | 52 | end |