File tree 4 files changed +69
-0
lines changed
lib/generators/suspenders/production
test/generators/suspenders/production
4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Unreleased
18
18
* Introduce ` suspenders:prerequisites ` generator
19
19
* Introduce ` suspenders:ci ` generator
20
20
* Introduce ` suspenders:cleanup:organize_gemfile ` task
21
+ * Introduce ` suspenders:production:environment ` generator
21
22
22
23
20230113.0 (January, 13, 2023)
23
24
Original file line number Diff line number Diff line change @@ -197,6 +197,20 @@ Creates CI files for GitHub Actions.
197
197
bin/rails g suspenders:ci
198
198
```
199
199
200
+ ### Environments
201
+
202
+ #### Production
203
+
204
+ Configures the production environment.
205
+
206
+ - Enables [ require_master_key] [ ]
207
+
208
+ [ require_master_key ] : https://guides.rubyonrails.org/configuring.html#config-require-master-key
209
+
210
+ ```
211
+ bin/rails g suspenders:production:environment
212
+ ```
213
+
200
214
## Contributing
201
215
202
216
See the [ CONTRIBUTING] document.
Original file line number Diff line number Diff line change
1
+ module Suspenders
2
+ module Generators
3
+ module Production
4
+ class EnvironmentGenerator < Rails ::Generators ::Base
5
+ desc <<~MARKDOWN
6
+ Configures the production environment.
7
+
8
+ - Enables [require_master_key][]
9
+
10
+ [require_master_key]: https://guides.rubyonrails.org/configuring.html#config-require-master-key
11
+ MARKDOWN
12
+
13
+ def require_master_key
14
+ uncomment_lines "config/environments/production.rb" , /config\. require_master_key\s *=\s *true/
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
Original file line number Diff line number Diff line change
1
+ require "test_helper"
2
+ require "generators/suspenders/production/environment_generator"
3
+
4
+ module Suspenders
5
+ module Generators
6
+ module Production
7
+ class EnvironmentGeneratorTest < Rails ::Generators ::TestCase
8
+ include Suspenders ::TestHelpers
9
+
10
+ tests Suspenders ::Generators ::Production ::EnvironmentGenerator
11
+ destination Rails . root
12
+ setup :prepare_destination
13
+ teardown :restore_destination
14
+
15
+ test "requires master key" do
16
+ run_generator
17
+
18
+ assert_file app_root ( "config/environments/production.rb" ) do |file |
19
+ assert_match ( /^\s *config\. require_master_key\s *=\s *true/ , file )
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def prepare_destination
26
+ backup_file "config/environments/production.rb"
27
+ end
28
+
29
+ def restore_destination
30
+ restore_file "config/environments/production.rb"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
You can’t perform that action at this time.
0 commit comments