From c43ce00aee592974e758f8ce4011ffad1c9ca3b5 Mon Sep 17 00:00:00 2001 From: Patryk Smolarz Date: Thu, 16 Apr 2026 17:39:45 +0200 Subject: [PATCH] tests fix --- __tests__/lib/loyalties.rb | 2 +- __tests__/spec/07_vouchers_spec.rb | 23 +++++++++++++++++-- .../support/get_snapshot_without_uniq_keys.rb | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/__tests__/lib/loyalties.rb b/__tests__/lib/loyalties.rb index 387f925a..1e3837ff 100644 --- a/__tests__/lib/loyalties.rb +++ b/__tests__/lib/loyalties.rb @@ -12,7 +12,7 @@ def update_loyalty_card_balance(loyalties_api_instance, memberId) return updated_loyalty_member_card rescue VoucherifySdk::ApiError => e - retun nil + return nil end end diff --git a/__tests__/spec/07_vouchers_spec.rb b/__tests__/spec/07_vouchers_spec.rb index 071acb1e..2105b4db 100644 --- a/__tests__/spec/07_vouchers_spec.rb +++ b/__tests__/spec/07_vouchers_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Vouchers API', :order => :defined do before(:each) do @vouchers_api_instance = Config.vouchers_api_instance() + @publications_api_instance = Config.publications_api_instance() @voucherify_data = VoucherifyData.instance() end @@ -41,14 +42,32 @@ expect(validate_deep_match(filtered_snapshot, voucher)).to be true end - it 'update loyalty card balance', :order => :fourth do + it 'publish loyalty card', :order => :fourth do + loyalty_card = @voucherify_data.get_loyalty_card() + customer = @voucherify_data.get_customer() + + publication = @publications_api_instance.create_publication({ + publications_create_request_body: VoucherifySdk::PublicationsCreateRequestBody.new({ + voucher: loyalty_card.code, + customer: VoucherifySdk::Customer.new({ + id: customer.id + }) + }) + }) + + expect(publication).not_to be_nil + end + + it 'update loyalty card balance', :order => :fifth do + loyalty_card = @voucherify_data.get_loyalty_card() + vouchers_balance_update_request_body = VoucherifySdk::VouchersBalanceUpdateRequestBody.new({ source_id: generate_random_string(), amount: 10000, reason: "Regular customer" }) - response = @vouchers_api_instance.update_voucher_balance(@voucherify_data.get_loyalty_card().code, vouchers_balance_update_request_body) + response = @vouchers_api_instance.update_voucher_balance(loyalty_card.code, vouchers_balance_update_request_body) snapshot_name = 'vouchers/updated_loyalty_card_balance' filtered_snapshot = get_snapshot_without_uniq_keys(snapshot_name) diff --git a/__tests__/spec/support/get_snapshot_without_uniq_keys.rb b/__tests__/spec/support/get_snapshot_without_uniq_keys.rb index ecef4b18..6dafabf5 100644 --- a/__tests__/spec/support/get_snapshot_without_uniq_keys.rb +++ b/__tests__/spec/support/get_snapshot_without_uniq_keys.rb @@ -2,7 +2,7 @@ require_relative 'snapshot_helper' def get_snapshot_without_uniq_keys(snapshot_name, keys_to_remove = nil) - keys_to_remove ||= ['id', 'created_at', 'updated_at', 'name', 'rule_id', 'customer_id', 'related_object_id', 'source_id', 'product_id', 'promotion_id', 'campaign_id', 'banner', 'code', 'date', 'voucher_id', 'rule_id', 'related_object_id', 'url', 'tracking_id', 'vouchers_id', 'holder_id'] + keys_to_remove ||= ['id', 'created_at', 'updated_at', 'name', 'rule_id', 'customer_id', 'related_object_id', 'source_id', 'product_id', 'promotion_id', 'campaign_id', 'banner', 'code', 'date', 'voucher_id', 'rule_id', 'related_object_id', 'url', 'tracking_id', 'vouchers_id', 'holder_id', 'join_once', 'orders', 'segments', 'daily_events'] # Load snapshot snapshot = load_snapshot(snapshot_name)