Skip to content

Commit

Permalink
[uffizzi_app_113] changed rescued exception type
Browse files Browse the repository at this point in the history
  • Loading branch information
moklidia committed Jun 6, 2022
1 parent 1e606b6 commit 5e37f46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/app/services/uffizzi_core/user_generator_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UffizziCore::UserGeneratorService
class << self
def safe_generate(email, password, project_name)
generate(email, password, project_name)
rescue StandardError => e
rescue ActiveRecord::RecordInvalid => e
puts e.message
end

Expand Down
18 changes: 4 additions & 14 deletions core/test/services/user_generator_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class UffizziCore::UserGeneratorServiceTest < ActiveSupport::TestCase

create(:user, :with_organizational_account, email: email)

assert_raises StandardError do
assert_raises ActiveRecord::RecordInvalid do
UffizziCore::UserGeneratorService.generate(email, password, project_name)
end
end
Expand All @@ -175,7 +175,7 @@ class UffizziCore::UserGeneratorServiceTest < ActiveSupport::TestCase
console_mock.stubs(:gets).returns(email)
IO.stubs(:console).returns(console_mock)

assert_raises StandardError do
assert_raises ActiveRecord::RecordInvalid do
UffizziCore::UserGeneratorService.generate(email, password, project_name)
end
end
Expand Down Expand Up @@ -206,7 +206,7 @@ class UffizziCore::UserGeneratorServiceTest < ActiveSupport::TestCase

IO.stubs(:console).returns(nil)

assert_raises StandardError do
assert_raises ActiveRecord::RecordInvalid do
UffizziCore::UserGeneratorService.generate(email, password, project_name)
end
end
Expand All @@ -218,7 +218,7 @@ class UffizziCore::UserGeneratorServiceTest < ActiveSupport::TestCase

IO.stubs(:console).returns(nil)

assert_raises StandardError do
assert_raises ActiveRecord::RecordInvalid do
UffizziCore::UserGeneratorService.generate(email, password, project_name)
end
end
Expand All @@ -241,14 +241,4 @@ class UffizziCore::UserGeneratorServiceTest < ActiveSupport::TestCase
UffizziCore::UserGeneratorService.generate(email, password, project_name)
end
end

test '#safe_generate if exception' do
email = generate(:email)
password = generate(:password)
project_name = generate(:string)
UffizziCore::UserGeneratorService.stubs(:generate).raises(StandardError)
StandardError.any_instance.expects(:message).times(1)

UffizziCore::UserGeneratorService.safe_generate(email, password, project_name)
end
end

0 comments on commit 5e37f46

Please sign in to comment.