mirror of
https://github.com/internetee/registry.git
synced 2025-06-13 16:14:47 +02:00
Merge pull request #1572 from internetee/1201-registration-deadline-whois
Add registration deadline field to auction model
This commit is contained in:
commit
bc84ba0b5e
7 changed files with 49 additions and 10 deletions
|
@ -30,6 +30,8 @@ module Api
|
||||||
raise "Invalid status #{params[:status]}"
|
raise "Invalid status #{params[:status]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
auction.mark_deadline(params[:registration_deadline]) if params[:registration_deadline]
|
||||||
|
|
||||||
if auction.payment_not_received? || auction.domain_not_registered?
|
if auction.payment_not_received? || auction.domain_not_registered?
|
||||||
update_whois_from_auction(Auction.pending(auction.domain))
|
update_whois_from_auction(Auction.pending(auction.domain))
|
||||||
else
|
else
|
||||||
|
|
|
@ -23,10 +23,19 @@ class Auction < ApplicationRecord
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def whois_deadline
|
||||||
|
registration_deadline.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def mark_as_no_bids
|
def mark_as_no_bids
|
||||||
no_bids!
|
no_bids!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mark_deadline(registration_deadline)
|
||||||
|
self.registration_deadline = registration_deadline
|
||||||
|
save!
|
||||||
|
end
|
||||||
|
|
||||||
def mark_as_payment_received
|
def mark_as_payment_received
|
||||||
self.status = self.class.statuses[:payment_received]
|
self.status = self.class.statuses[:payment_received]
|
||||||
generate_registration_code
|
generate_registration_code
|
||||||
|
|
|
@ -16,7 +16,8 @@ module Whois
|
||||||
elsif auction.awaiting_payment? || auction.payment_received?
|
elsif auction.awaiting_payment? || auction.payment_received?
|
||||||
update!(json: { name: auction.domain,
|
update!(json: { name: auction.domain,
|
||||||
status: ['PendingRegistration'],
|
status: ['PendingRegistration'],
|
||||||
disclaimer: self.class.disclaimer })
|
disclaimer: self.class.disclaimer,
|
||||||
|
registration_deadline: auction.whois_deadline })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddRegistrationDeadlineDateToModels < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :auctions, :registration_deadline, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -325,7 +325,8 @@ CREATE TABLE public.auctions (
|
||||||
status character varying NOT NULL,
|
status character varying NOT NULL,
|
||||||
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
registration_code character varying
|
registration_code character varying,
|
||||||
|
registration_deadline timestamp without time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -4463,5 +4464,5 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20200130092113'),
|
('20200130092113'),
|
||||||
('20200203143458'),
|
('20200203143458'),
|
||||||
('20200204103125'),
|
('20200204103125'),
|
||||||
('20200311114649');
|
('20200311114649'),
|
||||||
|
('20200417075720');
|
||||||
|
|
|
@ -39,6 +39,17 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
||||||
assert @auction.awaiting_payment?
|
assert @auction.awaiting_payment?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_sets_registration_deadline
|
||||||
|
deadline = (Time.zone.now + 10.days).end_of_day
|
||||||
|
patch api_v1_auction_path(@auction.uuid),
|
||||||
|
params: { status: Auction.statuses[:awaiting_payment],
|
||||||
|
registration_deadline: deadline},
|
||||||
|
as: :json
|
||||||
|
@auction.reload
|
||||||
|
|
||||||
|
assert_in_delta @auction.registration_deadline, deadline, 1.second
|
||||||
|
end
|
||||||
|
|
||||||
def test_marks_as_no_bids
|
def test_marks_as_no_bids
|
||||||
patch api_v1_auction_path(@auction.uuid),
|
patch api_v1_auction_path(@auction.uuid),
|
||||||
params: { status: Auction.statuses[:no_bids] },
|
params: { status: Auction.statuses[:no_bids] },
|
||||||
|
|
|
@ -40,24 +40,34 @@ class Whois::RecordTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_updates_whois_record_from_auction_when_awaiting_payment
|
def test_updates_whois_record_from_auction_when_awaiting_payment
|
||||||
@auction.update!(domain: 'domain.test', status: Auction.statuses[:awaiting_payment])
|
@auction.update!(domain: 'domain.test',
|
||||||
|
status: Auction.statuses[:awaiting_payment],
|
||||||
|
registration_deadline: registration_deadline)
|
||||||
@whois_record.update!(name: 'domain.test')
|
@whois_record.update!(name: 'domain.test')
|
||||||
@whois_record.update_from_auction(@auction)
|
@whois_record.update_from_auction(@auction)
|
||||||
@whois_record.reload
|
@whois_record.reload
|
||||||
|
|
||||||
assert_equal ({ 'name' => 'domain.test',
|
assert_equal ({ 'name' => 'domain.test',
|
||||||
'status' => ['PendingRegistration'],
|
'status' => ['PendingRegistration'],
|
||||||
'disclaimer' => 'disclaimer' }), @whois_record.json
|
'disclaimer' => 'disclaimer',
|
||||||
|
'registration_deadline' => registration_deadline.to_s }), @whois_record.json
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_updates_whois_record_from_auction_when_payment_received
|
def test_updates_whois_record_from_auction_when_payment_received
|
||||||
@auction.update!(domain: 'domain.test', status: Auction.statuses[:payment_received])
|
@auction.update!(domain: 'domain.test',
|
||||||
|
status: Auction.statuses[:payment_received],
|
||||||
|
registration_deadline: registration_deadline)
|
||||||
@whois_record.update!(name: 'domain.test')
|
@whois_record.update!(name: 'domain.test')
|
||||||
@whois_record.update_from_auction(@auction)
|
@whois_record.update_from_auction(@auction)
|
||||||
@whois_record.reload
|
@whois_record.reload
|
||||||
|
|
||||||
assert_equal ({ 'name' => 'domain.test',
|
assert_equal ({ 'name' => 'domain.test',
|
||||||
'status' => ['PendingRegistration'],
|
'status' => ['PendingRegistration'],
|
||||||
'disclaimer' => 'disclaimer' }), @whois_record.json
|
'disclaimer' => 'disclaimer',
|
||||||
|
'registration_deadline' => registration_deadline.to_s }), @whois_record.json
|
||||||
|
end
|
||||||
|
|
||||||
|
def registration_deadline
|
||||||
|
Time.zone.now + 10.days
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue