heroku-rails-saas 0.1.7 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +0,0 @@
1
- module HashRecursiveMerge
2
- def rmerge!(other_hash)
3
- merge!(other_hash) do |key, old_value, new_value|
4
- old_value.class == self.class ? old_value.rmerge!(new_value) : new_value
5
- end
6
- end
7
- end
8
-
9
- class Hash
10
- include HashRecursiveMerge
11
- end
@@ -1,189 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module HerokuRailsSaas
4
- describe Config do
5
- before(:each) do
6
- config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("awesomeapp.yml"), config_path("mediocreapp.yml")]}
7
- @config = Config.new(config_files)
8
- end
9
-
10
- it "should read the configuration file" do
11
- @config.settings.should_not be_empty
12
- end
13
-
14
- describe "#apps" do
15
- it "should return the list of apps defined" do
16
- @config.apps.should have(2).apps
17
- @config.apps.should include("awesomeapp")
18
- @config.apps.should include("mediocreapp")
19
- end
20
- end
21
-
22
- describe "#app_names" do
23
- it "should return the list of apps defined" do
24
- @config.app_names.should have(2).names
25
- @config.apps.should include("awesomeapp")
26
- @config.apps.should include("mediocreapp")
27
- end
28
- end
29
-
30
- describe "#app_environments" do
31
- it "should return a list of the environments defined" do
32
- @config.app_environments.should have(3).environments
33
- @config.app_environments.should include("awesomeapp:production")
34
- @config.app_environments.should include("awesomeapp:staging")
35
- @config.app_environments.should include("awesomeapp:staging")
36
- end
37
- end
38
-
39
- describe "#stack" do
40
- it "should return the associated stack for awesomeapp:staging" do
41
- @config.stack("awesomeapp:staging").should == "bamboo-ree-1.8.7"
42
- end
43
-
44
- it "should return the default stack for awesomeapp:production" do
45
- @config.stack("awesomeapp:production").should == "bamboo-mri-1.9.2"
46
- end
47
-
48
- it "should default to the all setting if not explicitly defined" do
49
- @config.stack("mediocreapp").should == "bamboo-mri-1.9.2"
50
- end
51
- end
52
-
53
- describe "#config" do
54
- context "staging environment" do
55
- before(:each) do
56
- @config = @config.config("awesomeapp:staging")
57
- end
58
- it "should include configs defined in 'staging'" do
59
- @config["STAGING_CONFIG"].should == "special-staging"
60
- end
61
-
62
- it "should include configs defined in 'all'" do
63
- @config["BUNDLE_WITHOUT"].should == "test:development"
64
- end
65
-
66
- it "should use configs defined in 'staging' ahead of configs defined in 'all'" do
67
- @config["CONFIG_VAR1"].should == "config1-staging"
68
- end
69
- end
70
- end
71
-
72
- describe "#collaborators" do
73
- context "awesomeapp:staging" do
74
- before(:each) do
75
- @collaborators = @config.collaborators('awesomeapp:staging')
76
- end
77
-
78
- it "should include the collaborators defined in 'all'" do
79
- @collaborators.should include('all-user1@somedomain.com')
80
- @collaborators.should include('all-user2@somedomain.com')
81
- @collaborators.should have(3).collaborators
82
- end
83
-
84
- it "should include collaborators defined in 'staging'" do
85
- @collaborators.should include('staging-user@somedomain.com')
86
- end
87
-
88
- it "should not include collaborators defined in 'production'" do
89
- @collaborators.should_not include('production-user@somedomain.com')
90
- end
91
- end
92
-
93
- context "mediocreapp:development" do
94
- before(:each) do
95
- @collaborators = @config.collaborators('mediocreapp:development')
96
- end
97
-
98
- it "should include the collaborators defined in 'all'" do
99
- @collaborators.should include('all-user1@somedomain.com')
100
- @collaborators.should include('all-user2@somedomain.com')
101
- @collaborators.should have(3).collaborators
102
- end
103
-
104
- it "should include collaborators defined in 'development'" do
105
- @collaborators.should include('mediocre-user@example.com')
106
- end
107
-
108
- it "should not include collaborators defined other apps" do
109
- @collaborators.should_not include("staging-user@somedomain.com")
110
- end
111
- end
112
- end
113
-
114
- describe "#domains" do
115
- context "staging environment" do
116
- before(:each) do
117
- @domains = @config.domains('awesomeapp:staging')
118
- end
119
-
120
- it "should include the domains defined in 'staging'" do
121
- @domains.should include('staging.awesomeapp.com')
122
- end
123
-
124
- it "should not include the domains defined in 'production'" do
125
- @domains.should_not include('awesomeapp.com')
126
- @domains.should_not include('www.awesomeapp.com')
127
- end
128
- end
129
-
130
- context "production environment" do
131
- it "should include the domains defined in 'production'" do
132
- @domains = @config.domains('awesomeapp:production')
133
- @domains.should include('awesomeapp.com')
134
- @domains.should include('www.awesomeapp.com')
135
- end
136
- end
137
- end
138
-
139
- describe "#addons" do
140
- context "staging environment" do
141
- before(:each) do
142
- @addons = @config.addons('awesomeapp:staging')
143
- end
144
-
145
- it "should include addons defined in 'all'" do
146
- @addons.should include('scheduler:standard')
147
- @addons.should include('newrelic:bronze')
148
- end
149
-
150
- it "should not include addons defined in 'production'" do
151
- @addons.should_not include('ssl:piggyback')
152
- end
153
- end
154
- end
155
-
156
- describe "#scale" do
157
- context "mediocrapp" do
158
- it "should include the scaling settings defined in 'all'" do
159
- @scale = @config.scale('mediocreapp:development')
160
- @scale['web'].should_not be_nil
161
- @scale['worker'].should_not be_nil
162
- @scale['web'].should eql 1
163
- @scale['worker'].should eql 0
164
- end
165
- end
166
-
167
- context "staging environment" do
168
- it "should include the scaling settings defined in 'staging'" do
169
- @scale = @config.scale('awesomeapp:staging')
170
- @scale['web'].should_not be_nil
171
- @scale['worker'].should_not be_nil
172
- @scale['web'].should eql 2
173
- @scale['worker'].should eql 1
174
- end
175
- end
176
-
177
- context "production environment" do
178
- it "should include the scaling settings defined in 'production'" do
179
- @scale = @config.scale('awesomeapp:production')
180
- @scale['web'].should_not be_nil
181
- @scale['worker'].should_not be_nil
182
- @scale['web'].should eql 3
183
- @scale['worker'].should eql 2
184
- end
185
- end
186
- end
187
-
188
- end
189
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module HerokuRailsSaas
4
- describe Runner do
5
- describe "#each_heroku_app" do
6
- it "should return all apps in all environments" do
7
- config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("awesomeapp.yml"), config_path("mediocreapp.yml")]}
8
- config = Config.new(config_files)
9
- runner = Runner.new(config)
10
- runner.all_environments
11
- runner.each_heroku_app {}.should == ["awesomeapp:production", "awesomeapp:staging", "mediocreapp:development"]
12
- end
13
-
14
- it "should not return a production app if @environment is not specified and there's only one app" do
15
- config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("mediocreapp.yml")]}
16
- config = Config.new(config_files)
17
- runner = Runner.new(config)
18
- runner.instance_variable_set("@environments", [])
19
- lambda { runner.each_heroku_app }.should raise_error(SystemExit)
20
- end
21
- end
22
- end
23
- end