mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
parent
bb108efedd
commit
fa52001be6
141 changed files with 1388 additions and 1664 deletions
|
@ -20,47 +20,53 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal '1b3ee442-e8fe-4922-9492-8fcb9dccc69c', @auction.uuid
|
||||
assert_equal 'auction.test', @auction.domain
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:awaiting_payment] },
|
||||
as: :json
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:awaiting_payment] }), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
.decode(response.body)
|
||||
end
|
||||
|
||||
def test_marks_as_awaiting_payment
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:awaiting_payment] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.awaiting_payment?
|
||||
end
|
||||
|
||||
def test_marks_as_no_bids
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:no_bids] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:no_bids] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.no_bids?
|
||||
end
|
||||
|
||||
def test_marks_as_payment_received
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.payment_received?
|
||||
end
|
||||
|
||||
def test_marks_as_payment_not_received
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_not_received] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.payment_not_received?
|
||||
end
|
||||
|
||||
def test_marks_as_domain_not_registered
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:domain_not_registered] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:domain_not_registered] },
|
||||
as: :json
|
||||
@auction.reload
|
||||
assert @auction.domain_not_registered?
|
||||
end
|
||||
|
@ -69,8 +75,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
@auction.update!(registration_code: 'auction-001',
|
||||
status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
|
||||
response_json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_not_nil response_json['registration_code']
|
||||
|
@ -79,8 +86,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_conceals_registration_code_when_payment_is_not_received
|
||||
@auction.update!(status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_not_received] },
|
||||
as: :json
|
||||
|
||||
response_json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_nil response_json['registration_code']
|
||||
|
@ -91,8 +99,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'auction.test', @auction.domain
|
||||
@whois_record.update!(updated_at: '2010-07-04')
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
@whois_record.reload
|
||||
|
||||
assert_equal Time.zone.parse('2010-07-05 10:00'), @whois_record.updated_at
|
||||
|
@ -103,8 +112,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 'auction.test', @auction.domain
|
||||
@whois_record.delete
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid),
|
||||
params: { status: Auction.statuses[:payment_received] },
|
||||
as: :json
|
||||
|
||||
new_whois_record = Whois::Record.find_by(name: @auction.domain)
|
||||
assert_equal Time.zone.parse('2010-07-05 10:00'), new_whois_record.updated_at
|
||||
|
@ -114,16 +124,16 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
|||
def test_inaccessible_when_ip_address_is_not_allowed
|
||||
ENV['auction_api_allowed_ips'] = ''
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: 'any' }.to_json,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
patch api_v1_auction_path(@auction.uuid), params: { status: 'any' }, as: :json
|
||||
|
||||
assert_response :unauthorized
|
||||
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
|
||||
patch api_v1_auction_path('non-existing-uuid'),
|
||||
params: { status: Auction.statuses[:no_bids] },
|
||||
as: :json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue