diff --git a/CHANGELOG.md b/CHANGELOG.md index 157cc9501..2258def21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +28.02.2017 +* Add missing registrar's website field in UI + 24.01.2017 * Disallow EPP domain:update/transfer/delete if a domain has "deleteCandidate" status diff --git a/README.md b/README.md index 0f40284b6..8ee6384a2 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,8 @@ For Apache, REPP goes to port 443 in production, /etc/apache2/sites-enabled/repp SSLVerifyDepth 1 SSLCACertificateFile /home/registry/registry/shared/ca/certs/ca.crt.pem SSLCARevocationPath /home/registry/registry/shared/ca/crl - SSLCARevocationCheck chain + # Uncomment this when upgrading to apache 2.4: + # SSLCARevocationCheck chain RequestHeader set SSL_CLIENT_S_DN_CN "" RequestHeader set SSL_CLIENT_CERT "" @@ -340,6 +341,42 @@ For Apache, epp goes to port 700. Be sure to update paths to match your system configuration. /etc/apache2/sites-enabled/epp.conf short example: ```apache + + Listen 127.0.0.1:8080 + + ServerName your-epp-backend-domain + ServerAdmin your@example.com + + PassengerEnabled on + PassengerMinInstances 10 + PassengerMaxPoolSize 10 + PassengerPoolIdleTime 0 + PassengerMaxRequests 1000 + PassengerRoot "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini" + PassengerRuby "/home/registry/.rbenv/shims/ruby" + + RailsEnv production # or staging + DocumentRoot "/home/registry/registry/public" + + # Possible values include: debug, info, notice, warn, error, crit, + LogLevel info + ErrorLog "/var/log/apache2/eppback.error.log" + CustomLog "/var/log/apache2/eppback.access.log" combined + + + Options +FollowSymLinks -Indexes + AllowOverride None + + + + Order allow,deny + Allow from all + Options -MultiViews -Indexes + AllowOverride all + + + + Listen 700 diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index 611687f9b..cd936a15c 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -23,10 +23,10 @@ class Admin::RegistrarsController < AdminController @registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR') end - flash[:notice] = I18n.t('registrar_added') + flash[:notice] = t('.created') redirect_to [:admin, @registrar] rescue ActiveRecord::RecordInvalid - flash.now[:alert] = I18n.t('failed_to_add_registrar') + flash.now[:alert] = t('.not_created') render 'new' end end @@ -35,10 +35,10 @@ class Admin::RegistrarsController < AdminController def update if @registrar.update(registrar_params) - flash[:notice] = I18n.t('registrar_updated') + flash[:notice] = t('.updated') redirect_to [:admin, @registrar] else - flash.now[:alert] = I18n.t('failed_to_update_registrar') + flash.now[:alert] = t('.not_updated') render 'edit' end end @@ -62,7 +62,7 @@ class Admin::RegistrarsController < AdminController def registrar_params params.require(:registrar).permit( :name, :reg_no, :vat_no, :street, :city, :state, :zip, :billing_address, - :country_code, :email, :phone, :billing_email, :code, :test_registrar + :country_code, :email, :phone, :website, :billing_email, :code, :test_registrar ) end end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 162aef292..734e68898 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -12,7 +12,7 @@ class Registrar < ActiveRecord::Base has_many :priv_contacts, -> { privs }, class_name: 'Contact' has_many :white_ips, dependent: :destroy - delegate :balance, to: :cash_account + delegate :balance, to: :cash_account, allow_nil: true validates :name, :reg_no, :country_code, :email, :code, presence: true validates :name, :reg_no, :reference_no, :code, uniqueness: true @@ -102,7 +102,7 @@ class Registrar < ActiveRecord::Base buyer_city: city, buyer_zip: zip, buyer_phone: phone, - buyer_url: url, + buyer_url: website, buyer_email: email, reference_no: reference_no, invoice_items_attributes: [ diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index e5de62ac0..bd16e0c99 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -85,7 +85,7 @@ class WhoisRecord < ActiveRecord::Base # update registar triggers when adding new attributes h[:registrar] = domain.registrar.name - h[:registrar_url] = domain.registrar.url + h[:registrar_website] = domain.registrar.website h[:registrar_phone] = domain.registrar.phone h[:registrar_address] = domain.registrar.address h[:registrar_changed] = domain.registrar.updated_at.try(:to_s, :iso8601) diff --git a/app/presenters/registrar_presenter.rb b/app/presenters/registrar_presenter.rb index 1fe415feb..57c130faa 100644 --- a/app/presenters/registrar_presenter.rb +++ b/app/presenters/registrar_presenter.rb @@ -16,8 +16,8 @@ class RegistrarPresenter registrar.phone end - def url - registrar.url + def website + registrar.website end private diff --git a/app/views/admin/epp_logs/show.haml b/app/views/admin/epp_logs/show.haml index 91e82272a..fe776e013 100644 --- a/app/views/admin/epp_logs/show.haml +++ b/app/views/admin/epp_logs/show.haml @@ -1,6 +1,6 @@ - content_for :actions do = link_to(t(:back), :back, class: 'btn btn-primary') -= render 'shared/title', name: t(:epp_log) += render 'shared/title', name: t('.title') .row .col-md-12 diff --git a/app/views/admin/registrars/_form.haml b/app/views/admin/registrars/_form.haml index 48cfc8066..d62a375f8 100644 --- a/app/views/admin/registrars/_form.haml +++ b/app/views/admin/registrars/_form.haml @@ -27,6 +27,11 @@ = f.label :phone .col-md-7 = f.text_field(:phone, class: 'form-control') + .form-group + .col-md-4.control-label + = f.label :website + .col-md-7 + = f.url_field :website, class: 'form-control' .form-group .col-md-4.control-label = f.label :email @@ -75,7 +80,7 @@ .col-md-8 .panel.panel-default .panel-heading.clearfix - .pull-left= t(:misc) + .pull-left= t('.misc') .panel-body .form-group .col-md-4.control-label @@ -91,4 +96,4 @@ %hr .row .col-md-8.text-right - = button_tag(t(:save), class: 'btn btn-primary') + = button_tag(t(".#{f.object.new_record? ? 'create' : 'update'}_btn"), class: 'btn btn-success') diff --git a/app/views/admin/registrars/index.haml b/app/views/admin/registrars/index.haml index 4e1c78294..ea9f7b312 100644 --- a/app/views/admin/registrars/index.haml +++ b/app/views/admin/registrars/index.haml @@ -1,5 +1,5 @@ - content_for :actions do - = link_to(t(:new), new_admin_registrar_path, class: 'btn btn-primary') + = link_to(t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary') = render 'shared/title', name: t(:registrars) .row diff --git a/app/views/admin/registrars/show.haml b/app/views/admin/registrars/show.haml index 4ea74029e..1907a63ed 100644 --- a/app/views/admin/registrars/show.haml +++ b/app/views/admin/registrars/show.haml @@ -39,6 +39,9 @@ %dt= t(:credit_balance) %dd= @registrar.balance + %dt= Registrar.human_attribute_name :website + %dd= @registrar.website + .col-md-6 .panel.panel-default .panel-heading diff --git a/app/views/for_models/whois.erb b/app/views/for_models/whois.erb index 303d95d72..390511031 100644 --- a/app/views/for_models/whois.erb +++ b/app/views/for_models/whois.erb @@ -40,7 +40,7 @@ changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %> <%- end -%> Registrar: name: <%= json['registrar'] %> -url: <%= json['registrar_url'] %> +url: <%= json['registrar_website'] %> phone: <%= json['registrar_phone'] %> changed: <%= json['registrar_changed'].to_s.tr('T',' ').sub('+', ' +') %> diff --git a/app/views/mailers/shared/registrar/_registrar.en.html.erb b/app/views/mailers/shared/registrar/_registrar.en.html.erb index 699fcd19d..914221e19 100644 --- a/app/views/mailers/shared/registrar/_registrar.en.html.erb +++ b/app/views/mailers/shared/registrar/_registrar.en.html.erb @@ -2,5 +2,5 @@ <%= registrar.name %>
Email: <%= registrar.email %>
Phone: <%= registrar.phone %>
- Website: <%= registrar.url %> + Website: <%= registrar.website %>

diff --git a/app/views/mailers/shared/registrar/_registrar.en.text.erb b/app/views/mailers/shared/registrar/_registrar.en.text.erb index 96882b11d..1a5fbd650 100644 --- a/app/views/mailers/shared/registrar/_registrar.en.text.erb +++ b/app/views/mailers/shared/registrar/_registrar.en.text.erb @@ -1,4 +1,4 @@ <%= registrar.name %> Email: <%= registrar.email %> Phone: <%= registrar.phone %> -Website: <%= registrar.url %> +Website: <%= registrar.website %> diff --git a/app/views/mailers/shared/registrar/_registrar.et.html.erb b/app/views/mailers/shared/registrar/_registrar.et.html.erb index 199115210..647b753d5 100644 --- a/app/views/mailers/shared/registrar/_registrar.et.html.erb +++ b/app/views/mailers/shared/registrar/_registrar.et.html.erb @@ -2,5 +2,5 @@ <%= registrar.name %>
Email: <%= registrar.email %>
Telefon: <%= registrar.phone %>
- Veebileht: <%= registrar.url %> + Veebileht: <%= registrar.website %>

diff --git a/app/views/mailers/shared/registrar/_registrar.et.text.erb b/app/views/mailers/shared/registrar/_registrar.et.text.erb index 0e8b16e30..2e435fbc9 100644 --- a/app/views/mailers/shared/registrar/_registrar.et.text.erb +++ b/app/views/mailers/shared/registrar/_registrar.et.text.erb @@ -1,4 +1,4 @@ <%= registrar.name %> Email: <%= registrar.email %> Telefon: <%= registrar.phone %> -Veebileht: <%= registrar.url %> +Veebileht: <%= registrar.website %> diff --git a/app/views/mailers/shared/registrar/_registrar.ru.html.erb b/app/views/mailers/shared/registrar/_registrar.ru.html.erb index 1c258f10d..63726c2dd 100644 --- a/app/views/mailers/shared/registrar/_registrar.ru.html.erb +++ b/app/views/mailers/shared/registrar/_registrar.ru.html.erb @@ -2,5 +2,5 @@ <%= registrar.name %>
Электронная почта: <%= registrar.email %>
Телефон: <%= registrar.phone %>
- Веб-сайт: <%= registrar.url %> + Веб-сайт: <%= registrar.website %>

diff --git a/app/views/mailers/shared/registrar/_registrar.ru.text.erb b/app/views/mailers/shared/registrar/_registrar.ru.text.erb index 0a74e8974..bb489b9fb 100644 --- a/app/views/mailers/shared/registrar/_registrar.ru.text.erb +++ b/app/views/mailers/shared/registrar/_registrar.ru.text.erb @@ -1,4 +1,4 @@ <%= registrar.name %> Электронная почта: <%= registrar.email %> Телефон: <%= registrar.phone %> -Веб-сайт: <%= registrar.url %> +Веб-сайт: <%= registrar.website %> diff --git a/config/application-example.yml b/config/application-example.yml index f1b17cc03..6ef70c9a0 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -133,34 +133,3 @@ payments_lhv_url: 'https://www.seb.ee/cgi-bin/dv.sh/ipank.r' payments_lhv_bank_certificate: 'eyp_pub.pem' payments_lhv_seller_private: 'kaupmees_priv.pem' payments_lhv_seller_account: 'testvpos' - -# -# AUTOTEST overwrites -# -test: - webclient_ips: '127.0.0.1' # it should match to localhost ip address - crl_dir: '/var/lib/jenkins/workspace/registry/ca/crl' - crl_path: '/var/lib/jenkins/workspace/registry/ca/crl/crl.pem' - ca_cert_path: '/var/lib/jenkins/workspace/registry/ca/certs/ca.crt.pem' - ca_key_path: '/var/lib/jenkins/workspace/registry/ca/private/ca.key.pem' - ca_key_password: 'test' - cert_path: '/var/lib/jenkins/workspace/registry/ca/certs/webclient.crt.pem' - - # Registrar/DEPP - key_path: '/var/lib/jenkins/workspace/registry/ca/private/webclient.key.pem' - epp_hostname: '127.0.0.1' - repp_url: 'http://127.0.0.1:8989/repp/v1/' - - -# -# DEVELOPMENT overwrites -# -development: - epp_hostname: '127.0.0.1' - repp_url: 'http://127.0.0.1:8080/repp/v1/' - cert_path: 'ca/certs/webclient.cert.pem' - key_path: 'ca/private/webclient.key.pem' - crl_dir: 'ca/crl' - ca_cert_path: 'ca/certs/ca.crt.pem' - ca_key_path: 'ca/private/ca.key.pem' - ca_key_password: 'your-root-key-password' diff --git a/config/locales/admin/epp_logs.en.yml b/config/locales/admin/epp_logs.en.yml index e30173673..ee634b1d0 100644 --- a/config/locales/admin/epp_logs.en.yml +++ b/config/locales/admin/epp_logs.en.yml @@ -4,3 +4,5 @@ en: index: title: EPP log reset_btn: Reset + show: + title: EPP log diff --git a/config/locales/admin/registrars.en.yml b/config/locales/admin/registrars.en.yml index 20da1a5ff..b30ad456e 100644 --- a/config/locales/admin/registrars.en.yml +++ b/config/locales/admin/registrars.en.yml @@ -1,7 +1,23 @@ en: admin: registrars: + index: + new_btn: New registrar + show: new_api_use_btn: New API user active: Active api_users: API users + + create: + created: Registrar has been successfully created + not_created: Unable to create registrar + + update: + updated: Registrar has been successfully updated + not_updated: Unable to update registrar + + form: + misc: Miscellaneous + create_btn: Create registrar + update_btn: Update registrar diff --git a/config/locales/en.yml b/config/locales/en.yml index 641b2d90d..0927446d0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -395,14 +395,10 @@ en: history: 'History' new_registrar: 'New registrar' - registrar_added: 'Registrar added!' - failed_to_add_registrar: 'Failed to add registrar' registrar_details: 'Registrar details' vat_no: 'VAT no' edit_registrar: 'Edit registrar' back_to_registrar: 'Back to registrar' - registrar_updated: 'Registrar updated' - failed_to_update_registrar: 'Failed to update registrar' registrar_deleted: 'Registrar deleted' failed_to_delete_registrar: 'Failed to delete registrar' diff --git a/db/migrate/20170221115548_rename_registrar_url_to_website.rb b/db/migrate/20170221115548_rename_registrar_url_to_website.rb new file mode 100644 index 000000000..6aa672b3f --- /dev/null +++ b/db/migrate/20170221115548_rename_registrar_url_to_website.rb @@ -0,0 +1,5 @@ +class RenameRegistrarUrlToWebsite < ActiveRecord::Migration + def change + rename_column :registrars, :url, :website + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 20659dafb..7bebdbba9 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: 20161227193500) do +ActiveRecord::Schema.define(version: 20170221115548) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1046,7 +1046,7 @@ ActiveRecord::Schema.define(version: 20161227193500) do t.string "street" t.string "zip" t.string "code" - t.string "url" + t.string "website" t.string "directo_handle" t.boolean "vat" t.integer "legacy_id" diff --git a/db/structure.sql b/db/structure.sql index 48226e245..373d7239e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2704,7 +2704,7 @@ CREATE TABLE registrars ( street character varying, zip character varying, code character varying, - url character varying, + website character varying, directo_handle character varying, vat boolean, legacy_id integer, @@ -5278,3 +5278,5 @@ INSERT INTO schema_migrations (version) VALUES ('20161004101419'); INSERT INTO schema_migrations (version) VALUES ('20161227193500'); +INSERT INTO schema_migrations (version) VALUES ('20170221115548'); + diff --git a/spec/fabricators/registrar_fabricator.rb b/spec/fabricators/registrar_fabricator.rb index bd801f642..f3a3fdc59 100644 --- a/spec/fabricators/registrar_fabricator.rb +++ b/spec/fabricators/registrar_fabricator.rb @@ -49,7 +49,7 @@ Fabricator(:eis, from: :registrar) do city 'Tallinn' street 'Paldiski mnt 80' zip '10617' - url 'www.internet.ee' + website 'www.internet.ee' code { sequence(:code) { |i| "EIS#{i}" } } accounts(count: 1) { Fabricate(:account, account_activities: []) } end diff --git a/spec/features/admin/registrars/create_spec.rb b/spec/features/admin/registrars/create_spec.rb new file mode 100644 index 000000000..24cc8bc2a --- /dev/null +++ b/spec/features/admin/registrars/create_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.feature 'New registrar' do + background do + sign_in_to_admin_area + end + + it 'creates registrar' do + visit admin_registrars_url + click_link_or_button 'New registrar' + + fill_in 'registrar[name]', with: 'test' + fill_in 'registrar[reg_no]', with: '1234567' + fill_in 'registrar[email]', with: 'test@test.com' + fill_in 'registrar[code]', with: 'test' + click_link_or_button 'Create registrar' + + expect(page).to have_text('Registrar has been successfully created') + end +end diff --git a/spec/features/admin/registrars/edit_spec.rb b/spec/features/admin/registrars/edit_spec.rb new file mode 100644 index 000000000..f02164f91 --- /dev/null +++ b/spec/features/admin/registrars/edit_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.feature 'Edit registrar' do + given!(:registrar) { create(:registrar) } + + background do + sign_in_to_admin_area + end + + it 'updates registrar' do + visit admin_registrar_url(registrar) + click_link_or_button 'Edit' + + click_link_or_button 'Update registrar' + + expect(page).to have_text('Registrar has been successfully updated') + end +end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 7af6cd1d1..65c96dbe8 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -607,7 +607,6 @@ end RSpec.describe Domain, db: false do it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) } - it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) } it { is_expected.to alias_attribute(:outzone_time, :outzone_at) } describe 'nameserver validation', db: true do diff --git a/spec/presenters/registrar_presenter_spec.rb b/spec/presenters/registrar_presenter_spec.rb index 8223341a8..8c0196c51 100644 --- a/spec/presenters/registrar_presenter_spec.rb +++ b/spec/presenters/registrar_presenter_spec.rb @@ -25,10 +25,10 @@ RSpec.describe RegistrarPresenter do end end - describe '#url' do - it 'returns url' do - expect(registrar).to receive(:url).and_return('test url') - expect(presenter.url).to eq('test url') + describe '#website' do + it 'returns website' do + expect(registrar).to receive(:website).and_return('test') + expect(presenter.website).to eq('test') end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 875162cae..110e8df27 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -31,10 +31,9 @@ RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers config.include Requests::SessionHelpers, type: :request config.include Features::SessionHelpers, type: :feature + config.include AbstractController::Translation, type: :request config.include AbstractController::Translation, type: :feature - config.include Requests::EPPHelpers, epp: true - - config.include Requests::EPPHelpers, epp: true + config.include Requests::EPPHelpers, type: :request config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata| metadata[:db] = true if metadata[:db].nil? @@ -60,10 +59,6 @@ RSpec.configure do |config| metadata[:type] = :request end - config.define_derived_metadata(file_path: %r[/spec/requests/epp/]) do |metadata| - metadata[:epp] = true if metadata[:epp].nil? - end - config.use_transactional_fixtures = false config.infer_spec_type_from_file_location! diff --git a/spec/requests/admin/registrars/create_spec.rb b/spec/requests/admin/registrars/create_spec.rb new file mode 100644 index 000000000..e144b19f8 --- /dev/null +++ b/spec/requests/admin/registrars/create_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe 'admin registrar create' do + subject(:registrar) { Registrar.first } + + before :example do + sign_in_to_admin_area + end + + it 'creates new registrar' do + expect { post admin_registrars_path, registrar: attributes_for(:registrar) } + .to change { Registrar.count }.from(0).to(1) + end + + it 'saves website' do + post admin_registrars_path, { registrar: attributes_for(:registrar, website: 'test') } + expect(registrar.website).to eq('test') + end + + it 'redirects to :show' do + post admin_registrars_path, { registrar: attributes_for(:registrar) } + expect(response).to redirect_to admin_registrar_path(registrar) + end +end diff --git a/spec/requests/admin/registrars/update_spec.rb b/spec/requests/admin/registrars/update_spec.rb new file mode 100644 index 000000000..fc99bccd0 --- /dev/null +++ b/spec/requests/admin/registrars/update_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe 'admin registrar update' do + before :example do + sign_in_to_admin_area + end + + it 'updates website' do + registrar = create(:registrar, website: 'test') + + patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, website: 'new-website') + registrar.reload + + expect(registrar.website).to eq('new-website') + end + + it 'redirects to :show' do + registrar = create(:registrar) + + patch admin_registrar_path(registrar), { registrar: attributes_for(:registrar) } + + expect(response).to redirect_to admin_registrar_path(registrar) + end +end diff --git a/spec/requests/epp/domain/update/registrant_change/verified_spec.rb b/spec/requests/epp/domain/update/registrant_change/verified_spec.rb new file mode 100644 index 000000000..996fffccf --- /dev/null +++ b/spec/requests/epp/domain/update/registrant_change/verified_spec.rb @@ -0,0 +1,196 @@ +require 'rails_helper' + +RSpec.describe 'EPP domain:update' do + let(:request) { post '/epp/command/update', frame: request_xml } + let!(:registrant) { create(:registrant, code: 'old-code') } + let!(:domain) { create(:domain, name: 'test.com', registrant: registrant) } + let!(:new_registrant) { create(:registrant, code: 'new-code') } + + before :example do + sign_in_to_epp_area + end + + context 'when registrant change confirmation is enabled' do + before :example do + Setting.request_confrimation_on_registrant_change_enabled = true + end + + context 'when verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1000) + end + + it 'changes registrant' do + expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') + end + + it 'does not send confirmation email' do + expect { request }.to_not change { ActionMailer::Base.deliveries.count } + end + + it 'does not set PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to_not include(DomainStatus::PENDING_UPDATE) + end + end + + context 'when not verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1001) + end + + it 'does not change registrant' do + expect { request; domain.reload }.to_not change { domain.registrant_code } + end + + it 'sends confirmation and notice emails' do + expect { request }.to change { ActionMailer::Base.deliveries.count }.by(2) + end + + it 'sets PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to include(DomainStatus::PENDING_UPDATE) + end + end + end + + context 'when registrant change confirmation is disabled' do + before :example do + Setting.request_confrimation_on_registrant_change_enabled = false + end + + context 'when verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1000) + end + + it 'changes registrant' do + expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') + end + + it 'does not send confirmation email' do + expect { request }.to_not change { ActionMailer::Base.deliveries.count } + end + + it 'does not set PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to_not include(DomainStatus::PENDING_UPDATE) + end + end + + context 'when not verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1000) + end + + it 'changes registrant' do + expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') + end + + it 'does not send confirmation email' do + expect { request }.to_not change { ActionMailer::Base.deliveries.count } + end + + it 'does not set PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to_not include(DomainStatus::PENDING_UPDATE) + end + end + end +end diff --git a/spec/routing/admin/registrars_routing_spec.rb b/spec/routing/admin/registrars_routing_spec.rb new file mode 100644 index 000000000..14ec765e9 --- /dev/null +++ b/spec/routing/admin/registrars_routing_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +RSpec.describe Admin::RegistrarsController do + describe 'routing' do + it 'routes to #index' do + expect(get: '/admin/registrars').to route_to('admin/registrars#index') + end + + it 'routes to #new' do + expect(get: '/admin/registrars/new').to route_to('admin/registrars#new') + end + + it 'routes to #show' do + expect(get: '/admin/registrars/1').to route_to('admin/registrars#show', id: '1') + end + + it 'routes to #edit' do + expect(get: '/admin/registrars/1/edit').to route_to('admin/registrars#edit', id: '1') + end + + it 'routes to #create' do + expect(post: '/admin/registrars').to route_to('admin/registrars#create') + end + + it 'routes to #update' do + expect(patch: '/admin/registrars/1').to route_to('admin/registrars#update', id: '1') + end + + it 'routes to #destroy' do + expect(delete: '/admin/registrars/1').to route_to('admin/registrars#destroy', id: '1') + end + end +end diff --git a/spec/support/requests/epp_helpers.rb b/spec/support/requests/epp_helpers.rb index 1372ae779..beb8ca2c2 100644 --- a/spec/support/requests/epp_helpers.rb +++ b/spec/support/requests/epp_helpers.rb @@ -3,5 +3,9 @@ module Requests def have_code_of(*args) Matchers::EPP::Code.new(*args) end + + def valid_legal_document + Base64.encode64('a' * 5000) + end end end diff --git a/spec/support/requests/session_helpers.rb b/spec/support/requests/session_helpers.rb index 3f75da577..9d8c69dc3 100644 --- a/spec/support/requests/session_helpers.rb +++ b/spec/support/requests/session_helpers.rb @@ -28,5 +28,9 @@ module Requests post '/epp/session/login', frame: login_xml end + + def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user)) + post admin_sessions_path, admin_user: { username: user.username, password: user.password } + end end end diff --git a/spec/views/admin/registrars/_form.haml_spec.rb b/spec/views/admin/registrars/_form.haml_spec.rb new file mode 100644 index 000000000..98021d93a --- /dev/null +++ b/spec/views/admin/registrars/_form.haml_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.describe 'admin/registrars/_form' do + let(:registrar) { build_stubbed(:registrar) } + + before :example do + assign(:registrar, registrar) + stub_template 'shared/_full_errors' => '' + end + + it 'has website' do + render + expect(rendered).to have_css('[name="registrar[website]"]') + end +end diff --git a/spec/views/admin/registrars/show.haml_spec.rb b/spec/views/admin/registrars/show.haml_spec.rb new file mode 100644 index 000000000..6ec9cab14 --- /dev/null +++ b/spec/views/admin/registrars/show.haml_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.describe 'admin/registrars/show' do + let(:registrar) { build_stubbed(:registrar, website: 'test website') } + + before :example do + assign(:registrar, registrar) + stub_template 'shared/_title' => '' + end + + it 'has website' do + render + expect(rendered).to have_text('test website') + end +end diff --git a/spec/views/mailers/shared/registrar/registrar_shared.rb b/spec/views/mailers/shared/registrar/registrar_shared.rb index f9c98c94a..2f8311545 100644 --- a/spec/views/mailers/shared/registrar/registrar_shared.rb +++ b/spec/views/mailers/shared/registrar/registrar_shared.rb @@ -11,7 +11,7 @@ RSpec.shared_examples 'domain mailer registrar info' do name email phone - url + website ) attributes.each do |attr_name|