mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Add show action
This commit is contained in:
parent
0ab9f6333f
commit
b33ad0d4e8
4 changed files with 28 additions and 8 deletions
|
@ -4,12 +4,15 @@ module Api
|
||||||
module V1
|
module V1
|
||||||
module Registrant
|
module Registrant
|
||||||
class DomainsController < ActionController::API
|
class DomainsController < ActionController::API
|
||||||
def index
|
|
||||||
render json: { success: true }
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render json: { success: true }
|
@domain = Domain.find_by(uuid: params[:uuid])
|
||||||
|
|
||||||
|
if @domain
|
||||||
|
render json: @domain
|
||||||
|
else
|
||||||
|
render json: { errors: ["Domain not found"] }, status: :not_found
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ module DomainNameRegistry
|
||||||
config.i18n.default_locale = :en
|
config.i18n.default_locale = :en
|
||||||
|
|
||||||
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
|
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
|
||||||
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
|
# config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
|
||||||
|
|
||||||
# Autoload all model subdirs
|
# Autoload all model subdirs
|
||||||
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
|
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
|
||||||
|
|
2
test/fixtures/domains.yml
vendored
2
test/fixtures/domains.yml
vendored
|
@ -45,7 +45,7 @@ metro:
|
||||||
hospital:
|
hospital:
|
||||||
name: hospital.test
|
name: hospital.test
|
||||||
registrar: goodnames
|
registrar: goodnames
|
||||||
registrant: william
|
registrant: john
|
||||||
transfer_code: 23118v2
|
transfer_code: 23118v2
|
||||||
valid_to: 2010-07-05
|
valid_to: 2010-07-05
|
||||||
period: 1
|
period: 1
|
||||||
|
|
|
@ -4,14 +4,31 @@ class RegistrantApiDomainsTest < ApplicationSystemTestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@registrant = contacts(:william)
|
@domain = domains(:hospital)
|
||||||
|
@registrant = @domain.registrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_domain_details_by_uuid
|
||||||
|
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37'
|
||||||
|
assert_equal(200, response.status)
|
||||||
|
|
||||||
def test_can_get_domain_details_by_uuid
|
domain = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
assert_equal('hospital.test', domain[:name])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_non_existent_domain_details_by_uuid
|
||||||
|
get '/api/v1/registrant/domains/random-uuid'
|
||||||
|
assert_equal(404, response.status)
|
||||||
|
|
||||||
|
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
assert_equal({errors: ['Domain not found']}, response_json)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_non_registrar_domain_details_by_uuid
|
||||||
|
# no op
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue