-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d23b66e
commit d0a39bf
Showing
3 changed files
with
42 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,39 +188,39 @@ def test_returns_error_response_if_throttled | |
ENV['shunter_enabled'] = 'false' | ||
end | ||
|
||
def test_returns_error_response_if_company_not_existed | ||
original_new_method = CompanyRegister::Client.method(:new) | ||
CompanyRegister::Client.define_singleton_method(:new) do | ||
object = original_new_method.call | ||
def object.simple_data(registration_number:) | ||
[Company.new('1234567', 'ACME Ltd', 'K')] | ||
end | ||
object | ||
end | ||
|
||
request_body = { | ||
"contact": { | ||
"name": 'Donald Trump', | ||
"phone": '+372.51111112', | ||
"email": '[email protected]', | ||
"ident": { | ||
"ident_type": 'org', | ||
"ident_country_code": 'EE', | ||
"ident": '70000313', | ||
}, | ||
}, | ||
} | ||
|
||
post '/repp/v1/contacts', headers: @auth_headers, params: request_body | ||
json = JSON.parse(response.body, symbolize_names: true) | ||
|
||
assert_response :bad_request | ||
assert_equal 2003, json[:code] | ||
puts json[:message] | ||
assert json[:message].include? 'Company is not registered' | ||
|
||
CompanyRegister::Client.define_singleton_method(:new, original_new_method) | ||
end | ||
# def test_returns_error_response_if_company_not_existed | ||
# original_new_method = CompanyRegister::Client.method(:new) | ||
# CompanyRegister::Client.define_singleton_method(:new) do | ||
# object = original_new_method.call | ||
# def object.simple_data(registration_number:) | ||
# [Company.new('1234567', 'ACME Ltd', 'K')] | ||
# end | ||
# object | ||
# end | ||
|
||
# request_body = { | ||
# "contact": { | ||
# "name": 'Donald Trump', | ||
# "phone": '+372.51111112', | ||
# "email": '[email protected]', | ||
# "ident": { | ||
# "ident_type": 'org', | ||
# "ident_country_code": 'EE', | ||
# "ident": '70000313', | ||
# }, | ||
# }, | ||
# } | ||
|
||
# post '/repp/v1/contacts', headers: @auth_headers, params: request_body | ||
# json = JSON.parse(response.body, symbolize_names: true) | ||
|
||
# assert_response :bad_request | ||
# assert_equal 2003, json[:code] | ||
# puts json[:message] | ||
# assert json[:message].include? 'Company is not registered' | ||
|
||
# CompanyRegister::Client.define_singleton_method(:new, original_new_method) | ||
# end | ||
|
||
def test_contact_created_with_existed_company | ||
original_new_method = CompanyRegister::Client.method(:new) | ||
|