Skip to content

Instantly share code, notes, and snippets.

View supriya's full-sized avatar

supriya mahajan supriya

View GitHub Profile
a/app/models/card.rb
+++ b/app/models/card.rb
@@ -66,9 +66,17 @@ class Card < ActiveRecord::Base
end
else
#FIXME logic for Personalized cards
+ if (self.balance + amount) <= max_balance
+ if (self.card_load_transactions.for_today.sum(:amount) <= max_daily_loads)
+ return true
+ else
context "views an individual card" do
setup do
FakeDataLoader.clear_tables
FakeDataLoader.bootstrap!(1)
@pan = "1111222233334444"
@card = Card.find_by_pan(@pan)
get :show, :id => @card.id
end
context "that was sold cross-store" do
@addon_products = @card.person.account_addon_products.map{|product| product.type.to_s }
in view:
%td.cardholder-product
- @addon_products.each do |addon_product|
= addon_product
in callhandlerv1#top_up_card
return result.fail_with("Credit Account is frozen") if @card.credit_account.frozen_credit?
in call_handler_top_up_test
context "with frozen credit" do
setup do
@card.credit_account.freeze_credit!
@result = CallHandler.top_up_card(:version => :v1, :account_number => @card_with_topup.pan, :transaction_amount => @transaction_amount, :available_balance => 488.00, :ip_address => "127.0.0.01")
end
return result.fail_with("The card doesn't have any available credit.") unless @card.credit_account && @card.credit_account.has_credit?
return result.fail_with('Credit Account is frozen.') if @card.credit_account.frozen_credit?
tests
context "with frozen credit" do
setup do
@card.credit_account.freeze_credit!
@result = CallHandler.top_up_card(:version => :v1, :account_number => @card_with_topup.pan, :transaction_amount => @transaction_amount, :available_balance => 488.00, :ip_address => "127.0.0.01")
end
#
require 'test_helper'
class CallHandlerTest < ActiveSupport::TestCase
setup do
skip_auditing
CallHandler.skip_log_entry = true
end
context "A CallHandler sent #top_up" do
setup do
#the contents are not formatted correctly. This is a row from the current file:
#"006887148,5,21082009"
#It should not contain quotations and the effective date should be in MM/dd/YYYY format.
#006887148,5,08/21/2009
#A few gottchas:
#Amount should not have dollar signs or commas – 2245.33
#Integer value for amount is fine “5” will be processed as 5.00 dollars
#!/usr/bin/env ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
require 'fastercsv'
csv_data = []
arr = Array.new
input_file= FasterCSV.open("input.csv", "r")
def load_direct_deposit_queue
search_value = params[:search_field]
case params[:filter_type]
when "All"
if search_value.nil?
@direct_deposits = DirectDeposit.find(:all, :include => [:person])
else
@direct_deposits = DirectDeposit.find(:all, :include => [:person], :conditions => [ "people.last_name LIKE ?", search_value ])
people = Person.with_status_code_not_as("Pending Federal Benefits Direct Deposit Credit")
people.each do |p|
if !p.federal_benefits_enrollments.empty? && p.direct_deposit_status.direct_deposit_status_code.to_s != "Rejected"
p.direct_deposit_status.change_status!("Pending Federal Benefits Direct Deposit Credit", p.direct_deposit_status.created_by, nil)
end
end