trusty-cms 7.1.3 → 8.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +118 -123
  3. data/config/application.rb +5 -1
  4. data/lib/string_extensions/string_extensions.rb +4 -2
  5. data/lib/trusty_cms/version.rb +1 -1
  6. data/spec/controllers/admin/assets_controller_spec.rb +124 -0
  7. data/spec/controllers/admin/changes_controller_spec.rb +72 -0
  8. data/spec/controllers/admin/configuration_controller_spec.rb +49 -0
  9. data/spec/controllers/admin/page_attachments_controller_spec.rb +54 -0
  10. data/spec/controllers/admin/pages_controller_spec.rb +162 -0
  11. data/spec/controllers/admin/preferences_controller_spec.rb +44 -0
  12. data/spec/controllers/admin/security_controller_spec.rb +85 -0
  13. data/spec/controllers/admin/sessions_controller_spec.rb +56 -0
  14. data/spec/controllers/admin/two_factor_controller_spec.rb +63 -0
  15. data/spec/controllers/admin/users_controller_spec.rb +132 -0
  16. data/spec/controllers/page_status_controller_spec.rb +66 -0
  17. data/spec/dummy/bin/rails +3 -3
  18. data/spec/dummy/bin/rake +2 -2
  19. data/spec/dummy/bin/setup +21 -13
  20. data/spec/dummy/config/application.rb +2 -0
  21. data/spec/dummy/config/boot.rb +1 -1
  22. data/spec/dummy/config/cable.yml +10 -0
  23. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  24. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -2
  25. data/spec/dummy/config/initializers/inflections.rb +4 -4
  26. data/spec/dummy/config/initializers/new_framework_defaults_7_2.rb +70 -0
  27. data/spec/dummy/config/initializers/permissions_policy.rb +13 -0
  28. data/spec/dummy/config/puma.rb +34 -0
  29. data/spec/dummy/config/storage.yml +28 -1
  30. data/spec/dummy/db/migrate/20260729201444_add_service_name_to_active_storage_blobs.active_storage.rb +22 -0
  31. data/spec/dummy/db/migrate/20260729201445_create_active_storage_variant_records.active_storage.rb +27 -0
  32. data/spec/dummy/db/migrate/20260729201446_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +8 -0
  33. data/spec/dummy/public/404.html +6 -6
  34. data/spec/dummy/public/406-unsupported-browser.html +66 -0
  35. data/spec/dummy/public/422.html +6 -6
  36. data/spec/dummy/public/500.html +6 -6
  37. data/spec/dummy/public/icon.png +0 -0
  38. data/spec/dummy/public/icon.svg +3 -0
  39. data/spec/dummy/public/robots.txt +1 -0
  40. data/spec/helpers/admin/configuration_helper_spec.rb +62 -0
  41. data/spec/helpers/admin/node_helper_spec.rb +132 -0
  42. data/spec/helpers/admin/pages_helper_spec.rb +84 -0
  43. data/spec/helpers/application_helper_spec.rb +115 -0
  44. data/spec/lib/string_extensions_spec.rb +41 -0
  45. data/spec/support/active_record_encryption.rb +10 -0
  46. data/spec/support/asset_type_registry.rb +29 -0
  47. data/trusty_cms.gemspec +2 -1
  48. metadata +74 -6
  49. data/spec/controllers/assets_controller.rb +0 -66
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ # Exercises Admin::UsersController, which layers admin-only authorization and
4
+ # several custom overrides (create/update/destroy/disable_2fa, plus the
5
+ # self-protection guards) on top of ResourceController. Devise/2FA touch points
6
+ # make this a useful regression net for a Rails/Ruby upgrade.
7
+ RSpec.describe Admin::UsersController, type: :controller do
8
+ routes { TrustyCms::Application.routes }
9
+
10
+ let(:admin) { create(:admin) }
11
+
12
+ before do
13
+ allow(controller).to receive(:authenticate_user!).and_return(true)
14
+ allow(controller).to receive(:current_user).and_return(admin)
15
+ end
16
+
17
+ def valid_user_params(overrides = {})
18
+ {
19
+ first_name: 'New',
20
+ last_name: 'Person',
21
+ email: 'newperson@example.com',
22
+ password: 'ComplexPass1!',
23
+ password_confirmation: 'ComplexPass1!',
24
+ }.merge(overrides)
25
+ end
26
+
27
+ describe 'GET #index' do
28
+ it 'succeeds for an admin' do
29
+ get :index
30
+ expect(response).to have_http_status(:ok)
31
+ end
32
+ end
33
+
34
+ describe 'GET #new' do
35
+ it 'succeeds' do
36
+ get :new
37
+ expect(response).to have_http_status(:ok)
38
+ end
39
+ end
40
+
41
+ describe 'GET #show' do
42
+ it 'redirects to the edit page' do
43
+ user = create(:user, email: 'showme@example.com')
44
+ get :show, params: { id: user.id }
45
+ expect(response).to redirect_to(edit_admin_user_path(user.id))
46
+ end
47
+ end
48
+
49
+ describe 'POST #create' do
50
+ it 'creates a user and redirects with a notice' do
51
+ expect {
52
+ post :create, params: { user: valid_user_params }
53
+ }.to change(User, :count).by(1)
54
+
55
+ expect(response).to redirect_to(admin_users_path)
56
+ expect(flash[:notice]).to eq('User was created.')
57
+ end
58
+
59
+ it 're-renders new with an error when the user is invalid' do
60
+ expect {
61
+ post :create, params: { user: valid_user_params(email: '') }
62
+ }.not_to change(User, :count)
63
+
64
+ expect(flash[:error]).to match(/error saving the user/)
65
+ end
66
+ end
67
+
68
+ describe 'PUT #update' do
69
+ it 'updates an existing user and redirects' do
70
+ user = create(:user, email: 'editme@example.com')
71
+
72
+ put :update, params: { id: user.id, user: { first_name: 'Renamed' } }
73
+
74
+ expect(response).to be_redirect
75
+ expect(user.reload.first_name).to eq('Renamed')
76
+ end
77
+
78
+ # NOTE: latent bug — the guard compares `user_params['admin'] == false`, but
79
+ # over a real HTTP request the checkbox param arrives as the string 'false',
80
+ # which is != false. So through the normal request path an admin CAN demote
81
+ # themselves and no warning is shown. Characterizing current behavior;
82
+ # revisit if the guard is ever fixed to coerce the param.
83
+ it 'does NOT block self-demotion when admin arrives as the string "false" (bug)' do
84
+ put :update, params: { id: admin.id, user: { admin: 'false' } }
85
+
86
+ expect(admin.reload.admin).to be(false)
87
+ end
88
+ end
89
+
90
+ describe 'DELETE #destroy' do
91
+ it 'destroys another user' do
92
+ user = create(:user, email: 'goner@example.com')
93
+
94
+ expect {
95
+ delete :destroy, params: { id: user.id }
96
+ }.to change(User, :count).by(-1)
97
+ end
98
+
99
+ it 'refuses to let a user delete themselves' do
100
+ expect {
101
+ delete :destroy, params: { id: admin.id }
102
+ }.not_to change(User, :count)
103
+
104
+ expect(response).to redirect_to(admin_users_path)
105
+ expect(flash[:error]).to be_present
106
+ end
107
+ end
108
+
109
+ describe 'PATCH #disable_2fa' do
110
+ it 'clears the OTP settings and redirects' do
111
+ user = create(:user, email: '2fa@example.com', otp_required_for_login: true)
112
+
113
+ patch :disable_2fa, params: { id: user.id }
114
+
115
+ user.reload
116
+ expect(user.otp_required_for_login).to be(false)
117
+ expect(user.otp_secret).to be_nil
118
+ expect(response).to redirect_to(admin_users_path)
119
+ end
120
+ end
121
+
122
+ describe 'authorization' do
123
+ it 'denies a non-admin user' do
124
+ allow(controller).to receive(:current_user).and_return(create(:non_admin, email: 'plain@example.com'))
125
+
126
+ get :index
127
+
128
+ expect(response).to be_redirect
129
+ expect(flash[:error]).to be_present
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ # Exercises PageStatusController#refresh — a token-authenticated, no-CSRF JSON
4
+ # endpoint that publishes scheduled pages whose time has come. Auth is a bearer
5
+ # token compared with secure_compare; cover the reject paths and the publish
6
+ # behaviour.
7
+ RSpec.describe PageStatusController, type: :controller do
8
+ routes { TrustyCms::Application.routes }
9
+ # refresh skips authenticate_user!, but ApplicationController before-actions
10
+ # still read current_user, which needs Warden injected on the request.
11
+ include Devise::Test::ControllerHelpers
12
+
13
+ let(:token) { 'secret-bearer-token' }
14
+
15
+ def authorize!(value = token)
16
+ request.headers['Authorization'] = "Bearer #{value}"
17
+ end
18
+
19
+ before do
20
+ allow(Rails.application.credentials).to receive(:dig)
21
+ .with(:trusty_cms, :page_status_bearer_token).and_return(token)
22
+ end
23
+
24
+ describe 'POST #refresh authentication' do
25
+ it 'returns 401 when no token is provided' do
26
+ post :refresh
27
+ expect(response).to have_http_status(:unauthorized)
28
+ expect(JSON.parse(response.body)['error']).to eq('Missing Bearer Token')
29
+ end
30
+
31
+ it 'returns 401 when the token is wrong' do
32
+ authorize!('nope')
33
+ post :refresh
34
+ expect(response).to have_http_status(:unauthorized)
35
+ expect(JSON.parse(response.body)['error']).to eq('Invalid Bearer Token')
36
+ end
37
+ end
38
+
39
+ describe 'POST #refresh' do
40
+ before { authorize! }
41
+
42
+ it 'publishes scheduled pages whose publish time has passed' do
43
+ due = create(:page, title: 'Due', slug: 'due', status_id: Status[:scheduled].id,
44
+ published_at: 1.day.ago)
45
+
46
+ post :refresh
47
+
48
+ expect(response).to have_http_status(:ok)
49
+ body = JSON.parse(response.body)
50
+ expect(body['updated_page_ids']).to include(due.id)
51
+ expect(due.reload.status_id).to eq(Status[:published].id)
52
+ end
53
+
54
+ it 'leaves future-scheduled pages alone' do
55
+ future = create(:page, title: 'Future', slug: 'future', status_id: Status[:scheduled].id,
56
+ published_at: 1.day.from_now)
57
+
58
+ post :refresh
59
+
60
+ body = JSON.parse(response.body)
61
+ expect(body['remaining_scheduled_page_ids']).to include(future.id)
62
+ expect(body['message']).to match(/No scheduled pages/)
63
+ expect(future.reload.status_id).to eq(Status[:scheduled].id)
64
+ end
65
+ end
66
+ end
data/spec/dummy/bin/rails CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
data/spec/dummy/bin/rake CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
2
+ require_relative "../config/boot"
3
+ require "rake"
4
4
  Rake.application.run
data/spec/dummy/bin/setup CHANGED
@@ -1,29 +1,37 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
2
+ require "fileutils"
3
3
 
4
- # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
4
+ APP_ROOT = File.expand_path("..", __dir__)
5
+ APP_NAME = "trusty-cms"
6
6
 
7
- Dir.chdir APP_ROOT do
8
- # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
7
+ def system!(*args)
8
+ system(*args, exception: true)
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
10
15
 
11
16
  puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
14
19
 
15
20
  # puts "\n== Copying sample files =="
16
21
  # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
18
23
  # end
19
24
 
20
25
  puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
26
+ system! "bin/rails db:prepare"
22
27
 
23
28
  puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
29
+ system! "bin/rails log:clear tmp:clear"
26
30
 
27
31
  puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
32
+ system! "bin/rails restart"
33
+
34
+ # puts "\n== Configuring puma-dev =="
35
+ # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
36
+ # system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
29
37
  end
@@ -41,6 +41,8 @@ module TrustyCms
41
41
 
42
42
  config.encoding = 'utf-8'
43
43
  config.time_zone = 'UTC'
44
+ # Rails 8.1 will make `to_time` always preserve the receiver's timezone.
45
+ config.active_support.to_time_preserves_timezone = :zone
44
46
  # Skip frameworks you're not going to use (only works if using vendor/rails).
45
47
  # To use Rails without a database, you must remove the Active Record framework
46
48
  # config.frameworks -= [ :action_mailer ]
@@ -2,4 +2,4 @@
2
2
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
3
 
4
4
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- #$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
5
+ #$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: trusty_cms_production
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
6
+
7
+ # Rails.application.configure do
8
+ # config.content_security_policy do |policy|
9
+ # policy.default_src :self, :https
10
+ # policy.font_src :self, :https, :data
11
+ # policy.img_src :self, :https, :data
12
+ # policy.object_src :none
13
+ # policy.script_src :self, :https
14
+ # policy.style_src :self, :https
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+ #
19
+ # # Generate session nonces for permitted importmap, inline scripts, and inline styles.
20
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
+ # config.content_security_policy_nonce_directives = %w(script-src style-src)
22
+ #
23
+ # # Report violations without enforcing the policy.
24
+ # # config.content_security_policy_report_only = true
25
+ # end
@@ -1,4 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
3
+ # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
4
+ # Use this to limit dissemination of sensitive information.
5
+ # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
6
+ Rails.application.config.filter_parameters += [
7
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8
+ ]
@@ -4,13 +4,13 @@
4
4
  # are locale specific, and you may define rules for as many different
5
5
  # locales as you wish. All of these examples are active by default:
6
6
  # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
- # inflect.plural /^(ox)$/i, '\1en'
8
- # inflect.singular /^(ox)en/i, '\1'
9
- # inflect.irregular 'person', 'people'
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
10
  # inflect.uncountable %w( fish sheep )
11
11
  # end
12
12
 
13
13
  # These inflection rules are supported but not enabled by default:
14
14
  # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
- # inflect.acronym 'RESTful'
15
+ # inflect.acronym "RESTful"
16
16
  # end
@@ -0,0 +1,70 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file eases your Rails 7.2 framework defaults upgrade.
4
+ #
5
+ # Uncomment each configuration one by one to switch to the new default.
6
+ # Once your application is ready to run with all new defaults, you can remove
7
+ # this file and set the `config.load_defaults` to `7.2`.
8
+ #
9
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
10
+ # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
11
+
12
+ ###
13
+ # Controls whether Active Job's `#perform_later` and similar methods automatically defer
14
+ # the job queuing to after the current Active Record transaction is committed.
15
+ #
16
+ # Example:
17
+ # Topic.transaction do
18
+ # topic = Topic.create(...)
19
+ # NewTopicNotificationJob.perform_later(topic)
20
+ # end
21
+ #
22
+ # In this example, if the configuration is set to `:never`, the job will
23
+ # be enqueued immediately, even though the `Topic` hasn't been committed yet.
24
+ # Because of this, if the job is picked up almost immediately, or if the
25
+ # transaction doesn't succeed for some reason, the job will fail to find this
26
+ # topic in the database.
27
+ #
28
+ # If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter
29
+ # will define the behaviour.
30
+ #
31
+ # Note: Active Job backends can disable this feature. This is generally done by
32
+ # backends that use the same database as Active Record as a queue, hence they
33
+ # don't need this feature.
34
+ #++
35
+ # Rails.application.config.active_job.enqueue_after_transaction_commit = :default
36
+
37
+ ###
38
+ # Adds image/webp to the list of content types Active Storage considers as an image
39
+ # Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png.
40
+ # This is possible due to broad browser support for WebP, but older browsers and email clients may still not support
41
+ # WebP. Requires imagemagick/libvips built with WebP support.
42
+ #++
43
+ # Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp]
44
+
45
+ ###
46
+ # Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError
47
+ # will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp
48
+ # associated with the current time. This is done to prevent forward-dating of migration files, which can
49
+ # impact migration generation and other migration commands.
50
+ #
51
+ # Applications with existing timestamped migrations that do not adhere to the
52
+ # expected format can disable validation by setting this config to `false`.
53
+ #++
54
+ # Rails.application.config.active_record.validate_migration_timestamps = true
55
+
56
+ ###
57
+ # Controls whether the PostgresqlAdapter should decode dates automatically with manual queries.
58
+ #
59
+ # Example:
60
+ # ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date
61
+ #
62
+ # This query used to return a `String`.
63
+ #++
64
+ # Rails.application.config.active_record.postgresql_adapter_decode_dates = true
65
+
66
+ ###
67
+ # Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are
68
+ # deploying to a memory constrained environment you may want to set this to `false`.
69
+ #++
70
+ # Rails.application.config.yjit = true
@@ -0,0 +1,13 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide HTTP permissions policy. For further
4
+ # information see: https://developers.google.com/web/updates/2018/06/feature-policy
5
+
6
+ # Rails.application.config.permissions_policy do |policy|
7
+ # policy.camera :none
8
+ # policy.gyroscope :none
9
+ # policy.microphone :none
10
+ # policy.usb :none
11
+ # policy.fullscreen :self
12
+ # policy.payment :self, "https://secure.example.com"
13
+ # end
@@ -0,0 +1,34 @@
1
+ # This configuration file will be evaluated by Puma. The top-level methods that
2
+ # are invoked here are part of Puma's configuration DSL. For more information
3
+ # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4
+
5
+ # Puma starts a configurable number of processes (workers) and each process
6
+ # serves each request in a thread from an internal thread pool.
7
+ #
8
+ # The ideal number of threads per worker depends both on how much time the
9
+ # application spends waiting for IO operations and on how much you wish to
10
+ # to prioritize throughput over latency.
11
+ #
12
+ # As a rule of thumb, increasing the number of threads will increase how much
13
+ # traffic a given process can handle (throughput), but due to CRuby's
14
+ # Global VM Lock (GVL) it has diminishing returns and will degrade the
15
+ # response time (latency) of the application.
16
+ #
17
+ # The default is set to 3 threads as it's deemed a decent compromise between
18
+ # throughput and latency for the average Rails application.
19
+ #
20
+ # Any libraries that use a connection pool or another resource pool should
21
+ # be configured to provide at least as many connections as the number of
22
+ # threads. This includes Active Record's `pool` parameter in `database.yml`.
23
+ threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
24
+ threads threads_count, threads_count
25
+
26
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
27
+ port ENV.fetch("PORT", 3000)
28
+
29
+ # Allow puma to be restarted by `bin/rails restart` command.
30
+ plugin :tmp_restart
31
+
32
+ # Specify the PID file. Defaults to tmp/pids/server.pid in development.
33
+ # In other environments, only set the PID file if requested.
34
+ pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
@@ -4,4 +4,31 @@ test:
4
4
 
5
5
  local:
6
6
  service: Disk
7
- root: <%= Rails.root.join("storage") %>
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket-<%= Rails.env %>
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket-<%= Rails.env %>
23
+
24
+ # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name-<%= Rails.env %>
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,22 @@
1
+ # This migration comes from active_storage (originally 20190112182829)
2
+ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
3
+ def up
4
+ return unless table_exists?(:active_storage_blobs)
5
+
6
+ unless column_exists?(:active_storage_blobs, :service_name)
7
+ add_column :active_storage_blobs, :service_name, :string
8
+
9
+ if configured_service = ActiveStorage::Blob.service.name
10
+ ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
11
+ end
12
+
13
+ change_column :active_storage_blobs, :service_name, :string, null: false
14
+ end
15
+ end
16
+
17
+ def down
18
+ return unless table_exists?(:active_storage_blobs)
19
+
20
+ remove_column :active_storage_blobs, :service_name
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # This migration comes from active_storage (originally 20191206030411)
2
+ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
3
+ def change
4
+ return unless table_exists?(:active_storage_blobs)
5
+
6
+ # Use Active Record's configured type for primary key
7
+ create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
8
+ t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
9
+ t.string :variation_digest, null: false
10
+
11
+ t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
12
+ t.foreign_key :active_storage_blobs, column: :blob_id
13
+ end
14
+ end
15
+
16
+ private
17
+ def primary_key_type
18
+ config = Rails.configuration.generators
19
+ config.options[config.orm][:primary_key_type] || :primary_key
20
+ end
21
+
22
+ def blobs_primary_key_type
23
+ pkey_name = connection.primary_key(:active_storage_blobs)
24
+ pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
25
+ pkey_column.bigint? ? :bigint : pkey_column.type
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ # This migration comes from active_storage (originally 20211119233751)
2
+ class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
3
+ def change
4
+ return unless table_exists?(:active_storage_blobs)
5
+
6
+ change_column_null(:active_storage_blobs, :checksum, true)
7
+ end
8
+ end
@@ -4,7 +4,7 @@
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/404.html -->
59
59
  <div class="dialog">
60
60
  <div>