Skip to content

Commit

Permalink
times_channel_destroyer_testを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ogawa-tomo committed Jun 10, 2023
1 parent 8f91c0b commit 71948fd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/models/times_channel_destroyer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'test_helper'

class TimesChannelCreatorTest < ActiveSupport::TestCase
test '#call' do
logs = []
user = users(:hajime)
user.update!(times_id: '987654321987654321')
Rails.logger.stub(:warn, ->(message) { logs << message }) do
Discord::Server.stub(:delete_text_channel, true) do
TimesChannelDestroyer.new.call(user)
end
assert_nil user.times_id
assert_nil logs.last
end
end

test '#call with failure' do
logs = []
user = users(:hajime)
user.update!(times_id: '987654321987654321')
Rails.logger.stub(:warn, ->(message) { logs << message }) do
Discord::Server.stub(:delete_text_channel, nil) do
TimesChannelDestroyer.new.call(user)
end
assert_equal '987654321987654321', user.times_id
assert_equal "[Discord API] #{user.login_name}の分報チャンネルが削除できませんでした。", logs.last
end
end
end

0 comments on commit 71948fd

Please sign in to comment.