-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
テスト環境でユーザーとアイコン画像が紐付けされるようにした #5096
Changes from all commits
0c7af0b
34b96a1
970ae21
a81f6ce
4519b60
ab75434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,4 @@ | |
] | ||
|
||
ActiveRecord::FixtureSet.create_fixtures 'db/fixtures', tables | ||
Bootcamp::Setup.attachment |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# companies | ||
company1_logo: | ||
name: logo | ||
record: company1 (Company) | ||
blob: company1_logo_blob | ||
|
||
company2_logo: | ||
name: logo | ||
record: company2 (Company) | ||
blob: company2_logo_blob | ||
|
||
company3_logo: | ||
name: logo | ||
record: company3 (Company) | ||
blob: company3_logo_blob | ||
|
||
company4_logo: | ||
name: logo | ||
record: company4 (Company) | ||
blob: company4_logo_blob | ||
|
||
# users | ||
hatsuno_avatar: | ||
name: avatar | ||
record: hatsuno (User) | ||
blob: hatsuno_avatar_blob | ||
|
||
komagata_avatar: | ||
name: avatar | ||
record: komagata (User) | ||
blob: komagata_avatar_blob | ||
|
||
machida_avatar: | ||
name: avatar | ||
record: machida (User) | ||
blob: machida_avatar_blob | ||
|
||
mentormentaro_avatar: | ||
name: avatar | ||
record: mentormentaro (User) | ||
blob: mentormentaro_avatar_blob | ||
|
||
mineo_avatar: | ||
name: avatar | ||
record: mineo (User) | ||
blob: mineo_avatar_blob | ||
|
||
tanaka_avatar: | ||
name: avatar | ||
record: tanaka (User) | ||
blob: tanaka_avatar_blob | ||
|
||
yameo_avatar: | ||
name: avatar | ||
record: yameo (User) | ||
blob: yameo_avatar_blob |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Pull Request #4182(https://github.com/fjordllc/bootcamp/pull/4182) で Rails 7 への移行完了後、 | ||
# ActiveStorage::FixtureSet.blob を使うように変更する | ||
|
||
# companies | ||
company1_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/1.jpg" %> | ||
|
||
company2_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/2.jpg" %> | ||
|
||
company3_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/3.jpg" %> | ||
|
||
company4_logo_blob: <%= ActiveStorage::Blob.fixture filename: "companies/logos/4.jpg" %> | ||
|
||
# users | ||
hatsuno_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/hatsuno.jpg" %> | ||
|
||
komagata_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/komagata.jpg" %> | ||
|
||
machida_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/machida.jpg" %> | ||
|
||
mentormentaro_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/mentormentaro.jpg" %> | ||
|
||
mineo_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/mineo.jpg" %> | ||
|
||
tanaka_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/tanaka.jpg" %> | ||
|
||
yameo_avatar_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/yameo.jpg" %> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
# Pull Request #4182(https://github.com/fjordllc/bootcamp/pull/4182) で Rails 7 への移行完了後に削除する | ||
require 'application_system_test_case' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. このテストは Rails 7 へのアップデートが完了後、デフォルトの機能で fixture の画像をアタッチするようになったら不要になるかなと思うので、他の変更箇所にあるコメントと同じようにその旨を書いておくといいかもなと思いました! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 確かにコメントがあった方がいいですね! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. コメントの対応ありがとうございます!
僕のこの書き方が悪くて申し訳ないのですが...🙇♂️
テストのプラクティスの説明にあった以下の内容のケースに当てはまるかなと思ってます。
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rails7移行後でもアタッチのテストは必要かな?と思っていましたが、確かに |
||
class AttachmentsTest < ApplicationSystemTestCase | ||
test 'attachment user avatar' do | ||
visit_with_auth "/users/#{users(:komagata).id}", 'komagata' | ||
assert find('img.user-profile__user-icon-image')['src'].include?('komagata.png') | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
現在、test/fixture/files には companies と users 以外に、
がありますが、これらはセットアップ時にアタッチしなくてよい画像でしょうか?
これらの画像の用途を把握できていないのですが、test/fixture/files 以下に扱いが異なるファイルがあるのが気になったので、確認できたらいいなと思いました!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4249 の方で2つの画像ファイルについて質問しました。
komagataさんからご回答いただき、
とのことです。
これらの画像の用途としては、
test/system/articles_test.rb
test/system/practices_test.rb
test/system/practice/completion_test.rb
で画像のアップロードのテストに使われているだけなので、アタッチの必要はなさそうです。