deploy_spec.rb
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'spec_helper'
describe Deploy do
context 'validations' do
it 'requires a username' do
deploy = Factory.build(:deploy, :username => nil)
deploy.should_not be_valid
deploy.errors[:username].should include("can't be blank")
end
it 'requires an environment' do
deploy = Factory.build(:deploy, :environment => nil)
deploy.should_not be_valid
deploy.errors[:environment].should include("can't be blank")
end
end
context 'being created' do
it 'should send an email notification' do
Mailer.should_receive(:deploy_notification).
and_return(mock('email', :deliver => true))
Factory(:deploy, :app => Factory(:app_with_watcher))
end
context 'when the app has resolve_errs_on_deploy set to false' do
it 'should not resolve the apps errs' do
app = Factory(:app, :resolve_errs_on_deploy => false)
@errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :app => app)}
Factory(:deploy, :app => app)
app.reload.errs.none?{|err| err.resolved?}.should == true
end
end
context 'when the app has resolve_errs_on_deploy set to true' do
it 'should resolve the apps errs that were in the same environment' do
app = Factory(:app, :resolve_errs_on_deploy => true)
@prod_errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :app => app, :environment => 'production')}
@staging_errs = 3.times.inject([]) {|errs,_| errs << Factory(:err, :resolved => false, :app => app, :environment => 'staging')}
Factory(:deploy, :app => app, :environment => 'production')
@prod_errs.all?{|err| err.reload.resolved?}.should == true
@staging_errs.all?{|err| err.reload.resolved?}.should == false
end
end
context 'when the app has deploy notifications set to false' do
it 'should not send an email notification' do
Mailer.should_not_receive(:deploy_notification)
Factory(:deploy, :app => Factory(:app_with_watcher, :notify_on_deploys => false))
end
end
end
it "should produce a shortened revision with 7 characters" do
Deploy.new(:revision => "1234567890abcdef").short_revision.should == "1234567"
end
end