mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Convert specs to tests
This commit is contained in:
parent
c85ebf542d
commit
cb9479994f
4 changed files with 102 additions and 253 deletions
18
test/jobs/registrant_change_confirm_email_job_test.rb
Normal file
18
test/jobs/registrant_change_confirm_email_job_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantChangeConfirmEmailJobTest < ActiveSupport::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_delivers_email
|
||||
domain_id = domains(:shop).id
|
||||
new_registrant_id = contacts(:william).id
|
||||
|
||||
RegistrantChangeConfirmEmailJob.enqueue(domain_id, new_registrant_id)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
end
|
84
test/mailers/registrant_change_mailer_test.rb
Normal file
84
test/mailers/registrant_change_mailer_test.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantChangeMailerTest < ActiveSupport::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_delivers_confirmation_request_email
|
||||
assert_equal 'shop.test', @domain.name
|
||||
assert_equal 'john@inbox.test', @domain.registrant.email
|
||||
|
||||
email = RegistrantChangeMailer.confirm(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
current_registrant: @domain.registrant,
|
||||
new_registrant: @domain.registrant).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal ['john@inbox.test'], email.to
|
||||
assert_equal 'Kinnitustaotlus domeeni shop.test registreerija vahetuseks' \
|
||||
' / Application for approval for registrant change of shop.test', email.subject
|
||||
end
|
||||
|
||||
def test_delivers_notification_email
|
||||
new_registrant = contacts(:william)
|
||||
assert_equal 'shop.test', @domain.name
|
||||
assert_equal 'william@inbox.test', new_registrant.email
|
||||
|
||||
email = RegistrantChangeMailer.notice(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
current_registrant: @domain.registrant,
|
||||
new_registrant: new_registrant).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal ['william@inbox.test'], email.to
|
||||
assert_equal 'Domeeni shop.test registreerija vahetus protseduur on algatatud' \
|
||||
' / shop.test registrant change', email.subject
|
||||
end
|
||||
|
||||
def test_delivers_confirmation_email
|
||||
new_registrant = contacts(:william)
|
||||
assert_equal 'shop.test', @domain.name
|
||||
assert_equal 'john@inbox.test', @domain.registrant.email
|
||||
assert_equal 'william@inbox.test', new_registrant.email
|
||||
|
||||
email = RegistrantChangeMailer.confirmed(domain: @domain,
|
||||
old_registrant: new_registrant).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal %w[john@inbox.test william@inbox.test], email.to
|
||||
assert_equal 'Domeeni shop.test registreerija vahetus teostatud' \
|
||||
' / Registrant change of shop.test has been finished', email.subject
|
||||
end
|
||||
|
||||
def test_delivers_rejection_email
|
||||
assert_equal 'shop.test', @domain.name
|
||||
@domain.update!(pending_json: { new_registrant_email: 'william@inbox.test' })
|
||||
|
||||
email = RegistrantChangeMailer.rejected(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
registrant: @domain.registrant).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal ['william@inbox.test'], email.to
|
||||
assert_equal 'Domeeni shop.test registreerija vahetuse taotlus tagasi lükatud' \
|
||||
' / shop.test registrant change declined', email.subject
|
||||
end
|
||||
|
||||
def test_delivers_expiration_email
|
||||
assert_equal 'shop.test', @domain.name
|
||||
@domain.update!(pending_json: { new_registrant_email: 'william@inbox.test' })
|
||||
|
||||
email = RegistrantChangeMailer.expired(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
registrant: @domain.registrant).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal ['william@inbox.test'], email.to
|
||||
assert_equal 'Domeeni shop.test registreerija vahetuse taotlus on tühistatud' \
|
||||
' / shop.test registrant change cancelled', email.subject
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue