diff --git a/app/models/concerns/domain/deletable.rb b/app/models/concerns/domain/deletable.rb
index f724162e5..86c296d88 100644
--- a/app/models/concerns/domain/deletable.rb
+++ b/app/models/concerns/domain/deletable.rb
@@ -5,6 +5,11 @@ module Concerns::Domain::Deletable
alias_attribute :delete_time, :delete_at
end
+ def discard
+ statuses << DomainStatus::DELETE_CANDIDATE
+ save
+ end
+
def discarded?
statuses.include?(DomainStatus::DELETE_CANDIDATE)
end
diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb
index 9597330b8..aac3c1527 100644
--- a/app/presenters/domain_presenter.rb
+++ b/app/presenters/domain_presenter.rb
@@ -6,6 +6,17 @@ class DomainPresenter
@view = view
end
+ def name_with_status
+ html = domain.name
+
+ if domain.discarded?
+ label = view.content_tag(:span, 'deleteCandidate', class: 'label label-warning')
+ html += " #{label}"
+ end
+
+ html.html_safe
+ end
+
def expire_time
view.l(domain.expire_time)
end
diff --git a/app/views/admin/domains/show.haml b/app/views/admin/domains/show.haml
deleted file mode 100644
index 17a85b841..000000000
--- a/app/views/admin/domains/show.haml
+++ /dev/null
@@ -1,24 +0,0 @@
-- content_for :actions do
- = link_to(t(:edit_statuses), edit_admin_domain_path(@domain), class: 'btn btn-primary')
- = link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
-
-= render 'shared/title', name: @domain.name
-
-.row
- .col-md-6= render 'admin/domains/partials/general'
- .col-md-6= render 'admin/domains/partials/owner'
-.row
- .col-md-12= render 'admin/domains/partials/tech_contacts'
-.row
- .col-md-12= render 'admin/domains/partials/admin_contacts'
-.row
- .col-md-12= render 'admin/domains/partials/statuses'
-.row
- .col-md-12= render 'admin/domains/partials/nameservers'
-.row
- .col-md-12= render 'admin/domains/partials/dnskeys'
-.row
- .col-md-12= render 'admin/domains/partials/keyrelays'
-.row
- .col-md-12
- = render 'admin/domains/partials/legal_documents', legal_documents: @domain.legal_documents
diff --git a/app/views/admin/domains/show.html.erb b/app/views/admin/domains/show.html.erb
new file mode 100644
index 000000000..1501b35bb
--- /dev/null
+++ b/app/views/admin/domains/show.html.erb
@@ -0,0 +1,71 @@
+<% domain = DomainPresenter.new(domain: @domain, view: self) %>
+
+
+ - <%= link_to t('admin.domains.index.header'), admin_domains_path %>
+
+
+
+
+
+
+ <%= render 'admin/domains/partials/general' %>
+
+
+ <%= render 'admin/domains/partials/owner' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/tech_contacts' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/admin_contacts' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/statuses' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/nameservers' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/dnskeys' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/keyrelays' %>
+
+
+
+
+
+ <%= render 'admin/domains/partials/legal_documents', legal_documents:
+ @domain.legal_documents %>
+
+
diff --git a/app/views/admin/domains/zonefile.haml b/app/views/admin/domains/zonefile.haml
deleted file mode 100644
index 72473ef53..000000000
--- a/app/views/admin/domains/zonefile.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-- content_for :actions do
- = link_to(t(:back_to_domain), admin_domain_path(@domain), class: 'btn btn-default')
-= render 'shared/title', name: t(:zonefile)
-
-.row
- .col-md-12
- = preserve do
- %pre= @zonefile
diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml
index 200657d01..87c2c9c6a 100644
--- a/config/locales/admin/domains.en.yml
+++ b/config/locales/admin/domains.en.yml
@@ -5,6 +5,10 @@ en:
header: Domains
registrant: Registrant
+ show:
+ edit_btn: Edit statuses
+ history_btn: History
+
search_form:
reset_btn: Reset
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 4cdd5a41f..7ac84379f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -337,7 +337,6 @@ en:
transfer_requested: 'Transfer requested.'
message_was_not_found: 'Message was not found'
- zonefile: 'Zonefile'
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
exactly_one_parameter_required: 'Exactly one parameter required: %{params}'
ds_data_with_key_allowed: 'Allow DS data with key'
diff --git a/spec/factories/domain.rb b/spec/factories/domain.rb
index 8abac339c..39ad2240d 100644
--- a/spec/factories/domain.rb
+++ b/spec/factories/domain.rb
@@ -11,9 +11,5 @@ FactoryBot.define do
domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact)
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
end
-
- factory :domain_discarded do
- statuses [DomainStatus::DELETE_CANDIDATE]
- end
end
end
diff --git a/spec/models/concerns/domain/deletable_spec.rb b/spec/models/concerns/domain/deletable_spec.rb
deleted file mode 100644
index 826299b69..000000000
--- a/spec/models/concerns/domain/deletable_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe Domain, db: false do
- it { is_expected.to alias_attribute(:delete_time, :delete_at) }
-
- describe '#discarded?' do
- context 'when :deleteCandidate status is present' do
- let(:domain) { described_class.new(statuses: [DomainStatus::DELETE_CANDIDATE]) }
-
- specify { expect(domain).to be_discarded }
- end
-
- context 'when :deleteCandidate status is absent' do
- let(:domain) { described_class.new(statuses: []) }
-
- specify { expect(domain).to_not be_discarded }
- end
- end
-end
diff --git a/spec/requests/epp/domain/delete/discarded_spec.rb b/spec/requests/epp/domain/delete/discarded_spec.rb
deleted file mode 100644
index 55e74d965..000000000
--- a/spec/requests/epp/domain/delete/discarded_spec.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe 'EPP domain:delete' do
- let(:registrar) { create(:registrar) }
- let(:user) { create(:api_user_epp, registrar: registrar) }
- let(:session_id) { create(:epp_session, user: user).session_id }
- let(:request_xml) { <<-XML
-
-
-
-
-
- test.com
-
-
-
-
- dGVzdCBmYWlsCg==
-
-
-
-
- XML
- }
-
- before :example do
- login_as user
- end
-
- context 'when domain is not discarded' do
- let!(:domain) { create(:domain, name: 'test.com') }
-
- it 'returns epp code of 1001' do
- post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
- expect(response).to have_code_of(1001)
- end
- end
-
- context 'when domain is discarded' do
- let!(:domain) { create(:domain_discarded, name: 'test.com') }
-
- it 'returns epp code of 2105' do
- post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
- expect(response).to have_code_of(2105)
- end
- end
-end
diff --git a/spec/requests/epp/domain/update/discarded_spec.rb b/spec/requests/epp/domain/update/discarded_spec.rb
deleted file mode 100644
index 4a31b7d10..000000000
--- a/spec/requests/epp/domain/update/discarded_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe 'EPP domain:update' do
- let(:registrar) { create(:registrar) }
- let(:user) { create(:api_user_epp, registrar: registrar) }
- let(:session_id) { create(:epp_session, user: user).session_id }
- let(:request_xml) { <<-XML
-
-
-
-
-
- test.com
-
-
-
-
- XML
- }
-
- before :example do
- login_as user
- end
-
- context 'when domain is not discarded' do
- let!(:domain) { create(:domain, name: 'test.com') }
-
- it 'returns epp code of 1000' do
- post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
- expect(response).to have_code_of(1000)
- end
- end
-
- context 'when domain is discarded' do
- let!(:domain) { create(:domain_discarded, name: 'test.com') }
-
- it 'returns epp code of 2105' do
- post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
- expect(response).to have_code_of(2105)
- end
- end
-end
diff --git a/test/integration/admin/domains/details_test.rb b/test/integration/admin/domains/details_test.rb
new file mode 100644
index 000000000..a3ec6bdeb
--- /dev/null
+++ b/test/integration/admin/domains/details_test.rb
@@ -0,0 +1,16 @@
+require 'test_helper'
+
+class AdminAreaDomainDetailsTest < ActionDispatch::IntegrationTest
+ setup do
+ login_as users(:admin)
+ @domain = domains(:shop)
+ end
+
+ def test_discarded_domain_has_corresponding_label
+ visit admin_domain_url(@domain)
+ assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
+ @domain.discard
+ visit admin_domain_url(@domain)
+ assert_css 'span.label.label-warning', text: 'deleteCandidate'
+ end
+end
diff --git a/test/integration/epp/domain/domain_delete_test.rb b/test/integration/epp/domain/domain_delete_test.rb
index bdd326a3e..eae4d39ff 100644
--- a/test/integration/epp/domain/domain_delete_test.rb
+++ b/test/integration/epp/domain/domain_delete_test.rb
@@ -25,4 +25,31 @@ class EppDomainDeleteTest < ActionDispatch::IntegrationTest
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
+
+ def test_discarded_domain_cannot_be_deleted
+ domains(:shop).discard
+
+ request_xml = <<-XML
+
+
+
+
+
+ shop.test
+
+
+
+
+ dGVzdCBmYWlsCg==
+
+
+
+
+ XML
+
+ assert_no_difference 'Domain.count' do
+ post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
+ end
+ assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
+ end
end
diff --git a/test/integration/epp/domain/update/transfer_code_test.rb b/test/integration/epp/domain/domain_update_test.rb
similarity index 53%
rename from test/integration/epp/domain/update/transfer_code_test.rb
rename to test/integration/epp/domain/domain_update_test.rb
index 92ee58a02..ac7160558 100644
--- a/test/integration/epp/domain/update/transfer_code_test.rb
+++ b/test/integration/epp/domain/domain_update_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
class EppDomainUpdateTest < ActionDispatch::IntegrationTest
- def test_overwrites_existing
+ def test_update_domain
request_xml = <<-XML
@@ -20,9 +20,29 @@ class EppDomainUpdateTest < ActionDispatch::IntegrationTest
XML
- post '/epp/command/update', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
assert_equal 'f0ff7d17b0', domains(:shop).transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
+
+ def test_discarded_domain_cannot_be_updated
+ domains(:shop).discard
+
+ request_xml = <<-XML
+
+
+
+
+
+ shop.test
+
+
+
+
+ XML
+
+ post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
+ assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
+ end
end
diff --git a/test/models/domain/deletable_test.rb b/test/models/domain/deletable_test.rb
new file mode 100644
index 000000000..dbec7bc7f
--- /dev/null
+++ b/test/models/domain/deletable_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class DomainDeletableTest < ActiveSupport::TestCase
+ setup do
+ @domain = domains(:shop)
+ end
+
+ def test_discard
+ refute @domain.discarded?
+ @domain.discard
+ @domain.reload
+ assert @domain.discarded?
+ end
+end