heroku-rails-saas 0.1.7 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.bundle/config +2 -0
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/.rvmrc +21 -0
- data/CHANGELOG +27 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +94 -42
- data/README.md +49 -17
- data/data/cacert.pem +3988 -0
- data/heroku-rails-saas.gemspec +25 -0
- data/lib/generators/templates/heroku.rake +13 -12
- data/lib/heroku-rails-saas.rb +1 -4
- data/lib/heroku-rails-saas/config.rb +28 -25
- data/lib/heroku-rails-saas/displayer.rb +26 -0
- data/lib/heroku-rails-saas/helper.rb +67 -0
- data/lib/heroku-rails-saas/heroku_client.rb +54 -0
- data/lib/heroku-rails-saas/railtie.rb +8 -2
- data/lib/heroku-rails-saas/runner.rb +471 -204
- data/lib/heroku-rails-saas/version.rb +3 -0
- data/lib/heroku/rails/tasks.rb +112 -193
- data/spec/fixtures/awesomeapp.yml +7 -0
- data/spec/fixtures/example.netrc +3 -0
- data/spec/fixtures/heroku-config.yml +1 -0
- data/spec/heroku-rails-saas/config_spec.rb +214 -0
- data/spec/heroku-rails-saas/displayer_spec.rb +35 -0
- data/spec/heroku-rails-saas/helper_spec.rb +19 -0
- data/spec/heroku-rails-saas/heorku_client_spec.rb +58 -0
- data/spec/heroku-rails-saas/runner_spec.rb +64 -0
- data/spec/spec_helper.rb +4 -1
- metadata +125 -35
- data/heroku-rails.gemspec +0 -39
- data/lib/heroku-rails-saas/hash_recursive_merge.rb +0 -11
- data/spec/heroku/rails/saas/heroku_config_spec.rb +0 -189
- data/spec/heroku/rails/saas/heroku_runner_spec.rb +0 -23
data/lib/heroku/rails/tasks.rb
CHANGED
@@ -1,22 +1,27 @@
|
|
1
1
|
require 'heroku-rails-saas'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# Get callback-like rake task to step into the deploy process.
|
4
|
+
import File.join(File.dirname(__FILE__), '../../generators/templates/heroku.rake')
|
5
|
+
|
6
|
+
# Suppress warnings from ruby when trying to redefine a constant, typically due to reloding of Rails.
|
7
|
+
silence_warnings do
|
8
|
+
HEROKU_CONFIG_FILE = File.join(HerokuRailsSaas::Config.root, 'config', 'heroku.yml')
|
9
|
+
HEROKU_APP_SPECIFIC_CONFIG_FILES = Dir.glob("#{File.join(HerokuRailsSaas::Config.root, 'config', 'heroku')}/*.yml")
|
10
|
+
HEROKU_CONFIG = HerokuRailsSaas::Config.new({:default => HEROKU_CONFIG_FILE, :apps => HEROKU_APP_SPECIFIC_CONFIG_FILES})
|
11
|
+
HEROKU_RUNNER = HerokuRailsSaas::Runner.new(HEROKU_CONFIG)
|
12
|
+
DISPLAYER = HerokuRailsSaas::Displayer
|
13
|
+
end
|
7
14
|
|
8
15
|
# create all the environment specific tasks
|
9
16
|
(HEROKU_CONFIG.apps).each do |app, hsh|
|
10
17
|
hsh.each do |env, heroku_env|
|
11
|
-
|
12
|
-
desc "Select #{
|
13
|
-
task
|
14
|
-
# callback switch_environment
|
15
|
-
@heroku_app = {:env => heroku_env, :app_name => app_name}
|
18
|
+
local_name = HerokuRailsSaas::Config.local_name(app, env)
|
19
|
+
desc "Select #{local_name} Heroku app for later commands"
|
20
|
+
task local_name do
|
16
21
|
Rake::Task["heroku:switch_environment"].reenable
|
17
22
|
Rake::Task["heroku:switch_environment"].invoke
|
18
23
|
|
19
|
-
HEROKU_RUNNER.
|
24
|
+
HEROKU_RUNNER.add_app(local_name)
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
@@ -26,168 +31,94 @@ task :all do
|
|
26
31
|
HEROKU_RUNNER.all_environments(true)
|
27
32
|
end
|
28
33
|
|
29
|
-
(HEROKU_CONFIG.all_environments).each do |
|
30
|
-
desc "Select all Heroku apps in #{
|
31
|
-
task "all:#{
|
32
|
-
HEROKU_RUNNER.
|
34
|
+
(HEROKU_CONFIG.all_environments).each do |environment|
|
35
|
+
desc "Select all Heroku apps in #{environment} environment"
|
36
|
+
task "all:#{environment}" do
|
37
|
+
HEROKU_RUNNER.add_environment(environment)
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
36
41
|
namespace :heroku do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
|
45
|
-
system_with_echo("git remote add #{app_name} #{repo}")
|
46
|
-
end
|
47
|
-
end
|
42
|
+
# desc 'Add git remotes for all apps in this project'
|
43
|
+
# task :remotes do
|
44
|
+
# HEROKU_RUNNER.all_environments
|
45
|
+
# HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
|
46
|
+
# system("git remote add #{app_name} #{repo}")
|
47
|
+
# end
|
48
|
+
# end
|
48
49
|
|
49
50
|
desc 'Lists configured apps'
|
50
51
|
task :apps do
|
51
52
|
HEROKU_RUNNER.all_environments
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
HEROKU_RUNNER.apps
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Run command on the heroku app (e.g. rake task)"
|
57
|
+
task :exec, :command do |t, args|
|
58
|
+
HEROKU_RUNNER.exec_on_all(args[:command])
|
58
59
|
end
|
59
60
|
|
60
61
|
desc "Get remote server information on the heroku app"
|
61
62
|
task :info do
|
62
|
-
HEROKU_RUNNER.
|
63
|
-
system_with_echo "heroku info --app #{app_name}"
|
64
|
-
puts "\n"
|
65
|
-
end
|
63
|
+
HEROKU_RUNNER.info
|
66
64
|
end
|
67
65
|
|
68
66
|
desc "Deploys, migrates and restarts latest git tag"
|
69
67
|
task :deploy => "heroku:before_deploy" do |t, args|
|
70
|
-
HEROKU_RUNNER.
|
71
|
-
puts "\n\nDeploying to #{app_name}..."
|
72
|
-
# set the current heroku_app so that callbacks can read the data
|
73
|
-
@heroku_app = {:env => heroku_env, :app_name => app_name, :repo => repo}
|
74
|
-
Rake::Task["heroku:before_each_deploy"].reenable
|
75
|
-
Rake::Task["heroku:before_each_deploy"].invoke(app_name)
|
76
|
-
|
77
|
-
cmd = HEROKU_CONFIG.cmd(heroku_env)
|
78
|
-
|
79
|
-
if heroku_env[HEROKU_RUNNER.regex_for(:production)]
|
80
|
-
all_tags = `git tag`
|
81
|
-
target_tag = `git describe --tags --abbrev=0`.chomp # Set latest tag as default
|
82
|
-
|
83
|
-
begin
|
84
|
-
puts "\nGit tags:"
|
85
|
-
puts all_tags
|
86
|
-
print "\nPlease enter a tag to deploy (or hit Enter for \"#{target_tag}\"): "
|
87
|
-
input_tag = STDIN.gets.chomp
|
88
|
-
if input_tag.present?
|
89
|
-
if all_tags[/^#{input_tag}\n/].present?
|
90
|
-
target_tag = input_tag
|
91
|
-
invalid = false
|
92
|
-
else
|
93
|
-
puts "\n\nInvalid git tag!"
|
94
|
-
invalid = true
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end while invalid
|
98
|
-
puts "Unable to determine the tag to deploy." and exit(1) if target_tag.empty?
|
99
|
-
to_deploy = "#{target_tag}^{}"
|
100
|
-
else
|
101
|
-
to_deploy = `git branch`.scan(/^\* (.*)\n/).flatten.first.to_s
|
102
|
-
puts "Unable to determine the current git branch, please checkout the branch you'd like to deploy." and exit(1) if to_deploy.empty?
|
103
|
-
end
|
104
|
-
|
105
|
-
@git_push_arguments ||= ['--force']
|
106
|
-
|
107
|
-
system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{to_deploy}:master"
|
108
|
-
|
109
|
-
system_with_echo "heroku maintenance:on --app #{app_name}"
|
110
|
-
|
111
|
-
Rake::Task["heroku:setup:config"].invoke
|
112
|
-
system_with_echo "#{cmd} rake --app #{app_name} db:migrate"
|
113
|
-
|
114
|
-
system_with_echo "#{cmd} \"#{HEROKU_CONFIG.rails_cli(:runner)} 'Rails.cache.clear'\" --app #{app_name}"
|
115
|
-
|
116
|
-
system_with_echo "heroku restart --app #{app_name}"
|
117
|
-
|
118
|
-
system_with_echo "heroku maintenance:off --app #{app_name}"
|
119
|
-
|
120
|
-
Rake::Task["heroku:after_each_deploy"].reenable
|
121
|
-
Rake::Task["heroku:after_each_deploy"].invoke(app_name)
|
122
|
-
puts "\n"
|
123
|
-
end
|
124
|
-
Rake::Task["heroku:after_deploy"].invoke
|
68
|
+
HEROKU_RUNNER.deploy
|
125
69
|
end
|
126
70
|
|
127
|
-
|
128
|
-
task :
|
129
|
-
|
130
|
-
|
131
|
-
# Callback after all deploys
|
132
|
-
task :after_deploy do
|
133
|
-
end
|
134
|
-
|
135
|
-
# Callback before each deploy
|
136
|
-
task :before_each_deploy, [:app_name] do |t,args|
|
137
|
-
end
|
138
|
-
|
139
|
-
# Callback after each deploy
|
140
|
-
task :after_each_deploy, [:app_name] do |t,args|
|
71
|
+
desc "Restarts remote servers"
|
72
|
+
task :restart do
|
73
|
+
HEROKU_RUNNER.restart
|
141
74
|
end
|
142
75
|
|
143
|
-
|
144
|
-
task :
|
76
|
+
desc "Scales heroku processes"
|
77
|
+
task :scale do
|
78
|
+
HEROKU_RUNNER.scale
|
145
79
|
end
|
146
80
|
|
147
|
-
desc "
|
148
|
-
task :
|
149
|
-
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
desc "Opens a remote console"
|
155
|
-
task :console do
|
156
|
-
HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
|
157
|
-
cmd = HEROKU_CONFIG.cmd(heroku_env)
|
158
|
-
system_with_echo "#{cmd} console --app #{app_name}"
|
159
|
-
end
|
160
|
-
end
|
81
|
+
# desc "Opens a remote console"
|
82
|
+
# task :console do
|
83
|
+
# HEROKU_RUNNER.console
|
84
|
+
# end
|
161
85
|
|
162
86
|
desc "Shows the Heroku logs"
|
163
87
|
task :logs do
|
164
|
-
HEROKU_RUNNER.
|
165
|
-
system_with_echo "heroku logs --app #{app_name}"
|
166
|
-
end
|
88
|
+
HEROKU_RUNNER.logs
|
167
89
|
end
|
168
90
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
91
|
+
namespace :maintenance do
|
92
|
+
desc "Turn maintenance mode on"
|
93
|
+
task :on do
|
94
|
+
HEROKU_RUNNER.maintenance(true)
|
173
95
|
end
|
174
|
-
end
|
175
96
|
|
176
|
-
|
177
|
-
|
178
|
-
|
97
|
+
desc "Turn maintenance mode off"
|
98
|
+
task :off do
|
99
|
+
HEROKU_RUNNER.maintenance(false)
|
100
|
+
end
|
179
101
|
end
|
180
102
|
|
181
|
-
|
103
|
+
desc "Setup Heroku deploy environment from heroku.yml config"
|
104
|
+
task :setup => [
|
105
|
+
"heroku:setup:app",
|
106
|
+
"heroku:setup:stack",
|
107
|
+
"heroku:setup:collaborators",
|
108
|
+
"heroku:setup:config",
|
109
|
+
"heroku:setup:addons",
|
110
|
+
"heroku:setup:domains",
|
111
|
+
]
|
182
112
|
|
183
|
-
|
184
|
-
|
185
|
-
|
113
|
+
namespace :setup do
|
114
|
+
desc "Creates the app on Heroku with the default stack"
|
115
|
+
task :app do
|
116
|
+
HEROKU_RUNNER.setup_app
|
186
117
|
end
|
187
118
|
|
188
119
|
desc "Setup the Heroku stacks from heroku.yml config"
|
189
|
-
task :
|
190
|
-
HEROKU_RUNNER.
|
120
|
+
task :stack do
|
121
|
+
HEROKU_RUNNER.setup_stack
|
191
122
|
end
|
192
123
|
|
193
124
|
desc "Setup the Heroku collaborators from heroku.yml config"
|
@@ -211,66 +142,54 @@ namespace :heroku do
|
|
211
142
|
end
|
212
143
|
end
|
213
144
|
|
214
|
-
desc "Setup Heroku deploy environment from heroku.yml config"
|
215
|
-
task :setup => [
|
216
|
-
"heroku:setup:apps",
|
217
|
-
"heroku:setup:stacks",
|
218
|
-
"heroku:setup:collaborators",
|
219
|
-
"heroku:setup:config",
|
220
|
-
"heroku:setup:addons",
|
221
|
-
"heroku:setup:domains",
|
222
|
-
]
|
223
|
-
|
224
145
|
namespace :db do
|
225
146
|
desc "Migrates and restarts remote servers"
|
226
147
|
task :migrate do
|
227
|
-
HEROKU_RUNNER.
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
desc "Pulls the database from heroku and stores it into db/dumps/"
|
234
|
-
task :pull do
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
148
|
+
HEROKU_RUNNER.exec_on_all("rake db:migrate")
|
149
|
+
HEROKU_RUNNER.restart
|
150
|
+
end
|
151
|
+
|
152
|
+
# NOTE: The following commands require the use of the heroku gem and not the heorku-api.
|
153
|
+
# Need to address these commands later.
|
154
|
+
# desc "Pulls the database from heroku and stores it into db/dumps/"
|
155
|
+
# task :pull do
|
156
|
+
# HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
|
157
|
+
# system_with_echo "heroku pgbackups:capture --app #{app_name}"
|
158
|
+
# dump = `heroku pgbackups --app #{app_name}`.split("\n").last.split(" ").first
|
159
|
+
# system_with_echo "mkdir -p #{HerokuRailsSaas::Config.root}/db/dumps"
|
160
|
+
# file = "#{HerokuRailsSaas::Config.root}/db/dumps/#{app_name}-#{dump}.sql.gz"
|
161
|
+
# url = `heroku pgbackups:url --app #{app_name} #{dump}`.chomp
|
162
|
+
# system_with_echo "wget", url, "-O", file
|
163
|
+
|
164
|
+
# # TODO: these are a bit distructive...
|
165
|
+
# # system_with_echo "rake db:drop db:create"
|
166
|
+
# # system_with_echo "gunzip -c #{file} | #{HerokuRailsSaas::Config.root}/script/dbconsole"
|
167
|
+
# # system_with_echo "rake jobs:clear"
|
168
|
+
# end
|
169
|
+
# end
|
249
170
|
|
250
|
-
desc "Resets a Non Production database"
|
251
|
-
task :reset do
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
end
|
171
|
+
# desc "Resets a Non Production database"
|
172
|
+
# task :reset do
|
173
|
+
# HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
|
174
|
+
# unless heroku_env[HEROKU_RUNNER.regex_for(:production)]
|
175
|
+
# system_with_echo "heroku pg:reset DATABASE_URL --app #{app_name} --confirm #{app_name}"
|
176
|
+
# else
|
177
|
+
# puts "Will not reset the Production database"
|
178
|
+
# end
|
179
|
+
# end
|
180
|
+
# end
|
260
181
|
|
261
|
-
desc "Copies a database over a Non Production database"
|
262
|
-
task :copy,[
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
end
|
274
|
-
|
182
|
+
# desc "Copies a database over a Non Production database"
|
183
|
+
# task :copy, [:source] => :reset do |t, args|
|
184
|
+
# HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
|
185
|
+
# raise "missing source" unless HEROKU_CONFIG.app_name_on_heroku(args.source)
|
186
|
+
# unless heroku_env[HEROKU_RUNNER.regex_for(:production)]
|
187
|
+
# source_app_name = HEROKU_CONFIG.app_name_on_heroku(args.source)
|
188
|
+
# system_with_echo "heroku pgbackups:restore DATABASE_URL `heroku pgbackups:url --app #{source_app_name}` --app #{app_name} --confirm #{app_name}"
|
189
|
+
# else
|
190
|
+
# puts "Will not overwrite the Production database"
|
191
|
+
# end
|
192
|
+
# end
|
193
|
+
# end
|
275
194
|
end
|
276
195
|
end
|
@@ -25,11 +25,18 @@ domains:
|
|
25
25
|
- "awesomeapp.com"
|
26
26
|
- "www.awesomeapp.com"
|
27
27
|
|
28
|
+
region:
|
29
|
+
staging: "UK"
|
30
|
+
production: "EU"
|
31
|
+
|
28
32
|
addons:
|
29
33
|
production:
|
30
34
|
# list production env specific addons here
|
31
35
|
- ssl:piggyback
|
32
36
|
- cron:daily
|
37
|
+
staging:
|
38
|
+
- cron:daily
|
39
|
+
- multi_tier:paid
|
33
40
|
|
34
41
|
scale:
|
35
42
|
production:
|
@@ -0,0 +1,214 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HerokuRailsSaas::Config do
|
4
|
+
before(:each) do
|
5
|
+
config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("awesomeapp.yml"), config_path("mediocreapp.yml")]}
|
6
|
+
@config = described_class.new(config_files)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should read the configuration file" do
|
10
|
+
@config.settings.should_not be_empty
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#apps" do
|
14
|
+
it "should return the list of apps defined" do
|
15
|
+
@config.apps.should have(2).apps
|
16
|
+
@config.apps.should include("awesomeapp")
|
17
|
+
@config.apps.should include("mediocreapp")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#app_names" do
|
22
|
+
it "should return the list of apps defined" do
|
23
|
+
@config.app_names.should have(2).names
|
24
|
+
@config.apps.should include("awesomeapp")
|
25
|
+
@config.apps.should include("mediocreapp")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#app_environments" do
|
30
|
+
it "should return a list of the environments defined" do
|
31
|
+
@config.app_environments.should have(3).environments
|
32
|
+
@config.app_environments.should include("awesomeapp:production")
|
33
|
+
@config.app_environments.should include("awesomeapp:staging")
|
34
|
+
@config.app_environments.should include("awesomeapp:staging")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#stack" do
|
39
|
+
it "should return the associated stack for awesomeapp:staging" do
|
40
|
+
@config.stack("awesomeapp:staging").should == "bamboo-ree-1.8.7"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return the default stack for awesomeapp:production" do
|
44
|
+
@config.stack("awesomeapp:production").should == "bamboo-mri-1.9.2"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should default to the all setting if not explicitly defined" do
|
48
|
+
@config.stack("mediocreapp").should == "bamboo-mri-1.9.2"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#config" do
|
53
|
+
context "staging environment" do
|
54
|
+
before(:each) do
|
55
|
+
@config = @config.config("awesomeapp:staging")
|
56
|
+
end
|
57
|
+
it "should include configs defined in 'staging'" do
|
58
|
+
@config["STAGING_CONFIG"].should == "special-staging"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should include configs defined in 'all'" do
|
62
|
+
@config["BUNDLE_WITHOUT"].should == "test:development"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should use configs defined in 'staging' ahead of configs defined in 'all'" do
|
66
|
+
@config["CONFIG_VAR1"].should == "config1-staging"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#collaborators" do
|
72
|
+
context "awesomeapp:staging" do
|
73
|
+
before(:each) do
|
74
|
+
@collaborators = @config.collaborators('awesomeapp:staging')
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should include the collaborators defined in 'all'" do
|
78
|
+
@collaborators.should include('all-user1@somedomain.com')
|
79
|
+
@collaborators.should include('all-user2@somedomain.com')
|
80
|
+
@collaborators.should have(3).collaborators
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should include collaborators defined in 'staging'" do
|
84
|
+
@collaborators.should include('staging-user@somedomain.com')
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should not include collaborators defined in 'production'" do
|
88
|
+
@collaborators.should_not include('production-user@somedomain.com')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "mediocreapp:development" do
|
93
|
+
before(:each) do
|
94
|
+
@collaborators = @config.collaborators('mediocreapp:development')
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should include the collaborators defined in 'all'" do
|
98
|
+
@collaborators.should include('all-user1@somedomain.com')
|
99
|
+
@collaborators.should include('all-user2@somedomain.com')
|
100
|
+
@collaborators.should have(3).collaborators
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should include collaborators defined in 'development'" do
|
104
|
+
@collaborators.should include('mediocre-user@example.com')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should not include collaborators defined other apps" do
|
108
|
+
@collaborators.should_not include("staging-user@somedomain.com")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#domains" do
|
114
|
+
context "staging environment" do
|
115
|
+
before(:each) do
|
116
|
+
@domains = @config.domains('awesomeapp:staging')
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should include the domains defined in 'staging'" do
|
120
|
+
@domains.should include('staging.awesomeapp.com')
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should not include the domains defined in 'production'" do
|
124
|
+
@domains.should_not include('awesomeapp.com')
|
125
|
+
@domains.should_not include('www.awesomeapp.com')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "production environment" do
|
130
|
+
it "should include the domains defined in 'production'" do
|
131
|
+
@domains = @config.domains('awesomeapp:production')
|
132
|
+
@domains.should include('awesomeapp.com')
|
133
|
+
@domains.should include('www.awesomeapp.com')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "#addons" do
|
139
|
+
context "staging environment" do
|
140
|
+
before(:each) do
|
141
|
+
@addons = @config.addons('awesomeapp:staging')
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should include addons defined in 'all'" do
|
145
|
+
@addons.should include('scheduler:standard')
|
146
|
+
@addons.should include('newrelic:bronze')
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should not include addons defined in 'production'" do
|
150
|
+
@addons.should_not include('ssl:piggyback')
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should override addons with a different tier with the one defined in 'staging'" do
|
154
|
+
@addons.should include('multi_tier:paid')
|
155
|
+
@addons.should_not include('multi_tier:free')
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "#scale" do
|
161
|
+
context "mediocreapp" do
|
162
|
+
it "should include the scaling settings defined in 'all'" do
|
163
|
+
@scale = @config.scale('mediocreapp:development')
|
164
|
+
@scale['web'].should_not be_nil
|
165
|
+
@scale['worker'].should_not be_nil
|
166
|
+
@scale['web'].should eql 1
|
167
|
+
@scale['worker'].should eql 0
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context "staging environment" do
|
172
|
+
it "should include the scaling settings defined in 'staging'" do
|
173
|
+
@scale = @config.scale('awesomeapp:staging')
|
174
|
+
@scale['web'].should_not be_nil
|
175
|
+
@scale['worker'].should_not be_nil
|
176
|
+
@scale['web'].should eql 2
|
177
|
+
@scale['worker'].should eql 1
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context "production environment" do
|
182
|
+
it "should include the scaling settings defined in 'production'" do
|
183
|
+
@scale = @config.scale('awesomeapp:production')
|
184
|
+
@scale['web'].should_not be_nil
|
185
|
+
@scale['worker'].should_not be_nil
|
186
|
+
@scale['web'].should eql 3
|
187
|
+
@scale['worker'].should eql 2
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "#region" do
|
193
|
+
context "staging environment" do
|
194
|
+
before(:each) do
|
195
|
+
@region = @config.region('awesomeapp:staging')
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should include the region defined in 'staging'" do
|
199
|
+
@region.should include('UK')
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should not include the region defined in 'production'" do
|
203
|
+
@region.should_not include('EU')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context "production environment" do
|
208
|
+
it "should include the region defined in 'production'" do
|
209
|
+
@region = @config.region('awesomeapp:production')
|
210
|
+
@region.should include('EU')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|