-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3795 from fjordllc/feature/delete-unassigned-coun…
…t-cache-when-original-value-changed 提出物一覧ページの「未アサイン」タブのバッジに表示する件数を適切に増減させる
- Loading branch information
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class UnassignedProductCountTest < ActiveSupport::TestCase | ||
test 'cached count of unassigned products increases by 1 after creating a product' do | ||
assert_difference 'Cache.unassigned_product_count', 1 do | ||
Product.create!(practice: practices(:practice5), user: users(:kimura), body: 'test') | ||
end | ||
end | ||
|
||
test 'cached count of unassigned products decreases by 1 after destroying an unassigned product' do | ||
unassigned_product = Product.not_wip.unassigned.first | ||
|
||
assert_difference 'Cache.unassigned_product_count', -1 do | ||
unassigned_product.destroy! | ||
end | ||
end | ||
|
||
test 'cached count of unassigned products decreases by 1 after a mentor gets assigned to an unassigned product' do | ||
unassigned_product = Product.not_wip.unassigned.first | ||
|
||
assert_difference 'Cache.unassigned_product_count', -1 do | ||
unassigned_product.update!(checker_id: users(:machida).id) | ||
end | ||
end | ||
|
||
test 'cached count of unassigned products increases by 1 after a mentor gets unassigned from an assigned product' do | ||
assigned_product = Product.self_assigned_product(users(:machida).id).first | ||
|
||
assert_difference 'Cache.unassigned_product_count', 1 do | ||
assigned_product.update!(checker_id: nil) | ||
end | ||
end | ||
end |