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

提出物個別ページのメンター用サイドカラムに提出物一覧を追加した #5347

Merged
merged 5 commits into from
Aug 27, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#side-tabs-3:checked ~ .side-tabs-contents #side-tabs-content-3
display: block

#side-tabs-4:checked ~ .side-tabs-contents #side-tabs-content-4
display: block

.side-tabs-contents__item
display: none
.a-card
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#side-tabs-1:checked ~ .side-tabs-nav #side-tabs-nav-1,
#side-tabs-2:checked ~ .side-tabs-nav #side-tabs-nav-2,
#side-tabs-3:checked ~ .side-tabs-nav #side-tabs-nav-3
#side-tabs-3:checked ~ .side-tabs-nav #side-tabs-nav-3,
#side-tabs-4:checked ~ .side-tabs-nav #side-tabs-nav-4
background-color: $base
color: $default-text

Expand Down
4 changes: 4 additions & 0 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def show
.limit(10)
.includes(:comments, :checks)
.order(reported_on: :DESC)
@products = @product.user
.products
.not_wip
.order(published_at: :DESC)
@practice = find_practice
@learning = @product.learning # decoratorメソッド用にcontrollerでインスタンス変数化
@footprints = find_footprints
Expand Down
8 changes: 8 additions & 0 deletions app/views/products/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ header.page-header
input.a-toggle-checkbox#side-tabs-1 type='radio' name='side-tabs-contents' checked='checked'
input.a-toggle-checkbox#side-tabs-2 type='radio' name='side-tabs-contents'
input.a-toggle-checkbox#side-tabs-3 type='radio' name='side-tabs-contents'
input.a-toggle-checkbox#side-tabs-4 type='radio' name='side-tabs-contents'
.side-tabs-nav
.side-tabs-nav__items
.side-tabs-nav__item
Expand All @@ -64,6 +65,9 @@ header.page-header
.side-tabs-nav__item
label.side-tabs-nav__item-link#side-tabs-nav-3 for='side-tabs-3'
| ユーザーメモ
.side-tabs-nav__item
label.side-tabs-nav__item-link#side-tabs-nav-4 for='side-tabs-4'
| 提出物
.side-tabs-contents
.side-tabs-contents__item#side-tabs-content-1
.card-list.a-card
Expand All @@ -85,6 +89,10 @@ header.page-header
= render 'users/user_secret_attributes', user: @product.user
= render 'users/metas', user: @product.user
#js-user-mentor-memo(data-user-id="#{@product.user.id}" data-products-mode="#{true}")
.side-tabs-contents__item#side-tabs-content-4
.card-list.a-card
- @products.each do |product|
= render partial: 'product', locals: { product: product }

- if !current_user.adviser? && @product.practice.open_product?
.sticky-message
Expand Down
12 changes: 12 additions & 0 deletions test/system/products_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ class ProductsTest < ApplicationSystemTestCase
assert_text '直近の日報'
assert_text 'プラクティスメモ'
assert_text 'ユーザーメモ'
assert_selector '#side-tabs-nav-4', text: '提出物'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここだけ、assert_selector '#side-tabs-nav-4', text: '提出物'の書き方をしているのが気になりました!自分の環境でassert_text '提出物'でテストを実行して問題はありませんでした。何か理由がない場合、assert_text '直近の日報'などのようにassert_text '提出物'で書いた方がいいかな?と思ったのですが、いかがでしょうか🙏

students can not see block for mentorsのテストも同様です。

Copy link
Contributor Author

@keiz1213 keiz1213 Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nabegon
とても難しそうなissueをやられてる中お時間をさいていただきありがとうございます!🙏

確かにこちらの書き方は不自然だな〜と自分でも思ってました😅
アサーションをassert_text '提出物'ではなくassert_selector '#side-tabs-nav-4', text: '提出物'にした理由としましては、このページにはサイドカラムのタブ以外にも提出物というテキストが存在するため、それとスコープを分ける目的でこのアサーションにしました。

試しに、assert_selector '#side-tabs-nav-4', text: '提出物'assert_text '提出物'に変えて、サイドカラムのタブの文言をていしゅつぶつにしてテストしてみたところテストが通ってしまい、テストの趣旨とは外れた結果となってしまいました。

※ 画像をわかりやすい方に取り替えました8/26
_development__OS_X_Mountain_Lionをクリーンインストールする___FBC

Copy link
Contributor

@Nabegon Nabegon Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keiz1213 さん、ご教示いただきありがとうございます!なるほどです、提出物という文言があるためにassert_text '提出物'だけでは不十分なのですね。なぜassert_selector '#side-tabs-nav-4', text: '提出物'と書いているのかについて理解できました🙏

end

test 'students can not see block for mentors' do
visit_with_auth "/products/#{products(:product2).id}", 'hatsuno'
assert_no_text '直近の日報'
assert_no_text 'プラクティスメモ'
assert_no_text 'ユーザーメモ'
assert_no_selector '#side-tabs-nav-4', text: '提出物'
end

test 'display the user memos after click on user-memos tab' do
Expand Down Expand Up @@ -463,6 +465,16 @@ class ProductsTest < ApplicationSystemTestCase
click_button '保存する'
end

test 'display a list of products in side-column' do
user = users(:kimura)
visit_with_auth "/products/#{products(:product2).id}", 'mentormentaro'
page.find('#side-tabs-nav-4').click
products = user.products.not_wip
products.each do |product|
assert_text "#{product.practice.title}の提出物"
end
end

test 'can see unassigned-tab' do
visit_with_auth products_path, 'komagata'
assert find('.page-tabs__item-link', text: '未アサイン')
Expand Down