mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 03:37:28 +02:00
Refactor epp error due to Rails 6.1 changes
This commit is contained in:
parent
39bbe6e06d
commit
c613de1a11
5 changed files with 12 additions and 11 deletions
|
@ -67,7 +67,7 @@ module Repp
|
||||||
@epp_errors ||= []
|
@epp_errors ||= []
|
||||||
|
|
||||||
obj&.construct_epp_errors
|
obj&.construct_epp_errors
|
||||||
@epp_errors += obj.errors[:epp_errors] if obj
|
@epp_errors += obj.errors.where(:epp_errors).map(&:options) if obj
|
||||||
|
|
||||||
format_epp_errors if update
|
format_epp_errors if update
|
||||||
@epp_errors.uniq!
|
@epp_errors.uniq!
|
||||||
|
|
|
@ -151,7 +151,7 @@ module Repp
|
||||||
@successful << { type: 'domain_transfer', domain_name: domain.name }
|
@successful << { type: 'domain_transfer', domain_name: domain.name }
|
||||||
else
|
else
|
||||||
@errors << { type: 'domain_transfer', domain_name: domain.name,
|
@errors << { type: 'domain_transfer', domain_name: domain.name,
|
||||||
errors: domain.errors[:epp_errors] }
|
errors: domain.errors.where(:epp_errors)[0].options }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ module Actions
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
return unless domain_exists?
|
return false unless domain_exists?
|
||||||
return unless valid_transfer_code?
|
return false unless valid_transfer_code?
|
||||||
|
|
||||||
run_validations
|
run_validations
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
module EppErrors
|
module EppErrors
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
included do
|
||||||
|
attr_accessor :epp_errors
|
||||||
|
end
|
||||||
|
|
||||||
def construct_epp_errors
|
def construct_epp_errors
|
||||||
epp_errors = []
|
epp_errors = []
|
||||||
|
@ -19,9 +22,7 @@ module EppErrors
|
||||||
|
|
||||||
epp_errors << collect_parent_errors(attr, errors)
|
epp_errors << collect_parent_errors(attr, errors)
|
||||||
end
|
end
|
||||||
|
errors.add(:epp_errors, epp_errors) unless epp_errors.empty?
|
||||||
errors.add(:epp_errors, epp_errors)
|
|
||||||
errors[:epp_errors].flatten!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect_parent_errors(attr, errors)
|
def collect_parent_errors(attr, errors)
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal 1000, json[:code]
|
assert_equal 1000, json[:code]
|
||||||
assert_equal 'Command completed successfully', json[:message]
|
assert_equal 'Command completed successfully', json[:message]
|
||||||
|
|
||||||
assert_equal 'Object status prohibits operation', json[:data][:failed][0][:errors][0][:msg]
|
assert_equal 'Object status prohibits operation', json[:data][:failed][0][:errors][:msg]
|
||||||
|
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal 1000, json[:code]
|
assert_equal 1000, json[:code]
|
||||||
assert_equal 'Command completed successfully', json[:message]
|
assert_equal 'Command completed successfully', json[:message]
|
||||||
|
|
||||||
assert_equal "Invalid authorization information", json[:data][:failed][0][:errors][0][:msg]
|
assert_equal "Invalid authorization information", json[:data][:failed][0][:errors][:msg]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_does_not_transfer_domain_to_same_registrar
|
def test_does_not_transfer_domain_to_same_registrar
|
||||||
|
@ -121,7 +121,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal 1000, json[:code]
|
assert_equal 1000, json[:code]
|
||||||
assert_equal 'Command completed successfully', json[:message]
|
assert_equal 'Command completed successfully', json[:message]
|
||||||
|
|
||||||
assert_equal 'Domain already belongs to the querying registrar', json[:data][:failed][0][:errors][0][:msg]
|
assert_equal 'Domain already belongs to the querying registrar', json[:data][:failed][0][:errors][:msg]
|
||||||
|
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal 1000, json[:code]
|
assert_equal 1000, json[:code]
|
||||||
assert_equal 'Command completed successfully', json[:message]
|
assert_equal 'Command completed successfully', json[:message]
|
||||||
|
|
||||||
assert_equal 'Object is not eligible for transfer', json[:data][:failed][0][:errors][0][:msg]
|
assert_equal 'Object is not eligible for transfer', json[:data][:failed][0][:errors][:msg]
|
||||||
|
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue