potassium 6.1.0 → 6.5.0

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +103 -38
  3. data/.circleci/setup-rubygems.sh +3 -0
  4. data/.gitignore +2 -1
  5. data/.node-version +1 -1
  6. data/.rubocop.yml +530 -0
  7. data/CHANGELOG.md +50 -1
  8. data/README.md +11 -3
  9. data/lib/potassium/assets/.circleci/config.yml.erb +107 -40
  10. data/lib/potassium/assets/.pryrc +0 -6
  11. data/lib/potassium/assets/.rubocop.yml +13 -0
  12. data/lib/potassium/assets/README.yml +45 -8
  13. data/lib/potassium/assets/active_admin/policies/admin_user_policy.rb +2 -0
  14. data/lib/potassium/assets/active_admin/policies/comment_policy.rb +2 -0
  15. data/lib/potassium/assets/active_admin/policies/default_policy.rb +49 -0
  16. data/lib/potassium/assets/active_admin/policies/page_policy.rb +2 -0
  17. data/lib/potassium/assets/app/javascript/app.spec.js +1 -1
  18. data/lib/potassium/assets/app/views/shared/_gtm_body.html.erb +4 -0
  19. data/lib/potassium/assets/app/views/shared/_gtm_head.html.erb +7 -0
  20. data/lib/potassium/assets/testing/.rspec +1 -0
  21. data/lib/potassium/assets/testing/devise_config.rb +6 -0
  22. data/lib/potassium/assets/testing/factory_bot_config.rb +3 -0
  23. data/lib/potassium/assets/testing/faker_config.rb +1 -0
  24. data/lib/potassium/assets/testing/power_types_config.rb +1 -0
  25. data/lib/potassium/assets/testing/rails_helper.rb +130 -49
  26. data/lib/potassium/assets/testing/shoulda_matchers_config.rb +8 -0
  27. data/lib/potassium/assets/testing/simplecov_config.rb +64 -0
  28. data/lib/potassium/assets/testing/system_tests_config.rb +6 -0
  29. data/lib/potassium/cli_options.rb +19 -3
  30. data/lib/potassium/helpers/template-helpers.rb +4 -0
  31. data/lib/potassium/recipes/admin.rb +27 -17
  32. data/lib/potassium/recipes/api.rb +2 -0
  33. data/lib/potassium/recipes/background_processor.rb +43 -32
  34. data/lib/potassium/recipes/ci.rb +9 -39
  35. data/lib/potassium/recipes/coverage.rb +35 -0
  36. data/lib/potassium/recipes/file_storage.rb +1 -1
  37. data/lib/potassium/recipes/front_end.rb +26 -13
  38. data/lib/potassium/recipes/google_tag_manager.rb +94 -0
  39. data/lib/potassium/recipes/heroku.rb +43 -31
  40. data/lib/potassium/recipes/mailer.rb +18 -5
  41. data/lib/potassium/recipes/monitoring.rb +5 -0
  42. data/lib/potassium/recipes/pundit.rb +29 -10
  43. data/lib/potassium/recipes/rails.rb +0 -4
  44. data/lib/potassium/recipes/schedule.rb +16 -1
  45. data/lib/potassium/recipes/spring.rb +9 -0
  46. data/lib/potassium/recipes/style.rb +2 -2
  47. data/lib/potassium/recipes/testing.rb +75 -18
  48. data/lib/potassium/templates/application.rb +7 -2
  49. data/lib/potassium/version.rb +7 -4
  50. data/potassium.gemspec +3 -1
  51. data/spec/features/background_processor_spec.rb +7 -5
  52. data/spec/features/ci_spec.rb +7 -4
  53. data/spec/features/coverage_spec.rb +26 -0
  54. data/spec/features/front_end_spec.rb +18 -1
  55. data/spec/features/google_tag_manager_spec.rb +36 -0
  56. data/spec/features/heroku_spec.rb +0 -4
  57. data/spec/features/mailer_spec.rb +16 -0
  58. data/spec/features/node_spec.rb +1 -1
  59. data/spec/features/pundit_spec.rb +34 -0
  60. data/spec/features/schedule_spec.rb +11 -4
  61. data/spec/features/testing_spec.rb +56 -0
  62. data/spec/support/potassium_test_helpers.rb +2 -3
  63. data/tmp/.keep +0 -0
  64. metadata +64 -15
  65. data/lib/potassium/assets/Dockerfile.ci +0 -6
  66. data/lib/potassium/assets/active_admin/admin_user_policy.rb +0 -2
  67. data/lib/potassium/assets/active_admin/comment_policy.rb +0 -2
  68. data/lib/potassium/assets/active_admin/pundit_page_policy.rb +0 -5
  69. data/lib/potassium/assets/bin/cibuild.erb +0 -117
  70. data/lib/potassium/assets/docker-compose.ci.yml +0 -12
  71. data/lib/potassium/assets/sidekiq_scheduler.yml +0 -9
@@ -1,13 +1,7 @@
1
1
  class Recipes::Heroku < Rails::AppBuilder
2
2
  NAME_PREFIX = 'pl'
3
-
4
- attr_accessor :app_name_staging
5
-
6
- def initialize(args)
7
- super(args)
8
- set(:heroku_app_name_staging, app_name_for('staging'))
9
- set(:heroku_app_name_production, app_name_for('production'))
10
- end
3
+ ENVIRONMENTS = ['staging', 'production']
4
+ HEROKU_NAMES_MAX_CHARS = 30
11
5
 
12
6
  def ask
13
7
  heroku = answer(:heroku) do
@@ -16,6 +10,8 @@ class Recipes::Heroku < Rails::AppBuilder
16
10
 
17
11
  if heroku
18
12
  set(:heroku, heroku)
13
+
14
+ ENVIRONMENTS.each { |environment| set_app_name_for(environment) }
19
15
  end
20
16
  end
21
17
 
@@ -28,14 +24,13 @@ class Recipes::Heroku < Rails::AppBuilder
28
24
  end
29
25
 
30
26
  def installed?
31
- gem_exists?(/rails_stdout_logging/)
27
+ gem_exists?(/heroku-stage/)
32
28
  end
33
29
 
34
30
  private
35
31
 
36
32
  def add_heroku
37
33
  gather_gems(:production) do
38
- gather_gem('rails_stdout_logging')
39
34
  gather_gem('heroku-stage')
40
35
  end
41
36
 
@@ -47,31 +42,34 @@ class Recipes::Heroku < Rails::AppBuilder
47
42
  template "../assets/bin/setup_heroku.erb", "bin/setup_heroku", force: true
48
43
  run "chmod a+x bin/setup_heroku"
49
44
 
50
- if logged_in?
51
- %w(staging production).each do |environment|
52
- create_app_on_heroku(environment)
53
- end
54
- puts "Remember to connect the github repository to the new pipeline"
55
- open_pipeline_command = "\e[33mheroku pipelines:open #{heroku_pipeline_name}\e[0m"
56
- puts "run #{open_pipeline_command} to open the dashboard"
57
- else
58
- puts "You are not logged in into heroku"
59
- login_command = "\e[33mheroku login\e[0m"
60
- puts "Run #{login_command} and enter your credentials"
61
- puts "You can install the heroku recipe again create the app in heroku"
62
- install_command = "\e[33mpostassium install heroku --force\e[0m"
63
- puts "Just run #{install_command}"
64
- end
45
+ logged_in? ? create_apps : puts_not_logged_in_msg
65
46
 
66
47
  add_readme_header :deployment
67
48
  end
68
49
 
50
+ def create_apps
51
+ ENVIRONMENTS.each { |environment| create_app_on_heroku(environment) }
52
+ puts "Remember to connect the github repository to the new pipeline"
53
+ open_pipeline_command = "\e[33mheroku pipelines:open #{heroku_pipeline_name}\e[0m"
54
+ puts "run #{open_pipeline_command} to open the dashboard"
55
+ end
56
+
57
+ def puts_not_logged_in_msg
58
+ puts "You are not logged in into heroku"
59
+ login_command = "\e[33mheroku login\e[0m"
60
+ puts "Run #{login_command} and enter your credentials"
61
+ puts "You can install the heroku recipe again to create the app in heroku"
62
+ install_command = "\e[33mpostassium install heroku --force\e[0m"
63
+ puts "Just run #{install_command}"
64
+ end
65
+
69
66
  def heroku_pipeline_name
70
- app_name.dasherize
67
+ @heroku_pipeline_name ||= valid_heroku_name(app_name.dasherize, 'pipeline', false)
71
68
  end
72
69
 
73
- def app_name_for(environment)
74
- "#{NAME_PREFIX}-#{app_name.dasherize}-#{environment}"
70
+ def set_app_name_for(environment)
71
+ default_name = "#{NAME_PREFIX}-#{app_name.dasherize}-#{environment}"
72
+ set("heroku_app_name_#{environment}".to_sym, valid_heroku_name(default_name, environment))
75
73
  end
76
74
 
77
75
  def logged_in?
@@ -84,7 +82,7 @@ class Recipes::Heroku < Rails::AppBuilder
84
82
 
85
83
  def create_app_on_heroku(environment)
86
84
  rack_env = "RACK_ENV=production"
87
- staged_app_name = app_name_for(environment)
85
+ staged_app_name = get("heroku_app_name_#{environment}".to_sym)
88
86
 
89
87
  run_toolbelt_command "create #{staged_app_name} --remote #{environment}"
90
88
  run_toolbelt_command "labs:enable runtime-dyno-metadata", staged_app_name
@@ -99,14 +97,14 @@ class Recipes::Heroku < Rails::AppBuilder
99
97
  def set_rails_secrets(environment)
100
98
  run_toolbelt_command(
101
99
  "config:add SECRET_KEY_BASE=#{generate_secret}",
102
- app_name_for(environment)
100
+ get("heroku_app_name_#{environment}".to_sym)
103
101
  )
104
102
  end
105
103
 
106
104
  def set_app_multi_buildpack(environment)
107
105
  run_toolbelt_command(
108
106
  "buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git",
109
- app_name_for(environment)
107
+ get("heroku_app_name_#{environment}".to_sym)
110
108
  )
111
109
  end
112
110
 
@@ -133,4 +131,18 @@ class Recipes::Heroku < Rails::AppBuilder
133
131
  `heroku #{command} --app #{app_env_name}`
134
132
  end
135
133
  end
134
+
135
+ def valid_heroku_name(name, element, force_suffix = true)
136
+ suffix = "-#{element}"
137
+ while name.length > HEROKU_NAMES_MAX_CHARS
138
+ puts "Heroku names must be shorter than #{HEROKU_NAMES_MAX_CHARS} chars."
139
+ if force_suffix
140
+ puts "Potassium uses the heroku-stage gem, because of that '#{suffix}' will be "\
141
+ "added to your app name. The suffix, #{suffix}, counts towards the app name length."
142
+ end
143
+ name = Ask.input("Please enter a valid name for #{element}:")
144
+ name += suffix if force_suffix && !name.end_with?(suffix)
145
+ end
146
+ name
147
+ end
136
148
  end
@@ -24,11 +24,7 @@ class Recipes::Mailer < Rails::AppBuilder
24
24
  dependencies(email_service)
25
25
  config(email_service)
26
26
 
27
- background_processor_recipe = load_recipe(:background_processor)
28
- background_processor_answer = get(:background_processor)
29
-
30
- background_processor_recipe.add_sidekiq unless background_processor_recipe.installed? ||
31
- background_processor_answer
27
+ ensure_sidekiq_install_and_add_mailers_queue
32
28
  end
33
29
 
34
30
  def install
@@ -36,6 +32,10 @@ class Recipes::Mailer < Rails::AppBuilder
36
32
  create
37
33
  end
38
34
 
35
+ def add_mailer_queue
36
+ insert_into_file "config/sidekiq.yml", " - mailers", after: "- default\n"
37
+ end
38
+
39
39
  private
40
40
 
41
41
  def email_services(service_name)
@@ -102,4 +102,17 @@ class Recipes::Mailer < Rails::AppBuilder
102
102
  gather_gems(:development) { gather_gem("letter_opener") }
103
103
  application "config.action_mailer.delivery_method = :letter_opener", env: "development"
104
104
  end
105
+
106
+ def ensure_sidekiq_install_and_add_mailers_queue
107
+ background_processor_recipe = load_recipe(:background_processor)
108
+ background_processor_answer = get(:background_processor)
109
+
110
+ if background_processor_recipe.installed?
111
+ add_mailer_queue
112
+ else
113
+ recipe = self
114
+ after(:install_sidekiq) { recipe.add_mailer_queue }
115
+ background_processor_recipe.add_sidekiq unless background_processor_answer
116
+ end
117
+ end
105
118
  end
@@ -0,0 +1,5 @@
1
+ class Recipes::Monitoring < Rails::AppBuilder
2
+ def create
3
+ gather_gem('scout_apm')
4
+ end
5
+ end
@@ -31,20 +31,39 @@ class Recipes::Pundit < Rails::AppBuilder
31
31
  end
32
32
 
33
33
  def install_admin_pundit
34
+ configure_active_admin_initializer
35
+ copy_policies
36
+ end
37
+
38
+ private
39
+
40
+ def configure_active_admin_initializer
41
+ config_active_admin_option("authorization_adapter", "ActiveAdmin::PunditAdapter")
42
+ config_active_admin_option("pundit_default_policy", "'BackOffice::DefaultPolicy'")
43
+ config_active_admin_option("pundit_policy_namespace", ":back_office")
44
+ end
45
+
46
+ def copy_policies
47
+ copy_policy("default_policy")
48
+ copy_policy("admin_user_policy")
49
+ copy_policy("page_policy", "active_admin")
50
+ copy_policy("comment_policy", "active_admin")
51
+ end
52
+
53
+ def config_active_admin_option(option, value)
34
54
  initializer = "config/initializers/active_admin.rb"
35
- gsub_file initializer, /# config\.authorization_adapter =[^\n]+\n/ do
36
- "config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
55
+ gsub_file initializer, /# config\.#{option} =[^\n]+\n/ do
56
+ "config.#{option} = #{value}\n"
37
57
  end
38
-
39
- template "../assets/active_admin/pundit_page_policy.rb",
40
- "app/policies/active_admin/page_policy.rb"
41
- template "../assets/active_admin/comment_policy.rb",
42
- "app/policies/active_admin/comment_policy.rb"
43
- template "../assets/active_admin/admin_user_policy.rb",
44
- "app/policies/admin_user_policy.rb"
45
58
  end
46
59
 
47
- private
60
+ def copy_policy(policy_name, model_namespace = nil)
61
+ destination_path = [model_namespace, policy_name].compact.join("/")
62
+ template(
63
+ "../assets/active_admin/policies/#{policy_name}.rb",
64
+ "app/policies/back_office/#{destination_path}.rb"
65
+ )
66
+ end
48
67
 
49
68
  def run_pundit_installer
50
69
  gather_gem 'pundit'
@@ -1,10 +1,6 @@
1
1
  class Recipes::Rails < Rails::AppBuilder
2
2
  def create
3
3
  gather_gem("bootsnap", require: false)
4
- gather_gems(:development) do
5
- gather_gem("spring")
6
- end
7
-
8
4
  environment 'config.force_ssl = true', env: 'production'
9
5
  disable_automatic_nonce_generation
10
6
  end
@@ -10,8 +10,8 @@ class Recipes::Schedule < Rails::AppBuilder
10
10
  if selected?(:schedule)
11
11
  gather_gem 'sidekiq-scheduler', '>= 3.0.1'
12
12
  add_readme_section :internal_dependencies, :sidekiq_scheduler
13
+ append_schedule_section_to_yml
13
14
  end
14
- template '../assets/sidekiq_scheduler.yml', 'config/sidekiq.yml', force: true
15
15
  end
16
16
 
17
17
  def install
@@ -22,4 +22,19 @@ class Recipes::Schedule < Rails::AppBuilder
22
22
  def installed?
23
23
  gem_exists?(/sidekiq-scheduler/) && file_exist?('config/sidekiq.yml')
24
24
  end
25
+
26
+ private
27
+
28
+ def append_schedule_section_to_yml
29
+ append_to_file(
30
+ 'config/sidekiq.yml',
31
+ <<-HERE.gsub(/^ {8}/, '')
32
+ # :schedule:
33
+ # an_scheduled_task:
34
+ # cron: '0 * * * * *' # Runs once per minute
35
+ # class: ExampleJob
36
+ # args: ['a', 'b']
37
+ HERE
38
+ )
39
+ end
25
40
  end
@@ -0,0 +1,9 @@
1
+ class Recipes::Spring < Rails::AppBuilder
2
+ def create
3
+ if answer(:spring)
4
+ gather_gems(:development) do
5
+ gather_gem("spring")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -13,10 +13,10 @@ class Recipes::Style < Rails::AppBuilder
13
13
 
14
14
  def add_linters
15
15
  gather_gems(:development, :test) do
16
- gather_gem 'rubocop', '~> 0.82.0'
16
+ gather_gem 'rubocop', Potassium::RUBOCOP_VERSION
17
17
  gather_gem 'rubocop-performance'
18
18
  gather_gem 'rubocop-rails'
19
- gather_gem 'rubocop-rspec'
19
+ gather_gem 'rubocop-rspec', Potassium::RUBOCOP_RSPEC_VERSION
20
20
  end
21
21
  run 'bin/yarn add --dev stylelint eslint eslint-plugin-import'
22
22
  run 'bin/yarn add --dev eslint-plugin-vue' if selected?(:front_end, :vue)
@@ -1,5 +1,76 @@
1
1
  class Recipes::Testing < Rails::AppBuilder
2
2
  def create
3
+ add_gems
4
+ add_readme_header(:testing)
5
+ recipe = self
6
+
7
+ after(:gem_install) do
8
+ recipe.install_rspec
9
+ recipe.install_guard
10
+ recipe.create_rspec_binary
11
+ end
12
+
13
+ config_raise_delivery_errors_option
14
+ end
15
+
16
+ def install_rspec
17
+ remove_dir 'test'
18
+ generate "rspec:install"
19
+ remove_file 'spec/rails_helper.rb'
20
+ copy_file '../assets/testing/rails_helper.rb', 'spec/rails_helper.rb'
21
+ remove_file '.rspec'
22
+ copy_file '../assets/testing/.rspec', '.rspec'
23
+ create_file 'spec/system/.keep'
24
+ create_support_directories
25
+ end
26
+
27
+ def create_support_directories
28
+ %w{
29
+ custom_matchers
30
+ shared_examples
31
+ configurations
32
+ helpers
33
+ helpers/system
34
+ }.each do |directory|
35
+ path = "spec/support/#{directory}"
36
+ empty_directory(path)
37
+ create_file("#{path}/.keep")
38
+ end
39
+
40
+ add_support_configuration_modules
41
+ end
42
+
43
+ def add_support_configuration_modules
44
+ files = %w{
45
+ faker_config
46
+ factory_bot_config
47
+ power_types_config
48
+ shoulda_matchers_config
49
+ system_tests_config
50
+ }
51
+ files << "devise_config" if selected?(:authentication)
52
+ files.each do |config_module|
53
+ copy_file(
54
+ "../assets/testing/#{config_module}.rb",
55
+ "spec/support/configurations/#{config_module}.rb"
56
+ )
57
+ end
58
+ end
59
+
60
+ def install_guard
61
+ run "bundle exec guard init"
62
+ run "bundle binstub guard"
63
+ line = /guard :rspec, cmd: "bundle exec rspec" do\n/
64
+ gsub_file 'Guardfile', line do
65
+ "guard :rspec, cmd: \"bin/rspec\" do\n"
66
+ end
67
+ end
68
+
69
+ def create_rspec_binary
70
+ run "bundle binstubs rspec-core"
71
+ end
72
+
73
+ def add_gems
3
74
  gather_gems(:development, :test) do
4
75
  gather_gem('rspec-rails')
5
76
  gather_gem('factory_bot_rails')
@@ -10,26 +81,12 @@ class Recipes::Testing < Rails::AppBuilder
10
81
 
11
82
  gather_gems(:test) do
12
83
  gather_gem('shoulda-matchers', require: false)
84
+ gather_gem('capybara')
85
+ gather_gem('webdrivers')
13
86
  end
87
+ end
14
88
 
15
- after(:gem_install) do
16
- remove_dir 'test'
17
-
18
- generate "rspec:install"
19
-
20
- remove_file 'spec/rails_helper.rb'
21
- copy_file '../assets/testing/rails_helper.rb', 'spec/rails_helper.rb'
22
-
23
- remove_file '.rspec'
24
- copy_file '../assets/testing/.rspec', '.rspec'
25
-
26
- empty_directory 'spec/support'
27
- create_file 'spec/support/.keep'
28
-
29
- run "bundle exec guard init"
30
- run "bundle binstubs rspec-core"
31
- end
32
-
89
+ def config_raise_delivery_errors_option
33
90
  raise_delivery_errors_regexp = /config.action_mailer.raise_delivery_errors = false\n/
34
91
  gsub_file 'config/environments/development.rb', raise_delivery_errors_regexp do
35
92
  "config.action_mailer.raise_delivery_errors = true"
@@ -20,6 +20,7 @@ run_action(:asking) do
20
20
  ask :database
21
21
  ask :devise
22
22
  ask :admin
23
+ ask :google_tag_manager
23
24
  ask :front_end
24
25
  ask :vue_admin
25
26
  ask :mailer
@@ -37,6 +38,7 @@ end
37
38
 
38
39
  run_action(:recipe_loading) do
39
40
  create :rails
41
+ create :spring
40
42
  create :readme
41
43
  create :heroku
42
44
  create :ci
@@ -58,13 +60,13 @@ run_action(:recipe_loading) do
58
60
  create :i18n
59
61
  create :pry
60
62
  create :better_errors
63
+ create :monitoring
61
64
  create :devise
62
- create :admin
63
- create :vue_admin
64
65
  create :seeds
65
66
  create :error_reporting
66
67
  create :pundit
67
68
  create :testing
69
+ create :coverage
68
70
  create :secrets
69
71
  create :api
70
72
  create :draper
@@ -76,6 +78,9 @@ run_action(:recipe_loading) do
76
78
  create :github
77
79
  create :cleanup
78
80
  create :front_end
81
+ create :admin
82
+ create :vue_admin
83
+ create :google_tag_manager
79
84
  end
80
85
 
81
86
  info "Gathered enough information. Applying the template. Wait a minute."
@@ -1,9 +1,12 @@
1
1
  module Potassium
2
- VERSION = "6.1.0"
2
+ VERSION = "6.5.0"
3
3
  RUBY_VERSION = "2.7.0"
4
- RAILS_VERSION = "~> 6.0.2"
5
- RUBOCOP_VERSION = "~> 0.65.0"
4
+ RAILS_VERSION = "~> 6.1.4.4"
5
+ RUBOCOP_VERSION = "~> 1.9"
6
+ RUBOCOP_RSPEC_VERSION = "~> 2.2"
6
7
  POSTGRES_VERSION = "11.3"
7
8
  MYSQL_VERSION = "5.7"
8
- NODE_VERSION = "12"
9
+ NODE_VERSION = "14"
10
+ TAILWINDCSS = "npm:@tailwindcss/postcss7-compat"
11
+ VUE_LOADER_VERSION = "^15.9.7"
9
12
  end
data/potassium.gemspec CHANGED
@@ -24,7 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rspec", "~> 3.4.0"
25
25
  spec.add_development_dependency "rspec_junit_formatter"
26
26
  spec.add_development_dependency "rubocop", Potassium::RUBOCOP_VERSION
27
- spec.add_development_dependency "rubocop-rspec"
27
+ spec.add_development_dependency "rubocop-performance"
28
+ spec.add_development_dependency "rubocop-rails"
29
+ spec.add_development_dependency "rubocop-rspec", Potassium::RUBOCOP_RSPEC_VERSION
28
30
  spec.add_runtime_dependency "gems", "~> 0.8"
29
31
  spec.add_runtime_dependency "gli", "~> 2.12.2"
30
32
  spec.add_runtime_dependency "inquirer", "~> 0.2"
@@ -2,11 +2,11 @@ require "spec_helper"
2
2
  require 'yaml'
3
3
 
4
4
  RSpec.describe "BackgroundProcessor" do
5
- context "working with sidekiq" do
5
+ context "when working with sidekiq and no mailer" do
6
6
  before :all do
7
7
  drop_dummy_database
8
8
  remove_project_directory
9
- create_dummy_project("background_processor" => "sidekiq", "heroku" => true)
9
+ create_dummy_project("background_processor" => true, "heroku" => true)
10
10
  end
11
11
 
12
12
  it "adds sidekiq gem to Gemfile" do
@@ -52,9 +52,11 @@ RSpec.describe "BackgroundProcessor" do
52
52
  expect(content).to include("require 'sidekiq'")
53
53
  end
54
54
 
55
- it "adds sidekiq.yml file" do
56
- content = IO.read("#{project_path}/config/sidekiq.yml")
57
- expect(content).to include("concurrency: 5")
55
+ it "adds sidekiq.yml file with no mailer queue" do
56
+ yml_path = "#{project_path}/config/sidekiq.yml"
57
+ content = IO.read(yml_path)
58
+ expect(File.exist?(yml_path)).to be true
59
+ expect(content).not_to include("- mailers")
58
60
  end
59
61
 
60
62
  it "adds redis.yml file" do
@@ -1,14 +1,17 @@
1
1
  require "spec_helper"
2
2
  require "rubocop"
3
3
 
4
- RSpec.describe "A new project" do
4
+ RSpec.describe 'CI' do
5
5
  before(:all) do
6
6
  drop_dummy_database
7
7
  remove_project_directory
8
- create_dummy_project("heroku" => true)
8
+ create_dummy_project
9
9
  end
10
10
 
11
- it "correctly runs continous integration" do
12
- expect { on_project { `bin/cibuild` } }.to_not output.to_stderr
11
+ it "correctly bundles the config file" do
12
+ yml_path = "#{project_path}/.circleci/config.yml"
13
+ content = IO.read(yml_path)
14
+ expect(File.exist?(yml_path)).to be true
15
+ expect(content).to include('cimg/ruby', 'cache', 'rspec', 'reviewdog')
13
16
  end
14
17
  end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Coverage" do
4
+ before(:all) do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ create_dummy_project
8
+ end
9
+
10
+ it "adds simplecov related gems to Gemfile" do
11
+ content = IO.read("#{project_path}/Gemfile")
12
+ expect(content).to include("gem 'simplecov'")
13
+ expect(content).to include("gem 'simplecov_linter_formatter'")
14
+ expect(content).to include("gem 'simplecov_text_formatter'")
15
+ end
16
+
17
+ it "requires simplecov config file before rails" do
18
+ content = IO.read("#{project_path}/spec/rails_helper.rb")
19
+ expect(content).to include("ENV['RACK_ENV'] ||= 'test'\nrequire 'simplecov_config'")
20
+ end
21
+
22
+ it "adds simplecov config file" do
23
+ content = IO.read("#{project_path}/spec/simplecov_config.rb")
24
+ expect(content).to include("SimpleCov.start 'rails'")
25
+ end
26
+ end
@@ -19,7 +19,12 @@ RSpec.describe "Front end" do
19
19
  remove_project_directory
20
20
  create_dummy_project("front_end" => "None")
21
21
  expect(gemfile).to include('webpacker')
22
- expect(File).not_to exist(application_css_path)
22
+ end
23
+
24
+ def expect_to_have_tailwind_compatibility_build
25
+ expect(node_modules_file).to include("\"tailwindcss\": \"npm:@tailwindcss/postcss7-compat\"")
26
+ expect(node_modules_file).to include("\"autoprefixer\": \"^9\"")
27
+ expect(node_modules_file).to include("\"postcss\": \"^7\"")
23
28
  end
24
29
 
25
30
  context "with vue" do
@@ -55,6 +60,14 @@ RSpec.describe "Front end" do
55
60
  expect(tailwind_config_file).to include('module.exports')
56
61
  end
57
62
 
63
+ it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
64
+ expect_to_have_tailwind_compatibility_build
65
+ end
66
+
67
+ it 'includes correct version of vue-loader in package' do
68
+ expect(node_modules_file).to include("\"vue-loader\": \"#{Potassium::VUE_LOADER_VERSION}\"")
69
+ end
70
+
58
71
  context "with graphql" do
59
72
  before(:all) do
60
73
  remove_project_directory
@@ -84,5 +97,9 @@ RSpec.describe "Front end" do
84
97
  it "creates application_js_file for tailwind without vue" do
85
98
  expect(application_js_file).to include("import '../css/application.css';")
86
99
  end
100
+
101
+ it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
102
+ expect_to_have_tailwind_compatibility_build
103
+ end
87
104
  end
88
105
  end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Google Tag Manager" do
4
+ before :all do
5
+ remove_project_directory
6
+ create_dummy_project('google_tag_manager' => true)
7
+ end
8
+
9
+ let(:gtm_head_file_path) do
10
+ "#{project_path}/app/views/shared/_gtm_head.html.erb"
11
+ end
12
+ let(:gtm_body_file_path) do
13
+ "#{project_path}/app/views/shared/_gtm_body.html.erb"
14
+ end
15
+ let(:content_security_policy_file_path) do
16
+ "#{project_path}/config/initializers/content_security_policy.rb"
17
+ end
18
+ let(:application_layout_file) do
19
+ IO.read("#{project_path}/app/views/layouts/application.html.erb")
20
+ end
21
+ let(:content_security_policy_file) do
22
+ IO.read(content_security_policy_file_path)
23
+ end
24
+
25
+ it 'adds google tag manager script' do
26
+ expect(File).to be_file(gtm_head_file_path)
27
+ expect(File).to be_file(gtm_body_file_path)
28
+ expect(application_layout_file).to include('shared/gtm_head')
29
+ expect(application_layout_file).to include('shared/gtm_body')
30
+ end
31
+
32
+ it 'add content security policy' do
33
+ expect(content_security_policy_file)
34
+ .to include("\nRails.application.config.content_security_policy do |policy|")
35
+ end
36
+ end
@@ -10,10 +10,6 @@ RSpec.describe "Heroku" do
10
10
  create_dummy_project("heroku" => true)
11
11
  app_name = PotassiumTestHelpers::APP_NAME.dasherize
12
12
 
13
- expect(FakeHeroku).to(
14
- have_gem_included(project_path, "rails_stdout_logging")
15
- )
16
-
17
13
  procfile_path = "#{project_path}/Procfile"
18
14
  procfile = IO.read(procfile_path)
19
15