mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Rename notifications.body
to text
This commit is contained in:
parent
8765baf319
commit
dfff6f6d12
16 changed files with 30 additions and 22 deletions
|
@ -6,7 +6,7 @@ module Admin
|
||||||
|
|
||||||
domain.transaction do
|
domain.transaction do
|
||||||
domain.schedule_force_delete
|
domain.schedule_force_delete
|
||||||
domain.registrar.notifications.create!(body: t('force_delete_set_on_domain',
|
domain.registrar.notifications.create!(text: t('force_delete_set_on_domain',
|
||||||
domain_name: domain.name))
|
domain_name: domain.name))
|
||||||
|
|
||||||
if notify_by_email?
|
if notify_by_email?
|
||||||
|
|
|
@ -9,7 +9,7 @@ class DomainDeleteJob < Que::Job
|
||||||
domain.destroy
|
domain.destroy
|
||||||
bye_bye = domain.versions.last
|
bye_bye = domain.versions.last
|
||||||
domain.registrar.notifications.create!(
|
domain.registrar.notifications.create!(
|
||||||
body: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||||
attached_obj_id: bye_bye.id,
|
attached_obj_id: bye_bye.id,
|
||||||
attached_obj_type: bye_bye.class.to_s
|
attached_obj_type: bye_bye.class.to_s
|
||||||
)
|
)
|
||||||
|
|
|
@ -272,7 +272,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def notify_registrar(message_key)
|
def notify_registrar(message_key)
|
||||||
registrar.notifications.create!(
|
registrar.notifications.create!(
|
||||||
body: "#{I18n.t(message_key)}: #{name}",
|
text: "#{I18n.t(message_key)}: #{name}",
|
||||||
attached_obj_id: id,
|
attached_obj_id: id,
|
||||||
attached_obj_type: self.class.to_s
|
attached_obj_type: self.class.to_s
|
||||||
)
|
)
|
||||||
|
|
|
@ -74,7 +74,7 @@ class DomainTransfer < ActiveRecord::Base
|
||||||
old_registrant_code = domain.registrant.code
|
old_registrant_code = domain.registrant.code
|
||||||
|
|
||||||
old_registrar.notifications.create!(
|
old_registrar.notifications.create!(
|
||||||
body: I18n.t('notifications.texts.domain_transfer',
|
text: I18n.t('notifications.texts.domain_transfer',
|
||||||
domain_name: domain.name,
|
domain_name: domain.name,
|
||||||
old_contacts_codes: old_contacts_codes,
|
old_contacts_codes: old_contacts_codes,
|
||||||
old_registrant_code: old_registrant_code),
|
old_registrant_code: old_registrant_code),
|
||||||
|
|
|
@ -626,7 +626,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
if dt.pending?
|
if dt.pending?
|
||||||
registrar.notifications.create!(
|
registrar.notifications.create!(
|
||||||
body: I18n.t('transfer_requested'),
|
text: I18n.t('transfer_requested'),
|
||||||
attached_obj_id: dt.id,
|
attached_obj_id: dt.id,
|
||||||
attached_obj_type: dt.class.to_s
|
attached_obj_type: dt.class.to_s
|
||||||
)
|
)
|
||||||
|
@ -728,7 +728,7 @@ class Epp::Domain < Domain
|
||||||
return false unless valid?
|
return false unless valid?
|
||||||
|
|
||||||
registrar.notifications.create!(
|
registrar.notifications.create!(
|
||||||
body: 'Key Relay action completed successfully.',
|
text: 'Key Relay action completed successfully.',
|
||||||
attached_obj_type: kr.class.to_s,
|
attached_obj_type: kr.class.to_s,
|
||||||
attached_obj_id: kr.id
|
attached_obj_id: kr.id
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Notification < ActiveRecord::Base
|
||||||
|
|
||||||
scope :queued, -> { where(queued: true) }
|
scope :queued, -> { where(queued: true) }
|
||||||
|
|
||||||
validates :body, presence: true
|
validates :text, presence: true
|
||||||
|
|
||||||
def dequeue
|
def dequeue
|
||||||
self.queued = false
|
self.queued = false
|
||||||
|
|
|
@ -12,7 +12,7 @@ xml.epp(
|
||||||
|
|
||||||
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
|
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
|
||||||
xml.qDate @notification.created_at.try(:iso8601)
|
xml.qDate @notification.created_at.try(:iso8601)
|
||||||
xml.msg @notification.body
|
xml.msg @notification.text
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
|
|
|
@ -6,7 +6,7 @@ xml.epp_head do
|
||||||
|
|
||||||
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
|
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
|
||||||
xml.qDate @notification.created_at.try(:iso8601)
|
xml.qDate @notification.created_at.try(:iso8601)
|
||||||
xml.msg @notification.body
|
xml.msg @notification.text
|
||||||
end
|
end
|
||||||
|
|
||||||
if @notification.attached_obj_type == 'DomainTransfer'
|
if @notification.attached_obj_type == 'DomainTransfer'
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenameNotificationsBodyToText < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :notifications, :body, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -1999,7 +1999,7 @@ ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id;
|
||||||
CREATE TABLE public.notifications (
|
CREATE TABLE public.notifications (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
registrar_id integer NOT NULL,
|
registrar_id integer NOT NULL,
|
||||||
body character varying NOT NULL,
|
text character varying NOT NULL,
|
||||||
attached_obj_type character varying,
|
attached_obj_type character varying,
|
||||||
attached_obj_id integer,
|
attached_obj_id integer,
|
||||||
queued boolean,
|
queued boolean,
|
||||||
|
@ -4763,3 +4763,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180823161237');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20180823163548');
|
INSERT INTO schema_migrations (version) VALUES ('20180823163548');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20180823174331');
|
||||||
|
|
||||||
|
|
|
@ -252,9 +252,10 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should notify registrar' do
|
it 'should notify registrar' do
|
||||||
|
text = 'Registrant confirmed domain update: testpollmessage123.ee'
|
||||||
domain = create(:domain, name: 'testpollmessage123.ee')
|
domain = create(:domain, name: 'testpollmessage123.ee')
|
||||||
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
|
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
|
||||||
domain.registrar.notifications.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee'
|
domain.registrar.notifications.first.text.should == text
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'about registrant update confirm' do
|
context 'about registrant update confirm' do
|
||||||
|
|
6
test/fixtures/notifications.yml
vendored
6
test/fixtures/notifications.yml
vendored
|
@ -1,15 +1,15 @@
|
||||||
greeting:
|
greeting:
|
||||||
body: Welcome!
|
text: Welcome!
|
||||||
queued: true
|
queued: true
|
||||||
registrar: bestnames
|
registrar: bestnames
|
||||||
|
|
||||||
domain_deleted:
|
domain_deleted:
|
||||||
body: Your domain has been deleted
|
text: Your domain has been deleted
|
||||||
queued: true
|
queued: true
|
||||||
registrar: bestnames
|
registrar: bestnames
|
||||||
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
|
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
|
||||||
|
|
||||||
farewell:
|
farewell:
|
||||||
body: Good bye!
|
text: Good bye!
|
||||||
queued: true
|
queued: true
|
||||||
registrar: goodnames
|
registrar: goodnames
|
|
@ -23,7 +23,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
last_registrar_notification = @domain.registrar.notifications.last
|
last_registrar_notification = @domain.registrar.notifications.last
|
||||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||||
assert_equal(last_registrar_notification.body, 'Registrant rejected domain deletion: shop.test')
|
assert_equal(last_registrar_notification.text, 'Registrant rejected domain deletion: shop.test')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_accepted_registrant_verification_notifies_registrar
|
def test_accepted_registrant_verification_notifies_registrar
|
||||||
|
@ -31,6 +31,6 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
last_registrar_notification = @domain.registrar.notifications.last
|
last_registrar_notification = @domain.registrar.notifications.last
|
||||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||||
assert_equal(last_registrar_notification.body, 'Registrant confirmed domain deletion: shop.test')
|
assert_equal(last_registrar_notification.text, 'Registrant confirmed domain deletion: shop.test')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
last_registrar_notification = @domain.registrar.notifications.last
|
last_registrar_notification = @domain.registrar.notifications.last
|
||||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||||
assert_equal(last_registrar_notification.body, 'Registrant rejected domain update: shop.test')
|
assert_equal(last_registrar_notification.text, 'Registrant rejected domain update: shop.test')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_accepted_registrant_verification_notifies_registrar
|
def test_accepted_registrant_verification_notifies_registrar
|
||||||
|
@ -31,6 +31,6 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
last_registrar_notification = @domain.registrar.notifications.last
|
last_registrar_notification = @domain.registrar.notifications.last
|
||||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||||
assert_equal(last_registrar_notification.body, 'Registrant confirmed domain update: shop.test')
|
assert_equal(last_registrar_notification.text, 'Registrant confirmed domain update: shop.test')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,14 +18,14 @@ class DomainTransferTest < ActiveSupport::TestCase
|
||||||
@domain_transfer.approve
|
@domain_transfer.approve
|
||||||
end
|
end
|
||||||
|
|
||||||
body = 'Transfer of domain shop.test has been approved.' \
|
text = 'Transfer of domain shop.test has been approved.' \
|
||||||
' It was associated with registrant john-001' \
|
' It was associated with registrant john-001' \
|
||||||
' and contacts acme-ltd-001, jane-001, william-001.'
|
' and contacts acme-ltd-001, jane-001, william-001.'
|
||||||
id = @domain_transfer.id
|
id = @domain_transfer.id
|
||||||
class_name = @domain_transfer.class.name
|
class_name = @domain_transfer.class.name
|
||||||
|
|
||||||
notification = old_registrar.notifications.last
|
notification = old_registrar.notifications.last
|
||||||
assert_equal body, notification.body
|
assert_equal text, notification.text
|
||||||
assert_equal id, notification.attached_obj_id
|
assert_equal id, notification.attached_obj_id
|
||||||
assert_equal class_name, notification.attached_obj_type
|
assert_equal class_name, notification.attached_obj_type
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ class NotificationTest < ActiveSupport::TestCase
|
||||||
assert @notification.valid?
|
assert @notification.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_body
|
def test_invalid_without_text
|
||||||
@notification.body = nil
|
@notification.text = ''
|
||||||
assert @notification.invalid?
|
assert @notification.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue