From 09d15a21693ce73a041f04bb4131d34f70ee04d9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Mar 2017 19:20:06 +0200 Subject: [PATCH] Add registrar area contact delete spec #270 --- .../registrar/contacts/delete_spec.rb | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 spec/features/registrar/contacts/delete_spec.rb diff --git a/spec/features/registrar/contacts/delete_spec.rb b/spec/features/registrar/contacts/delete_spec.rb new file mode 100644 index 0000000000..dd6305a109 --- /dev/null +++ b/spec/features/registrar/contacts/delete_spec.rb @@ -0,0 +1,52 @@ +require 'rails_helper' + +class FakeDeppContact + include ActiveModel::Model + + def id + 'test' + end + + def name + 'test' + end + + def persisted? + true + end + + def password + 'test' + end + + def delete + true + end +end + +RSpec.feature 'Contact deletion in registrar area' do + given!(:registrar) { create(:registrar) } + given!(:contact) { create(:contact, registrar: registrar) } + + background do + allow(Depp::Contact).to receive(:find_by_id).and_return(FakeDeppContact.new) + allow(Depp::Contact).to receive(:new).and_return(FakeDeppContact.new) + Setting.api_ip_whitelist_enabled = false + Setting.registrar_ip_whitelist_enabled = false + sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance, registrar: registrar)) + end + + it 'deletes contact' do + visit registrar_contacts_url + click_link_or_button 'Delete' + confirm + + expect(page).to have_text('Destroyed') + end + + private + + def confirm + click_link_or_button 'Delete' + end +end