mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Revert "Fix possible doubling of contact objects after race"
This commit is contained in:
parent
98a209505d
commit
3be2c384a2
5 changed files with 41 additions and 2238 deletions
|
@ -103,19 +103,13 @@ module Epp
|
||||||
def update
|
def update
|
||||||
authorize! :update, @domain, @password
|
authorize! :update, @domain, @password
|
||||||
|
|
||||||
updated = Domain.transaction(isolation: isolation_level) do
|
updated = @domain.update(params[:parsed_frame], current_user)
|
||||||
@domain.update(params[:parsed_frame], current_user)
|
|
||||||
end
|
|
||||||
(handle_errors(@domain) && return) unless updated
|
(handle_errors(@domain) && return) unless updated
|
||||||
|
|
||||||
pending = @domain.epp_pending_update.present?
|
pending = @domain.epp_pending_update.present?
|
||||||
render_epp_response "/epp/domains/success#{'_pending' if pending}"
|
render_epp_response "/epp/domains/success#{'_pending' if pending}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def isolation_level
|
|
||||||
:serializable unless Rails.env.test?
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
authorize! :delete, @domain, @password
|
authorize! :delete, @domain, @password
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
class AddUniqueConstraintsToDomainObjects < ActiveRecord::Migration[6.0]
|
|
||||||
def up
|
|
||||||
execute <<-SQL
|
|
||||||
alter table domain_contacts
|
|
||||||
add constraint uniq_contact_of_type_per_domain unique (domain_id, type, contact_id);
|
|
||||||
SQL
|
|
||||||
|
|
||||||
execute <<-SQL
|
|
||||||
alter table nameservers
|
|
||||||
add constraint uniq_hostname_per_domain unique (domain_id, hostname);
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
execute <<-SQL
|
|
||||||
alter table domain_contacts
|
|
||||||
drop constraint if exists uniq_contact_of_type_per_domain;
|
|
||||||
SQL
|
|
||||||
|
|
||||||
execute <<-SQL
|
|
||||||
alter table nameservers
|
|
||||||
drop constraint if exists uniq_hostname_per_domain;
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
end
|
|
2232
db/structure.sql
2232
db/structure.sql
File diff suppressed because it is too large
Load diff
|
@ -177,7 +177,7 @@ class ContactTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_linked_when_in_use_as_domain_contact
|
def test_linked_when_in_use_as_domain_contact
|
||||||
Domain.update_all(registrant_id: contacts(:william).id)
|
Domain.update_all(registrant_id: contacts(:william).id)
|
||||||
DomainContact.first.update(contact_id: @contact.id)
|
DomainContact.update_all(contact_id: @contact.id)
|
||||||
|
|
||||||
assert @contact.linked?
|
assert @contact.linked?
|
||||||
end
|
end
|
||||||
|
|
|
@ -137,9 +137,9 @@ class DomainTest < ActiveSupport::TestCase
|
||||||
contact = contacts(:john)
|
contact = contacts(:john)
|
||||||
|
|
||||||
domain.admin_contacts << contact
|
domain.admin_contacts << contact
|
||||||
assert_raise ActiveRecord::RecordNotUnique do
|
domain.admin_contacts << contact
|
||||||
domain.admin_contacts << contact
|
|
||||||
end
|
assert domain.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_when_the_same_tech_contact_is_linked_twice
|
def test_invalid_when_the_same_tech_contact_is_linked_twice
|
||||||
|
@ -147,9 +147,9 @@ class DomainTest < ActiveSupport::TestCase
|
||||||
contact = contacts(:john)
|
contact = contacts(:john)
|
||||||
|
|
||||||
domain.tech_contacts << contact
|
domain.tech_contacts << contact
|
||||||
assert_raise ActiveRecord::RecordNotUnique do
|
domain.tech_contacts << contact
|
||||||
domain.tech_contacts << contact
|
|
||||||
end
|
assert domain.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_name_server_count_when_name_servers_are_required
|
def test_validates_name_server_count_when_name_servers_are_required
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue