-
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
プラクティス、コース、カテゴリーの編集権限を管理者からメンターに移行する #6344
プラクティス、コース、カテゴリーの編集権限を管理者からメンターに移行する #6344
Conversation
cb05234
to
67d5207
Compare
@wata00913 |
@mono-nobe |
@wata00913 |
# frozen_string_literal: true | ||
|
||
class API::Mentor::BaseController < ApplicationController | ||
skip_before_action :require_active_user_login, raise: false |
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.
require_active_user_login
をスキップする理由は何故でしょうか?
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.
前提として、ApplicationController
で before_action :require_active_user_login
が定義されているため、継承している API::Mentor::BaseController
においても before_action :require_active_user_login
が実行されてしまいます。
しかし、この Controller は API 専用であるため画面でのログインができないため、 skip_before_action
しています!
代わりに、同 Controller 内にある before_action :require_mentor_login_for_api
で権限チェックをしています。
before_action :require_mentor_login_for_api |
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.
詳しく説明して頂きありがとうございます!require_active_user_login
をスキップする理由が理解できました〜
@@ -17,7 +17,7 @@ def create | |||
@category = Category.new(category_params) | |||
|
|||
if @category.save | |||
redirect_to admin_categories_url, notice: 'カテゴリーを作成しました。' | |||
redirect_to mentor_categories_url, notice: 'カテゴリーを作成しました。' | |||
else |
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.
以下のCoursesController#create
アクションとMentor::CoursesController#create
の処理が重複しているようです。CoursesController#create
は削除しても良さそうです。
Mentor::CoursesController
側の処理を残す理由は、名前空間のMentor
があるので責務がより明確になると思いました〜
def create |
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.
CoursesController#create
はコース一覧画面/courses
の「コース作成」ボタンをクリック時に実行されるようです。
もし、Mentor::CoursesController#create
に処理をまとめる場合は、「コース作成」ボタンの遷移先URLを変更する必要がありそうです。
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.
確認したところ、同じ機能を持つ画面が複数存在しているようでした...
そのため、wataさんのおっしゃる通り mentor 用の画面( /mentor/courses/...
)のみ残す方が良いかと思います!
しかし、そちらの対応は今回の issue のスコープ外である気もするため、一度駒形さんに確認させてください 🙇
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.
📝
こちらで確認中
#6344 (comment)
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.
こちら別issueで対応する方針となりましたので、ご確認をお願いします!
#6344 (comment)
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.
こちらの確認、自分の方で早めに対応しておくべきでした。
もののべさんの負担をかけてすみませんでした🙇♂️
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.
@wata00913
いえいえ!
wataさんのご指摘がなかったら今後対応されることはなかったと思うのでとても助かりました!🙌
|
||
class Mentor::PracticesController < MentorController | ||
def index; end | ||
end |
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.
以下のアクションをMentor::PracticesContorller
に移動させた方が責務が明確になるのではないかと思いました。いかがでしょうか?
ただし、処理を移す作業が大変そうなので駒形さんに意見を聞いた方が良さそうです。
def create |
def update |
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.
影響範囲の調査までありがとうございます!
こちらも駒形さんに確認します!
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.
📝
こちらで確認中
#6344 (comment)
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.
同様に別issueで対応する方針となりました。
#6344 (comment)
@@ -14,9 +14,9 @@ | |||
v-if='category.completed_all_practices === true') | |||
| 修了 | |||
.categories-item__description | |||
.categories-item__edit.is-only-mentor(v-if='isRole("admin")') | |||
.categories-item__edit.is-only-mentor(v-if='isRole("mentor")') |
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.
admin
の条件分岐を考慮をしなくても大丈夫でしょうか?
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.
adminユーザーは必ずmentorユーザーでもあるため、mentorのみを考慮しています!
= render @courses.order(:created_at) | ||
- elsif !current_user&.admin? && @courses.where(published: true).present? | ||
- elsif !current_user&.mentor? && @courses.where(published: true).present? |
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.
こちら(18行目、20行目)もadmin
の条件分岐を考慮をしなくても大丈夫でしょうか?
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.
同様の理由でmentorのみ考慮しています。
.courses-item__title-icon.is-closed | ||
| 非表示 | ||
span.courses-item__title-label | ||
= course.title | ||
.courses-item__description | ||
= simple_format(course.description) | ||
- if admin_login? | ||
- if mentor_login? |
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.
こちらも同様です。
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.
同様の理由でmentorのみ考慮しています。
= link_to new_admin_category_path, class: 'a-button is-md is-secondary is-block' do | ||
i.fa-regular.fa-plus | ||
| カテゴリー作成 | ||
- if current_user.admin_or_mentor? |
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.
MentorController
にてログインユーザーの判定をしているので削除して良いかなと思いました。
before_action :require_admin_or_mentor_login |
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.
おっしゃる通り、mentor専用のページでもあるため判定は不要ですね 👀
削除しました!
.page-header__inner | ||
h2.page-header__title = title | ||
.page-header-actions | ||
- if current_user.admin_or_mentor? |
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.
こちらの条件処理もMentorController
にてログインユーザーの判定をしているので削除して良いかなと思いました。
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.
こちらも同様の理由で削除しました!
test/system/admin/home_test.rb
Outdated
@@ -6,5 +6,12 @@ class Admin::HomeTest < ApplicationSystemTestCase | |||
test 'GET /admin' do | |||
visit_with_auth '/admin', 'komagata' | |||
assert_equal '管理ページ | FBC', title | |||
assert_selector '.page-tabs__item-link', text: '管理ページ', visible: true |
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.
visible: true
が必要なのは何故でしょうか?
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.
Capybara の仕様を正しく理解していませんでした...
オプション不要なため削除しました!
test/system/admin/home_test.rb
Outdated
assert_selector '.page-tabs__item-link', text: 'ユーザー', visible: true | ||
assert_selector '.page-tabs__item-link', text: '企業', visible: true | ||
assert_selector '.page-tabs__item-link', text: 'お試し延長', visible: true | ||
assert_no_selector '.page-tabs__item-link', text: 'プラクティス', visible: true |
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.
タブがないことを保証するテストを書いてて良いですね!👍
もう少し抽象化出来ると良さそうです!例えば、.page-tabs__item-link
をもつselectorの個数が4つ(つまり表示されているタブの個数)であることを保証するテストコードに置き換えるのはどうでしょうか?
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.
タブがないことを保証するテストを書いてて良いですね!👍
ありがとうございます!😊
例えば、.page-tabs__item-linkをもつselectorの個数が4つ(つまり表示されているタブの個数)であることを保証するテストコードに置き換えるのはどうでしょうか?
確かに、現状だとタブが増えてもテストが通ってしまいますね... 🤔
何のタブが表示されているかのテストは残したいので、selector の個数も確認するよう追加しました!
assert_selector '.page-tabs__item-link', text: 'コース', visible: true | ||
assert_no_selector '.page-tabs__item-link', text: 'ユーザー', visible: true | ||
assert_no_selector '.page-tabs__item-link', text: '企業', visible: true | ||
assert_no_selector '.page-tabs__item-link', text: 'お試し延長', visible: true |
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.
こちらのコメントと同じです。
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.
同様にassertionを追加しました!
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.
@mono-nobe
mononobeさん、お待たせしました🙏
動作確認について
動作確認はOKでした〜
変更確認方法について確認したいこと、指摘内容があります。
- 確認したいこと
- 手順7.「コースページについて、以下の内容を確認する」の「コースを並び替えられる」での動作確認対象のページは、
/courses/{course_id}/categories
で合っているでしょうか? - 手順7.「コースページについて、以下の内容を確認する」の「プラクティスを並び替えられる」での動作確認対象のページは、
/courses/{course_id}/practices/sort
で合っているでしょうか?
- 手順7.「コースページについて、以下の内容を確認する」の「コースを並び替えられる」での動作確認対象のページは、
- 指摘内容
コードについて
細かいコメントはコード毎に記載しております。自分の観点でコメントしましたが、気になることや間違いがあれば是非ご指摘をよろしくお願いします🙏
あと、1点確認したいことがあります。
管理者はメンターの役割も必ず持つのでしょうか?
今回のIssueではプラクティス
、カテゴリー
、コース
の編集権限を管理者だけでなく、メンターも追加することだと思いますが、メンターのみを考慮したコードが幾つかありました。
メンターでない管理者がいるケースだと、メンターのみを考慮したコードの修正が必要だと思います。
@wata00913 |
6eef41e
to
8a9bb1e
Compare
@komagata |
こちら @machida さんよりご回答いただき、別 issue(#6536) で実施することになった https://discord.com/channels/715806612824260640/809595476847493192/1109043419441016862 |
@wata00913
はい!どちらとも合っております! 🙆♂️
失礼しました。
ありがとうございます!😊
こちら確認したところ、管理者はメンターの役割を必ず持つとのことでした! これからは時間が取りやすくなるため、今回のように時間がかかることはないかと思います。。 |
@wata00913 |
了解しました、動作確認やコードの確認はテストが通った後確認しようと思います! それと、現在コンフリクトが起きているみたいなので、対応の方を後程よろしくお願いします!🙏 |
a3ea8b7
to
2ff8a75
Compare
- 各種作成 - カテゴリー削除 - プラクティスの順番変更
0d4cb90
to
e21f240
Compare
@komagata |
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.
確認させて頂きました。OKです〜🙆♂️
Issue
概要
プラクティス、コース、カテゴリーの編集権限を管理者からメンター(管理ページからメンターページ)に移行しました。
また、管理ページから上記項目を削除しました。
変更確認方法
feature/grant-edit-permission-to-mentor-for-categories-courses-practices
をローカルに取り込むmentormentaro
でログインするkomagata
でログインするコースを並び替える操作
プラクティスを並び替える操作
Screenshot
変更前
メンターページ
プラクティス、コース、カテゴリーのタブが存在しない
管理ページ
プラクティス、コース、カテゴリーのタブが存在する
変更後
メンターページ
プラクティス、コース、カテゴリーのタブが存在する
管理ページ
プラクティス、コース、カテゴリーのタブが存在しない