mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Add registrant verification versions table according to existing logic
Creates a log_registrant_verifications table and version class as per https://github.com/internetee/registry/issues/1425#issuecomment-567117002
This commit is contained in:
parent
7f308d4123
commit
c4ffdbd650
6 changed files with 300 additions and 202 deletions
|
@ -1,7 +1,7 @@
|
|||
# Used in Registrant portal to collect registrant verifications
|
||||
# Registrant postgres user can access this table directly.
|
||||
class RegistrantVerification < ApplicationRecord
|
||||
has_paper_trail
|
||||
has_paper_trail class_name: 'RegistrantVerificationVersion'
|
||||
|
||||
# actions
|
||||
CONFIRMED = 'confirmed'
|
||||
|
|
7
app/models/version/registrant_verification_version.rb
Normal file
7
app/models/version/registrant_verification_version.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class RegistrantVerificationVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_registrant_verifications
|
||||
self.sequence_name = :log_registrant_verifications_id_seq
|
||||
|
||||
scope :deleted, -> { where(event: 'destroy') }
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
class AddJsonBasedVersionToRegistrantVerifications < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
name = 'registrant_verification'
|
||||
table_name = "log_#{name.tableize}"
|
||||
|
||||
create_table table_name do |t|
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.string :whodunnit
|
||||
t.json :object
|
||||
t.json :object_changes
|
||||
t.datetime :created_at
|
||||
t.string :session
|
||||
end
|
||||
add_index table_name, [:item_type, :item_id]
|
||||
add_index table_name, :whodunnit
|
||||
|
||||
add_column name.tableize, :creator_id_tmp, :integer
|
||||
add_column name.tableize, :updater_id_tmp, :integer
|
||||
rename_column name.tableize, :creator_id_tmp, :creator_id
|
||||
rename_column name.tableize, :updater_id_tmp, :updater_id
|
||||
end
|
||||
end
|
466
db/structure.sql
466
db/structure.sql
File diff suppressed because it is too large
Load diff
1
test/fixtures/registrant_verifications.yml
vendored
1
test/fixtures/registrant_verifications.yml
vendored
|
@ -3,5 +3,4 @@ one:
|
|||
action_type: domain_delete
|
||||
created_at: <%= Time.zone.parse('2010-07-05') %>
|
||||
domain: shop
|
||||
domain_name: shop.test
|
||||
verification_token: 1234
|
||||
|
|
|
@ -5,7 +5,7 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
|
|||
registrant_verification = registrant_verifications(:one)
|
||||
random_action = "random#{rand(100)}"
|
||||
|
||||
assert_difference -> { PaperTrail::Version.count } do
|
||||
assert_difference -> { RegistrantVerificationVersion.count } do
|
||||
registrant_verification.update_attributes!(action: random_action)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue