-
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
提出物未チェックの場合、学習ステータスを修了にできないように変更 #7994
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
require 'supports/product_helper' | ||
require 'active_decorator_test_case' | ||
|
||
class UserDecoratorTest < ActiveDecoratorTestCase | ||
include ProductHelper | ||
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. 他の箇所でもincludeとテストやsetupのメソッドは1行開けているので開けた方がいいかなと思います。 |
||
setup do | ||
@admin_mentor_user = decorate(users(:komagata)) | ||
@student_user = decorate(users(:hajime)) | ||
|
@@ -74,23 +76,27 @@ class UserDecoratorTest < ActiveDecoratorTestCase | |
test '#completed_fraction don\'t calculate practice that include_progress: false' do | ||
user = @admin_mentor_user | ||
old_fraction = user.completed_practices_include_progress_size | ||
create_checked_product(user, practices(:practice5)) | ||
user.completed_practices << practices(:practice5) | ||
|
||
assert_not_equal old_fraction, user.completed_fraction | ||
|
||
old_fraction = user.completed_practices_include_progress_size | ||
create_checked_product(user, practices(:practice53)) | ||
user.completed_practices << practices(:practice53) | ||
|
||
assert_equal old_fraction, user.completed_practices_include_progress_size | ||
end | ||
|
||
test '#completed_fraction don\'t calculate practice unrelated cource' do | ||
old_fraction = @admin_mentor_user.completed_practices_include_progress_size | ||
create_checked_product(@admin_mentor_user, practices(:practice5)) | ||
@admin_mentor_user.completed_practices << practices(:practice5) | ||
|
||
assert_not_equal old_fraction, @admin_mentor_user.completed_practices_include_progress_size | ||
|
||
old_fraction = @admin_mentor_user.completed_practices_include_progress_size | ||
create_checked_product(@admin_mentor_user, practices(:practice55)) | ||
@admin_mentor_user.completed_practices << practices(:practice55) | ||
|
||
assert_equal old_fraction, @admin_mentor_user.completed_practices_include_progress_size | ||
|
@@ -99,6 +105,8 @@ class UserDecoratorTest < ActiveDecoratorTestCase | |
test '#completed_fraction_in_metas' do | ||
fraction_in_metas = '2 (必須:1)' | ||
@non_required_subject_completed_user.completed_practices = [] | ||
create_checked_product(@non_required_subject_completed_user, practices(:practice5)) | ||
create_checked_product(@non_required_subject_completed_user, practices(:practice61)) | ||
@non_required_subject_completed_user.completed_practices << practices(:practice5) | ||
@non_required_subject_completed_user.completed_practices << practices(:practice61) | ||
assert_equal fraction_in_metas, @non_required_subject_completed_user.completed_fraction_in_metas | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,9 +53,9 @@ class ProductTest < ActiveSupport::TestCase | |
practice: | ||
) | ||
|
||
status = :complete | ||
status = :started | ||
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. このステータスを変更している理由は、このテストの目的から変更先のステータスが「修了」でなくてもいいと判断したからです。 |
||
product.change_learning_status(status) | ||
assert Learning.find_by(user:, practice:, status: :complete) | ||
assert Learning.find_by(user:, practice:, status: :started) | ||
end | ||
|
||
test '#category' do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,9 @@ def delete_most_unassigned_products! | |
|
||
products[2..products.size].each(&:delete) | ||
end | ||
|
||
def create_checked_product(user, practice) | ||
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. validation追加の関係で、テストがvalidationに引っかかるものがいくつかあったため対応策として作成しました。 |
||
product = Product.create(user:, practice:, body: 'test') | ||
Check.create(user:, checkable: product) | ||
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.
2回使うのでなければproductという変数を作る意味はないかもです。(1行で良いと思います。)
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.
@reckyy こちらいかがでしょうか?
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.
@komagata
おっしゃる通りです。
変数削除する修正をしたあと、返信させていただこうと思ってました。返信が遅れて申し訳ないです。 🙇
加えて長期間作業できておらず、ご迷惑をおかけしている点も重ねて申し訳ないです。
こちらのPRは一週間以内に作業再開するようにします!