welaika-suspenders 2.28.0 → 2.29.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -1
  4. data/CONTRIBUTING.md +8 -3
  5. data/NEWS.md +35 -0
  6. data/README.md +1 -1
  7. data/RELEASING.md +6 -7
  8. data/Rakefile +1 -1
  9. data/diff_suspenders.sh +15 -0
  10. data/lib/suspenders.rb +21 -8
  11. data/lib/suspenders/actions.rb +55 -8
  12. data/lib/suspenders/app_builder.rb +20 -191
  13. data/lib/suspenders/generators/app_generator.rb +26 -55
  14. data/lib/suspenders/generators/ci_generator.rb +22 -0
  15. data/lib/suspenders/generators/db_optimizations_generator.rb +30 -0
  16. data/lib/suspenders/generators/decorator_generator.rb +19 -0
  17. data/lib/suspenders/generators/error_reporting_generator.rb +55 -0
  18. data/lib/suspenders/generators/factories_generator.rb +23 -0
  19. data/lib/suspenders/generators/faker_generator.rb +19 -0
  20. data/lib/suspenders/generators/forms_generator.rb +18 -0
  21. data/lib/suspenders/generators/js_driver_generator.rb +20 -0
  22. data/lib/suspenders/generators/lint_generator.rb +35 -0
  23. data/lib/suspenders/generators/production/email_generator.rb +45 -0
  24. data/lib/suspenders/generators/production/force_tls_generator.rb +14 -0
  25. data/lib/suspenders/generators/production/timeout_generator.rb +21 -0
  26. data/lib/suspenders/generators/security_generator.rb +29 -0
  27. data/lib/suspenders/generators/testing_generator.rb +72 -0
  28. data/lib/suspenders/generators/views_generator.rb +44 -0
  29. data/lib/suspenders/version.rb +2 -2
  30. data/spec/features/api_spec.rb +18 -0
  31. data/spec/features/new_project_spec.rb +9 -21
  32. data/spec/features/production/email_spec.rb +47 -0
  33. data/spec/support/contain_json_matcher.rb +24 -0
  34. data/spec/support/exist_as_a_file_matcher.rb +7 -0
  35. data/spec/support/match_contents_matcher.rb +6 -0
  36. data/spec/support/suspenders.rb +113 -30
  37. data/suspenders.gemspec +2 -2
  38. data/templates/Gemfile.erb +8 -31
  39. data/templates/Procfile +1 -1
  40. data/templates/_css_overrides.html.slim +4 -0
  41. data/templates/_javascript.html.slim +3 -3
  42. data/templates/action_mailer.rb +2 -0
  43. data/templates/app.json.erb +0 -15
  44. data/templates/brakeman.rake +2 -0
  45. data/templates/bundler_audit.rake +3 -1
  46. data/templates/capybara_helpers.rb +15 -0
  47. data/templates/chromedriver.rb +20 -0
  48. data/templates/dev.rake +4 -2
  49. data/templates/dotfiles/.env +2 -1
  50. data/templates/email.rb +5 -0
  51. data/templates/errors.rb +2 -0
  52. data/templates/factory_bot_rspec.rb +5 -0
  53. data/templates/faker_rspec.rb +2 -0
  54. data/templates/flashes_helper.rb +2 -0
  55. data/templates/i18n.rb +2 -0
  56. data/templates/json_encoding.rb +2 -0
  57. data/templates/puma.rb +2 -0
  58. data/templates/queries_helper_rspec.rb +2 -0
  59. data/templates/rack_mini_profiler.rb +2 -0
  60. data/templates/rails_helper.rb +11 -1
  61. data/templates/rubocop.rake +2 -0
  62. data/templates/rubocop.yml +2 -22
  63. data/templates/sentry.rb +8 -0
  64. data/templates/shoulda_matchers_config_rspec.rb +2 -0
  65. data/templates/slim-lint.rake +2 -0
  66. data/templates/slim.rb +2 -0
  67. data/templates/smtp.rb +2 -4
  68. data/templates/spec_helper.rb +12 -3
  69. data/templates/suspenders_layout.html.slim +3 -3
  70. metadata +42 -36
  71. data/lib/suspenders/generators/enforce_ssl_generator.rb +0 -12
  72. data/lib/suspenders/generators/initialize_active_job_generator.rb +0 -19
  73. data/templates/_css_overrides.html.erb +0 -7
  74. data/templates/active_job.rb +0 -13
  75. data/templates/capybara.rb +0 -29
  76. data/templates/circle.yml.erb +0 -15
  77. data/templates/database_cleaner_rspec.rb +0 -28
  78. data/templates/errbit.rb +0 -12
  79. data/templates/factories.rb +0 -2
  80. data/templates/factory_girl_rspec.rb +0 -3
  81. data/templates/fixtures_helper_rspec.rb +0 -9
  82. data/templates/sample_service.rb +0 -5
data/suspenders.gemspec CHANGED
@@ -5,6 +5,7 @@ require 'date'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.required_ruby_version = ">= #{Suspenders::RUBY_VERSION}"
8
+ s.required_rubygems_version = ">= 2.7.4"
8
9
  s.authors = ['thoughtbot', 'weLaika']
9
10
  s.date = Date.today.strftime('%Y-%m-%d')
10
11
 
@@ -25,8 +26,7 @@ weLaika's fork of the famous thoughbot suspenders gem.
25
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
27
  s.version = Suspenders::VERSION
27
28
 
28
- s.add_dependency 'bundler', '>= 1.8.4'
29
29
  s.add_dependency 'rails', Suspenders::RAILS_VERSION
30
30
 
31
- s.add_development_dependency 'rspec', '~> 3.6'
31
+ s.add_development_dependency 'rspec', '~> 3.8'
32
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  git_source(:github) do |repo_name|
@@ -7,71 +9,46 @@ end
7
9
 
8
10
  ruby "<%= Suspenders::RUBY_VERSION %>"
9
11
 
10
- gem "bundler", ">= 1.8.4"
11
-
12
- gem "active_interaction", "~> 3.5"
13
- gem "airbrake"
12
+ gem "active_interaction", "~> 3.6"
14
13
  gem "autoprefixer-rails"
15
14
  gem "coffee-rails", "~> 4.2"
16
- gem "delayed_job_active_record"
17
- gem "draper"
18
15
  gem "email_validator"
19
16
  gem "flutie"
20
- gem "pg"
21
- gem "puma", "~> 3.7"
17
+ gem "jquery-rails" #TODO keep it?
18
+ gem "pg", ">= 0.18", "< 2.0"
19
+ gem "puma", "~> 3.11"
22
20
  gem "rack-canonical-host"
23
21
  gem "rails", "<%= Suspenders::RAILS_VERSION %>"
24
22
  gem "rails-i18n"
25
23
  gem "recipient_interceptor"
26
24
  gem "sass-rails", "~> 5.0"
27
- gem "simple_form"
28
- gem "skylight"
29
- gem "slim-rails"
30
25
  gem "title"
31
26
  gem "uglifier", ">= 1.3.0"
27
+ gem "bootsnap", ">= 1.1.0", require: false
32
28
  <% if options[:webpack] %>
33
29
  gem "webpacker"
34
30
  <% end %>
35
- gem "welaika-suspenders"
36
31
 
37
32
  group :development do
38
33
  gem "letter_opener"
39
34
  gem "listen", ">= 3.0.5", "< 3.2"
40
35
  gem "rack-mini-profiler", require: false
41
36
  gem "spring"
42
- gem "spring-commands-rspec"
43
- gem "spring-watcher-listen", "~> 2.0.0"
44
37
  gem "web-console", ">= 3.3.0"
45
38
  end
46
39
 
47
40
  group :development, :test do
48
41
  gem "awesome_print"
49
- gem "brakeman", require: false
50
- gem "bullet"
51
- gem "bundler-audit", ">= 0.5.0", require: false
52
42
  gem "dotenv-rails"
53
- gem "factory_girl_rails"
54
- gem "faker"
55
43
  gem "pry-byebug"
56
44
  gem "pry-rails"
57
- gem "rspec-rails", "~> 3.6"
58
- gem "rspec_junit_formatter"
59
- gem "rubocop", require: false
60
- gem "rubocop-rspec", require: false
61
- gem "slim_lint", require: false
62
45
  end
63
46
 
64
47
  group :test do
65
- gem "capybara"
66
- gem "database_cleaner"
67
48
  gem "launchy"
68
- gem "selenium-webdriver"
69
- gem "shoulda-matchers"
70
49
  gem "simplecov", require: false
71
50
  gem "timecop"
72
51
  gem "webmock"
73
52
  end
74
53
 
75
- group :production do
76
- gem "rack-timeout"
77
- end
54
+ gem "welaika-suspenders", "~> <%= Suspenders::VERSION %>", group: [:development, :test]
data/templates/Procfile CHANGED
@@ -1,2 +1,2 @@
1
1
  web: bundle exec puma -p $PORT -C ./config/puma.rb
2
- worker: bundle exec rails jobs:work
2
+ # worker:
@@ -0,0 +1,4 @@
1
+ - if Rails.env.test?
2
+ sass:
3
+ *
4
+ transition-property: none !important
@@ -3,6 +3,6 @@
3
3
  = yield :javascript
4
4
 
5
5
  - if Rails.env.test?
6
- javascript:
7
- $.fx.off = true;
8
- $.ajaxSetup({ async: false });
6
+ coffee:
7
+ $.fx.off = true
8
+ $.ajaxSetup(async: false)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.before do
3
5
  ActionMailer::Base.deliveries.clear
@@ -19,21 +19,6 @@
19
19
  },
20
20
  "SECRET_KEY_BASE":{
21
21
  "generator":"secret"
22
- },
23
- "SMTP_ADDRESS":{
24
- "required":true
25
- },
26
- "SMTP_DOMAIN":{
27
- "required":true
28
- },
29
- "SMTP_PASSWORD":{
30
- "required":true
31
- },
32
- "SMTP_USERNAME":{
33
- "required":true
34
- },
35
- "ERRBIT_API_KEY":{
36
- "required":true
37
22
  }
38
23
  },
39
24
  "addons":[
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if Rails.env.development? || Rails.env.test?
2
4
  namespace :brakeman do
3
5
  desc 'Run Brakeman'
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if Rails.env.development? || Rails.env.test?
2
- require "bundler/audit/task"
4
+ require 'bundler/audit/task'
3
5
  Bundler::Audit::Task.new
4
6
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CapybaraHelpers
4
+ def page!
5
+ save_and_open_page
6
+ end
7
+
8
+ def screenshot!
9
+ save_and_open_screenshot
10
+ end
11
+ end
12
+
13
+ RSpec.configure do |config|
14
+ config.include CapybaraHelpers, type: :feature
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "selenium/webdriver"
4
+
5
+ Capybara.register_driver :chrome do |app|
6
+ Capybara::Selenium::Driver.new(app, browser: :chrome)
7
+ end
8
+
9
+ Capybara.register_driver :headless_chrome do |app|
10
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
11
+ chromeOptions: { args: %w(headless disable-gpu) },
12
+ )
13
+
14
+ Capybara::Selenium::Driver.new app,
15
+ browser: :chrome,
16
+ desired_capabilities: capabilities
17
+ end
18
+
19
+ Capybara.javascript_driver = :headless_chrome
20
+ Capybara.asset_host = 'http://localhost:3000'
data/templates/dev.rake CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if Rails.env.development? || Rails.env.test?
2
- require 'factory_girl'
4
+ require 'factory_bot'
3
5
 
4
6
  namespace :dev do
5
7
  desc 'Sample data for local development environment'
6
8
  task prime: 'db:setup' do
7
- include FactoryGirl::Syntax::Methods
9
+ include FactoryBot::Syntax::Methods
8
10
 
9
11
  # create(:user, email: 'user@example.com', password: 'password')
10
12
  end
@@ -11,4 +11,5 @@ SMTP_DOMAIN=example.com
11
11
  SMTP_PASSWORD=password
12
12
  SMTP_USERNAME=username
13
13
  WEB_CONCURRENCY=1
14
- ERRBIT_API_KEY=
14
+ SENTRY_DSN=
15
+ SENTRY_CURRENT_ENV=
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ if ENV["EMAIL_RECIPIENTS"].present?
4
+ Mail.register_interceptor RecipientInterceptor.new(ENV["EMAIL_RECIPIENTS"])
5
+ end
data/templates/errors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "net/http"
2
4
  require "net/smtp"
3
5
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.include FactoryBot::Syntax::Methods
5
+ end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Faker::Config.locale = 'it'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FlashesHelper
2
4
  def user_facing_flashes
3
5
  flash.to_hash.slice('alert', 'error', 'notice', 'success')
data/templates/i18n.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.include ActionView::Helpers::TranslationHelper
3
5
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveSupport::JSON::Encoding.time_precision = 0
data/templates/puma.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server
2
4
 
3
5
  # The environment variable WEB_CONCURRENCY may be set to a default value based
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module QueriesHelper
2
4
  def log_queries!
3
5
  ActiveRecord::Base.logger = Logger.new(STDOUT)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if ENV["RACK_MINI_PROFILER"].to_i > 0
2
4
  require "rack-mini-profiler"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ENV['RACK_ENV'] = 'test'
2
4
 
3
5
  require File.expand_path('../../config/environment', __FILE__)
@@ -7,13 +9,21 @@ require 'rspec/rails'
7
9
 
8
10
  Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |file| require file }
9
11
 
12
+ begin
13
+ ActiveRecord::Migration.maintain_test_schema!
14
+ rescue ActiveRecord::PendingMigrationError => e
15
+ puts e.to_s.strip
16
+ exit 1
17
+ end
18
+
10
19
  RSpec.configure do |config|
20
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
11
21
  config.infer_base_class_for_anonymous_controllers = false
12
22
  config.infer_spec_type_from_file_location!
23
+ config.use_transactional_fixtures = true
13
24
 
14
25
  config.filter_rails_from_backtrace!
15
26
  # arbitrary gems may also be filtered via:
16
27
  # config.filter_gems_from_backtrace('gem name')
17
28
  end
18
29
 
19
- ActiveRecord::Migration.maintain_test_schema!
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if Rails.env.development? || Rails.env.test?
2
4
  require 'rubocop/rake_task'
3
5
 
@@ -2,7 +2,7 @@ require: rubocop-rspec
2
2
  inherit_from: .rubocop_todo.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.4
5
+ DisplayCopNames: true
6
6
  Exclude:
7
7
  - 'bin/*'
8
8
  - 'config/**/*'
@@ -10,16 +10,9 @@ AllCops:
10
10
  - 'tmp/**/*'
11
11
  - 'vendor/**/*'
12
12
 
13
- Layout/TrailingBlankLines:
14
- Exclude:
15
- - "Gemfile"
16
-
17
13
  Lint/Debugger:
18
14
  Exclude:
19
- - "spec/support/capybara.rb"
20
-
21
- Metrics/AbcSize:
22
- Max: 20
15
+ - 'spec/support/capybara_helpers.rb'
23
16
 
24
17
  Metrics/BlockLength:
25
18
  Exclude:
@@ -30,18 +23,5 @@ Metrics/BlockLength:
30
23
  Metrics/LineLength:
31
24
  Max: 100
32
25
 
33
- Naming/FileName:
34
- Exclude:
35
- - 'app/views/**/*'
36
-
37
26
  Rails:
38
27
  Enabled: true
39
-
40
- Style/Documentation:
41
- Enabled: false
42
-
43
- Style/FrozenStringLiteralComment:
44
- Enabled: false
45
-
46
- Style/StringLiterals:
47
- Enabled: false
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Raven.configure do |config|
4
+ config.dsn = ENV.fetch('SENTRY_DSN')
5
+ config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
6
+ config.environments = %w[ staging production ]
7
+ config.current_environment = ENV.fetch('SENTRY_CURRENT_ENV', Rails.env)
8
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Shoulda::Matchers.configure do |config|
2
4
  config.integrate do |with|
3
5
  with.test_framework :rspec
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if Rails.env.development? || Rails.env.test?
2
4
  require 'slim_lint/rake_task'
3
5
  SlimLint::RakeTask.new do |t|
data/templates/slim.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Slim::Engine.set_options(js_wrapper: :cdata)
data/templates/smtp.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  SMTP_SETTINGS = {
2
4
  address: ENV.fetch("SMTP_ADDRESS"), # example: "smtp.sendgrid.net"
3
5
  authentication: :plain,
@@ -7,7 +9,3 @@ SMTP_SETTINGS = {
7
9
  port: "587",
8
10
  user_name: ENV.fetch("SMTP_USERNAME")
9
11
  }
10
-
11
- if ENV["EMAIL_RECIPIENTS"].present?
12
- Mail.register_interceptor RecipientInterceptor.new(ENV["EMAIL_RECIPIENTS"])
13
- end
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
4
+
2
5
  SimpleCov.start 'rails' do
3
- add_group 'Services', 'app/services'
6
+ # TODO: interactors
7
+ add_group 'Interactions', 'app/interactions'
4
8
  end
5
9
 
6
- # Save to CircleCI's artifacts directory if we're on CircleCI
7
10
  if ENV['CIRCLE_ARTIFACTS']
8
11
  dir = File.join(ENV['CIRCLE_ARTIFACTS'], 'coverage')
9
12
  SimpleCov.coverage_dir(dir)
@@ -15,6 +18,7 @@ require 'timecop'
15
18
  # http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
19
  RSpec.configure do |config|
17
20
  config.expect_with :rspec do |expectations|
21
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
18
22
  expectations.syntax = :expect
19
23
  end
20
24
 
@@ -23,10 +27,15 @@ RSpec.configure do |config|
23
27
  mocks.verify_partial_doubles = true
24
28
  end
25
29
 
30
+ config.default_formatter = 'doc' if config.files_to_run.one?
31
+ config.disable_monkey_patching!
26
32
  config.example_status_persistence_file_path = 'tmp/rspec_examples.txt'
33
+ config.filter_run_when_matching :focus
27
34
  config.order = :random
35
+ config.profile_examples = 10
36
+ config.shared_context_metadata_behavior = :apply_to_host_groups
28
37
 
29
- config.default_formatter = 'doc' if config.files_to_run.one?
38
+ Kernel.srand config.seed
30
39
  end
31
40
 
32
41
  WebMock.disable_net_connect!(allow_localhost: true)