mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
Migrate publishable
field name to registrant_publishable
This commit is contained in:
parent
4286a6bab7
commit
59fe7dffbe
9 changed files with 15 additions and 13 deletions
|
@ -72,7 +72,7 @@ module Api
|
|||
contact.disclosed_attributes = disclosed_attributes
|
||||
end
|
||||
|
||||
contact.publishable = reparsed_request_json[:publishable] if reparsed_request_json[:publishable].present?
|
||||
contact.registrant_publishable = reparsed_request_json[:registrant_publishable]
|
||||
|
||||
logger.debug "Setting.address_processing is set to #{Setting.address_processing}"
|
||||
|
||||
|
|
|
@ -64,7 +64,8 @@ class Contact < ApplicationRecord
|
|||
|
||||
validate :validate_html
|
||||
validate :validate_country_code, if: -> { self.class.address_processing? }
|
||||
validates :publishable, inclusion: { in: [true, false] }
|
||||
validates :registrant_publishable, inclusion: { in: [true, false] }, if: -> { registrant? }
|
||||
validates :registrant_publishable, inclusion: { in: [false] }, unless: -> { registrant? }
|
||||
|
||||
after_initialize do
|
||||
self.status_notes = {} if status_notes.nil?
|
||||
|
|
|
@ -5,6 +5,6 @@ class Registrant < Contact
|
|||
end
|
||||
|
||||
def publishable?
|
||||
publishable
|
||||
registrant_publishable
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class WhoisRecord < ApplicationRecord
|
|||
|
||||
h[:email] = registrant.email
|
||||
h[:phone] = registrant.phone
|
||||
h[:publishable] = registrant.publishable?
|
||||
h[:registrant_publishable] = registrant.publishable?
|
||||
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
|
||||
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class AddPublishableToContacts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :contacts, :publishable, :boolean, default: false
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddRegistrantPublishableToContacts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :contacts, :registrant_publishable, :boolean, default: false
|
||||
end
|
||||
end
|
|
@ -671,7 +671,7 @@ CREATE TABLE public.contacts (
|
|||
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
disclosed_attributes character varying[] DEFAULT '{}'::character varying[] NOT NULL,
|
||||
email_history character varying,
|
||||
publishable boolean DEFAULT false
|
||||
registrant_publishable boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ module Serializers
|
|||
auth_info: contact.auth_info,
|
||||
statuses: contact.statuses,
|
||||
disclosed_attributes: contact.disclosed_attributes,
|
||||
registrant_publishable: contact.registrant_publishable,
|
||||
}
|
||||
|
||||
obj[:links] = contact.related_domains if @links
|
||||
|
|
|
@ -229,9 +229,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal %w[phone], @contact.disclosed_attributes
|
||||
end
|
||||
|
||||
def test_publishable_change_when_present
|
||||
def test_registrant_publishable_change_when_present
|
||||
@contact = contacts(:acme_ltd)
|
||||
@contact.update!(publishable: false)
|
||||
@contact.update!(registrant_publishable: false)
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[], publishable: true },
|
||||
|
@ -240,7 +240,7 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.reload
|
||||
|
||||
assert_response :ok
|
||||
assert @contact.publishable
|
||||
assert @contact.registrant_publishable
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue