Skip to content

Commit

Permalink
Merge pull request #7619 from fjordllc/feature/update-users-filtering…
Browse files Browse the repository at this point in the history
…-rules-about-student-and-trainee

ユーザー一覧ページの絞り込みにおける現役生と研修生のルールを整理
  • Loading branch information
komagata authored May 28, 2024
2 parents f73c490 + 6984d3c commit b79fc6c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def search_for_users(target, target_users, search_word)
end

def target_allowlist
target_allowlist = %w[student_and_trainee followings mentor graduate adviser trainee year_end_party]
target_allowlist = %w[student_and_trainee student trainee followings mentor graduate adviser year_end_party]
target_allowlist.push('job_seeking') if current_user.adviser?
target_allowlist.push('all') if @company
target_allowlist.concat(%w[job_seeking hibernated retired inactive all]) if current_user.mentor? || current_user.admin?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def fetch_target_users
end

def target_allowlist
target_allowlist = %w[student_and_trainee followings mentor graduate adviser trainee year_end_party]
target_allowlist = %w[student_and_trainee student trainee followings mentor graduate adviser year_end_party]
target_allowlist.push('job_seeking') if current_user.adviser?
target_allowlist.concat(%w[job_seeking hibernated retired inactive all]) if current_user.mentor? || current_user.admin?
target_allowlist
Expand Down
8 changes: 5 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class User < ApplicationRecord
RESERVED_LOGIN_NAMES = %w[adviser all graduate inactive job_seeking mentor retired student student_and_trainee trainee year_end_party].freeze
MAX_PERCENTAGE = 100
DEPRESSED_SIZE = 2
ALL_ALLOWED_TARGETS = %w[adviser all campaign graduate hibernated inactive job_seeking mentor retired student_and_trainee trainee year_end_party].freeze
ALL_ALLOWED_TARGETS = %w[adviser all campaign graduate hibernated inactive job_seeking mentor retired student_and_trainee student trainee
year_end_party].freeze
# 本来であればtarget = scope名としたいが、歴史的経緯によりtargetとscope名が一致しないものが多数あるため、名前が一致しない場合はこのハッシュを使ってscope名に変換する
TARGET_TO_SCOPE = {
'student_and_trainee' => :students_and_trainees,
'student' => :students,
'trainee' => :trainees,
'graduate' => :graduated,
'adviser' => :advisers,
'trainee' => :trainees
'adviser' => :advisers
}.freeze
DEFAULT_REGULAR_EVENT_ORGANIZER = 'komagata'
HIBERNATION_LIMIT = 6.months
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_nav.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nav.tab-nav
li.tab-nav__item
= link_to t("watch.#{watch}"), users_path(target: @target, watch:), class: (@watch == watch ? ['is-active'] : []) << 'tab-nav__item-link'
- else
- targets = %w[student_and_trainee mentor graduate adviser trainee]
- targets = %w[student_and_trainee student trainee mentor graduate adviser]
- if current_user.mentor?
- targets += %w[job_seeking hibernated retired all]
- elsif current_user.adviser?
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ ja:
end_at:
format: 'は%{shortest_end_at}以降を入力してください。'
target:
student_and_trainee: 現役生
student_and_trainee: 現役 + 研修生
student: 現役生
job_seeking: 就職活動中
hibernationed: 休会中
Expand Down
4 changes: 2 additions & 2 deletions test/system/company/users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class Company::UsersTest < ApplicationSystemTestCase

test 'show users by user category' do
visit_with_auth "/companies/#{companies(:company2).id}/users", 'kimura'
# デフォルトは現役生のユーザーを表示
# デフォルトは現役 + 研修生のユーザーを表示
# Kensyu Owata は研修を終えている研修生
assert_no_text 'Kensyu Owata'

click_link '全員'
assert_text 'Kensyu Owata'

click_link '現役生'
click_link '現役 + 研修生'
assert_no_text 'Kensyu Owata'
end
end
21 changes: 21 additions & 0 deletions test/system/users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,25 @@ class UsersTest < ApplicationSystemTestCase
assert_selector '.users-item__inactive-message-container.is-only-mentor .users-item__inactive-message', text: '休会中: 2020年01月01日〜(10日経過)'
end
end

test 'students and trainees filter' do
visit_with_auth '/users', 'komagata'
click_link '現役 + 研修生'

assert_selector('a.tab-nav__item-link.is-active', text: '現役 + 研修生')
filtered_users = all('.users-item__icon .a-user-role')
assert(filtered_users.all? do |user|
classes = user[:class].split(' ')
classes.include?('is-student') || classes.include?('is-trainee')
end)
end

test 'students filter' do
visit_with_auth '/users', 'komagata'
click_link '現役生'

assert_selector('a.tab-nav__item-link.is-active', text: '現役生')
filtered_users = all('.users-item__icon .a-user-role')
assert(filtered_users.all? { |user| user[:class].split(' ').include?('is-student') })
end
end

0 comments on commit b79fc6c

Please sign in to comment.