Skip to content

Commit

Permalink
Merge pull request #8169 from fjordllc/bug/users-in-other-courses-are…
Browse files Browse the repository at this point in the history
…-not-displayed

コース別ユーザー一覧ページにおいて「その他」のコースに所属するユーザーが表示されない不具合を修正した
  • Loading branch information
komagata authored Nov 7, 2024
2 parents e925480 + f1f6a1f commit cf95cfd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
8 changes: 7 additions & 1 deletion app/controllers/users/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ class Users::CoursesController < ApplicationController

def index
@target = ALLOWED_TARGETS.include?(params[:target]) ? params[:target] : ALLOWED_TARGETS.first
course_names = Course.where(published: true).where(title: I18n.t("course_names.#{@target}")).pluck(:title)
course_names =
if @target == 'other_courses'
Course.where(published: false).pluck(:title)
else
Course.where(published: true).where(title: I18n.t("course_names.#{@target}")).pluck(:title)
end

target_users = User.by_course(course_names).students_and_trainees
@users = target_users
.page(params[:page]).per(PAGER_NUMBER)
Expand Down
9 changes: 5 additions & 4 deletions app/views/users/courses/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ main.page-main
label.a-form-label
| 絞り込み
= hidden_field_tag :target, params[:target]
= text_field_tag :search_word, params[:search_word], class: 'a-text-input',
placeholder: 'ユーザーID、ユーザー名、読み方、Discord ID など',
onchange: 'this.form.submit()',
id: 'js-user-search-input'
= text_field_tag :search_word, params[:search_word],
class: 'a-text-input',
placeholder: 'ユーザーID、ユーザー名、読み方、Discord ID など',
onchange: 'this.form.submit()',
id: 'js-user-search-input'
.page-content.is-users
#user_lists.users__items
= render 'users/user_list', users: @users
1 change: 0 additions & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ ja:
course_names:
rails_course: Railsエンジニア
front_end_course: フロントエンドエンジニア
other_courses: [Unityゲームエンジニア, iOSエンジニア]
watch:
all: すべて
true: コメントあり
Expand Down
13 changes: 6 additions & 7 deletions test/system/user/courses_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ class User::CoursesTest < ApplicationSystemTestCase
test 'show users sorted by other courses' do
visit_with_auth '/users/courses?target=other_courses', 'kimura'
assert_selector('a.tab-nav__item-link.is-active', text: 'その他')
assert_text 'その他のコース(0)'
assert_selector '.users-item', count: 0
assert_text 'その他のユーザーはいません'
assert_no_link 'unity-course'
assert_no_text 'Unityゲームエンジニアコースのユーザー'
assert_no_link 'ios-course'
assert_no_text 'iOSエンジニアコースのユーザー'
assert_text 'その他のコース(2)'
assert_selector '.users-item', count: 2
assert_link 'unity-course'
assert_text 'Unityゲームエンジニアコースのユーザー'
assert_link 'ios-course'
assert_text 'iOSエンジニアコースのユーザー'
end
end

0 comments on commit cf95cfd

Please sign in to comment.