Skip to content
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

担当が決まっていない提出物にメンターがコメントをした場合にアラートを出す #7953

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/javascript/checkable.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ export default {
console.warn(error)
})
},
checkProduct(productId, currentUserId, url, method, token) {
checkProduct(
productId,
currentUserId,
url,
method,
token,
isChargeFromComment
) {
const params = {
product_id: productId,
current_user_id: currentUserId
Expand All @@ -81,6 +88,9 @@ export default {
this.id = json.checker_id
this.name = json.checker_name
if (this.id !== null) {
if (isChargeFromComment) {
alert('提出物の担当になりました。') // 担当が決まっていない提出物にメンターがコメントをした場合にアラートを出す
}
this.toast('担当になりました。')
} else {
this.toast('担当から外れました。')
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ export default {
this.currentUserId,
'/api/products/checker',
'PATCH',
CSRF.getToken()
CSRF.getToken(),
true
)
}
},
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/product_checker.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template lang="pug">
button(
v-if='!checkerId || checkerId === currentUserId',
:class='["a-button", "is-block", id ? "is-warning" : "is-secondary", checkableType ? "is-sm" : "is-sm"]',
:class='["a-button", "is-block", productCheckerId ? "is-warning" : "is-secondary", checkableType ? "is-sm" : "is-sm"]',
@click='checkInCharge')
i(
v-if='!checkerId || checkerId === currentUserId',
Expand Down Expand Up @@ -64,7 +64,8 @@ export default {
this.currentUserId,
'/api/products/checker',
this.productCheckerId ? 'DELETE' : 'PATCH',
CSRF.getToken()
CSRF.getToken(),
false
)
}
}
Expand Down
1 change: 1 addition & 0 deletions test/system/comments_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class CommentsTest < ApplicationSystemTestCase
fill_in('new_comment[description]', with: 'test')
end
click_button 'コメントする'
accept_alert '提出物の担当になりました。'
assert_text 'test'
assert_text 'Watch中'
end
Expand Down
1 change: 1 addition & 0 deletions test/system/product/checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def assigned_product_count
visit "/products/#{products(:product1).id}"

post_comment('担当者がいない提出物の場合、担当者になる')
accept_alert '提出物の担当になりました。'
assert_text '担当になりました。'
assert_text '担当から外れる'

Expand Down
1 change: 1 addition & 0 deletions test/system/product/unchecked_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Product::UncheckedTest < ApplicationSystemTestCase
visit_with_auth "/products/#{product.id}", 'mentormentaro'
fill_in('new_comment[description]', with: 'test')
click_button 'コメントする'
accept_alert '提出物の担当になりました。'
within('.thread-comment.is-latest') do
assert_text 'mentormentaro'
assert_text 'test'
Expand Down
1 change: 1 addition & 0 deletions test/system/products_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class ProductsTest < ApplicationSystemTestCase
visit_with_auth "/products/#{products(:product1).id}", 'komagata'
fill_in 'new_comment[description]', with: 'コメントしたら担当になるテスト'
click_button 'コメントする'
accept_alert '提出物の担当になりました。'
assert_text 'コメントしたら担当になるテスト'
visit current_path
assert_text '担当から外れる'
Expand Down