administrate-field-active_storage 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +21 -0
  3. data/.gitignore +0 -1
  4. data/.ruby-version +1 -1
  5. data/Gemfile.lock +217 -0
  6. data/README.md +8 -1
  7. data/administrate-field-active_storage.gemspec +3 -2
  8. data/app/views/fields/active_storage/_form.html.erb +4 -1
  9. data/app/views/fields/active_storage/_index.html.erb +4 -1
  10. data/app/views/fields/active_storage/_item.html.erb +2 -1
  11. data/app/views/fields/active_storage/_show.html.erb +1 -1
  12. data/config/i18n-tasks.yml +8 -0
  13. data/config/locales/administrate-field-active_storage.en.yml +10 -0
  14. data/config/locales/administrate-field-active_storage.ru.yml +10 -0
  15. data/contribute.md +1 -0
  16. data/lib/administrate/field/active_storage.rb +1 -1
  17. data/spec/i18n_spec.rb +35 -0
  18. data/test_app/.browserslistrc +1 -0
  19. data/test_app/.gitattributes +10 -0
  20. data/{example-project → test_app}/.gitignore +9 -7
  21. data/test_app/.ruby-version +1 -0
  22. data/test_app/Gemfile +45 -0
  23. data/test_app/Gemfile.lock +237 -0
  24. data/{example-project → test_app}/README.md +0 -0
  25. data/{example-project → test_app}/Rakefile +1 -1
  26. data/test_app/app/assets/config/manifest.js +4 -0
  27. data/{example-project → test_app}/app/assets/images/.keep +0 -0
  28. data/{example-project → test_app}/app/assets/stylesheets/application.css +0 -0
  29. data/{example-project → test_app}/app/controllers/admin/application_controller.rb +3 -3
  30. data/test_app/app/controllers/admin/posts_controller.rb +46 -0
  31. data/{example-project → test_app}/app/controllers/application_controller.rb +0 -0
  32. data/{example-project/app/dashboards/user_dashboard.rb → test_app/app/dashboards/post_dashboard.rb} +29 -27
  33. data/{example-project → test_app}/app/helpers/application_helper.rb +0 -0
  34. data/test_app/app/javascript/packs/application.js +10 -0
  35. data/{example-project → test_app}/app/models/application_record.rb +0 -0
  36. data/test_app/app/models/post.rb +3 -0
  37. data/test_app/app/views/layouts/application.html.erb +16 -0
  38. data/test_app/bin/bundle +114 -0
  39. data/test_app/bin/rails +4 -0
  40. data/test_app/bin/rake +4 -0
  41. data/{example-project → test_app}/bin/setup +6 -9
  42. data/{example-project → test_app}/config.ru +2 -1
  43. data/test_app/config/application.rb +35 -0
  44. data/{example-project/bin/bundle → test_app/config/boot.rb} +2 -2
  45. data/test_app/config/credentials.yml.enc +1 -0
  46. data/{example-project → test_app}/config/database.yml +1 -1
  47. data/{example-project → test_app}/config/environment.rb +1 -1
  48. data/{example-project → test_app}/config/environments/development.rb +21 -11
  49. data/{example-project → test_app}/config/environments/production.rb +36 -24
  50. data/{example-project → test_app}/config/environments/test.rb +20 -14
  51. data/{example-project → test_app}/config/initializers/application_controller_renderer.rb +0 -0
  52. data/{example-project → test_app}/config/initializers/assets.rb +0 -0
  53. data/test_app/config/initializers/backtrace_silencers.rb +8 -0
  54. data/{example-project → test_app}/config/initializers/content_security_policy.rb +5 -0
  55. data/{example-project → test_app}/config/initializers/cookies_serializer.rb +0 -0
  56. data/{example-project → test_app}/config/initializers/filter_parameter_logging.rb +3 -1
  57. data/{example-project → test_app}/config/initializers/inflections.rb +0 -0
  58. data/{example-project → test_app}/config/initializers/mime_types.rb +0 -0
  59. data/test_app/config/initializers/permissions_policy.rb +11 -0
  60. data/{example-project → test_app}/config/initializers/wrap_parameters.rb +0 -0
  61. data/{example-project → test_app}/config/locales/en.yml +1 -1
  62. data/{example-project → test_app}/config/puma.rb +13 -4
  63. data/test_app/config/routes.rb +9 -0
  64. data/{example-project → test_app}/config/storage.yml +0 -0
  65. data/{example-project/db/migrate/20181221134334_create_active_storage_tables.active_storage.rb → test_app/db/migrate/20210118122804_create_active_storage_tables.active_storage.rb} +15 -5
  66. data/test_app/db/migrate/20210118122927_create_posts.rb +8 -0
  67. data/{example-project → test_app}/db/schema.rb +18 -10
  68. data/{example-project → test_app}/db/seeds.rb +1 -1
  69. data/test_app/lib/active_storage/fixture_set.rb +71 -0
  70. data/{example-project → test_app}/public/404.html +0 -0
  71. data/{example-project → test_app}/public/422.html +0 -0
  72. data/{example-project → test_app}/public/500.html +0 -0
  73. data/{example-project → test_app}/public/apple-touch-icon-precomposed.png +0 -0
  74. data/{example-project → test_app}/public/apple-touch-icon.png +0 -0
  75. data/{example-project → test_app}/public/favicon.ico +0 -0
  76. data/test_app/public/robots.txt +1 -0
  77. data/{example-project → test_app}/test/application_system_test_case.rb +0 -0
  78. data/test_app/test/controllers/admin/posts_controller_test.rb +14 -0
  79. data/test_app/test/fixtures/active_storage/attachments.yml +4 -0
  80. data/test_app/test/fixtures/active_storage/blobs.yml +2 -0
  81. data/test_app/test/fixtures/files/cover_image.jpg +0 -0
  82. data/test_app/test/fixtures/posts.yml +11 -0
  83. data/test_app/test/models/post_test.rb +9 -0
  84. data/test_app/test/test_helper.rb +20 -0
  85. metadata +97 -99
  86. data/Rakefile +0 -22
  87. data/example-project/.ruby-version +0 -1
  88. data/example-project/Gemfile +0 -67
  89. data/example-project/Gemfile.lock +0 -265
  90. data/example-project/app/assets/config/manifest.js +0 -3
  91. data/example-project/app/assets/javascripts/application.js +0 -16
  92. data/example-project/app/assets/javascripts/cable.js +0 -13
  93. data/example-project/app/assets/javascripts/channels/.keep +0 -0
  94. data/example-project/app/channels/application_cable/channel.rb +0 -4
  95. data/example-project/app/channels/application_cable/connection.rb +0 -4
  96. data/example-project/app/controllers/admin/users_controller.rb +0 -27
  97. data/example-project/app/controllers/concerns/.keep +0 -0
  98. data/example-project/app/controllers/users_controller.rb +0 -7
  99. data/example-project/app/jobs/application_job.rb +0 -2
  100. data/example-project/app/mailers/application_mailer.rb +0 -4
  101. data/example-project/app/models/concerns/.keep +0 -0
  102. data/example-project/app/models/user.rb +0 -3
  103. data/example-project/app/views/layouts/application.html.erb +0 -15
  104. data/example-project/app/views/layouts/mailer.html.erb +0 -13
  105. data/example-project/app/views/layouts/mailer.text.erb +0 -1
  106. data/example-project/bin/rails +0 -9
  107. data/example-project/bin/rake +0 -9
  108. data/example-project/bin/spring +0 -17
  109. data/example-project/bin/update +0 -31
  110. data/example-project/bin/yarn +0 -11
  111. data/example-project/config/application.rb +0 -19
  112. data/example-project/config/boot.rb +0 -4
  113. data/example-project/config/cable.yml +0 -10
  114. data/example-project/config/credentials.yml.enc +0 -1
  115. data/example-project/config/initializers/backtrace_silencers.rb +0 -7
  116. data/example-project/config/routes.rb +0 -10
  117. data/example-project/config/spring.rb +0 -6
  118. data/example-project/db/migrate/20181013145025_create_users.rb +0 -9
  119. data/example-project/lib/assets/.keep +0 -0
  120. data/example-project/lib/tasks/.keep +0 -0
  121. data/example-project/log/.keep +0 -0
  122. data/example-project/package.json +0 -5
  123. data/example-project/public/robots.txt +0 -1
  124. data/example-project/test/controllers/.keep +0 -0
  125. data/example-project/test/fixtures/.keep +0 -0
  126. data/example-project/test/fixtures/files/.keep +0 -0
  127. data/example-project/test/fixtures/users.yml +0 -7
  128. data/example-project/test/helpers/.keep +0 -0
  129. data/example-project/test/integration/.keep +0 -0
  130. data/example-project/test/mailers/.keep +0 -0
  131. data/example-project/test/models/.keep +0 -0
  132. data/example-project/test/models/user_test.rb +0 -7
  133. data/example-project/test/system/.keep +0 -0
  134. data/example-project/test/test_helper.rb +0 -10
  135. data/example-project/tmp/.keep +0 -0
  136. data/example-project/vendor/.keep +0 -0
@@ -1,10 +1,13 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
1
8
  Rails.application.configure do
2
9
  # Settings specified here will take precedence over those in config/application.rb.
3
10
 
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
11
  config.cache_classes = true
9
12
 
10
13
  # Do not eager load code on boot. This avoids loading your whole application
@@ -21,6 +24,7 @@ Rails.application.configure do
21
24
  # Show full error reports and disable caching.
22
25
  config.consider_all_requests_local = true
23
26
  config.action_controller.perform_caching = false
27
+ config.cache_store = :null_store
24
28
 
25
29
  # Raise exceptions instead of rendering exception templates.
26
30
  config.action_dispatch.show_exceptions = false
@@ -28,19 +32,21 @@ Rails.application.configure do
28
32
  # Disable request forgery protection in test environment.
29
33
  config.action_controller.allow_forgery_protection = false
30
34
 
31
- # Store uploaded files on the local file system in a temporary directory
35
+ # Store uploaded files on the local file system in a temporary directory.
32
36
  config.active_storage.service = :test
33
37
 
34
- config.action_mailer.perform_caching = false
35
-
36
- # Tell Action Mailer not to deliver emails to the real world.
37
- # The :test delivery method accumulates sent emails in the
38
- # ActionMailer::Base.deliveries array.
39
- config.action_mailer.delivery_method = :test
40
-
41
38
  # Print deprecation notices to the stderr.
42
39
  config.active_support.deprecation = :stderr
43
40
 
44
- # Raises error for missing translations
45
- # config.action_view.raise_on_missing_translations = true
41
+ # Raise exceptions for disallowed deprecations.
42
+ config.active_support.disallowed_deprecation = :raise
43
+
44
+ # Tell Active Support which deprecation messages to disallow.
45
+ config.active_support.disallowed_deprecation_warnings = []
46
+
47
+ # Raises error for missing translations.
48
+ # config.i18n.raise_on_missing_translations = true
49
+
50
+ # Annotate rendered view with file names.
51
+ # config.action_view.annotate_rendered_view_with_filenames = true
46
52
  end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
7
+ # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
8
+ Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
@@ -11,6 +11,8 @@
11
11
  # policy.object_src :none
12
12
  # policy.script_src :self, :https
13
13
  # policy.style_src :self, :https
14
+ # # If you are using webpack-dev-server then specify webpack-dev-server host
15
+ # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
14
16
 
15
17
  # # Specify URI for violation reports
16
18
  # # policy.report_uri "/csp-violation-report-endpoint"
@@ -19,6 +21,9 @@
19
21
  # If you are using UJS then enable automatic nonce generation
20
22
  # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
23
 
24
+ # Set the nonce only to specific directives
25
+ # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
26
+
22
27
  # Report CSP violations to a specified URI
23
28
  # For further information see the following documentation:
24
29
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
@@ -1,4 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
4
+ Rails.application.config.filter_parameters += [
5
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
6
+ ]
@@ -0,0 +1,11 @@
1
+ # Define an application-wide HTTP permissions policy. For further
2
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
+ #
4
+ # Rails.application.config.permissions_policy do |f|
5
+ # f.camera :none
6
+ # f.gyroscope :none
7
+ # f.microphone :none
8
+ # f.usb :none
9
+ # f.fullscreen :self
10
+ # f.payment :self, "https://secure.example.com"
11
+ # end
@@ -27,7 +27,7 @@
27
27
  # 'true': 'foo'
28
28
  #
29
29
  # To learn more, please read the Rails Internationalization guide
30
- # available at http://guides.rubyonrails.org/i18n.html.
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
31
 
32
32
  en:
33
33
  hello: "Hello world"
@@ -4,19 +4,28 @@
4
4
  # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
5
  # and maximum; this matches the default thread size of Active Record.
6
6
  #
7
- threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
- threads threads_count, threads_count
7
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
9
15
 
10
16
  # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
17
  #
12
- port ENV.fetch("PORT") { 3000 }
18
+ port ENV.fetch("PORT") { 3000 }
13
19
 
14
20
  # Specifies the `environment` that Puma will run in.
15
21
  #
16
22
  environment ENV.fetch("RAILS_ENV") { "development" }
17
23
 
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26
+
18
27
  # Specifies the number of `workers` to boot in clustered mode.
19
- # Workers are forked webserver processes. If using threads and workers together
28
+ # Workers are forked web server processes. If using threads and workers together
20
29
  # the concurrency of the application would be max `threads` * `workers`.
21
30
  # Workers do not work on JRuby or Windows (both of which do not support
22
31
  # processes).
@@ -0,0 +1,9 @@
1
+ Rails.application.routes.draw do
2
+ # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3
+
4
+ namespace :admin do
5
+ resources :posts
6
+
7
+ root to: "posts#index"
8
+ end
9
+ end
File without changes
@@ -2,13 +2,14 @@
2
2
  class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3
3
  def change
4
4
  create_table :active_storage_blobs do |t|
5
- t.string :key, null: false
6
- t.string :filename, null: false
5
+ t.string :key, null: false
6
+ t.string :filename, null: false
7
7
  t.string :content_type
8
8
  t.text :metadata
9
- t.bigint :byte_size, null: false
10
- t.string :checksum, null: false
11
- t.datetime :created_at, null: false
9
+ t.string :service_name, null: false
10
+ t.bigint :byte_size, null: false
11
+ t.string :checksum, null: false
12
+ t.datetime :created_at, null: false
12
13
 
13
14
  t.index [ :key ], unique: true
14
15
  end
@@ -21,6 +22,15 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
21
22
  t.datetime :created_at, null: false
22
23
 
23
24
  t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
25
+ t.foreign_key :active_storage_blobs, column: :blob_id
26
+ end
27
+
28
+ create_table :active_storage_variant_records do |t|
29
+ t.belongs_to :blob, null: false, index: false
30
+ t.string :variation_digest, null: false
31
+
32
+ t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
33
+ t.foreign_key :active_storage_blobs, column: :blob_id
24
34
  end
25
35
  end
26
36
  end
@@ -0,0 +1,8 @@
1
+ class CreatePosts < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :posts do |t|
4
+
5
+ t.timestamps
6
+ end
7
+ end
8
+ end
@@ -2,15 +2,15 @@
2
2
  # of editing this file, please use the migrations feature of Active Record to
3
3
  # incrementally modify your database, and then regenerate this schema definition.
4
4
  #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2018_12_21_134334) do
13
+ ActiveRecord::Schema.define(version: 2021_01_18_122927) do
14
14
 
15
15
  create_table "active_storage_attachments", force: :cascade do |t|
16
16
  t.string "name", null: false
@@ -27,16 +27,24 @@ ActiveRecord::Schema.define(version: 2018_12_21_134334) do
27
27
  t.string "filename", null: false
28
28
  t.string "content_type"
29
29
  t.text "metadata"
30
+ t.string "service_name", null: false
30
31
  t.bigint "byte_size", null: false
31
32
  t.string "checksum", null: false
32
33
  t.datetime "created_at", null: false
33
34
  t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
34
35
  end
35
36
 
36
- create_table "users", force: :cascade do |t|
37
- t.string "name"
38
- t.datetime "created_at", null: false
39
- t.datetime "updated_at", null: false
37
+ create_table "active_storage_variant_records", force: :cascade do |t|
38
+ t.integer "blob_id", null: false
39
+ t.string "variation_digest", null: false
40
+ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
41
+ end
42
+
43
+ create_table "posts", force: :cascade do |t|
44
+ t.datetime "created_at", precision: 6, null: false
45
+ t.datetime "updated_at", precision: 6, null: false
40
46
  end
41
47
 
48
+ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
49
+ add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
42
50
  end
@@ -1,5 +1,5 @@
1
1
  # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
3
  #
4
4
  # Examples:
5
5
  #
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/testing/file_fixtures"
4
+ require "active_record/secure_token"
5
+
6
+ module ActiveStorage
7
+ # Fixtures are a way of organizing data that you want to test against; in
8
+ # short, sample data.
9
+ #
10
+ # To learn more about fixtures, read the
11
+ # {ActiveRecord::FixtureSet}[rdoc-ref:ActiveRecord::FixtureSet] documentation.
12
+ #
13
+ # === YAML
14
+ #
15
+ # Like other Active Record-backed models,
16
+ # {ActiveStorage::Attachment}[rdoc-ref:ActiveStorage::Attachment] and
17
+ # {ActiveStorage::Blob}[rdoc-ref:ActiveStorage::Blob] records inherit from
18
+ # {ActiveRecord::Base}[rdoc-ref:ActiveRecord::Base] instances and therefore
19
+ # can be populated by fixtures.
20
+ #
21
+ # Consider a hypothetical <tt>Article</tt> model class, its related
22
+ # fixture data, as well as fixture data for related ActiveStorage::Attachment
23
+ # and ActiveStorage::Blob records:
24
+ #
25
+ # # app/models/article.rb
26
+ # class Article < ApplicationRecord
27
+ # has_one_attached :thumbnail
28
+ # end
29
+ #
30
+ # # fixtures/active_storage/blobs.yml
31
+ # first_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob filename: "first.png" %>
32
+ #
33
+ # # fixtures/active_storage/attachments.yml
34
+ # first_thumbnail_attachment:
35
+ # name: thumbnail
36
+ # record: first (Article)
37
+ # blob: first_thumbnail_blob
38
+ #
39
+ # When processed, Active Record will insert database records for each fixture
40
+ # entry and will ensure the Action Text relationship is intact.
41
+ class FixtureSet
42
+ include ActiveSupport::Testing::FileFixtures
43
+ include ActiveRecord::SecureToken
44
+
45
+ # Generate a YAML-encoded representation of an ActiveStorage::Blob
46
+ # instance's attributes, resolve the file relative to the directory mentioned
47
+ # by <tt>ActiveSupport::Testing::FileFixtures.file_fixture</tt>, and upload
48
+ # the file to the Service
49
+ #
50
+ # === Examples
51
+ #
52
+ # # tests/fixtures/action_text/blobs.yml
53
+ # second_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob(
54
+ # filename: "second.svg",
55
+ # content_type: "image/svg+xml",
56
+ # ) %>
57
+ #
58
+ def self.blob(filename:, **attributes)
59
+ new.prepare Blob.new(filename: filename, key: generate_unique_secure_token), **attributes
60
+ end
61
+
62
+ def prepare(instance, **attributes)
63
+ io = file_fixture(instance.filename.to_s).open
64
+ instance.unfurl(io)
65
+ instance.assign_attributes(attributes)
66
+ instance.upload_without_unfurling(io)
67
+
68
+ instance.attributes.transform_values { |value| value.is_a?(Hash) ? value.to_json : value }.compact.to_json
69
+ end
70
+ end
71
+ end
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ module Admin
4
+ class PostsControllerTest < ActionDispatch::IntegrationTest
5
+ test "index" do
6
+ post = posts(:one)
7
+
8
+ get admin_posts_path
9
+
10
+ assert_response :ok
11
+ assert_select "td.cell-data--active-storage > a[href='#{admin_post_path(post)}']"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ post_cover_image:
2
+ name: cover_image
3
+ record: one (Post)
4
+ blob: cover_image
@@ -0,0 +1,2 @@
1
+ cover_image:
2
+ <%= ActiveStorage::FixtureSet.blob filename: "cover_image.jpg" %>
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ test "post has cover image" do
5
+ post = posts(:one)
6
+
7
+ assert post.cover_image.attached?
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require_relative "../config/environment"
3
+ require "rails/test_help"
4
+ require "active_storage/fixture_set"
5
+ ActiveStorage::FixtureSet.file_fixture_path = File.expand_path("fixtures/files", __dir__)
6
+
7
+ class ActiveSupport::TestCase
8
+ # Run tests in parallel with specified workers
9
+ parallelize(workers: :number_of_processors)
10
+
11
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
12
+ fixtures :all
13
+
14
+ def after_teardown
15
+ super
16
+ FileUtils.rm_rf(Rails.root.join('tmp', 'storage'))
17
+ end
18
+
19
+ # Add more helper methods to be used by all tests here...
20
+ end