diff --git a/app/controllers/admin/domains/force_delete_controller.rb b/app/controllers/admin/domains/force_delete_controller.rb index 155b4fa41..946231077 100644 --- a/app/controllers/admin/domains/force_delete_controller.rb +++ b/app/controllers/admin/domains/force_delete_controller.rb @@ -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? diff --git a/app/jobs/domain_delete_job.rb b/app/jobs/domain_delete_job.rb index 15195b588..b45f96713 100644 --- a/app/jobs/domain_delete_job.rb +++ b/app/jobs/domain_delete_job.rb @@ -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 ) diff --git a/app/models/domain.rb b/app/models/domain.rb index d39e86272..84ecc37d0 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -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 ) diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 2ac35a0db..91cdb2d67 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -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), diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 2bfd10215..2f25f3da5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -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 ) diff --git a/app/models/notification.rb b/app/models/notification.rb index 09f9377da..5fbdeccb5 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -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 diff --git a/app/views/epp/poll/poll_keyrelay.xml.builder b/app/views/epp/poll/poll_keyrelay.xml.builder index c79b2a574..606f03936 100644 --- a/app/views/epp/poll/poll_keyrelay.xml.builder +++ b/app/views/epp/poll/poll_keyrelay.xml.builder @@ -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 diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index f483e017b..3eb78f7a1 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -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' diff --git a/db/migrate/20180823174331_rename_notifications_body_to_text.rb b/db/migrate/20180823174331_rename_notifications_body_to_text.rb new file mode 100644 index 000000000..d0b5e0514 --- /dev/null +++ b/db/migrate/20180823174331_rename_notifications_body_to_text.rb @@ -0,0 +1,5 @@ +class RenameNotificationsBodyToText < ActiveRecord::Migration + def change + rename_column :notifications, :body, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index d1f6adb36..355b5ef63 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -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'); + diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 1c00a9a4d..858570c68 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -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 diff --git a/test/fixtures/notifications.yml b/test/fixtures/notifications.yml index 58ae3bd6d..aaa601a61 100644 --- a/test/fixtures/notifications.yml +++ b/test/fixtures/notifications.yml @@ -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 \ No newline at end of file diff --git a/test/jobs/domain_delete_confirm_job_test.rb b/test/jobs/domain_delete_confirm_job_test.rb index fcd956213..51af58c24 100644 --- a/test/jobs/domain_delete_confirm_job_test.rb +++ b/test/jobs/domain_delete_confirm_job_test.rb @@ -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 diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index fdbf0feb4..070b5d5f7 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -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 diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index 16c8fa6d8..943fc2a0a 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -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 diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index cd85532f0..c9ee91a8e 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -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