potassium 6.3.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.node-version +1 -1
  4. data/CHANGELOG.md +45 -0
  5. data/README.md +30 -3
  6. data/docs/CONTRIBUTING.md +2 -2
  7. data/lib/potassium/assets/.circleci/config.yml.erb +40 -12
  8. data/lib/potassium/assets/.eslintrc.json +15 -9
  9. data/lib/potassium/assets/.pryrc +0 -6
  10. data/lib/potassium/assets/.rubocop.yml +1 -0
  11. data/lib/potassium/assets/Aptfile +5 -0
  12. data/lib/potassium/assets/README.yml +74 -7
  13. data/lib/potassium/assets/active_admin/admin-component.vue +22 -30
  14. data/lib/potassium/assets/active_admin/policies/admin_user_policy.rb +2 -0
  15. data/lib/potassium/assets/active_admin/policies/comment_policy.rb +2 -0
  16. data/lib/potassium/assets/active_admin/policies/default_policy.rb +49 -0
  17. data/lib/potassium/assets/active_admin/policies/page_policy.rb +2 -0
  18. data/lib/potassium/assets/app/javascript/{app.spec.js → components/app.spec.ts} +2 -2
  19. data/lib/potassium/assets/app/javascript/components/app.vue +9 -0
  20. data/lib/potassium/assets/app/javascript/types/vue.d.ts +5 -0
  21. data/lib/potassium/assets/app/jobs/shrine_promote_job.rb +14 -0
  22. data/lib/potassium/assets/app/mailers/application_mailer.rb +1 -1
  23. data/lib/potassium/assets/app/mailers/example_mailer.rb +6 -0
  24. data/lib/potassium/assets/app/serializers/base_serializer.rb +3 -0
  25. data/lib/potassium/assets/app/serializers/concerns/image_handling_attributes.rb +20 -0
  26. data/lib/potassium/assets/app/uploaders/cover_image_uploader.rb +52 -0
  27. data/lib/potassium/assets/app/views/example_mailer/example_mail.html.mjml +7 -0
  28. data/lib/potassium/assets/app/views/layouts/default_mail.html.mjml +49 -0
  29. data/lib/potassium/assets/config/initializers/shrine/plugins/image_handling_utilities.rb +143 -0
  30. data/lib/potassium/assets/config/mailer.rb.erb +0 -2
  31. data/lib/potassium/assets/config/shrine.rb +15 -0
  32. data/lib/potassium/assets/config/webpack/rules/css.js +5 -0
  33. data/lib/potassium/assets/config/webpack/rules/index.js +11 -0
  34. data/lib/potassium/assets/config/webpack/rules/jquery.js +11 -0
  35. data/lib/potassium/assets/config/webpack/rules/typescript.js +32 -0
  36. data/lib/potassium/assets/config/webpack/rules/vue.js +19 -0
  37. data/lib/potassium/assets/config/webpack/webpack.config.js +4 -0
  38. data/lib/potassium/assets/public/mails/platanus-logo.png +0 -0
  39. data/lib/potassium/assets/testing/.rspec +1 -0
  40. data/lib/potassium/assets/testing/devise_config.rb +6 -0
  41. data/lib/potassium/assets/testing/factory_bot_config.rb +3 -0
  42. data/lib/potassium/assets/testing/faker_config.rb +1 -0
  43. data/lib/potassium/assets/testing/power_types_config.rb +1 -0
  44. data/lib/potassium/assets/testing/rails_helper.rb +130 -49
  45. data/lib/potassium/assets/testing/shoulda_matchers_config.rb +8 -0
  46. data/lib/potassium/assets/testing/simplecov_config.rb +64 -0
  47. data/lib/potassium/assets/testing/system_tests_config.rb +6 -0
  48. data/lib/potassium/assets/tsconfig.json +31 -0
  49. data/lib/potassium/cli/commands/create.rb +3 -1
  50. data/lib/potassium/cli_options.rb +23 -3
  51. data/lib/potassium/platanus_config.rb +20 -0
  52. data/lib/potassium/recipes/admin.rb +37 -16
  53. data/lib/potassium/recipes/api.rb +8 -85
  54. data/lib/potassium/recipes/coverage.rb +66 -0
  55. data/lib/potassium/recipes/file_storage.rb +50 -0
  56. data/lib/potassium/recipes/front_end.rb +87 -108
  57. data/lib/potassium/recipes/google_tag_manager.rb +20 -16
  58. data/lib/potassium/recipes/heroku.rb +1 -2
  59. data/lib/potassium/recipes/mailer.rb +22 -10
  60. data/lib/potassium/recipes/mjml.rb +31 -0
  61. data/lib/potassium/recipes/node.rb +11 -13
  62. data/lib/potassium/recipes/pundit.rb +29 -10
  63. data/lib/potassium/recipes/rails.rb +0 -4
  64. data/lib/potassium/recipes/spring.rb +9 -0
  65. data/lib/potassium/recipes/style.rb +9 -2
  66. data/lib/potassium/recipes/testing.rb +75 -18
  67. data/lib/potassium/recipes/vue_admin.rb +38 -8
  68. data/lib/potassium/templates/application.rb +5 -2
  69. data/lib/potassium/version.rb +10 -4
  70. data/spec/features/api_spec.rb +6 -1
  71. data/spec/features/ci_spec.rb +1 -1
  72. data/spec/features/coverage_spec.rb +43 -0
  73. data/spec/features/file_storage_spec.rb +102 -26
  74. data/spec/features/front_end_spec.rb +16 -47
  75. data/spec/features/google_tag_manager_spec.rb +1 -24
  76. data/spec/features/heroku_spec.rb +0 -4
  77. data/spec/features/mailer_spec.rb +79 -33
  78. data/spec/features/mjml_spec.rb +53 -0
  79. data/spec/features/node_spec.rb +1 -1
  80. data/spec/features/pundit_spec.rb +34 -0
  81. data/spec/features/testing_spec.rb +56 -0
  82. data/spec/features/vue_admin_spec.rb +0 -10
  83. data/spec/support/potassium_test_helpers.rb +2 -2
  84. data/spec/support/shared_examples.rb +5 -0
  85. metadata +50 -27
  86. data/lib/potassium/assets/active_admin/admin_application.js +0 -14
  87. data/lib/potassium/assets/active_admin/admin_user_policy.rb +0 -2
  88. data/lib/potassium/assets/active_admin/comment_policy.rb +0 -2
  89. data/lib/potassium/assets/active_admin/init_activeadmin_vue.rb +0 -10
  90. data/lib/potassium/assets/active_admin/pundit_page_policy.rb +0 -5
  91. data/lib/potassium/assets/app/graphql/graphql_controller.rb +0 -55
  92. data/lib/potassium/assets/app/graphql/mutations/login_mutation.rb +0 -23
  93. data/lib/potassium/assets/app/graphql/queries/base_query.rb +0 -4
  94. data/lib/potassium/assets/app/graphql/types/base/base_argument.rb +0 -4
  95. data/lib/potassium/assets/app/graphql/types/base/base_enum.rb +0 -4
  96. data/lib/potassium/assets/app/graphql/types/base/base_field.rb +0 -5
  97. data/lib/potassium/assets/app/graphql/types/base/base_input_object.rb +0 -5
  98. data/lib/potassium/assets/app/graphql/types/base/base_interface.rb +0 -7
  99. data/lib/potassium/assets/app/graphql/types/base/base_object.rb +0 -5
  100. data/lib/potassium/assets/app/graphql/types/base/base_scalar.rb +0 -4
  101. data/lib/potassium/assets/app/graphql/types/base/base_union.rb +0 -4
  102. data/lib/potassium/assets/app/graphql/types/mutation_type.rb +0 -10
  103. data/lib/potassium/assets/app/graphql/types/query_type.rb +0 -13
  104. data/lib/potassium/assets/config/graphql_playground.rb +0 -20
  105. data/spec/features/graphql_spec.rb +0 -71
@@ -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"
@@ -35,15 +35,18 @@ class Recipes::VueAdmin < Rails::AppBuilder
35
35
  def add_vue_admin
36
36
  add_vue_component_library
37
37
  add_component_integration
38
- copy_file '../assets/active_admin/init_activeadmin_vue.rb',
39
- 'config/initializers/init_activeadmin_vue.rb'
40
- copy_file '../assets/active_admin/admin_application.js',
41
- 'app/javascript/packs/admin_application.js',
42
- force: true
43
- empty_directory 'app/javascript/components'
38
+ js_line = 'import "activeadmin_addons"'
39
+ gsub_file(
40
+ 'app/javascript/active_admin.js',
41
+ js_line,
42
+ <<~HERE
43
+ #{js_line}
44
+ #{active_admin_js}
45
+ HERE
46
+ )
44
47
  copy_file '../assets/active_admin/admin-component.vue',
45
- 'app/javascript/components/admin-component.vue',
46
- force: true
48
+ 'app/javascript/components/admin-component.vue',
49
+ force: true
47
50
  end
48
51
 
49
52
  def add_component_integration
@@ -121,4 +124,31 @@ class Recipes::VueAdmin < Rails::AppBuilder
121
124
  end
122
125
  HERE
123
126
  end
127
+
128
+ def active_admin_js
129
+ <<~HERE
130
+ import { createApp } from 'vue';
131
+ import AdminComponent from './components/admin-component.vue';
132
+
133
+ function onLoad() {
134
+ if (document.getElementById('wrapper') !== null) {
135
+ const app = createApp({
136
+ mounted() {
137
+ // We need to re-trigger DOMContentLoaded for ArcticAdmin after Vue replaces DOM elements
138
+ window.document.dispatchEvent(new Event('DOMContentLoaded', {
139
+ bubbles: true,
140
+ cancelable: true,
141
+ }));
142
+ },
143
+ });
144
+ app.component('AdminComponent', AdminComponent);
145
+ app.mount('#wrapper');
146
+ }
147
+
148
+ return null;
149
+ }
150
+
151
+ document.addEventListener('DOMContentLoaded', onLoad, { once: true });
152
+ HERE
153
+ end
124
154
  end
@@ -38,6 +38,7 @@ end
38
38
 
39
39
  run_action(:recipe_loading) do
40
40
  create :rails
41
+ create :spring
41
42
  create :readme
42
43
  create :heroku
43
44
  create :ci
@@ -61,12 +62,11 @@ run_action(:recipe_loading) do
61
62
  create :better_errors
62
63
  create :monitoring
63
64
  create :devise
64
- create :admin
65
- create :vue_admin
66
65
  create :seeds
67
66
  create :error_reporting
68
67
  create :pundit
69
68
  create :testing
69
+ create :coverage
70
70
  create :secrets
71
71
  create :api
72
72
  create :draper
@@ -78,7 +78,10 @@ run_action(:recipe_loading) do
78
78
  create :github
79
79
  create :cleanup
80
80
  create :front_end
81
+ create :admin
82
+ create :vue_admin
81
83
  create :google_tag_manager
84
+ create :mjml
82
85
  end
83
86
 
84
87
  info "Gathered enough information. Applying the template. Wait a minute."
@@ -1,11 +1,17 @@
1
1
  module Potassium
2
- VERSION = "6.3.0"
2
+ VERSION = "6.6.0"
3
3
  RUBY_VERSION = "2.7.0"
4
- RAILS_VERSION = "~> 6.0.2"
4
+ RAILS_VERSION = "~> 6.1.4.4"
5
5
  RUBOCOP_VERSION = "~> 1.9"
6
6
  RUBOCOP_RSPEC_VERSION = "~> 2.2"
7
7
  POSTGRES_VERSION = "11.3"
8
8
  MYSQL_VERSION = "5.7"
9
- NODE_VERSION = "12"
10
- TAILWINDCSS = "npm:@tailwindcss/postcss7-compat"
9
+ NODE_VERSION = "14"
10
+ TAILWINDCSS_VERSION = "^3"
11
+ POSTCSS_VERSION = "^8"
12
+ AUTOPREFIXER_VERSION = "^10"
13
+ VUE_VERSION = "^3"
14
+ VUE_LOADER_VERSION = "^16"
15
+ VUE_TEST_UTILS_VERSION = "^2.0.0-rc.18"
16
+ VUE_JEST_VERSION = "^27.0.0-alpha.1"
11
17
  end
@@ -4,7 +4,7 @@ RSpec.describe "Api" do
4
4
  before :all do
5
5
  drop_dummy_database
6
6
  remove_project_directory
7
- create_dummy_project("api" => :rest)
7
+ create_dummy_project("api" => true)
8
8
  end
9
9
 
10
10
  it "adds power_api related gems to Gemfile" do
@@ -22,4 +22,9 @@ RSpec.describe "Api" do
22
22
  content = IO.read("#{project_path}/app/controllers/api/base_controller.rb")
23
23
  expect(content).to include("Api::BaseController < PowerApi::BaseController")
24
24
  end
25
+
26
+ it "installs internal API mode" do
27
+ content = IO.read("#{project_path}/app/controllers/api/internal/base_controller.rb")
28
+ expect(content).to include("Api::Internal::BaseController < Api::BaseController")
29
+ end
25
30
  end
@@ -12,6 +12,6 @@ RSpec.describe 'CI' do
12
12
  yml_path = "#{project_path}/.circleci/config.yml"
13
13
  content = IO.read(yml_path)
14
14
  expect(File.exist?(yml_path)).to be true
15
- expect(content).to include('circleci/ruby', 'cache', 'rspec', 'reviewdog')
15
+ expect(content).to include('cimg/ruby', 'cache', 'rspec', 'reviewdog')
16
16
  end
17
17
  end
@@ -0,0 +1,43 @@
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
+
27
+ context "with vue" do
28
+ let(:node_modules_file) { IO.read("#{project_path}/package.json") }
29
+
30
+ before(:all) do
31
+ remove_project_directory
32
+ create_dummy_project("front_end" => "vue")
33
+ end
34
+
35
+ it "adds jest coverage configuration" do
36
+ expect(node_modules_file).to include('"collectCoverage": true')
37
+ end
38
+
39
+ it "adds jest text formatter package" do
40
+ expect(node_modules_file).to include('jest-text-formatter')
41
+ end
42
+ end
43
+ end
@@ -32,44 +32,120 @@ RSpec.describe "File Storage" do
32
32
  content = IO.read("#{project_path}/.env.development")
33
33
  expect(content).to include("S3_BUCKET=")
34
34
  end
35
+
36
+ it "does not add vips install step to ci config" do
37
+ content = IO.read("#{project_path}/.circleci/config.yml")
38
+ expect(content).not_to include("Install apt and vips buildpack dependencies")
39
+ end
35
40
  end
36
41
 
37
42
  context "when selecting shrine" do
38
- before :all do
39
- drop_dummy_database
40
- remove_project_directory
41
- create_dummy_project(storage: :shrine)
42
- end
43
+ shared_examples 'common shrine setup' do
44
+ it "adds the aws-sdk-s3, shrine and marcel gems to Gemfile" do
45
+ gemfile_content = IO.read("#{project_path}/Gemfile")
46
+ expect(gemfile_content).to include("gem 'aws-sdk-s3'")
47
+ expect(gemfile_content).to include("gem 'shrine'")
48
+ expect(gemfile_content).to include("gem 'marcel'")
49
+ end
43
50
 
44
- it "adds the aws-sdk-s3, shrine and marcel gems to Gemfile" do
45
- gemfile_content = IO.read("#{project_path}/Gemfile")
46
- expect(gemfile_content).to include("gem 'aws-sdk-s3'")
47
- expect(gemfile_content).to include("gem 'shrine'")
48
- expect(gemfile_content).to include("gem 'marcel'")
49
- end
51
+ it "adds brief to README file" do
52
+ content = IO.read("#{project_path}/README.md")
53
+ expect(content).to include("Shrine")
54
+ end
50
55
 
51
- it "adds brief to README file" do
52
- content = IO.read("#{project_path}/README.md")
53
- expect(content).to include("Shrine")
54
- end
56
+ it "adds shrine initializer" do
57
+ expect(File.exist?("#{project_path}/config/initializers/shrine.rb")).to be true
58
+ end
59
+
60
+ it "adds base_uploader and image_uploader" do
61
+ expect(File.exist?("#{project_path}/app/uploaders/base_uploader.rb")).to be true
62
+ expect(File.exist?("#{project_path}/app/uploaders/image_uploader.rb")).to be true
63
+ end
64
+
65
+ it "adds S3 bucket ENV vars" do
66
+ content = IO.read("#{project_path}/.env.development")
67
+ expect(content).to include("S3_BUCKET=")
68
+ end
69
+
70
+ it "adds filestorage path to gitignore" do
71
+ content = IO.read("#{project_path}/.gitignore")
72
+ expect(content).to include("/public/uploads")
73
+ end
55
74
 
56
- it "adds shrine initializer" do
57
- expect(File.exist?("#{project_path}/config/initializers/shrine.rb")).to be true
75
+ it "adds vips install step to ci config" do
76
+ content = IO.read("#{project_path}/.circleci/config.yml")
77
+ expect(content).to include("Install apt and vips buildpack dependencies")
78
+ end
58
79
  end
59
80
 
60
- it "adds base_uploader and image_uploader" do
61
- expect(File.exist?("#{project_path}/app/uploaders/base_uploader.rb")).to be true
62
- expect(File.exist?("#{project_path}/app/uploaders/image_uploader.rb")).to be true
81
+ context 'with no heroku or api' do
82
+ before :all do
83
+ drop_dummy_database
84
+ remove_project_directory
85
+ create_dummy_project(storage: :shrine)
86
+ end
87
+
88
+ it_behaves_like 'common shrine setup'
89
+
90
+ it 'does not add buildpacks to missing .buildpacks' do
91
+ expect { IO.read("#{project_path}/.buildpacks") }.to raise_error(Errno::ENOENT)
92
+ end
93
+
94
+ it 'does not add Aptfile' do
95
+ expect { IO.read("#{project_path}/Aptfile") }.to raise_error(Errno::ENOENT)
96
+ end
97
+
98
+ it 'does not image_handling_attributes serializer concern' do
99
+ expect do
100
+ IO.read("#{project_path}/app/serializers/concerns/image_handling_attributes.rb")
101
+ end.to raise_error(Errno::ENOENT)
102
+ end
103
+
104
+ it 'does not add base serializer' do
105
+ expect do
106
+ IO.read("#{project_path}/app/serializers/base_serializer.rb")
107
+ end.to raise_error(Errno::ENOENT)
108
+ end
63
109
  end
64
110
 
65
- it "adds S3 bucket ENV vars" do
66
- content = IO.read("#{project_path}/.env.development")
67
- expect(content).to include("S3_BUCKET=")
111
+ context 'with heroku' do
112
+ before :all do
113
+ drop_dummy_database
114
+ remove_project_directory
115
+ create_dummy_project(storage: :shrine, heroku: true)
116
+ end
117
+
118
+ it_behaves_like 'common shrine setup'
119
+
120
+ it 'adds buildpacks .buildpacks' do
121
+ content = IO.read("#{project_path}/.buildpacks")
122
+ expect(content).to include("heroku-buildpack-apt")
123
+ expect(content).to include("heroku-buildpack-vips")
124
+ end
125
+
126
+ it 'adds Aptfile' do
127
+ expect(File.exist?("#{project_path}/Aptfile")).to be(true)
128
+ end
68
129
  end
69
130
 
70
- it "adds filestorage path to gitignore" do
71
- content = IO.read("#{project_path}/.gitignore")
72
- expect(content).to include("/public/uploads")
131
+ context 'with api' do
132
+ before :all do
133
+ drop_dummy_database
134
+ remove_project_directory
135
+ create_dummy_project(storage: :shrine, api: true)
136
+ end
137
+
138
+ it_behaves_like 'common shrine setup'
139
+
140
+ it 'adds image_handling_attributes serializer concern' do
141
+ expect(
142
+ File.exist?("#{project_path}/app/serializers/concerns/image_handling_attributes.rb")
143
+ ).to be(true)
144
+ end
145
+
146
+ it 'adds base serializer' do
147
+ expect(File.exist?("#{project_path}/app/serializers/base_serializer.rb")).to be(true)
148
+ end
73
149
  end
74
150
  end
75
151
  end
@@ -9,7 +9,7 @@ RSpec.describe "Front end" do
9
9
  let(:application_css_path) { "#{project_path}/app/javascript/css/application.css" }
10
10
  let(:gemfile) { IO.read("#{project_path}/Gemfile") }
11
11
  let(:node_modules_file) { IO.read("#{project_path}/package.json") }
12
- let(:application_js_file) { IO.read("#{project_path}/app/javascript/packs/application.js") }
12
+ let(:application_js_file) { IO.read("#{project_path}/app/javascript/application.js") }
13
13
  let(:layout_file) { IO.read("#{project_path}/app/views/layouts/application.html.erb") }
14
14
  let(:application_css_file) { IO.read(application_css_path) }
15
15
  let(:tailwind_config_file) { IO.read("#{project_path}/tailwind.config.js") }
@@ -18,14 +18,13 @@ RSpec.describe "Front end" do
18
18
  it "creates a project without a front end framework" do
19
19
  remove_project_directory
20
20
  create_dummy_project("front_end" => "None")
21
- expect(gemfile).to include('webpacker')
22
- expect(File).not_to exist(application_css_path)
21
+ expect(gemfile).to include('shakapacker')
23
22
  end
24
23
 
25
- def expect_to_have_tailwind_compatibility_build
26
- expect(node_modules_file).to include("\"tailwindcss\": \"npm:@tailwindcss/postcss7-compat\"")
27
- expect(node_modules_file).to include("\"autoprefixer\": \"^9\"")
28
- expect(node_modules_file).to include("\"postcss\": \"^7\"")
24
+ def expect_to_have_tailwind_package_versions
25
+ expect(node_modules_file).to include("\"tailwindcss\": \"^3\"")
26
+ expect(node_modules_file).to include("\"autoprefixer\": \"^10\"")
27
+ expect(node_modules_file).to include("\"postcss\": \"^8\"")
29
28
  end
30
29
 
31
30
  context "with vue" do
@@ -34,11 +33,11 @@ RSpec.describe "Front end" do
34
33
  create_dummy_project("front_end" => "vue")
35
34
  end
36
35
 
37
- it "creates a project with vue in compiler mode as frontend framework" do
38
- expect(gemfile).to include('webpacker')
36
+ it "creates a project with vue as frontend framework" do
37
+ expect(gemfile).to include('shakapacker')
39
38
  expect(node_modules_file).to include("\"vue\"")
40
- expect(application_js_file).to include('vue/dist/vue.esm')
41
- expect(application_js_file).to include("el: '#vue-app'")
39
+ expect(application_js_file).to include('vue')
40
+ expect(application_js_file).to include("app.mount('#vue-app')")
42
41
  expect(layout_file).to include('id="vue-app"')
43
42
  end
44
43
 
@@ -47,7 +46,7 @@ RSpec.describe "Front end" do
47
46
  end
48
47
 
49
48
  it "creates a vue project with client css" do
50
- expect(application_js_file).to include("import '../css/application.css';")
49
+ expect(application_js_file).to include("import './css/application.css';")
51
50
  expect(layout_file).to include("<%= stylesheet_pack_tag 'application' %>")
52
51
  expect(rails_css_file).not_to include('*= require_tree', '*= require_self')
53
52
  end
@@ -55,48 +54,18 @@ RSpec.describe "Front end" do
55
54
  it "creates a vue project with tailwindcss" do
56
55
  expect(node_modules_file).to include("\"tailwindcss\"")
57
56
  expect(application_css_file).to include(
58
- "@import 'tailwindcss/base';",
59
- "@import 'tailwindcss/components';"
57
+ "@tailwind base;",
58
+ "@tailwind components;"
60
59
  )
61
60
  expect(tailwind_config_file).to include('module.exports')
62
61
  end
63
62
 
64
63
  it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
65
- expect_to_have_tailwind_compatibility_build
64
+ expect_to_have_tailwind_package_versions
66
65
  end
67
66
 
68
- context "with graphql" do
69
- before(:all) do
70
- remove_project_directory
71
- create_dummy_project("front_end" => "vue", "api" => "graphql")
72
- end
73
-
74
- it "creates a vue project with apollo" do
75
- expect(node_modules_file).to include("\"vue-apollo\"")
76
- expect(application_js_file).to include("import { ApolloClient } from 'apollo-client';")
77
- expect(application_js_file).to include("Vue.use(VueApollo)")
78
- expect(application_js_file).to include("apolloProvider,")
79
- end
80
- end
81
- end
82
-
83
- context "with angular" do
84
- before(:all) do
85
- remove_project_directory
86
- create_dummy_project("front_end" => "angular")
87
- end
88
-
89
- it "creates a project without vue as front end framework" do
90
- expect(gemfile).to include('webpacker')
91
- expect(node_modules_file).to include("\"@angular/core\"")
92
- end
93
-
94
- it "creates application_js_file for tailwind without vue" do
95
- expect(application_js_file).to include("import '../css/application.css';")
96
- end
97
-
98
- it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
99
- expect_to_have_tailwind_compatibility_build
67
+ it 'includes correct version of vue-loader in package' do
68
+ expect(node_modules_file).to include("\"vue-loader\": \"#{Potassium::VUE_LOADER_VERSION}\"")
100
69
  end
101
70
  end
102
71
  end
@@ -31,29 +31,6 @@ RSpec.describe "Google Tag Manager" do
31
31
 
32
32
  it 'add content security policy' do
33
33
  expect(content_security_policy_file)
34
- .to include(content_security_policy_code)
35
- end
36
-
37
- def content_security_policy_code
38
- <<~HERE
39
- Rails.application.config.content_security_policy do |policy|
40
- if Rails.env.development?
41
- policy.connect_src :self, :https, 'http://localhost:3035', 'ws://localhost:3035'
42
- policy.script_src :self, :https, :unsafe_eval
43
- else
44
- policy.script_src :self, :https
45
- # google tag manager requires to enable unsafe inline:
46
- # https://developers.google.com/tag-manager/web/csp
47
- policy.connect_src :self, :https, 'https://www.google-analytics.com'
48
- policy.script_src :self,
49
- :https,
50
- :unsafe_inline,
51
- 'https://www.googletagmanager.com',
52
- 'https://www.google-analytics.com',
53
- 'https://ssl.google-analytics.com'
54
- policy.img_src :self, :https, 'https://www.googletagmanager.com', 'https://www.google-analytics.com'
55
- end
56
- end
57
- HERE
34
+ .to include("\nRails.application.config.content_security_policy do |policy|")
58
35
  end
59
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