Skip to content

Commit 46fcce3

Browse files
authored
Merge pull request rails#42286 from zzak/actionmailbox/test/dummy/defaults
Update test dummy application defaults to remove warnings
2 parents 799d263 + 379232f commit 46fcce3

File tree

13 files changed

+34
-46
lines changed

13 files changed

+34
-46
lines changed

actionmailbox/test/dummy/config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module Dummy
88
class Application < Rails::Application
99
# Initialize configuration defaults for originally generated Rails version.
10-
config.load_defaults 6.0
10+
config.load_defaults 7.0
1111

1212
# Settings in config/environments/* take precedence over those specified here.
1313
# Application configuration can go into files in config/initializers

actiontext/test/dummy/config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
module Dummy
99
class Application < Rails::Application
1010
# Initialize configuration defaults for originally generated Rails version.
11-
config.load_defaults 6.0
11+
config.load_defaults 7.0
1212

1313
# Settings in config/environments/* take precedence over those specified here.
1414
# Application configuration can go into files in config/initializers

actiontext/test/template/form_helper_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def form_with(*, **)
3333
end
3434

3535
assert_dom_equal \
36-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
36+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
3737
'<input type="hidden" name="content" id="trix_input_1" />' \
3838
'<trix-editor input="trix_input_1" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
3939
"</trix-editor>" \
@@ -47,7 +47,7 @@ def form_with(*, **)
4747
end
4848

4949
assert_dom_equal \
50-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
50+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
5151
'<input type="hidden" name="message[content]" id="message_content_trix_input_message" />' \
5252
'<trix-editor id="message_content" input="message_content_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
5353
"</trix-editor>" \
@@ -61,7 +61,7 @@ def form_with(*, **)
6161
end
6262

6363
assert_dom_equal \
64-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
64+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
6565
'<input type="hidden" name="message[content]" id="message_content_trix_input_message" />' \
6666
'<trix-editor id="message_content" input="message_content_trix_input_message" class="custom-class" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
6767
"</trix-editor>" \
@@ -75,7 +75,7 @@ def form_with(*, **)
7575
end
7676

7777
assert_dom_equal \
78-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
78+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
7979
'<input type="hidden" name="message[not_an_attribute]" id="message_not_an_attribute_trix_input_message" />' \
8080
'<trix-editor id="message_not_an_attribute" input="message_not_an_attribute_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
8181
"</trix-editor>" \
@@ -89,7 +89,7 @@ def form_with(*, **)
8989
end
9090

9191
assert_dom_equal \
92-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
92+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
9393
'<input type="hidden" name="message[content]" id="trix_input_2" />' \
9494
'<trix-editor id="message_content" input="trix_input_2" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
9595
"</trix-editor>" \
@@ -103,7 +103,7 @@ def form_with(*, **)
103103
end
104104

105105
assert_dom_equal \
106-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
106+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
107107
'<input type="hidden" name="message[content]" id="message_content_trix_input_message" />' \
108108
'<trix-editor placeholder="Content" id="message_content" input="message_content_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
109109
"</trix-editor>" \
@@ -119,7 +119,7 @@ def form_with(*, **)
119119
end
120120

121121
assert_dom_equal \
122-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
122+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
123123
'<input type="hidden" name="message[title]" id="message_title_trix_input_message" />' \
124124
'<trix-editor placeholder="Story title" id="message_title" input="message_title_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
125125
"</trix-editor>" \
@@ -133,7 +133,7 @@ def form_with(*, **)
133133
end
134134

135135
assert_dom_equal \
136-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
136+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
137137
'<input type="hidden" name="message[title]" id="message_title_trix_input_message" value="&lt;h1&gt;hello world&lt;/h1&gt;" />' \
138138
'<trix-editor id="message_title" input="message_title_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
139139
"</trix-editor>" \
@@ -147,7 +147,7 @@ def form_with(*, **)
147147
end
148148

149149
assert_dom_equal \
150-
'<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
150+
'<form action="/messages" accept-charset="UTF-8" method="post">' \
151151
'<input type="hidden" name="message[title]" id="message_title_trix_input_message" form="other_form" />' \
152152
'<trix-editor id="message_title" input="message_title_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/redirect/:signed_id/:filename">' \
153153
"</trix-editor>" \

activestorage/app/models/active_storage/variant_with_record.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# ActiveStorage::VariantRecord. This is only used if `ActiveStorage.track_variants` is enabled.
55
class ActiveStorage::VariantWithRecord
66
attr_reader :blob, :variation
7+
delegate :service, to: :blob
78

89
def initialize(blob, variation)
910
@blob, @variation = blob, ActiveStorage::Variation.wrap(variation)

activestorage/test/database/setup.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
require_relative "create_users_migration"
44
require_relative "create_groups_migration"
55

6-
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
6+
# Writing and reading roles are required for the "previewing on the writer DB" test
7+
ActiveRecord::Base.connects_to(database: { writing: :primary, reading: :replica })
78
ActiveRecord::Base.connection.migration_context.migrate
89
ActiveStorageCreateUsers.migrate(:up)
910
ActiveStorageCreateGroups.migrate(:up)

activestorage/test/dummy/config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
module Dummy
1717
class Application < Rails::Application
18-
config.load_defaults 6.0
18+
config.load_defaults 7.0
1919

2020
config.active_storage.service = :local
2121
end
Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
1-
# SQLite version 3.x
2-
# gem install sqlite3
3-
#
4-
# Ensure the SQLite 3 gem is defined in your Gemfile
5-
# gem 'sqlite3'
6-
#
7-
default: &default
8-
adapter: sqlite3
9-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10-
timeout: 5000
11-
12-
development:
13-
<<: *default
14-
database: db/development.sqlite3
15-
16-
# Warning: The database defined as "test" will be erased and
17-
# re-generated from your development database when you run "rake".
18-
# Do not set this db to the same as development or production.
191
test:
20-
<<: *default
21-
database: db/test.sqlite3
22-
23-
production:
24-
<<: *default
25-
database: db/production.sqlite3
2+
primary: &primary
3+
adapter: sqlite3
4+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
5+
timeout: 5000
6+
database: ':memory:'
7+
replica:
8+
<<: *primary

activestorage/test/models/blob_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class ActiveStorage::BlobTest < ActiveSupport::TestCase
88
include ActiveSupport::Testing::MethodCallAssertions
9+
include ActiveJob::TestHelper
910

1011
test "unattached scope" do
1112
[ create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg") ].tap do |blobs|
@@ -229,12 +230,12 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase
229230
assert_not ActiveStorage::Blob.service.exist?(blob.key)
230231
end
231232

232-
test "purge deletes variants from external service" do
233+
test "purge deletes variants from external service with the purge_later" do
233234
blob = create_file_blob
234235
variant = blob.variant(resize: "100>").processed
235236

236237
blob.purge
237-
assert_not ActiveStorage::Blob.service.exist?(variant.key)
238+
assert_enqueued_with(job: ActiveStorage::PurgeJob, args: [variant.image.blob])
238239
end
239240

240241
test "purge does nothing when attachments exist" do

activestorage/test/models/preview_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class ActiveStorage::PreviewTest < ActiveSupport::TestCase
5454
test "previewing on the writer DB" do
5555
blob = create_file_blob(filename: "report.pdf", content_type: "application/pdf")
5656

57-
# Simulate a selector middleware switching to a read-only replica.
58-
ActiveRecord::Base.connection_handler.while_preventing_writes do
57+
# prevent_writes option is required because there is no automatic write protection anymore
58+
ActiveRecord::Base.connected_to(role: ActiveRecord.reading_role, prevent_writes: true) do
5959
blob.preview(resize: "640x280").processed
6060
end
6161

guides/source/configuring.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla
10681068

10691069
* `config.active_storage.video_preview_arguments` can be used to alter the way ffmpeg generates video preview images.
10701070

1071-
The default is `"-vf select=eq(n\,0)+eq(key\,1)+gt(scene\,0.015),loop=loop=-1:size=2,trim=start_frame=1 -frames:v 1 -f image2"`
1071+
The default is `"-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"`
10721072

10731073
1. `select=eq(n\,0)+eq(key\,1)+gt(scene\,0.015)`: Select the first video frame, plus keyframes, plus frames that meet the scene change threshold.
10741074
2. `loop=loop=-1:size=2,trim=start_frame=1`: To use the first video frame as a fallback when no other frames meet the criteria, loop the first (one or) two selected frames, then drop the first looped frame.
@@ -1090,7 +1090,7 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla
10901090
- `config.active_support.cache_format_version`: `7.0`
10911091
- `config.action_dispatch.return_only_request_media_type_on_content_type`: `false`
10921092
- `config.action_mailer.smtp_timeout`: `5`
1093-
- `config.active_storage.video_preview_arguments`: `"-vf select=eq(n\,0)+eq(key\,1)+gt(scene\,0.015),loop=loop=-1:size=2,trim=start_frame=1 -frames:v 1 -f image2"`
1093+
- `config.active_storage.video_preview_arguments`: `"-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"`
10941094

10951095
#### For '6.1', defaults from previous versions below and:
10961096

0 commit comments

Comments
 (0)