deploys_controller_spec.rb
1.37 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
require 'spec_helper'
describe DeploysController do
context 'POST #create' do
before do
@params = {
'local_username' => 'john.doe',
'scm_repository' => 'git@github.com/jdpace/errbit.git',
'rails_env' => 'production',
'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5'
}
@app = Factory(:app_with_watcher, :api_key => 'APIKEY')
end
it 'finds the app via the api key' do
App.should_receive(:find_by_api_key!).with('APIKEY').and_return(@app)
post :create, :deploy => @params, :api_key => 'APIKEY'
end
it 'creates a deploy' do
App.stub(:find_by_api_key!).and_return(@app)
@app.deploys.should_receive(:create!).
with({
:username => 'john.doe',
:environment => 'production',
:repository => 'git@github.com/jdpace/errbit.git',
:revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5'
}).and_return(Factory(:deploy))
post :create, :deploy => @params, :api_key => 'APIKEY'
end
it 'sends an email notification', :focused => true do
post :create, :deploy => @params, :api_key => 'APIKEY'
email = ActionMailer::Base.deliveries.last
email.to.should include(@app.watchers.first.email)
email.subject.should == "[#{@app.name}] Deployed to production by john.doe"
end
end
end