Merge pull request #2393 from internetee/fix-plarform-indicator-for-next-rounds

fixed type of auction for next rounds
This commit is contained in:
Timo Võhmar 2022-09-29 15:17:13 +03:00 committed by GitHub
commit c2cea06060
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 2 deletions

View file

@ -31,6 +31,7 @@ module Api
end
auction.mark_deadline(params[:registration_deadline]) if params[:registration_deadline]
auction.platform = params[:platform] == 'english' ? :manual : :auto
if auction.payment_not_received? || auction.domain_not_registered?
update_whois_from_auction(Auction.pending(auction.domain))

View file

@ -84,7 +84,9 @@ class Auction < ApplicationRecord
end
def restart
new_auction = self.class.new(domain: domain)
new_platform = platform.nil? ? :auto : platform
new_auction = self.class.new(domain: domain, platform: new_platform)
new_auction.start
end

View file

@ -28,7 +28,7 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:awaiting_payment],
'platform' => nil }), ActiveSupport::JSON.decode(response.body)
'platform' => "auto" }), ActiveSupport::JSON.decode(response.body)
end
def test_marks_as_awaiting_payment

View file

@ -131,6 +131,49 @@ class AuctionTest < ActiveSupport::TestCase
assert_not @auction.domain_registrable?('')
end
def test_restart_new_auction_should_with_previous_manual_platform
@auction.update(platform: 'manual')
@auction.reload
assert_equal @auction.platform, 'manual'
assert_difference 'Auction.count' do
@auction.restart
end
new_auction = Auction.last
assert_equal new_auction.platform, 'manual'
end
def test_restart_new_auction_should_with_previous_auto_platform
@auction.update(platform: 'auto')
@auction.reload
assert_equal @auction.platform, 'auto'
assert_difference 'Auction.count' do
@auction.restart
end
new_auction = Auction.last
assert_equal new_auction.platform, 'auto'
end
def test_restart_new_auction_should_with_auto_if_platform_is_nil
@auction.update(platform: nil)
@auction.reload
assert_nil @auction.platform
assert_difference 'Auction.count' do
@auction.restart
end
new_auction = Auction.last
assert_equal new_auction.platform, 'auto'
end
def test_restarts_an_auction
assert_equal 'auction.test', @auction.domain
@ -142,4 +185,30 @@ class AuctionTest < ActiveSupport::TestCase
assert_equal 'auction.test', new_auction.domain
assert new_auction.started?
end
def test_auction_restart_should_assign_the_previous_manual_platform
assert_equal 'auction.test', @auction.domain
@auction.update(platform: :manual)
@auction.reload
assert_difference 'Auction.count' do
@auction.restart
end
auctions = Auction.where(domain: @auction.domain)
assert_equal auctions.first.platform, auctions.last.platform
end
def test_auction_restart_should_assign_the_previous_auto_platform
assert_equal 'auction.test', @auction.domain
@auction.update(platform: :auto)
@auction.reload
assert_difference 'Auction.count' do
@auction.restart
end
auctions = Auction.where(domain: @auction.domain)
assert_equal auctions.first.platform, auctions.last.platform
end
end