-
Notifications
You must be signed in to change notification settings - Fork 71
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
管理者の場合、ユーザー情報変更ページでコース変更できるようにした #4596
Merged
komagata
merged 6 commits into
main
from
feature/enable-change-courses-at-user-info-edit-page-when-logined-as-admin
Apr 17, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2cc338f
ユーザー情報変更ページの管理者が変更できる項目に、コースを追加
Saki-htr 41f5e07
不要な{}を削除
Saki-htr e552597
管理者が登録情報変更ページで、コース変更できることを確認するテストを追加
Saki-htr 1a89100
findよりreloadを使ったほうが、シンプルかつuserのデータを再読み込みしているとすぐに理解できるため、変更
Saki-htr 935a07a
Choices-jsを使って、インクリメンタルサーチできる仕様にする際に必要になるため、{}を再追加
Saki-htr 16b7905
管理者以外の一般ユーザーは、ユーザーのコースを変更できないテストを追加
Saki-htr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,4 +216,21 @@ class Admin::UsersTest < ApplicationSystemTestCase | |
assert has_checked_field?('user_trainee', visible: false) | ||
assert has_field?('user_training_ends_on', with: '') | ||
end | ||
|
||
test 'admin can change user course' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 逆に一般ユーザーで変更できると困るので、「一般ユーザーは変更できない」というテストもあるとありがたいです〜 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
user = users(:kensyu) | ||
visit_with_auth "/admin/users/#{user.id}/edit", 'machida' | ||
within 'form[name=user]' do | ||
select 'iOSプログラマー', from: 'user[course_id]' | ||
end | ||
click_on '更新する' | ||
assert_equal 'iOSプログラマー', user.reload.course.title | ||
end | ||
|
||
test 'general user cannot change user course' do | ||
user = users(:kensyu) | ||
visit_with_auth "/admin/users/#{user.id}/edit", 'kimura' | ||
assert_current_path('/') | ||
assert_text '管理者としてログインしてください' | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
余談なんですが、以前レビューさせてもらった、#4385のapp/views/users/form/_company.html.slim で
{}
がないと、その後ろに記述されるHTML属性
が効かなかったので、今後、Choices-js
を使って、インクリメンタルサーチできる仕様にする可能性ありそうな気がしたので、残しておいてもいいのかな〜って一瞬思ったのですが、現状なくても動くので問題ないと思います…!参考にしたサイト
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{}
は、Choices-js
を使って、インクリメンタルサーチできるようにする際に必要なのですね〜勉強になります。ありがとうございます!
Choices-js
を使って、インクリメンタルサーチできる仕様にする可能性があるので削除しないでおくかで非常に迷ったのですが、今後に備えて残しておくことにしました。
61e71e5のコミットで修正しましたので、ご確認をお願いいたします🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
戻して頂いたんですね…!ありがとうございます🙏
Choices-jsに限らず、javascriptとかで何かイベントを発火させたい時に、記述の順番として
HTML属性={} or イベント属性={}
の指定の前にはオプション={}
が必要そうな感じがしました…!もしかしたら、なくても内容によっては動くかもしれませんが😅
参考にしたサイトより↓
私が以前レビューさせてもらったissueの場合だと、
company-select.js
の4行目のgetElementById('js-company-select')
を_company.html.slim
の= f.collection_select
に指定した時に{}
を外すと動かなかったんですよね〜。bootcamp/app/javascript/company-select.js
Lines 3 to 15 in a55ba9f
bootcamp/app/views/users/form/_company.html.slim
Line 4 in a55ba9f