diff --git a/app/controllers/admin/dns/zones_controller.rb b/app/controllers/admin/dns/zones_controller.rb
new file mode 100644
index 000000000..67d1790f5
--- /dev/null
+++ b/app/controllers/admin/dns/zones_controller.rb
@@ -0,0 +1,64 @@
+module Admin
+ module DNS
+ class ZonesController < AdminController
+ #load_and_authorize_resource(class: DNS::Zone)
+ skip_authorization_check
+ before_action :load_zone, only: %i[edit update destroy]
+
+ def index
+ @zones = ::DNS::Zone.all
+ end
+
+ def new
+ @zone = ::DNS::Zone.new
+ end
+
+ def create
+ @zone = ::DNS::Zone.new(zone_params)
+
+ if @zone.save
+ flash[:notice] = t('.created')
+ redirect_to_index
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @zone = ::DNS::Zone.find(params[:id])
+ end
+
+ def update
+ if @zone.update(zone_params)
+ flash[:notice] = t('.updated')
+ redirect_to_index
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @zone.destroy!
+ flash[:notice] = t('.destroyed')
+ redirect_to_index
+ end
+
+ private
+
+ def load_zone
+ @zone = ::DNS::Zone.find(params[:id])
+ end
+
+ def zone_params
+ params.require(:zone).permit(
+ :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email,
+ :master_nameserver, :ns_records, :a_records, :a4_records
+ )
+ end
+
+ def redirect_to_index
+ redirect_to admin_zones_url
+ end
+ end
+ end
+end
diff --git a/app/controllers/admin/zonefile_settings_controller.rb b/app/controllers/admin/zonefile_settings_controller.rb
deleted file mode 100644
index 34283d872..000000000
--- a/app/controllers/admin/zonefile_settings_controller.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-class Admin::ZonefileSettingsController < AdminController
- load_and_authorize_resource
- before_action :set_zonefile_setting, only: [:update, :edit]
- def index
- @zonefile_settings = ZonefileSetting.all
- end
-
- def new
- @zonefile_setting = ZonefileSetting.new
- end
-
- def create
- @zonefile_setting = ZonefileSetting.new(zonefile_setting_params)
-
- if @zonefile_setting.save
- flash[:notice] = I18n.t('record_created')
- redirect_to admin_zonefile_settings_path
- else
- flash.now[:alert] = I18n.t('failed_to_create_record')
- render 'new'
- end
- end
-
- def edit
- @zonefile_setting = ZonefileSetting.find(params[:id])
- end
-
- def update
- if @zonefile_setting.update(zonefile_setting_params)
- flash[:notice] = I18n.t('record_updated')
- redirect_to admin_zonefile_settings_path
- else
- flash.now[:alert] = I18n.t('failed_to_update_record')
- render 'edit'
- end
- end
-
- def destroy
- if @zonefile_setting.destroy
- flash[:notice] = I18n.t('record_deleted')
- redirect_to admin_zonefile_settings_path
- else
- flash.now[:alert] = I18n.t('failed_to_delete_record')
- render 'edit'
- end
- end
-
- private
-
- def set_zonefile_setting
- @zonefile_setting = ZonefileSetting.find(params[:id])
- end
-
- def zonefile_setting_params
- params.require(:zonefile_setting).permit(
- :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email,
- :master_nameserver, :ns_records, :a_records, :a4_records
- )
- end
-end
diff --git a/app/controllers/admin/zonefiles_controller.rb b/app/controllers/admin/zonefiles_controller.rb
index 1c0fed936..20d57dc90 100644
--- a/app/controllers/admin/zonefiles_controller.rb
+++ b/app/controllers/admin/zonefiles_controller.rb
@@ -3,7 +3,7 @@ class Admin::ZonefilesController < ApplicationController
# TODO: Refactor this
def create
- if ZonefileSetting.origins.include?(params[:origin])
+ if DNS::Zone.origins.include?(params[:origin])
@zonefile = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{params[:origin]}')"
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 82ffd7c2e..3abe9d860 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -93,7 +93,7 @@ class Ability
can :manage, Setting
can :manage, BlockedDomain
can :manage, ReservedDomain
- can :manage, ZonefileSetting
+ can :manage, DNS::Zone
can :manage, DomainVersion
can :manage, ContactVersion
can :manage, Pricelist
diff --git a/app/models/dns.rb b/app/models/dns.rb
new file mode 100644
index 000000000..bdc95d4f2
--- /dev/null
+++ b/app/models/dns.rb
@@ -0,0 +1,5 @@
+module DNS
+ def self.use_relative_model_naming?
+ true
+ end
+end
diff --git a/app/models/dns/zone.rb b/app/models/dns/zone.rb
new file mode 100644
index 000000000..e57c7b712
--- /dev/null
+++ b/app/models/dns/zone.rb
@@ -0,0 +1,48 @@
+module DNS
+ class Zone < ActiveRecord::Base
+ validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
+ validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
+ validates :origin, uniqueness: true
+
+ before_destroy :check_for_dependencies
+
+ def check_for_dependencies
+ dc = Domain.where("name ILIKE ?", "%.#{origin}").count
+ return if dc == 0
+ errors.add(:base, I18n.t('there_are_count_domains_in_this_zone', count: dc))
+ false
+ end
+
+ def self.generate_zonefiles
+ pluck(:origin).each do |origin|
+ generate_zonefile(origin)
+ end
+ end
+
+ def self.generate_zonefile(origin)
+ filename = "#{origin}.zone"
+
+ STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
+
+ zf = ActiveRecord::Base.connection.execute(
+ "select generate_zonefile('#{origin}')"
+ )[0]['generate_zonefile']
+
+ File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
+
+ STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
+ end
+
+ def self.origins
+ pluck(:origin)
+ end
+
+ def to_s
+ origin
+ end
+
+ def to_partial_path
+ 'zone'
+ end
+ end
+end
diff --git a/app/models/version/zonefile_setting_version.rb b/app/models/version/zonefile_setting_version.rb
deleted file mode 100644
index d8d195d5a..000000000
--- a/app/models/version/zonefile_setting_version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ZonefileSettingVersion < PaperTrail::Version
- include VersionSession
- self.table_name = :log_zonefile_settings
- self.sequence_name = :log_zonefile_settings_id_seq
-end
diff --git a/app/models/zonefile_setting.rb b/app/models/zonefile_setting.rb
deleted file mode 100644
index 9f2b2b862..000000000
--- a/app/models/zonefile_setting.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-class ZonefileSetting < ActiveRecord::Base
- include Versions # version/zonefile_setting_version.rb
- validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
- validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
- validates :origin, uniqueness: true
-
- before_destroy :check_for_dependencies
- def check_for_dependencies
- dc = Domain.where("name ILIKE ?", "%.#{origin}").count
- return if dc == 0
- errors.add(:base, I18n.t('there_are_count_domains_in_this_zone', count: dc))
- false
- end
-
- def self.generate_zonefiles
- pluck(:origin).each do |origin|
- generate_zonefile(origin)
- end
- end
-
- def self.generate_zonefile(origin)
- filename = "#{origin}.zone"
-
- STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
-
- zf = ActiveRecord::Base.connection.execute(
- "select generate_zonefile('#{origin}')"
- )[0]['generate_zonefile']
-
- File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
-
- STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
- end
-
- def self.origins
- pluck(:origin)
- end
-
- def to_s
- origin
- end
-end
diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb
index be8cbb65f..49939087c 100644
--- a/app/validators/domain_name_validator.rb
+++ b/app/validators/domain_name_validator.rb
@@ -12,7 +12,7 @@ class DomainNameValidator < ActiveModel::EachValidator
return true unless value
value = value.mb_chars.downcase.strip
- origins = ZonefileSetting.origins
+ origins = DNS::Zone.origins
# if someone tries to register an origin domain, let this validation pass
# the error will be caught in blocked domains validator
return true if origins.include?(value)
@@ -38,7 +38,7 @@ class DomainNameValidator < ActiveModel::EachValidator
def validate_blocked(value)
return true unless value
return false if BlockedDomain.where(name: value).count > 0
- ZonefileSetting.where(origin: value).count.zero?
+ DNS::Zone.where(origin: value).count.zero?
end
end
end
diff --git a/app/views/admin/_menu.haml b/app/views/admin/_menu.haml
index 8b63b2c25..fbb1728a9 100644
--- a/app/views/admin/_menu.haml
+++ b/app/views/admin/_menu.haml
@@ -31,7 +31,7 @@
%li.divider
%li.dropdown-header= t(:system)
%li= link_to t(:settings), admin_settings_path
- %li= link_to t(:zonefile), admin_zonefile_settings_path
+ %li= link_to t('.zones'), admin_zones_path
%li= link_to t('.blocked_domains'), admin_blocked_domains_path
%li= link_to t('.reserved_domains'), admin_reserved_domains_path
%li= link_to t(:mail_templates), admin_mail_templates_path
diff --git a/app/views/admin/zonefile_settings/_form.haml b/app/views/admin/dns/zones/_form.haml
similarity index 91%
rename from app/views/admin/zonefile_settings/_form.haml
rename to app/views/admin/dns/zones/_form.haml
index 42ef94efa..e935c5d97 100644
--- a/app/views/admin/zonefile_settings/_form.haml
+++ b/app/views/admin/dns/zones/_form.haml
@@ -1,5 +1,4 @@
-
-= form_for [:admin, @zonefile_setting], html: { class: 'form-horizontal' } do |f|
+= form_for [:admin, zone], html: { class: 'form-horizontal' } do |f|
.row
.col-md-8
#domain-statuses
@@ -9,7 +8,7 @@
.col-md-4.control-label
= f.label :origin
.col-md-8
- - if @zonefile_setting.persisted?
+ - if zone.persisted?
= f.text_field :origin, class: 'form-control', disabled: true
- else
= f.text_field :origin, class: 'form-control'
@@ -77,4 +76,4 @@
%hr
.row
.col-md-8.text-right
- %button.btn.btn-primary= t(:save)
+ %button.btn.btn-success= t(".#{zone.new_record? ? 'create' : 'update'}_btn")
diff --git a/app/views/admin/dns/zones/_zone.html.erb b/app/views/admin/dns/zones/_zone.html.erb
new file mode 100644
index 000000000..3a2d782d4
--- /dev/null
+++ b/app/views/admin/dns/zones/_zone.html.erb
@@ -0,0 +1,9 @@
+
+ <%= zone.origin %> |
+
+ <%= link_to t('.edit_btn'), edit_admin_zone_path(zone), class: 'btn btn-xs btn-primary' %>
+ <%= link_to t('.generate_zone_file_btn'),
+ admin_zonefiles_path(origin: zone.origin),
+ method: 'post', class: 'btn btn-xs btn-primary' %>
+ |
+
diff --git a/app/views/admin/dns/zones/edit.html.erb b/app/views/admin/dns/zones/edit.html.erb
new file mode 100644
index 000000000..645a77197
--- /dev/null
+++ b/app/views/admin/dns/zones/edit.html.erb
@@ -0,0 +1,20 @@
+
+ - <%= link_to t('admin.dns.zones.index.title'), admin_zones_path %>
+
+
+
+
+<%= render 'form', zone: @zone %>
diff --git a/app/views/admin/dns/zones/index.html.erb b/app/views/admin/dns/zones/index.html.erb
new file mode 100644
index 000000000..eb945873e
--- /dev/null
+++ b/app/views/admin/dns/zones/index.html.erb
@@ -0,0 +1,28 @@
+
+
+<% if @zones.present? %>
+
+
+
+ <%= DNS::Zone.human_attribute_name :origin %> |
+ |
+
+
+
+
+ <%= render @zones %>
+
+
+<% else %>
+ <%= t '.not_found' %>
+<% end %>
diff --git a/app/views/admin/dns/zones/new.html.erb b/app/views/admin/dns/zones/new.html.erb
new file mode 100644
index 000000000..fc37f984b
--- /dev/null
+++ b/app/views/admin/dns/zones/new.html.erb
@@ -0,0 +1,9 @@
+
+ - <%= link_to t('admin.dns.zones.index.title'), admin_zones_path %>
+
+
+
+
+<%= render 'form', zone: @zone %>
diff --git a/app/views/admin/zonefile_settings/edit.haml b/app/views/admin/zonefile_settings/edit.haml
deleted file mode 100644
index 93234ed2e..000000000
--- a/app/views/admin/zonefile_settings/edit.haml
+++ /dev/null
@@ -1,7 +0,0 @@
-- content_for :actions do
- = link_to(t(:back), admin_zonefile_settings_path, class: 'btn btn-default')
- = link_to(t(:delete), admin_zonefile_setting_path(@zonefile_setting),
- method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger')
-= render 'shared/title', name: t(:edit_zone)
-
-= render 'form'
diff --git a/app/views/admin/zonefile_settings/index.haml b/app/views/admin/zonefile_settings/index.haml
deleted file mode 100644
index a062c0793..000000000
--- a/app/views/admin/zonefile_settings/index.haml
+++ /dev/null
@@ -1,22 +0,0 @@
-- content_for :actions do
- = link_to(t(:new), new_admin_zonefile_setting_path, class: 'btn btn-primary')
-= render 'shared/title', name: t(:zonefile_settings)
-
-.row
- .col-md-12
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-10'}
- = t(:origin)
- %th{class: 'col-xs-2'}
- = t(:action)
- %tbody
- - @zonefile_settings.each do |x|
- %tr
- %td= link_to(x, edit_admin_zonefile_setting_path(x))
- %td
- = link_to(t(:generate_zonefile),
- admin_zonefiles_path(origin: x.origin),
- method: 'post', class: 'btn btn-xs btn-primary')
diff --git a/app/views/admin/zonefile_settings/new.haml b/app/views/admin/zonefile_settings/new.haml
deleted file mode 100644
index 211054e03..000000000
--- a/app/views/admin/zonefile_settings/new.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-- content_for :actions do
- = link_to(t(:back), admin_zonefile_settings_path, class: 'btn btn-default')
-= render 'shared/title', name: t(:new_zone)
-
-= render 'form'
diff --git a/config/locales/admin/dns/zones.en.yml b/config/locales/admin/dns/zones.en.yml
new file mode 100644
index 000000000..c6fd4093b
--- /dev/null
+++ b/config/locales/admin/dns/zones.en.yml
@@ -0,0 +1,33 @@
+en:
+ admin:
+ dns:
+ zones:
+ index:
+ title: Zones
+ new_btn: New zone
+ not_found: No zone found
+
+ new:
+ title: New zone
+
+ create:
+ created: Zone has been created
+
+ edit:
+ title: Edit zone
+ delete_btn: Delete
+ delete_btn_confirm: Are you sure you want to delete zone?
+
+ update:
+ updated: Zone has been updated
+
+ destroy:
+ destroyed: Zone has been deleted
+
+ form:
+ create_btn: Create zone
+ update_btn: Update zone
+
+ zone:
+ edit_btn: Edit
+ generate_zone_file_btn: Generate zone file
diff --git a/config/locales/admin/menu.en.yml b/config/locales/admin/menu.en.yml
index 2eaab9ed7..30b289797 100644
--- a/config/locales/admin/menu.en.yml
+++ b/config/locales/admin/menu.en.yml
@@ -7,6 +7,7 @@ en:
archive: Archive
domain_history: Domain history
contact_history: Contact history
+ zones: Zones
blocked_domains: Blocked domains
reserved_domains: Reserved domains
epp_log: EPP log
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d57fcde60..14c0d3188 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -232,14 +232,6 @@ en:
protocol: 'Protocol'
alg: 'Algorithm'
public_key: 'Public key'
-
- zonefile_setting:
- ttl: 'TTL'
- refresh: 'Refresh'
- retry: 'Retry'
- expire: 'Expire'
- minimum_ttl: 'Minimum TTL'
- email: 'E-Mail'
registrar:
billing_email: 'Billing e-mail'
phone: 'Contact phone'
@@ -436,7 +428,6 @@ en:
transfer_requested: 'Transfer requested.'
message_was_not_found: 'Message was not found'
host_obj_is_not_allowed: 'hostObj object is not allowed'
- generate_zonefile: 'Generate zonefile'
zonefile: 'Zonefile'
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
exactly_one_parameter_required: 'Exactly one parameter required: %{params}'
@@ -450,7 +441,6 @@ en:
ds_data_with_key_allowed: 'Allow DS data with key'
key_data_allowed: 'Allow key data'
ds_digest_type: 'DS digest type'
- zonefile_settings: 'Zonefile settings'
background_jobs: Background jobs
domains_history: Domains history
role: 'Role'
@@ -895,8 +885,6 @@ en:
failed_to_generate_invoice_invoice_number_limit_reached: 'Failed to generate invoice - invoice number limit reached'
is_too_small_minimum_deposit_is: 'is too small. Minimum deposit is %{amount} %{currency}'
a4_records: 'AAAA records'
- new_zone: 'New zone'
- edit_zone: 'Edit zone'
there_are_count_domains_in_this_zone: 'There are %{count} domains in this zone'
poll_pending_update_confirmed_by_registrant: 'Registrant confirmed domain update'
poll_pending_update_rejected_by_registrant: 'Registrant rejected domain update'
diff --git a/config/routes.rb b/config/routes.rb
index 8b52e7091..371ecc066 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -170,7 +170,7 @@ Rails.application.routes.draw do
namespace :admin do
resources :keyrelays
resources :zonefiles
- resources :zonefile_settings
+ resources :zones, controller: 'dns/zones', except: %i[show]
resources :legal_documents
resources :keyrelays
resources :pricelists
diff --git a/config/schedule.rb b/config/schedule.rb
index b364f59e0..a2676ef65 100644
--- a/config/schedule.rb
+++ b/config/schedule.rb
@@ -14,7 +14,7 @@ set :output, 'log/cron.log'
if @cron_group == 'registry'
every 10.minutes do
- runner 'ZonefileSetting.generate_zonefiles'
+ runner 'DNS::Zone.generate_zonefiles'
end
every 6.months, at: '12:01am' do
diff --git a/db/migrate/20170419120048_rename_zonefile_settings_to_zones.rb b/db/migrate/20170419120048_rename_zonefile_settings_to_zones.rb
new file mode 100644
index 000000000..6ea53529a
--- /dev/null
+++ b/db/migrate/20170419120048_rename_zonefile_settings_to_zones.rb
@@ -0,0 +1,5 @@
+class RenameZonefileSettingsToZones < ActiveRecord::Migration
+ def change
+ rename_table :zonefile_settings, :zones
+ end
+end
diff --git a/db/migrate/20170420125200_remove_log_zonefile_settings.rb b/db/migrate/20170420125200_remove_log_zonefile_settings.rb
new file mode 100644
index 000000000..1cfed1de6
--- /dev/null
+++ b/db/migrate/20170420125200_remove_log_zonefile_settings.rb
@@ -0,0 +1,5 @@
+class RemoveLogZonefileSettings < ActiveRecord::Migration
+ def change
+ drop_table :log_zonefile_settings
+ end
+end
diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb
index 7bebdbba9..11fdff432 100644
--- a/db/schema-read-only.rb
+++ b/db/schema-read-only.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170221115548) do
+ActiveRecord::Schema.define(version: 20170420125200) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -914,22 +914,6 @@ ActiveRecord::Schema.define(version: 20170221115548) do
t.string "uuid"
end
- create_table "log_zonefile_settings", force: :cascade do |t|
- t.string "item_type", null: false
- t.integer "item_id", null: false
- t.string "event", null: false
- t.string "whodunnit"
- t.json "object"
- t.json "object_changes"
- t.datetime "created_at"
- t.string "session"
- t.json "children"
- t.string "uuid"
- end
-
- add_index "log_zonefile_settings", ["item_type", "item_id"], name: "index_log_zonefile_settings_on_item_type_and_item_id", using: :btree
- add_index "log_zonefile_settings", ["whodunnit"], name: "index_log_zonefile_settings_on_whodunnit", using: :btree
-
create_table "mail_templates", force: :cascade do |t|
t.string "name", null: false
t.string "subject"
@@ -1141,7 +1125,7 @@ ActiveRecord::Schema.define(version: 20170221115548) do
add_index "whois_records", ["domain_id"], name: "index_whois_records_on_domain_id", using: :btree
add_index "whois_records", ["registrar_id"], name: "index_whois_records_on_registrar_id", using: :btree
- create_table "zonefile_settings", force: :cascade do |t|
+ create_table "zones", force: :cascade do |t|
t.string "origin"
t.integer "ttl"
t.integer "refresh"
diff --git a/db/seeds.rb b/db/seeds.rb
index 0ed61cba6..3375a433a 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -34,7 +34,7 @@ ActiveRecord::Base.transaction do
roles: ['admin']
)
- ZonefileSetting.create!(
+ DNS::Zone.create!(
origin: 'tld',
ttl: 43200,
refresh: 3600,
diff --git a/db/structure.sql b/db/structure.sql
index 373d7239e..37dadaf65 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -2374,44 +2374,6 @@ CREATE SEQUENCE log_white_ips_id_seq
ALTER SEQUENCE log_white_ips_id_seq OWNED BY log_white_ips.id;
---
--- Name: log_zonefile_settings; Type: TABLE; Schema: public; Owner: -; Tablespace:
---
-
-CREATE TABLE log_zonefile_settings (
- id integer NOT NULL,
- item_type character varying NOT NULL,
- item_id integer NOT NULL,
- event character varying NOT NULL,
- whodunnit character varying,
- object json,
- object_changes json,
- created_at timestamp without time zone,
- session character varying,
- children json,
- uuid character varying
-);
-
-
---
--- Name: log_zonefile_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE log_zonefile_settings_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: log_zonefile_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE log_zonefile_settings_id_seq OWNED BY log_zonefile_settings.id;
-
-
--
-- Name: mail_templates; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -2968,10 +2930,10 @@ ALTER SEQUENCE whois_records_id_seq OWNED BY whois_records.id;
--
--- Name: zonefile_settings; Type: TABLE; Schema: public; Owner: -; Tablespace:
+-- Name: zones; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
-CREATE TABLE zonefile_settings (
+CREATE TABLE zones (
id integer NOT NULL,
origin character varying,
ttl integer,
@@ -2992,10 +2954,10 @@ CREATE TABLE zonefile_settings (
--
--- Name: zonefile_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+-- Name: zones_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
-CREATE SEQUENCE zonefile_settings_id_seq
+CREATE SEQUENCE zones_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -3004,10 +2966,10 @@ CREATE SEQUENCE zonefile_settings_id_seq
--
--- Name: zonefile_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+-- Name: zones_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
-ALTER SEQUENCE zonefile_settings_id_seq OWNED BY zonefile_settings.id;
+ALTER SEQUENCE zones_id_seq OWNED BY zones.id;
--
@@ -3381,13 +3343,6 @@ ALTER TABLE ONLY log_users ALTER COLUMN id SET DEFAULT nextval('log_users_id_seq
ALTER TABLE ONLY log_white_ips ALTER COLUMN id SET DEFAULT nextval('log_white_ips_id_seq'::regclass);
---
--- Name: id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY log_zonefile_settings ALTER COLUMN id SET DEFAULT nextval('log_zonefile_settings_id_seq'::regclass);
-
-
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -3490,7 +3445,7 @@ ALTER TABLE ONLY whois_records ALTER COLUMN id SET DEFAULT nextval('whois_record
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY zonefile_settings ALTER COLUMN id SET DEFAULT nextval('zonefile_settings_id_seq'::regclass);
+ALTER TABLE ONLY zones ALTER COLUMN id SET DEFAULT nextval('zones_id_seq'::regclass);
--
@@ -3917,14 +3872,6 @@ ALTER TABLE ONLY log_white_ips
ADD CONSTRAINT log_white_ips_pkey PRIMARY KEY (id);
---
--- Name: log_zonefile_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
---
-
-ALTER TABLE ONLY log_zonefile_settings
- ADD CONSTRAINT log_zonefile_settings_pkey PRIMARY KEY (id);
-
-
--
-- Name: mail_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -4038,11 +3985,11 @@ ALTER TABLE ONLY whois_records
--
--- Name: zonefile_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+-- Name: zones_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
-ALTER TABLE ONLY zonefile_settings
- ADD CONSTRAINT zonefile_settings_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY zones
+ ADD CONSTRAINT zones_pkey PRIMARY KEY (id);
--
@@ -4675,20 +4622,6 @@ CREATE INDEX index_log_users_on_item_type_and_item_id ON log_users USING btree (
CREATE INDEX index_log_users_on_whodunnit ON log_users USING btree (whodunnit);
---
--- Name: index_log_zonefile_settings_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
---
-
-CREATE INDEX index_log_zonefile_settings_on_item_type_and_item_id ON log_zonefile_settings USING btree (item_type, item_id);
-
-
---
--- Name: index_log_zonefile_settings_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace:
---
-
-CREATE INDEX index_log_zonefile_settings_on_whodunnit ON log_zonefile_settings USING btree (whodunnit);
-
-
--
-- Name: index_messages_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -5280,3 +5213,7 @@ INSERT INTO schema_migrations (version) VALUES ('20161227193500');
INSERT INTO schema_migrations (version) VALUES ('20170221115548');
+INSERT INTO schema_migrations (version) VALUES ('20170419120048');
+
+INSERT INTO schema_migrations (version) VALUES ('20170420125200');
+
diff --git a/doc/controllers_brief.svg b/doc/controllers_brief.svg
index a5a1a555a..7c4770d50 100644
--- a/doc/controllers_brief.svg
+++ b/doc/controllers_brief.svg
@@ -142,11 +142,6 @@
Admin::DashboardsController
-
-Admin::ZonefileSettingsController
-
-Admin::ZonefileSettingsController
-
Admin::RegistrarsController
diff --git a/doc/controllers_complete.svg b/doc/controllers_complete.svg
index 40c0a2ec1..8f3253a67 100644
--- a/doc/controllers_complete.svg
+++ b/doc/controllers_complete.svg
@@ -377,20 +377,6 @@
_layout
-
-Admin::ZonefileSettingsController
-
-Admin::ZonefileSettingsController
-
-edit
-index
-update
-
-
-_layout
-set_zonefile_setting
-zonefile_setting_params
-
Admin::RegistrarsController
diff --git a/doc/models_brief.svg b/doc/models_brief.svg
index 6cd637e1b..8075f6e58 100644
--- a/doc/models_brief.svg
+++ b/doc/models_brief.svg
@@ -337,17 +337,6 @@
-
-ZonefileSettingVersion
-
-ZonefileSettingVersion
-
-
-ZonefileSettingVersion->VersionAssociation
-
-
-
-
DomainVersion
@@ -1219,18 +1208,6 @@
RegistrantVerification
-
-ZonefileSetting
-
-ZonefileSetting
-
-
-ZonefileSetting->ZonefileSettingVersion
-
-
-
-versions
-
TechDomainContact->DomainContactVersion
diff --git a/doc/models_complete.svg b/doc/models_complete.svg
index 38d17ab3d..a0889d72b 100644
--- a/doc/models_complete.svg
+++ b/doc/models_complete.svg
@@ -665,28 +665,6 @@
-
-ZonefileSettingVersion
-
-ZonefileSettingVersion
-
-id :integer
-item_type :string
-item_id :integer
-event :string
-whodunnit :string
-object :json
-object_changes :json
-created_at :datetime
-session :string
-children :json
-
-
-ZonefileSettingVersion->VersionAssociation
-
-
-
-
DomainVersion
@@ -1981,32 +1959,6 @@
domain_id :integer
action_type :string
-
-ZonefileSetting
-
-ZonefileSetting
-
-id :integer
-origin :string
-ttl :integer
-refresh :integer
-retry :integer
-expire :integer
-minimum_ttl :integer
-email :string
-master_nameserver :string
-created_at :datetime
-updated_at :datetime
-creator_str :string
-updator_str :string
-
-
-ZonefileSetting->ZonefileSettingVersion
-
-
-
-versions
-
TechDomainContact->DomainContactVersion
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index 546543100..cb37c0f1d 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -604,7 +604,7 @@ namespace :import do
ns_records, a_records, a4_records = parse_zone_ns_data('ee', 1)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'ee',
ttl: 43200,
refresh: 3600,
@@ -621,7 +621,7 @@ namespace :import do
# edu.ee
ns_records, a_records, a4_records = parse_zone_ns_data('edu.ee', 6)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'edu.ee',
ttl: 43200,
refresh: 3600,
@@ -638,7 +638,7 @@ namespace :import do
# aip.ee
ns_records, a_records, a4_records = parse_zone_ns_data('aip.ee', 9)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'aip.ee',
ttl: 43200,
refresh: 3600,
@@ -655,7 +655,7 @@ namespace :import do
# org.ee
ns_records, a_records, a4_records = parse_zone_ns_data('org.ee', 10)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'org.ee',
ttl: 43200,
refresh: 3600,
@@ -672,7 +672,7 @@ namespace :import do
# pri.ee
ns_records, a_records, a4_records = parse_zone_ns_data('pri.ee', 2)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'pri.ee',
ttl: 43200,
refresh: 3600,
@@ -689,7 +689,7 @@ namespace :import do
# med.ee
ns_records, a_records, a4_records = parse_zone_ns_data('med.ee', 3)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'med.ee',
ttl: 43200,
refresh: 3600,
@@ -706,7 +706,7 @@ namespace :import do
# fie.ee
ns_records, a_records, a4_records = parse_zone_ns_data('fie.ee', 4)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'fie.ee',
ttl: 43200,
refresh: 3600,
@@ -723,7 +723,7 @@ namespace :import do
# com.ee
ns_records, a_records, a4_records = parse_zone_ns_data('com.ee', 5)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'com.ee',
ttl: 43200,
refresh: 3600,
@@ -740,7 +740,7 @@ namespace :import do
# gov.ee
ns_records, a_records, a4_records = parse_zone_ns_data('gov.ee', 7)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'gov.ee',
ttl: 43200,
refresh: 3600,
@@ -757,7 +757,7 @@ namespace :import do
# riik.ee
ns_records, a_records, a4_records = parse_zone_ns_data('riik.ee', 8)
- ZonefileSetting.create!({
+ DNS::Zone.create!({
origin: 'riik.ee',
ttl: 43200,
refresh: 3600,
diff --git a/spec/fabricators/zonefile_setting_fabricator.rb b/spec/fabricators/zone_fabricator.rb
similarity index 95%
rename from spec/fabricators/zonefile_setting_fabricator.rb
rename to spec/fabricators/zone_fabricator.rb
index eae2663b3..e7bf81c42 100644
--- a/spec/fabricators/zonefile_setting_fabricator.rb
+++ b/spec/fabricators/zone_fabricator.rb
@@ -1,4 +1,4 @@
-Fabricator(:zonefile_setting) do
+Fabricator(:zone, from: 'DNS::Zone') do
origin 'ee'
ttl 43200
refresh 3600
diff --git a/spec/factories/dns/zone.rb b/spec/factories/dns/zone.rb
new file mode 100644
index 000000000..35a38826d
--- /dev/null
+++ b/spec/factories/dns/zone.rb
@@ -0,0 +1,12 @@
+FactoryGirl.define do
+ factory :zone, class: DNS::Zone do
+ origin 'test'
+ ttl 1
+ refresh 1
+ add_attribute :retry, 1
+ expire 1
+ minimum_ttl 1
+ email 'test@test.test'
+ master_nameserver 'test.test'
+ end
+end
diff --git a/spec/features/admin/dns/zones/delete_spec.rb b/spec/features/admin/dns/zones/delete_spec.rb
new file mode 100644
index 000000000..724ba8680
--- /dev/null
+++ b/spec/features/admin/dns/zones/delete_spec.rb
@@ -0,0 +1,16 @@
+require 'rails_helper'
+
+RSpec.feature 'Deleting zone in admin area' do
+ given!(:zone) { create(:zone) }
+
+ background do
+ sign_in_to_admin_area
+ end
+
+ scenario 'deletes zone' do
+ visit edit_admin_zone_url(zone)
+ click_link_or_button t('admin.dns.zones.edit.delete_btn')
+
+ expect(page).to have_text(t('admin.dns.zones.destroy.destroyed'))
+ end
+end
diff --git a/spec/features/admin/dns/zones/edit_spec.rb b/spec/features/admin/dns/zones/edit_spec.rb
new file mode 100644
index 000000000..26019cb3c
--- /dev/null
+++ b/spec/features/admin/dns/zones/edit_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+RSpec.feature 'Editing zone in admin area' do
+ given!(:zone) { create(:zone) }
+
+ background do
+ sign_in_to_admin_area
+ end
+
+ scenario 'updates zone' do
+ open_list
+ open_form
+ submit_form
+
+ expect(page).to have_text(t('admin.dns.zones.update.updated'))
+ end
+
+ def open_list
+ click_link_or_button t('admin.menu.zones')
+ end
+
+ def open_form
+ click_link_or_button t('admin.dns.zones.zone.edit_btn')
+ end
+
+ def submit_form
+ click_link_or_button t('admin.dns.zones.form.update_btn')
+ end
+end
diff --git a/spec/features/admin/dns/zones/new_spec.rb b/spec/features/admin/dns/zones/new_spec.rb
new file mode 100644
index 000000000..95c87f46e
--- /dev/null
+++ b/spec/features/admin/dns/zones/new_spec.rb
@@ -0,0 +1,39 @@
+require 'rails_helper'
+
+RSpec.feature 'New zone in admin area' do
+ background do
+ sign_in_to_admin_area
+ end
+
+ scenario 'it creates new zone' do
+ open_list
+ open_form
+ fill_form
+ submit_form
+
+ expect(page).to have_text(t('admin.dns.zones.create.created'))
+ end
+
+ def open_list
+ click_link_or_button t('admin.menu.zones')
+ end
+
+ def open_form
+ click_link_or_button t('admin.dns.zones.index.new_btn')
+ end
+
+ def fill_form
+ fill_in 'zone_origin', with: 'test'
+ fill_in 'zone_ttl', with: '1'
+ fill_in 'zone_refresh', with: '1'
+ fill_in 'zone_retry', with: '1'
+ fill_in 'zone_expire', with: '1'
+ fill_in 'zone_minimum_ttl', with: '1'
+ fill_in 'zone_email', with: 'test@test.com'
+ fill_in 'zone_master_nameserver', with: 'test.test'
+ end
+
+ def submit_form
+ click_link_or_button t('admin.dns.zones.form.create_btn')
+ end
+end
diff --git a/spec/models/concerns/domain/expirable_spec.rb b/spec/models/concerns/domain/expirable_spec.rb
index 2a2c9b9cf..17c366819 100644
--- a/spec/models/concerns/domain/expirable_spec.rb
+++ b/spec/models/concerns/domain/expirable_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Domain, db: false do
before :example do
travel_to Time.zone.parse('05.07.2010 00:00')
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
Fabricate.create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
Fabricate.create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))
diff --git a/spec/models/concerns/domain/force_delete_spec.rb b/spec/models/concerns/domain/force_delete_spec.rb
index 3e0563366..b454fb034 100644
--- a/spec/models/concerns/domain/force_delete_spec.rb
+++ b/spec/models/concerns/domain/force_delete_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Domain do
it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) }
before :example do
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
it 'should set force delete time' do
diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb
index 44133ede2..8c93d3545 100644
--- a/spec/models/contact_spec.rb
+++ b/spec/models/contact_spec.rb
@@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe Contact do
before :example do
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
context 'about class' do
@@ -328,7 +328,7 @@ end
describe Contact, '.destroy_orphans' do
before do
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
@contact_1 = Fabricate(:contact, code: 'asd12')
@contact_2 = Fabricate(:contact, code: 'asd13')
end
diff --git a/spec/models/zonefile_setting_spec.rb b/spec/models/dns/zone_spec.rb
similarity index 68%
rename from spec/models/zonefile_setting_spec.rb
rename to spec/models/dns/zone_spec.rb
index d1cd61119..815ce4aca 100644
--- a/spec/models/zonefile_setting_spec.rb
+++ b/spec/models/dns/zone_spec.rb
@@ -1,10 +1,6 @@
require 'rails_helper'
-RSpec.describe ZonefileSetting, db: false do
- it 'has versions' do
- expect(described_class.new.versions).to eq([])
- end
-
+RSpec.describe DNS::Zone do
describe '::origins' do
before :example do
expect(described_class).to receive(:pluck).with(:origin).and_return('origins')
diff --git a/spec/models/dnskey_spec.rb b/spec/models/dnskey_spec.rb
index 5267f3eac..9987de090 100644
--- a/spec/models/dnskey_spec.rb
+++ b/spec/models/dnskey_spec.rb
@@ -21,7 +21,7 @@ describe Dnskey do
Setting.client_side_status_editing_enabled = true
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do
diff --git a/spec/models/domain_cron_spec.rb b/spec/models/domain_cron_spec.rb
index 50c4ca80a..9b5e68f54 100644
--- a/spec/models/domain_cron_spec.rb
+++ b/spec/models/domain_cron_spec.rb
@@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe DomainCron do
it 'should expire domains' do
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
@domain = Fabricate(:domain)
Setting.expire_warning_period = 1
@@ -25,7 +25,7 @@ RSpec.describe DomainCron do
end
it 'should start redemption grace period' do
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
@domain = Fabricate(:domain)
old_valid_to = Time.zone.now - 10.days
diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb
index 65c96dbe8..d0bad297c 100644
--- a/spec/models/domain_spec.rb
+++ b/spec/models/domain_spec.rb
@@ -21,11 +21,11 @@ RSpec.describe Domain do
Setting.client_side_status_editing_enabled = true
- Fabricate(:zonefile_setting, origin: 'ee')
- Fabricate(:zonefile_setting, origin: 'pri.ee')
- Fabricate(:zonefile_setting, origin: 'med.ee')
- Fabricate(:zonefile_setting, origin: 'fie.ee')
- Fabricate(:zonefile_setting, origin: 'com.ee')
+ Fabricate(:zone, origin: 'ee')
+ Fabricate(:zone, origin: 'pri.ee')
+ Fabricate(:zone, origin: 'med.ee')
+ Fabricate(:zone, origin: 'fie.ee')
+ Fabricate(:zone, origin: 'com.ee')
end
context 'with invalid attribute' do
@@ -809,7 +809,7 @@ RSpec.describe Domain, db: false do
before :example do
travel_to Time.zone.parse('05.07.2010 00:00')
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
Fabricate.create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59'))
Fabricate.create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00'))
@@ -825,7 +825,7 @@ RSpec.describe Domain, db: false do
before :example do
travel_to Time.zone.parse('05.07.2010 00:00')
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
Fabricate.create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59'))
Fabricate.create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00'))
diff --git a/spec/models/domain_transfer_spec.rb b/spec/models/domain_transfer_spec.rb
index 3609b2f7d..d1ff29eee 100644
--- a/spec/models/domain_transfer_spec.rb
+++ b/spec/models/domain_transfer_spec.rb
@@ -21,7 +21,7 @@ describe DomainTransfer do
Setting.client_side_status_editing_enabled = true
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do
diff --git a/spec/models/keyrelay_spec.rb b/spec/models/keyrelay_spec.rb
index 73e26a098..319faf87c 100644
--- a/spec/models/keyrelay_spec.rb
+++ b/spec/models/keyrelay_spec.rb
@@ -21,7 +21,7 @@ describe Keyrelay do
Setting.client_side_status_editing_enabled = true
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do
diff --git a/spec/models/legal_document_spec.rb b/spec/models/legal_document_spec.rb
index 58774df4b..e87a3b77a 100644
--- a/spec/models/legal_document_spec.rb
+++ b/spec/models/legal_document_spec.rb
@@ -3,11 +3,11 @@ require 'rails_helper'
describe LegalDocument do
context 'tasks' do
it 'make files uniq' do
- Fabricate(:zonefile_setting, origin: 'ee')
- Fabricate(:zonefile_setting, origin: 'pri.ee')
- Fabricate(:zonefile_setting, origin: 'med.ee')
- Fabricate(:zonefile_setting, origin: 'fie.ee')
- Fabricate(:zonefile_setting, origin: 'com.ee')
+ Fabricate(:zone, origin: 'ee')
+ Fabricate(:zone, origin: 'pri.ee')
+ Fabricate(:zone, origin: 'med.ee')
+ Fabricate(:zone, origin: 'fie.ee')
+ Fabricate(:zone, origin: 'com.ee')
LegalDocument.explicitly_write_file = true
PaperTrail.enabled = true
diff --git a/spec/models/nameserver_spec.rb b/spec/models/nameserver_spec.rb
index 1844bc0f9..494d5696b 100644
--- a/spec/models/nameserver_spec.rb
+++ b/spec/models/nameserver_spec.rb
@@ -21,7 +21,7 @@ describe Nameserver do
Setting.client_side_status_editing_enabled = true
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do
diff --git a/spec/models/registrant_verification_spec.rb b/spec/models/registrant_verification_spec.rb
index 5997797c7..13036ef21 100644
--- a/spec/models/registrant_verification_spec.rb
+++ b/spec/models/registrant_verification_spec.rb
@@ -21,7 +21,7 @@ describe RegistrantVerification do
Setting.client_side_status_editing_enabled = true
- Fabricate(:zonefile_setting, origin: 'ee')
+ Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do
before :example do
diff --git a/spec/views/admin/dns/zones/index.html.erb_spec.rb b/spec/views/admin/dns/zones/index.html.erb_spec.rb
new file mode 100644
index 000000000..3ebbc468d
--- /dev/null
+++ b/spec/views/admin/dns/zones/index.html.erb_spec.rb
@@ -0,0 +1,40 @@
+require 'rails_helper'
+
+RSpec.describe 'admin/dns/zones/index' do
+ let(:zones) { [] }
+
+ before :example do
+ assign(:zones, zones)
+ stub_template '_zone' => 'zone-row'
+ end
+
+ it 'has title' do
+ render
+ expect(rendered).to have_text(t('admin.dns.zones.index.title'))
+ end
+
+ context 'when zones are present' do
+ let(:zones) { [build_stubbed(:zone)] }
+
+ it 'has zone row' do
+ render
+ expect(rendered).to have_text('zone-row')
+ end
+
+ it 'has no :not_found message' do
+ render
+ expect(rendered).to_not have_text(not_found_message)
+ end
+ end
+
+ context 'when zones are absent' do
+ it 'has :not_found message' do
+ render
+ expect(rendered).to have_text(not_found_message)
+ end
+ end
+
+ def not_found_message
+ t('admin.dns.zones.index.not_found')
+ end
+end