Skip to content

Commit

Permalink
Merge pull request #7902 from fjordllc/bug/fix_to_update_admin_attrib…
Browse files Browse the repository at this point in the history
…utes

管理者の登録情報変更からの変更をDBに反映されるように修正
  • Loading branch information
komagata authored Jul 19, 2024
2 parents 8d708ca + 66c3f2d commit 2d068fe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/current_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def user_params
:profile_name, :profile_job, :profile_text, { authored_books_attributes: %i[id title url cover _destroy] },
:feed_url, :country_code, :subdivision_code, { discord_profile_attributes: %i[id account_name times_url] }
]
user_attribute.push(:retired_on, :graduated_on, :free, :github_collaborator) if current_user.admin?
if current_user.admin?
user_attribute.push(:retired_on, :graduated_on, :free, :github_collaborator, :auto_retire, :invoice_payment, :mentor, :subscription_id)
end
params.require(:user).permit(user_attribute)
end

Expand Down
32 changes: 32 additions & 0 deletions test/system/current_user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,36 @@ class CurrentUserTest < ApplicationSystemTestCase

assert_text 'textbringer'
end

test 'update admin user\'s auto_retire' do
visit_with_auth '/current_user/edit', 'komagata'
check '休会六ヶ月後に自動退会しない', allow_label_click: true
click_on '更新する'

assert_not users(:komagata).reload.auto_retire
end

test 'update admin user\'s invoice_payment' do
visit_with_auth '/current_user/edit', 'komagata'
check '請求書払いのユーザーである', allow_label_click: true
click_on '更新する'

assert users(:komagata).reload.invoice_payment
end

test 'update admin user\'s mentor' do
visit_with_auth '/current_user/edit', 'komagata'
uncheck 'メンター', allow_label_click: true
click_on '更新する'

assert_not users(:komagata).reload.mentor
end

test 'update admin user\'s subscription_id' do
visit_with_auth '/current_user/edit', 'komagata'
fill_in 'サブスクリプションID', with: 'sub_987654321'
click_on '更新する'

assert_match users(:komagata).reload.subscription_id, 'sub_987654321'
end
end

0 comments on commit 2d068fe

Please sign in to comment.