Rename notifications.body to text

This commit is contained in:
Artur Beljajev 2018-08-23 21:26:33 +03:00
parent 8765baf319
commit dfff6f6d12
16 changed files with 30 additions and 22 deletions

View file

@ -6,7 +6,7 @@ module Admin
domain.transaction do
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))
if notify_by_email?

View file

@ -9,7 +9,7 @@ class DomainDeleteJob < Que::Job
domain.destroy
bye_bye = domain.versions.last
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_type: bye_bye.class.to_s
)

View file

@ -272,7 +272,7 @@ class Domain < ActiveRecord::Base
def notify_registrar(message_key)
registrar.notifications.create!(
body: "#{I18n.t(message_key)}: #{name}",
text: "#{I18n.t(message_key)}: #{name}",
attached_obj_id: id,
attached_obj_type: self.class.to_s
)

View file

@ -74,7 +74,7 @@ class DomainTransfer < ActiveRecord::Base
old_registrant_code = domain.registrant.code
old_registrar.notifications.create!(
body: I18n.t('notifications.texts.domain_transfer',
text: I18n.t('notifications.texts.domain_transfer',
domain_name: domain.name,
old_contacts_codes: old_contacts_codes,
old_registrant_code: old_registrant_code),

View file

@ -626,7 +626,7 @@ class Epp::Domain < Domain
if dt.pending?
registrar.notifications.create!(
body: I18n.t('transfer_requested'),
text: I18n.t('transfer_requested'),
attached_obj_id: dt.id,
attached_obj_type: dt.class.to_s
)
@ -728,7 +728,7 @@ class Epp::Domain < Domain
return false unless valid?
registrar.notifications.create!(
body: 'Key Relay action completed successfully.',
text: 'Key Relay action completed successfully.',
attached_obj_type: kr.class.to_s,
attached_obj_id: kr.id
)

View file

@ -6,7 +6,7 @@ class Notification < ActiveRecord::Base
scope :queued, -> { where(queued: true) }
validates :body, presence: true
validates :text, presence: true
def dequeue
self.queued = false

View file

@ -12,7 +12,7 @@ xml.epp(
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
xml.qDate @notification.created_at.try(:iso8601)
xml.msg @notification.body
xml.msg @notification.text
end
xml.resData do

View file

@ -6,7 +6,7 @@ xml.epp_head do
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
xml.qDate @notification.created_at.try(:iso8601)
xml.msg @notification.body
xml.msg @notification.text
end
if @notification.attached_obj_type == 'DomainTransfer'

View file

@ -0,0 +1,5 @@
class RenameNotificationsBodyToText < ActiveRecord::Migration
def change
rename_column :notifications, :body, :text
end
end

View file

@ -1999,7 +1999,7 @@ ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id;
CREATE TABLE public.notifications (
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_id integer,
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 ('20180823174331');

View file

@ -252,9 +252,10 @@ RSpec.describe Domain do
end
it 'should notify registrar' do
text = 'Registrant confirmed domain update: testpollmessage123.ee'
domain = create(:domain, name: 'testpollmessage123.ee')
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
context 'about registrant update confirm' do

View file

@ -1,15 +1,15 @@
greeting:
body: Welcome!
text: Welcome!
queued: true
registrar: bestnames
domain_deleted:
body: Your domain has been deleted
text: Your domain has been deleted
queued: true
registrar: bestnames
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
farewell:
body: Good bye!
text: Good bye!
queued: true
registrar: goodnames

View file

@ -23,7 +23,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
last_registrar_notification = @domain.registrar.notifications.last
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
def test_accepted_registrant_verification_notifies_registrar
@ -31,6 +31,6 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
last_registrar_notification = @domain.registrar.notifications.last
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

View file

@ -23,7 +23,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
last_registrar_notification = @domain.registrar.notifications.last
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
def test_accepted_registrant_verification_notifies_registrar
@ -31,6 +31,6 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
last_registrar_notification = @domain.registrar.notifications.last
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

View file

@ -18,14 +18,14 @@ class DomainTransferTest < ActiveSupport::TestCase
@domain_transfer.approve
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' \
' and contacts acme-ltd-001, jane-001, william-001.'
id = @domain_transfer.id
class_name = @domain_transfer.class.name
notification = old_registrar.notifications.last
assert_equal body, notification.body
assert_equal text, notification.text
assert_equal id, notification.attached_obj_id
assert_equal class_name, notification.attached_obj_type
end

View file

@ -9,8 +9,8 @@ class NotificationTest < ActiveSupport::TestCase
assert @notification.valid?
end
def test_invalid_without_body
@notification.body = nil
def test_invalid_without_text
@notification.text = ''
assert @notification.invalid?
end