Skip to content

Commit

Permalink
fix: xudt only need to update description website and logo (#1979)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Jun 20, 2024
1 parent 695f5f8 commit 1a70ae0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
30 changes: 20 additions & 10 deletions app/controllers/api/v1/udts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,26 @@ def index

def update
udt = Udt.find_by!(type_hash: params[:id])
attrs = {
symbol: params[:symbol],
full_name: params[:full_name],
decimal: params[:decimal],
description: params[:description],
operator_website: params[:operator_website],
icon_file: params[:icon_file],
email: params[:email],
published: true,
}
attrs =
if udt.udt_type == "xudt"
{
description: params[:description],
operator_website: params[:operator_website],
icon_file: params[:icon_file],
email: params[:email],
}
else
{
symbol: params[:symbol],
full_name: params[:full_name],
decimal: params[:decimal],
description: params[:description],
operator_website: params[:operator_website],
icon_file: params[:icon_file],
email: params[:email],
published: true,
}
end
if udt.email.blank?
raise Api::V1::Exceptions::UdtInfoInvalidError.new("Email can't be blank") if params[:email].blank?

Expand Down
15 changes: 15 additions & 0 deletions test/controllers/api/v1/udts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,21 @@ class UdtsControllerTest < ActionDispatch::IntegrationTest
assert_equal "[email protected]", udt.reload.email
end

test "should not update symbol when is xudt" do
xudt = create(:udt, :xudt)
create(:udt_verification, udt: xudt)
valid_put api_v1_udt_url("#{xudt.type_hash}"), params: {
operator_website: "www.testxudt.com",
email: "[email protected]",

}

assert_equal 200, response.status
assert_equal "ok", JSON.parse(response.body)
assert_equal "BBQ", xudt.reload.symbol
assert_equal "www.testxudt.com", xudt.reload.operator_website
end

test "should raise token not exist error when update udt but token not passed" do
udt = create(:udt, email: "[email protected]")
create(:udt_verification, udt:)
Expand Down

0 comments on commit 1a70ae0

Please sign in to comment.