From 258eb6b80e5fc8a4c9b64bd1c8ecdc61b2578a38 Mon Sep 17 00:00:00 2001 From: Ryan Kulp Date: Mon, 9 Oct 2023 21:54:43 -0400 Subject: [PATCH 1/5] stub github actions CI --- .github/dependabot.yml | 10 ++++++++ .github/workflows/ci.yml | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..75bc9cd6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "bundler" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..23362d4f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: Tests + +on: + pull_request: + branches: + - '*' + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + ports: ['5432:5432'] + redis: + image: redis + ports: ['6379:6379'] + options: --entrypoint redis-server + + steps: + - uses: actions/checkout@v3 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler: default + bundler-cache: true + + - name: Precompile assets + run: RAILS_ENV=test bundle exec rake assets:precompile + + - name: Use sample application.yml file + run: mv config/application-sample.yml config/application.yml + + # - name: Rubocop Check + # run: bundle exec rubocop + + - name: Run tests + env: + DATABASE_URL: postgres://postgres:password@localhost:5432/test + REDIS_URL: redis://localhost:6379/0 + RAILS_ENV: test + PG_USER: postgres + run: | + bundle exec rails db:drop db:create db:schema:load RAILS_ENV=test + bundle exec rspec spec/ From 8e88435f08c1d41245eee3b91315428f1e408bb4 Mon Sep 17 00:00:00 2001 From: Ryan Kulp Date: Mon, 9 Oct 2023 21:56:47 -0400 Subject: [PATCH 2/5] add linux platform for GitHub CI, stub Rubocop --- Gemfile | 5 +++++ Gemfile.lock | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/Gemfile b/Gemfile index fd649404..a87515cb 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,11 @@ gem 'bootsnap', require: false group :development, :test do gem 'debug', platforms: %i[ mri mingw x64_mingw ] + gem 'rubocop', require: false # code styling + gem 'rubocop-capybara', require: false + gem 'rubocop-factory_bot', require: false + gem 'rubocop-rails', require: false + gem 'rubocop-rspec', require: false end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 9052bb81..d48b4f5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -92,6 +92,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) base64 (0.1.1) bcrypt (3.1.19) bigdecimal (3.1.4) @@ -156,6 +157,7 @@ GEM actionview (>= 5.0.0) activesupport (>= 5.0.0) json (2.6.3) + language_server-protocol (3.17.0.3) launchy (2.5.2) addressable (~> 2.8) letter_opener (1.8.1) @@ -189,7 +191,13 @@ GEM nio4r (2.5.9) nokogiri (1.15.4-x86_64-darwin) racc (~> 1.4) + nokogiri (1.15.4-x86_64-linux) + racc (~> 1.4) orm_adapter (0.5.0) + parallel (1.23.0) + parser (3.2.2.4) + ast (~> 2.4.1) + racc pg (1.5.4) postmark (1.24.1) json @@ -241,6 +249,7 @@ GEM rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) + rainbow (3.1.1) rake (13.0.6) rdoc (6.5.0) psych (>= 4.0.0) @@ -272,6 +281,33 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.1) + rubocop (1.56.4) + base64 (~> 0.1.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.19.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.24.0) + rubocop (~> 1.33) + rubocop-rails (2.21.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + rubocop-rspec (2.24.1) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) selenium-webdriver (4.10.0) @@ -295,6 +331,8 @@ GEM stripe (9.4.0) tailwindcss-rails (2.0.30-x86_64-darwin) railties (>= 6.0.0) + tailwindcss-rails (2.0.30-x86_64-linux) + railties (>= 6.0.0) thor (1.2.2) timeout (0.4.0) turbo-rails (1.4.0) @@ -303,6 +341,7 @@ GEM railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -325,6 +364,7 @@ GEM PLATFORMS x86_64-darwin-21 + x86_64-linux DEPENDENCIES bootsnap @@ -350,6 +390,11 @@ DEPENDENCIES redis rename (= 1.1.3)! rspec-rails (= 6.0.3) + rubocop + rubocop-capybara + rubocop-factory_bot + rubocop-rails + rubocop-rspec selenium-webdriver shoulda-callback-matchers shoulda-matchers From 2452fc2be70a15d65cd7313505caaa4658aba243 Mon Sep 17 00:00:00 2001 From: Ryan Kulp Date: Mon, 9 Oct 2023 22:04:11 -0400 Subject: [PATCH 3/5] require and run capybara + webdrivers in test env --- spec/spec_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a0d40805..3818a921 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,15 @@ +require 'capybara' +server_port = 3055 +Capybara.server_port = server_port +require 'webdrivers/chromedriver' +require 'webdrivers/geckodriver' +require 'selenium/webdriver' + +# https://github.com/teamcapybara/capybara#selenium +driver = :selenium_headless +driver = :selenium if ENV['HEADED'] == 'TRUE' +Capybara.default_driver = Capybara.javascript_driver = driver + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause From 4f7a80513eb2a2450801049bad5ce6fbe8b8a1e2 Mon Sep 17 00:00:00 2001 From: Ryan Kulp Date: Mon, 9 Oct 2023 22:10:06 -0400 Subject: [PATCH 4/5] enable rubocop --- .github/workflows/ci.yml | 4 +- .rubocop.yml | 98 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 .rubocop.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23362d4f..4208d4dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: - name: Use sample application.yml file run: mv config/application-sample.yml config/application.yml - # - name: Rubocop Check - # run: bundle exec rubocop + - name: Rubocop Check + run: bundle exec rubocop - name: Run tests env: diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..40f9d8ec --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,98 @@ +inherit_mode: + merge: + - Exclude + +AllCops: + TargetRubyVersion: 3.2 + DisplayCopNames: true + Exclude: + - bin/* + - tmp/**/* + - db/schema.rb + - vendor/*/** + SuggestExtensions: + rubocop-capybara: true + rubocop-factory_bot: true + rubocop-rails: true + rubocop-rspec: true + + +Layout/EmptyLinesAroundClassBody: + Enabled: false + +Layout/HashAlignment: + Enabled: true + +Lint/ConstantDefinitionInBlock: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Naming/VariableNumber: + Enabled: false + +Naming/MemoizedInstanceVariableName: + Enabled: false + +Style/ClassAndModuleChildren: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/GuardClause: + Enabled: false + +Style/HashSyntax: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/NumericLiterals: + Enabled: false + +Style/RedundantFreeze: + Enabled: false + +Style/RedundantSelf: + Enabled: false + +Style/StringLiterals: + Enabled: false + +Style/SymbolArray: + Enabled: false + +Style/WordArray: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false + +Metrics/CyclomaticComplexity: + Max: 20 + +Metrics/MethodLength: + Max: 60 + +Metrics/BlockLength: + Enabled: false + +Metrics/AbcSize: + Max: 50 + +Metrics/PerceivedComplexity: + Max: 20 + +Layout/LineLength: + Severity: warning + Max: 250 + +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +# Global variable is the only way to subscribe for more tickers in the websocket connection between Rails <-> Polygon +Style/GlobalVars: + Enabled: false From 9ef59cbf8166d68d531360431fa864cba0b71942 Mon Sep 17 00:00:00 2001 From: Ryan Kulp Date: Mon, 9 Oct 2023 22:10:28 -0400 Subject: [PATCH 5/5] rubocop fixes --- Gemfile | 46 +++++----- app/controllers/account_controller.rb | 3 +- app/controllers/admin/users_controller.rb | 3 +- app/controllers/application_controller.rb | 5 +- app/controllers/dashboard_controller.rb | 3 +- app/controllers/pages_controller.rb | 5 +- app/controllers/subscribe_controller.rb | 3 +- app/mailers/application_mailer.rb | 4 +- app/models/concerns/signupable.rb | 2 +- config/application.rb | 5 +- config/environments/production.rb | 8 +- .../initializers/filter_parameter_logging.rb | 4 +- config/puma.rb | 4 +- config/routes.rb | 8 +- ..._to_active_storage_blobs.active_storage.rb | 2 +- ..._storage_variant_records.active_storage.rb | 21 +++-- lib/tasks/scheduler.rake | 1 + spec/spec_helper.rb | 92 +++++++++---------- 18 files changed, 106 insertions(+), 113 deletions(-) diff --git a/Gemfile b/Gemfile index a87515cb..943b7fd3 100644 --- a/Gemfile +++ b/Gemfile @@ -3,36 +3,36 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.2.0' -gem 'rails', '7.1.0' -gem 'sprockets-rails' -gem 'pg' -gem 'puma', '6' +gem 'chartkick' +gem 'delayed' # delayed_job_active_record rails 7 fork: https://github.com/betterment/delayed +gem 'devise' +gem 'figaro', git: 'https://github.com/ryanckulp/figaro' # patched version for Ruby 3.2.0 File.exist?() +gem 'groupdate' # used by Chartkick +gem 'httparty' gem 'importmap-rails' -gem 'turbo-rails' -gem 'stimulus-rails' -gem 'tailwindcss-rails' gem 'jbuilder' -gem 'redis' -gem 'httparty' -gem 'figaro', git: 'https://github.com/ryanckulp/figaro' # patched version for Ruby 3.2.0 File.exist?() -gem 'rename', '1.1.3', git: 'https://github.com/ryanckulp/rename' # remove this gem after use -gem 'delayed' # delayed_job_active_record rails 7 fork: https://github.com/betterment/delayed gem 'metamagic' # easily insert metatags for SEO / opengraph -gem 'rack-cors', :require => 'rack/cors' +gem 'pg' gem 'postmark-rails' -gem 'devise' +gem 'puma', '6' +gem 'rack-cors', :require => 'rack/cors' +gem 'rails', '7.1.0' +gem 'redis' +gem 'rename', '1.1.3', git: 'https://github.com/ryanckulp/rename' # remove this gem after use +gem 'sprockets-rails' +gem 'stimulus-rails' gem 'stripe' -gem 'chartkick' -gem 'groupdate' # used by Chartkick +gem 'tailwindcss-rails' +gem 'turbo-rails' # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: %i[ mingw mswin x64_mingw jruby ] +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', require: false group :development, :test do - gem 'debug', platforms: %i[ mri mingw x64_mingw ] + gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'rubocop', require: false # code styling gem 'rubocop-capybara', require: false gem 'rubocop-factory_bot', require: false @@ -41,17 +41,17 @@ group :development, :test do end group :development do - gem 'web-console' gem 'letter_opener' # view mailers in browser + gem 'web-console' end group :test do gem 'capybara' - gem 'selenium-webdriver' - gem 'webdrivers' - gem 'rspec-rails', '6.0.3' gem 'factory_bot_rails' + gem 'faker' + gem 'rspec-rails', '6.0.3' + gem 'selenium-webdriver' gem 'shoulda-callback-matchers' gem 'shoulda-matchers' - gem 'faker' + gem 'webdrivers' end diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 24608fd8..28abbd2f 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -2,8 +2,7 @@ class AccountController < ApplicationController before_action :authenticate_user! before_action :set_flashes - def index - end + def index; end def update current_user.update(account_update_params) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 94c827d4..60421eb8 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -2,8 +2,7 @@ class Admin::UsersController < ApplicationController before_action :authenticate_user! before_action :set_user - def edit - end + def edit; end def update @user.update(user_params) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1cad9c9f..36bba8b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,15 +4,12 @@ class ApplicationController < ActionController::Base def after_sign_in_path_for(resource) resource.paying_customer? ? dashboard_index_path : subscribe_index_path # point these wherever you want - end + end def maybe_skip_onboarding redirect_to dashboard_index_path, notice: "You're already subscribed" if current_user.finished_onboarding? end - - protected - # whitelist extra User model params by uncommenting below and adding User attrs as keys # def configure_permitted_parameters # devise_parameter_sanitizer.permit(:sign_up, keys: [:username]) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 80a517cb..c971f8ee 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -2,8 +2,7 @@ class DashboardController < ApplicationController before_action :authenticate_user! before_action :set_flashes - def index - end + def index; end private diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index feed2473..cc4297a1 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,8 +1,7 @@ class PagesController < ApplicationController before_action :authenticate_user!, only: [:logout] - def home - end + def home; end def logout sign_out(current_user) @@ -10,7 +9,7 @@ def logout end def page - @page_key = request.path[1..-1] + @page_key = request.path[1..] render "pages/#{@page_key}" end end diff --git a/app/controllers/subscribe_controller.rb b/app/controllers/subscribe_controller.rb index 820d8f81..bb36321e 100644 --- a/app/controllers/subscribe_controller.rb +++ b/app/controllers/subscribe_controller.rb @@ -2,6 +2,5 @@ class SubscribeController < ApplicationController before_action :authenticate_user! before_action :maybe_skip_onboarding - def index - end + def index; end end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 527c47c0..523f6215 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -2,8 +2,10 @@ class ApplicationMailer < ActionMailer::Base layout 'mailer' default from: '"Support Team" ' - # mailer views live in views/mailers + # rubocop:disable Lint/MissingSuper def self.inherited(subclass) + # lets mailer views live in views/mailers, much cleaner subclass.default template_path: "mailers/#{subclass.name.to_s.underscore}" end + # rubocop:enable Lint/MissingSuper end diff --git a/app/models/concerns/signupable.rb b/app/models/concerns/signupable.rb index 13dada4c..5561c660 100644 --- a/app/models/concerns/signupable.rb +++ b/app/models/concerns/signupable.rb @@ -6,7 +6,7 @@ module Signupable # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable # devise :database_authenticatable, :registerable, :recoverable, :rememberable # validates :email, uniqueness: { case_sensitive: false }, presence: true - + devise :database_authenticatable, :registerable, :recoverable, :rememberable validates :email, uniqueness: { case_sensitive: false }, presence: true end diff --git a/config/application.rb b/config/application.rb index ef1f1cab..cf4dec8b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,8 +14,7 @@ class Application < Rails::Application # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w(assets tasks)) - + config.autoload_lib(ignore: %w[assets tasks]) # allow cross origin requests config.middleware.insert_before 0, Rack::Cors do @@ -39,7 +38,7 @@ class Application < Rails::Application # customize generators config.generators do |g| - g.test_framework :rspec, :fixture => false + g.test_framework :rspec, :fixture => false g.fixture_replacement :factory_bot, dir: 'spec/factories' g.view_specs = false g.helper_specs = false diff --git a/config/environments/production.rb b/config/environments/production.rb index 13ea4401..e4695b74 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -52,12 +52,12 @@ config.force_ssl = true # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + config.logger = ActiveSupport::Logger.new($stdout) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Info include generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 41551f64..c2d89e28 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. -# Use this to limit dissemination of sensitive information. +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn diff --git a/config/puma.rb b/config/puma.rb index daaf0369..ce4878f4 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,7 +4,7 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count @@ -15,7 +15,7 @@ # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT", 3000) # Specifies the `environment` that Puma will run in. # diff --git a/config/routes.rb b/config/routes.rb index d0ec73f6..9abb988c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,16 +12,16 @@ match '/cancel' => 'billing_portal#destroy', via: [:get] # static pages - pages = %w( + pages = %w[ privacy terms - ) + ] pages.each do |page| - get "/#{page}", to: "pages##{page}", as: "#{page.gsub('-', '_')}" + get "/#{page}", to: "pages##{page}", as: page.gsub('-', '_').to_s end # admin panels - authenticated :user, -> user { user.admin? } do + authenticated :user, ->(user) { user.admin? } do namespace :admin do resources :dashboard, only: [:index] resources :impersonations, only: [:new] diff --git a/db/migrate/20231009160056_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20231009160056_add_service_name_to_active_storage_blobs.active_storage.rb index a15c6ce8..0267f128 100644 --- a/db/migrate/20231009160056_add_service_name_to_active_storage_blobs.active_storage.rb +++ b/db/migrate/20231009160056_add_service_name_to_active_storage_blobs.active_storage.rb @@ -6,7 +6,7 @@ def up unless column_exists?(:active_storage_blobs, :service_name) add_column :active_storage_blobs, :service_name, :string - if configured_service = ActiveStorage::Blob.service.name + if (configured_service = ActiveStorage::Blob.service.name) ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) end diff --git a/db/migrate/20231009160057_create_active_storage_variant_records.active_storage.rb b/db/migrate/20231009160057_create_active_storage_variant_records.active_storage.rb index 94ac83af..95fd27fa 100644 --- a/db/migrate/20231009160057_create_active_storage_variant_records.active_storage.rb +++ b/db/migrate/20231009160057_create_active_storage_variant_records.active_storage.rb @@ -8,20 +8,21 @@ def change t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type t.string :variation_digest, null: false - t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true t.foreign_key :active_storage_blobs, column: :blob_id end end private - def primary_key_type - config = Rails.configuration.generators - config.options[config.orm][:primary_key_type] || :primary_key - end - def blobs_primary_key_type - pkey_name = connection.primary_key(:active_storage_blobs) - pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } - pkey_column.bigint? ? :bigint : pkey_column.type - end + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end end diff --git a/lib/tasks/scheduler.rake b/lib/tasks/scheduler.rake index 3b60f6a3..f2b3e79b 100644 --- a/lib/tasks/scheduler.rake +++ b/lib/tasks/scheduler.rake @@ -6,6 +6,7 @@ end task :reminder_to_start_trial => :environment do User.where(created_at: 24.hours.ago..23.hours.ago).each do |user| next if user.paying_customer? + UserMailer.reminder_to_start_trial(user).deliver_later end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3818a921..5fdb6e24 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -56,51 +56,49 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end