From 1189300abd747ba03bdfb177152cc1828495c6f0 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Wed, 31 Jul 2024 16:53:33 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E5=85=A5=E5=8A=9B=E5=BE=8Creturn=E3=82=92=E6=8A=BC?= =?UTF-8?q?=E3=81=99=E3=82=88=E3=81=86=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/users_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/system/users_test.rb b/test/system/users_test.rb index b39e8d1a96a..8ee87c23c7d 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -437,6 +437,7 @@ class UsersTest < ApplicationSystemTestCase visit_with_auth '/users', 'komagata' assert_selector '.users-item', count: 24 fill_in 'js-user-search-input', with: '木村です' + find('#js-user-search-input').send_keys :return assert_text 'Kimura Tadasi', count: 1 end From ed5a3260f77e6943499c266115d4b6831cf67820 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Wed, 7 Aug 2024 21:09:09 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8fixture?= =?UTF-8?q?s=E3=81=AE=E6=B7=BB=E4=BB=98=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E4=BF=9D=E5=AD=98=E5=85=88=E3=82=92=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/storage.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/storage.yml b/config/storage.yml index 2d8a90ff91f..bd43af95917 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -15,6 +15,11 @@ google: bucket: <%= ENV["GCS_BUCKET"] %> public: true +test_fixtures: + service: Disk + root: <%= Rails.root.join("tmp/storage_fixtures") %> + public: true + # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) # amazon: # service: S3 From 70f5749652bbefcbbcd243024d869d8697b6878b Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Wed, 7 Aug 2024 21:13:23 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fixture=E3=81=9D=E3=82=8C=E3=81=9E=E3=82=8C?= =?UTF-8?q?=E3=81=AB=E4=BF=9D=E5=AD=98=E5=85=88=E3=82=92=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fixtures/active_storage/blobs.yml | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/fixtures/active_storage/blobs.yml b/test/fixtures/active_storage/blobs.yml index f1f541fc9bf..f7a4661b11a 100644 --- a/test/fixtures/active_storage/blobs.yml +++ b/test/fixtures/active_storage/blobs.yml @@ -2,31 +2,31 @@ # ActiveStorage::FixtureSet.blob を使うように変更する # companies -company1_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/1.jpg" %> +company1_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/1.jpg", service_name: "test_fixtures" %> -company2_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/2.jpg" %> +company2_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/2.jpg", service_name: "test_fixtures" %> -company3_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/3.jpg" %> +company3_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/3.jpg", service_name: "test_fixtures" %> -company4_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/4.jpg" %> +company4_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/4.jpg", service_name: "test_fixtures" %> # users -hatsuno_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/hatsuno.jpg" %> +hatsuno_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/hatsuno.jpg", service_name: "test_fixtures" %> -komagata_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/komagata.jpg" %> +komagata_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/komagata.jpg", service_name: "test_fixtures" %> -machida_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/machida.jpg" %> +machida_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/machida.jpg", service_name: "test_fixtures" %> -mentormentaro_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/mentormentaro.jpg" %> +mentormentaro_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/mentormentaro.jpg", service_name: "test_fixtures" %> -mineo_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/mineo.jpg" %> +mineo_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/mineo.jpg", service_name: "test_fixtures" %> -tanaka_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/tanaka.jpg" %> +tanaka_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/tanaka.jpg", service_name: "test_fixtures" %> -yameo_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/yameo.jpg" %> +yameo_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/yameo.jpg", service_name: "test_fixtures" %> -komagata_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/komagata.jpg" %> +komagata_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/komagata.jpg", service_name: "test_fixtures" %> -machida_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/machida.jpg" %> +machida_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/machida.jpg", service_name: "test_fixtures" %> -kimuramitai_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/default.jpg" %> +kimuramitai_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/default.jpg", service_name: "test_fixtures" %> From c9e8359e2666537d3378ad6f4b46da5b06bea967 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Wed, 7 Aug 2024 21:14:57 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E4=B8=A6=E5=88=97=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=82=8B=E3=83=97=E3=83=AD=E3=82=BB=E3=82=B9=E3=81=9D=E3=82=8C?= =?UTF-8?q?=E3=81=9E=E3=82=8C=E3=81=AB=E4=BF=9D=E5=AD=98=E5=85=88=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=97=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 1c3bf7f383b..21f854e7b1d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -32,6 +32,11 @@ class ActiveSupport::TestCase teardown do ActiveStorage::Current.host = nil end + + parallelize_setup do |i| + ActiveStorage::Blob.service.instance_variable_set(:@root, "#{ActiveStorage::Blob.service.root}/storage-#{i}") + ActiveStorage::Blob.services.fetch(:test_fixtures).instance_variable_set(:@root, "#{ActiveStorage::Blob.services.fetch(:test_fixtures).root}/fixtures-#{i}") + end end class ActionDispatch::IntegrationTest From 19f294ef4c2b6bf1feec7a42eab6386a0335f516 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Wed, 7 Aug 2024 21:17:50 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=B5=82?= =?UTF-8?q?=E4=BA=86=E6=99=82=E3=81=AB/tmp/storage=E3=83=95=E3=82=A9?= =?UTF-8?q?=E3=83=AB=E3=83=80=E3=81=A8/tmp/storage=5Ffixtures=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=AB=E3=83=80=E3=82=92=E5=89=8A=E9=99=A4=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 21f854e7b1d..e1f15fdd426 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -37,6 +37,11 @@ class ActiveSupport::TestCase ActiveStorage::Blob.service.instance_variable_set(:@root, "#{ActiveStorage::Blob.service.root}/storage-#{i}") ActiveStorage::Blob.services.fetch(:test_fixtures).instance_variable_set(:@root, "#{ActiveStorage::Blob.services.fetch(:test_fixtures).root}/fixtures-#{i}") end + + Minitest.after_run do + FileUtils.rm_rf(ActiveStorage::Blob.service.root) + FileUtils.rm_rf(ActiveStorage::Blob.services.fetch(:test_fixtures).root) + end end class ActionDispatch::IntegrationTest From 1342612011fc8b6745b36c3473dcc4cecb9f7a08 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Wed, 7 Aug 2024 21:25:06 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Rails7=E3=81=A7=E5=BF=85=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=82=92=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index e1f15fdd426..13ea93e7106 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -33,6 +33,12 @@ class ActiveSupport::TestCase ActiveStorage::Current.host = nil end + # Rails7になったら以下のように修正する + # parallelize_setup do |i| + # ActiveStorage::Blob.service.root = "#{ActiveStorage::Blob.service.root}/storage-#{i}" + # ActiveStorage::Blob.services.fetch(:test_fixtures).root = "#{ActiveStorage::Blob.services.fetch(:test_fixtures).root}/fixtures-#{i}" + # end + # 参考: https://guides.rubyonrails.org/active_storage_overview.html#discarding-files-created-during-tests parallelize_setup do |i| ActiveStorage::Blob.service.instance_variable_set(:@root, "#{ActiveStorage::Blob.service.root}/storage-#{i}") ActiveStorage::Blob.services.fetch(:test_fixtures).instance_variable_set(:@root, "#{ActiveStorage::Blob.services.fetch(:test_fixtures).root}/fixtures-#{i}")