---
# System prepended metadata

title: Teste MR 647

---

---
title: Teste MR 647
---

## Tentar recriar zona de mx já existente. Não deve duplicar

```ruby
irb(main):001:0> list_dns_record = CartorioClient::DnsRecord.list 'cafefriocomcalor.com'
=> [#<CartorioClient::DnsRecord:0x0000000674faa8 @domain="cafefriocomcalor.com", @type="CNAME", @content=["autodiscover.email.locaweb.com.br"], @ttl=3600, @disabled=false, @name="autodiscover", @full_name="autodiscover.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674eea0 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="smtp", @full_name="smtp.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674e5b8 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="pop", @full_name="pop.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674e018 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="imap", @full_name="imap.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674d7f8 @domain="cafefriocomcalor.com", @type="CNAME", @content=["calendario.locaweb.com.br"], @ttl=3600, @disabled=false, @name="calendario", @full_name="calendario.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674cf10 @domain="cafefriocomcalor.com", @type="CNAME", @content=["webmail-seguro.com.br"], @ttl=3600, @disabled=false, @name="webmail", @full_name="webmail.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674c970 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="pop3", @full_name="pop3.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000674c1c8 @domain="cafefriocomcalor.com", @type="TXT", @content=["\"v=spf1 include:_spf.locaweb.com.br -all\""], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000676fad8 @domain="cafefriocomcalor.com", @type="MX", @content=["20 mx.jk.locaweb.com.br", "10 mx.core.locaweb.com.br", "10 mx.b.locaweb.com.br", "20 mx.a.locaweb.com.br"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000676f218 @domain="cafefriocomcalor.com", @type="SOA", @content=["ns1.systemintegration.locaweb.com.br. postmaster.locaweb.com.br. 2022030905 3600 600 1209600 3600"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000676e5c0 @domain="cafefriocomcalor.com", @type="NS", @content=["ns2.systemintegration.locaweb.com.br", "ns1.systemintegration.locaweb.com.br", "ns3.systemintegration.locaweb.com.br"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">]
```

```ruby
irb(main):002:0> list_dns_record.find { |m| m.type == 'MX' }
=> #<CartorioClient::DnsRecord:0x0000000676fad8 @domain="cafefriocomcalor.com", @type="MX", @content=["20 mx.jk.locaweb.com.br", "10 mx.core.locaweb.com.br", "10 mx.b.locaweb.com.br", "20 mx.a.locaweb.com.br"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">
```
        
```ruby
irb(main):006:0> Dns::EntryCreator.call('cafefriocomcalor.com')
=> [{"content"=>"webmail-seguro.com.br", "name"=>"webmail", "type"=>"CNAME"}, {"content"=>"mail.ita.locamail.com.br", "name"=>"smtp", "type"=>"CNAME"}, {"content"=>"mail.ita.locamail.com.br", "name"=>"pop", "type"=>"CNAME"}, {"content"=>"mail.ita.locamail.com.br", "name"=>"pop3", "type"=>"CNAME"}, {"content"=>"mail.ita.locamail.com.br", "name"=>"imap", "type"=>"CNAME"}, {"content"=>"calendario.locaweb.com.br", "name"=>"calendario", "type"=>"CNAME"}, {"content"=>{0=>{"priority"=>20, "value"=>"mx.a.locaweb.com.br"}, 1=>{"priority"=>10, "value"=>"mx.b.locaweb.com.br"}, 2=>{"priority"=>10, "value"=>"mx.core.locaweb.com.br"}, 3=>{"priority"=>20, "value"=>"mx.jk.locaweb.com.br"}}, "name"=>".", "type"=>"MX"}, {"content"=>"\"v=spf1 include:_spf.locaweb.com.br -all\"", "name"=>".", "type"=>"TXT"}, {"content"=>"autodiscover.email.locaweb.com.br", "name"=>"autodiscover", "type"=>"CNAME"}]
```
    
```ruby        
irb(main):007:0> list_dns_record = CartorioClient::DnsRecord.list 'cafefriocomcalor.com'
=> [#<CartorioClient::DnsRecord:0x00000007371f70 @domain="cafefriocomcalor.com", @type="CNAME", @content=["autodiscover.email.locaweb.com.br"], @ttl=3600, @disabled=false, @name="autodiscover", @full_name="autodiscover.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x00000007371a48 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="smtp", @full_name="smtp.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x00000007371598 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="pop", @full_name="pop.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x00000007370dc8 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="imap", @full_name="imap.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x000000073707d8 @domain="cafefriocomcalor.com", @type="CNAME", @content=["calendario.locaweb.com.br"], @ttl=3600, @disabled=false, @name="calendario", @full_name="calendario.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x000000073702b0 @domain="cafefriocomcalor.com", @type="CNAME", @content=["webmail-seguro.com.br"], @ttl=3600, @disabled=false, @name="webmail", @full_name="webmail.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000736bdc8 @domain="cafefriocomcalor.com", @type="CNAME", @content=["mail.ita.locamail.com.br"], @ttl=3600, @disabled=false, @name="pop3", @full_name="pop3.cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000736b760 @domain="cafefriocomcalor.com", @type="TXT", @content=["\"v=spf1 include:_spf.locaweb.com.br -all\""], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000736b1c0 @domain="cafefriocomcalor.com", @type="MX", @content=["20 mx.jk.locaweb.com.br", "10 mx.core.locaweb.com.br", "10 mx.b.locaweb.com.br", "20 mx.a.locaweb.com.br"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000736ab30 @domain="cafefriocomcalor.com", @type="SOA", @content=["ns1.systemintegration.locaweb.com.br. postmaster.locaweb.com.br. 2022030905 3600 600 1209600 3600"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">, #<CartorioClient::DnsRecord:0x0000000736a6a8 @domain="cafefriocomcalor.com", @type="NS", @content=["ns2.systemintegration.locaweb.com.br", "ns1.systemintegration.locaweb.com.br", "ns3.systemintegration.locaweb.com.br"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">]
```

```ruby
irb(main):008:0> list_dns_record.find { |m| m.type == 'MX' }
=> #<CartorioClient::DnsRecord:0x0000000736b1c0 @domain="cafefriocomcalor.com", @type="MX", @content=["20 mx.jk.locaweb.com.br", "10 mx.core.locaweb.com.br", "10 mx.b.locaweb.com.br", "20 mx.a.locaweb.com.br"], @ttl=3600, @disabled=false, @name=".", @full_name="cafefriocomcalor.com.">
```
---
        
## Tentar criar entradas com MX faltando
    
```ruby
irb(main):007:0> Dns::EntryCreator.call('cafefriocomcalor.com')
DNSErrors::Entries: MX Content without: 20 mx.a.locaweb.com.br 10 mx.b.locaweb.com.br 10 mx.core.locaweb.com.br 20 mx.jk.locaweb.com.br Is required to create the DNS Zone before activate the service.
	from /var/www/email-gift-api/app/services/dns/entry_creator.rb:18:in `block in call'
	from /var/www/email-gift-api/app/services/dns/entry_creator.rb:14:in `each'
	from /var/www/email-gift-api/app/services/dns/entry_creator.rb:14:in `call'
	from /var/www/email-gift-api/app/services/dns/entry_creator.rb:6:in `call'
	from (irb):7
	from /var/www/email-gift-api/vendor/bundle/ruby/2.3.0/gems/railties-4.2.11.1/lib/rails/commands/console.rb:110:in `start'
	from /var/www/email-gift-api/vendor/bundle/ruby/2.3.0/gems/railties-4.2.11.1/lib/rails/commands/console.rb:9:in `start'
	from /var/www/email-gift-api/vendor/bundle/ruby/2.3.0/gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /var/www/email-gift-api/vendor/bundle/ruby/2.3.0/gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /var/www/email-gift-api/vendor/bundle/ruby/2.3.0/gems/railties-4.2.11.1/lib/rails/commands.rb:17:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'
```

