mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Complete auction integration
This commit is contained in:
parent
f1148bd4f4
commit
446b9fbf77
6 changed files with 62 additions and 6 deletions
|
@ -23,4 +23,10 @@ class ApiV1AuctionDetailsTest < ActionDispatch::IntegrationTest
|
|||
'status' => Auction.statuses[:no_bids] }), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
end
|
||||
end
|
||||
|
||||
def test_auction_not_found
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
get api_v1_auction_path('non-existing-uuid'), nil, 'Content-Type' => Mime::JSON.to_s
|
||||
end
|
||||
end
|
||||
end
|
|
@ -89,6 +89,15 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert DNS::DomainName.new('auction.test').at_auction?
|
||||
end
|
||||
|
||||
def test_restarts_an_auction_when_domain_is_not_registered
|
||||
@auction.update!(domain: 'auction.test', status: Auction.statuses[:payment_received])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:domain_not_registered] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert DNS::DomainName.new('auction.test').at_auction?
|
||||
end
|
||||
|
||||
def test_inaccessible_when_ip_address_is_not_allowed
|
||||
ENV['auction_api_allowed_ips'] = ''
|
||||
|
||||
|
@ -97,4 +106,11 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
|
||||
assert_response :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
def test_auction_not_found
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
patch api_v1_auction_path('non-existing-uuid'), { status: Auction.statuses[:no_bids] }.to_json,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,7 +15,8 @@ class AuctionTest < ActiveSupport::TestCase
|
|||
'awaiting_payment' => 'awaiting_payment',
|
||||
'payment_received' => 'payment_received',
|
||||
'payment_not_received' => 'payment_not_received',
|
||||
'domain_registered' => 'domain_registered' }), Auction.statuses
|
||||
'domain_registered' => 'domain_registered',
|
||||
'domain_not_registered' => 'domain_not_registered' }), Auction.statuses
|
||||
end
|
||||
|
||||
def test_selling_domain_starts_new_auction
|
||||
|
@ -95,6 +96,27 @@ class AuctionTest < ActiveSupport::TestCase
|
|||
assert new_auction.started?
|
||||
end
|
||||
|
||||
def test_marking_as_domain_not_registered
|
||||
@auction.update!(status: Auction.statuses[:payment_received])
|
||||
|
||||
@auction.mark_as_domain_not_registered
|
||||
@auction.reload
|
||||
|
||||
assert @auction.domain_not_registered?
|
||||
end
|
||||
|
||||
def test_restarts_an_auction_when_domain_is_not_registered
|
||||
@auction.update!(domain: 'auction.test', status: Auction.statuses[:domain_not_registered])
|
||||
|
||||
assert_difference 'Auction.count' do
|
||||
@auction.mark_as_domain_not_registered
|
||||
end
|
||||
|
||||
new_auction = Auction.last
|
||||
assert_equal 'auction.test', new_auction.domain
|
||||
assert new_auction.started?
|
||||
end
|
||||
|
||||
def test_domain_registrable
|
||||
assert @auction.no_bids?
|
||||
assert_not @auction.domain_registrable?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue