Skip to content

Commit

Permalink
引数の順番を修正する
Browse files Browse the repository at this point in the history
  • Loading branch information
yocchan-git committed Mar 29, 2024
1 parent 5d240d3 commit 871bce7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/talks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def index
users = User.users_role(@target, allowed_targets: ALLOWED_TARGETS, default_target: 'all')

if params[:search_word]
search_user = SearchUser.new(users:, target: @target, search_word: params[:search_word], require_retire_user: true)
search_user = SearchUser.new(search_word: params[:search_word], users:, target: @target, require_retire_user: true)
@search_word = search_user.search_word
end

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 @@ -22,7 +22,7 @@ def index

@users = @users.unhibernated.unretired unless @target.in? %w[hibernated retired]
if params[:search_word]
search_user = SearchUser.new(users: @users, target: @target, search_word: params[:search_word])
search_user = SearchUser.new(search_word: params[:search_word], users: @users, target: @target)
@users = search_user.search
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/search_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class SearchUser
attr_reader :search_word

def initialize(users: nil, search_word:, target: nil, require_retire_user: false)
def initialize(search_word:, users: nil, target: nil, require_retire_user: false)
@users = users
@search_word = validate_search_word(search_word)
@target = target
Expand Down
6 changes: 3 additions & 3 deletions test/models/search_user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SearchUserTest < ActiveSupport::TestCase
kimura = users(:kimura)
komagata = users(:komagata)
search_user = SearchUser.new(search_word: 'kimu')

searched_users = search_user.search
assert_includes searched_users, kimura
assert_not_includes searched_users, komagata
Expand Down Expand Up @@ -45,10 +45,10 @@ class SearchUserTest < ActiveSupport::TestCase
allowed_targets = %w[student_and_trainee followings mentor graduate adviser trainee year_end_party]
users = User.users_role('mentor', allowed_targets:)

search_user = SearchUser.new(users: , search_word: 'kimu')
search_user = SearchUser.new(search_word: 'kimu', users:)
assert_not_includes search_user.search, kimura

search_user = SearchUser.new(users: , search_word: 'メンター')
search_user = SearchUser.new(search_word: 'メンター', users:)
assert_includes search_user.search, mentor
end
end

0 comments on commit 871bce7

Please sign in to comment.