Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/lib/loyalties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 21 additions & 2 deletions __tests__/spec/07_vouchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion __tests__/spec/support/get_snapshot_without_uniq_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading