Skip to content

Commit

Permalink
system testを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ogawa-tomo committed Jun 10, 2023
1 parent 71948fd commit d7932e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/system/admin/users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,19 @@ class Admin::UsersTest < ApplicationSystemTestCase

test 'make user retired' do
user = users(:hatsuno)
user.update!(times_id: '987654321987654321')
date = Date.current
VCR.use_cassette 'subscription/update' do
visit_with_auth edit_admin_user_path(user.id), 'komagata'
check '退会済', allow_label_click: true
fill_in 'user_retired_on', with: date
click_on '更新する'
Discord::Server.stub(:delete_text_channel, true) do
VCR.use_cassette 'subscription/update' do
visit_with_auth edit_admin_user_path(user.id), 'komagata'
check '退会済', allow_label_click: true
fill_in 'user_retired_on', with: date
click_on '更新する'
end
end
assert_text 'ユーザー情報を更新しました。'
assert_equal date, user.reload.retired_on
assert_nil user.times_id

assert_requested(:post, "https://api.stripe.com/v1/subscriptions/#{user.subscription_id}") do |req|
req.body.include?('cancel_at_period_end=true')
Expand Down
14 changes: 14 additions & 0 deletions test/system/retirement_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ class RetirementTest < ApplicationSystemTestCase
assert_text '退会したユーザーです'
end

test 'retire user with times_channel' do
user = users(:hajime)
user.update!(times_id: '987654321987654321')
Discord::Server.stub(:delete_text_channel, true) do
visit_with_auth new_retirement_path, user.login_name
find('label', text: 'とても良い').click
click_on '退会する'
page.driver.browser.switch_to.alert.accept
assert_text '退会処理が完了しました'
end
assert_equal Date.current, user.reload.retired_on
assert_nil user.times_id
end

test 'retire user with postmark error' do
logs = []
stub_warn_logger = ->(message) { logs << message }
Expand Down

0 comments on commit d7932e3

Please sign in to comment.