-
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
メンターダッシュボードに表示しているn日経過の提出物一覧を非vue化したい。 #7947
Comments
📝 関連するPR
|
@komagata @machida 解決したいことViewComponentのテストでActiveDecoratorメソッドが エラー内容例えば、ViewComponentの ❯ rails test test/components/product/product_component_test.rb
Running via Spring preloader in process 11715
Run options: --seed 21297
# Running:
....E
Error:
Products::ProductComponentTest#test_render_comments_count_when_there_are_comments:
NoMethodError: undefined method `icon_title' for #<User id: ...
...
{中略}
...
app/components/products/product_component.html.slim:71:in `block in call'
app/components/products/product_component.html.slim:69:in `call'
test/components/product/product_component_test.rb:67:in `test_render_comments_count_when_there_are_comments'
rails test test/components/product/product_component_test.rb:64 全文❯ rails test test/components/product/product_component_test.rb
Running via Spring preloader in process 11715
Run options: --seed 21297
# Running:
....E
Error:
Products::ProductComponentTest#test_render_comments_count_when_there_are_comments:
NoMethodError: undefined method `icon_title' for #<User id: 459775584, login_name: "komagata", email: "[email protected]", crypted_password: "$2a$10$n/xv4/1luueN6plzm2OyDezWlZFyGHjQEf4hwAW1r3k...", salt: "zW3kQ9ubsxQQtzzzs4ap", created_at: "2014-01-01 09:00:01.000000000 +0900", updated_at: "2024-09-26 18:37:04.934627000 +0900", remember_me_token: nil, remember_me_token_expires_at: nil, twitter_account: "komagata", facebook_url: "https://www.facebook.com/fjordllc/komagata1111", blog_url: "http://komagata.org", company_id: 636488896, description: "平日10〜19時勤務です。", accessed_at: nil, github_account: "komagata", adviser: false, nda: true, reset_password_token: nil, reset_password_token_expires_at: nil, reset_password_email_sent_at: nil, mentor: true, graduated_on: nil, course_id: 829913840, retired_on: nil, admin: true, job: "office_worker", organization: "株式会社ロッカ", os: "mac", experience: nil, retire_reason: nil, trainee: false, free: false, customer_id: nil, job_seeking: false, subscription_id: nil, mail_notification: true, job_seeker: false, github_id: nil, github_collaborator: true, name: "Komagata Masaki", name_kana: "コマガタ マサキ", satisfaction: nil, opinion: nil, retire_reasons: 0, unsubscribe_email_token: "037i-ef5n7V4EnPv74mtyQ", mentor_memo: nil, after_graduation_hope: nil, training_ends_on: nil, sad_streak: true, last_sad_report_id: 354780143, last_activity_at: "2014-01-01 09:00:01.000000000 +0900", hibernated_at: nil, profile_name: "駒形 真幸", profile_job: "エンジニア", profile_text: "株式会社ロッカの代表兼エンジニア。Rubyが大好きで怖話、フィヨルドブートキャンプなどを開発している...", feed_url: "https://example3.com/index.rdf", sent_student_followup_message: false, country_code: nil, subdivision_code: nil, auto_retire: true, editor: nil, other_editor: nil, invoice_payment: false, hide_mentor_profile: false, experiences: 6, tag_list: nil>
app/components/products/product_component.html.slim:71:in `block in call'
app/components/products/product_component.html.slim:69:in `call'
test/components/product/product_component_test.rb:67:in `test_render_comments_count_when_there_are_comments'
rails test test/components/product/product_component_test.rb:64 調べたことActiveDecorator
ViewComponentのテストでのActiveDecoratorの利用
エラーが発生するパターン以下のように、コンポーネントテストでデコレーターを適用した
# test/components/product/product_component_test.rb
def test_render_comments_count_when_there_are_comments
commented_user = users(:komagata).extend(UserDecorator)
unassigned_product = decorate_product_user(products(:product6))
unassigned_product.comments.create!(user: commented_user, description: 'コメントを追加')
render_inline(Products::ProductComponent.new(
product: unassigned_product,
is_mentor: @is_mentor,
current_user_id: @current_user_id
))
assert_selector '.a-meta', text: 'コメント(2)'
assert_selector 'img.a-user-icon[title=?]', commented_user.icon_title
end
bootcamp/app/components/products/product_component.html.slim Lines 69 to 71 in 56997a8
対応方法対応方法を検討しましたのでご助言お願いできますでしょうか。
以上、お手数ですがご回答をお願いいたします。 |
2でお願いします。もうちょっとだけ調べてみてください〜 |
@komagata
require 'test_helper'
require 'supports/decorator_helper' # ヘルパーをrequireする
class Products::ProductsComponentTest < ViewComponent::TestCase
def setup
DecoratorHelper.auto_decorate(User) # デコレーターを適用したいモデルを引数で渡す
# その他の処理
end
# テスト
end これにより 参考 |
いいと思います。ただ下記に似たコードがあるので何かしら共通化できるといいかもですね。 bootcamp/test/active_decorator_test_case.rb at main · fjordllc/bootcamp |
@komagata |
メンターでログインしたときにダッシュボードに表示されるこれが今はVueで実装されているので、Railsのviewに移行する。
The text was updated successfully, but these errors were encountered: