diff --git a/Gemfile b/Gemfile index cc0b249..c1feaa5 100644 --- a/Gemfile +++ b/Gemfile @@ -30,6 +30,7 @@ gem "sanitize" gem "awesome_print" gem "resend" gem "icalendar" +gem "hash_diff" gem "aliyunsdkcore" gem "imagekitio" diff --git a/Gemfile.lock b/Gemfile.lock index fa104f4..d1801cb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,6 +137,7 @@ GEM forwardable (1.3.3) globalid (1.2.1) activesupport (>= 6.1) + hash_diff (1.1.1) http-accept (1.7.0) http-cookie (1.0.7) domain_name (~> 0.5) @@ -414,6 +415,7 @@ DEPENDENCIES dotenv-rails ed25519 (= 1.3.0) eth + hash_diff icalendar imagekitio importmap-rails diff --git a/test/controllers/api/ticket_controller_test.rb b/test/controllers/api/ticket_controller_test.rb index eef46af..b6cb701 100644 --- a/test/controllers/api/ticket_controller_test.rb +++ b/test/controllers/api/ticket_controller_test.rb @@ -57,5 +57,35 @@ class Api::TicketControllerTest < ActionDispatch::IntegrationTest params: { auth_token: auth_token, id: event.id, ticket_id: ticket.id, payment_method_id: nil } assert_response :success end + + test "api#ticket/rsvp with crypto ticket" do + profile = Profile.find_by(handle: "cookie") + auth_token = profile.gen_auth_token + group = Group.find_by(handle: "guildx") + + event = events(:with_ticket) + ticket = Ticket.find_by(event: event, title: 'crypto') + op_paymethod = PaymentMethod.find_by(item: ticket, chain: 'op') + + post api_ticket_rsvp_url, + params: { auth_token: auth_token, id: event.id, ticket_id: ticket.id, payment_method_id: op_paymethod.id } + assert_response :success + + ticket_item = TicketItem.find_by(event: event) + assert ticket_item.status == "pending" + + ENV['NEXT_TOKEN'] = "VBNM" + + post api_ticket_set_ticket_payment_status_url, + params: { next_token: ENV['NEXT_TOKEN'], chain: ticket_item.chain, product_id: event.id, item_id: ticket_item.order_number, amount: ticket_item.amount, txhash: "0x7890"} + assert_response :success + + ticket_item.reload + assert ticket_item.txhash == "0x7890" + assert ticket_item.status == "succeeded" + + # hash_diff = HashDiff::Comparison.new( ticket_item.as_json, ticket_item.reload.as_json ) + # p hash_diff.diff + end end