Skip to content

Commit

Permalink
Merge pull request #6969 from fjordllc/feature/mentor_category_list_n…
Browse files Browse the repository at this point in the history
…umber_of_practices

メンターが見れるカテゴリー画面に、各カテゴリーに所属するプラクティス数を表示
  • Loading branch information
komagata authored Oct 24, 2023
2 parents c8f1423 + 9db236f commit 99b899b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/javascript/components/Categories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const Category = ({ category }) => {
return (
<tr className="admin-table__item">
<td className="admin-table__item-value">
<a href={`/mentor/categories/${category.id}`}>{category.name}</a>
<a href={`/mentor/categories/${category.id}`}>{category.name}</a>(
{category.practices.length})
</td>
<td className="admin-table__item-value">{category.slug}</td>
<td className="admin-table__item-value is-text-align-center">
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/categories/_category.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1 @@
json.(category, :id, :name, :slug)
json.(category, :id, :name, :slug, :practices)
9 changes: 9 additions & 0 deletions test/system/mentor/categories_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,13 @@ class Mentor::CategoriesTest < ApplicationSystemTestCase
find("a[href='/mentor/categories/#{category.id}/practices']").click
assert_text '学習の準備カテゴリーのプラクティス並び替え'
end

test 'should display practice count correctly' do
category_name = '学習の準備'
category = Category.find_by(name: category_name)
practice_count = category.practices.length

visit_with_auth '/mentor/categories', 'komagata'
assert_text "#{category_name}(#{practice_count})"
end
end

0 comments on commit 99b899b

Please sign in to comment.