diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 6fa77b3ae..c5d60ced3 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -2,6 +2,9 @@ class Admin::DomainsController < AdminController load_and_authorize_resource before_action :set_domain, only: [:show, :edit, :update, :zonefile] + # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/CyclomaticComplexity + # rubocop: disable Metrics/AbcSize def index params[:q] ||= {} if params[:statuses_contains] @@ -29,6 +32,9 @@ class Admin::DomainsController < AdminController @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 end + # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/CyclomaticComplexity + # rubocop: enable Metrics/AbcSize def show @domain.valid? diff --git a/app/views/admin/domains/index.haml b/app/views/admin/domains/index.haml index 553f416bf..ce2a16ed3 100644 --- a/app/views/admin/domains/index.haml +++ b/app/views/admin/domains/index.haml @@ -18,8 +18,8 @@ = f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) .col-md-3 .form-group - = f.label t(:nameserver) - = f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver) + = f.label t(:nameserver_hostname) + = f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) .row .col-md-6 .form-group diff --git a/config/locales/en.yml b/config/locales/en.yml index 87a3946ba..7e32b672b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -891,3 +891,4 @@ en: registrant_ident: 'Registrant ident' contact_ident: 'Contact ident' results_per_page: 'Results per page' + nameserver_hostname: 'Nameserver hostname' diff --git a/spec/features/admin/domain_spec.rb b/spec/features/admin/domain_spec.rb new file mode 100644 index 000000000..20ee508d8 --- /dev/null +++ b/spec/features/admin/domain_spec.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +feature 'Domain', type: :feature do + before :all do + @user = Fabricate(:admin_user) + end + + it 'should show index of domains' do + Fabricate(:domain, name: 'testing.ee') + sign_in @user + visit admin_domains_url + + page.should have_content('testing.ee') + end + + it 'should search domains by name' do + d1 = Fabricate(:domain, name: 'abcde.ee') + Fabricate(:domain, name: 'abcdee.ee') + Fabricate(:domain, name: 'defgh.pri.ee') + sign_in @user + visit admin_domains_url + + page.should have_content('abcde.ee') + page.should have_content('abcdee.ee') + page.should have_content('defgh.pri.ee') + + fill_in 'q_name_matches', with: 'abcde.ee' + find('.btn.btn-primary').click + + current_path.should == "/admin/domains/#{d1.id}" + + visit admin_domains_url + fill_in 'q_name_matches', with: '.ee' + find('.btn.btn-primary').click + + current_path.should == "/admin/domains" + page.should have_content('abcde.ee') + page.should have_content('abcdee.ee') + page.should have_content('defgh.pri.ee') + + fill_in 'q_name_matches', with: 'abcd%.ee' + find('.btn.btn-primary').click + page.should have_content('abcde.ee') + page.should have_content('abcdee.ee') + page.should_not have_content('defgh.pri.ee') + + fill_in 'q_name_matches', with: 'abcd_.ee' + find('.btn.btn-primary').click + current_path.should == "/admin/domains/#{d1.id}" + end +end