-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1492 from nervosnetwork/testnet
Deploy to mainnet
- Loading branch information
Showing
10 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Api | ||
module V1 | ||
class UdtQueriesController < ApplicationController | ||
def index | ||
udts = Udt.query_by_name_or_symbl(params[:q].downcase) | ||
|
||
render json: UdtSerializer.new(udts, { fields: { udt: [:full_name, :symbol, :type_hash, :icon_file] } }) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require "test_helper" | ||
|
||
module Api | ||
module V1 | ||
class UdtQueriesControllerTest < ActionDispatch::IntegrationTest | ||
test "should return empty array" do | ||
valid_get api_v1_udt_queries_url, params: { q: "CKB" } | ||
|
||
response_json = { data: [] }.to_json | ||
|
||
assert_response :success | ||
assert_equal "application/vnd.api+json", response.media_type | ||
assert_equal response_json, response.body | ||
end | ||
|
||
test "should query by symbol" do | ||
udt = create(:udt, full_name: "Nervos Token", symbol: "CKB") | ||
|
||
valid_get api_v1_udt_queries_url, params: { q: "CKB" } | ||
|
||
response_json = UdtSerializer.new([udt], | ||
{ | ||
fields: { | ||
udt: [ | ||
:full_name, :symbol, :type_hash, | ||
:icon_file | ||
] } }).serialized_json | ||
|
||
assert_response :success | ||
assert_equal response_json, response.body | ||
end | ||
|
||
test "should query by name" do | ||
udt = create(:udt, full_name: "Nervos Token", symbol: "CKB") | ||
|
||
valid_get api_v1_udt_queries_url, params: { q: "nervos" } | ||
|
||
response_json = UdtSerializer.new([udt], | ||
{ | ||
fields: { | ||
udt: [ | ||
:full_name, :symbol, :type_hash, | ||
:icon_file | ||
] } }).serialized_json | ||
|
||
assert_response :success | ||
assert_equal response_json, response.body | ||
end | ||
|
||
test "should query by symbol and name" do | ||
udt1 = create(:udt, full_name: "Nervos Token", symbol: "CKB") | ||
udt2 = create(:udt, full_name: "Nervos CKB", symbol: "NCKB") | ||
|
||
valid_get api_v1_udt_queries_url, params: { q: "CKB" } | ||
|
||
response_json = UdtSerializer.new([udt1, udt2], | ||
{ | ||
fields: { | ||
udt: [ | ||
:full_name, :symbol, :type_hash, | ||
:icon_file | ||
] } }).serialized_json | ||
|
||
assert_response :success | ||
assert_equal response_json, response.body | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters