Skip to content

Commit

Permalink
Adding tests for transaction/refund extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansch committed Jan 21, 2011
1 parent 8e83fe9 commit 0551c8e
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion spec/remote/remote_spec.rb
Expand Up @@ -277,6 +277,50 @@
@subscription.transactions.first.amount_in_cents.should == 700
@subscription.transactions.first.transaction_type.should == 'refund'
end

context "via subscription payment (Chargify::Subscription::Transaction)" do
before :each do
@payment = @subscription.transactions.first
end

it "creates a refund" do
lambda{
@payment.refund :amount => 7, :memo => 'Refunding One Time Charge'
}.should change{@subscription.reload.transactions.size}.by(1)
@subscription.transactions.first.amount_in_cents.should == 700
@subscription.transactions.first.transaction_type.should == 'refund'
end

it "creates a full refund" do
lambda{
@payment.full_refund :memo => 'Refunding One Time Charge'
}.should change{@subscription.reload.transactions.size}.by(1)
@subscription.transactions.first.amount_in_cents.should == 700
@subscription.transactions.first.transaction_type.should == 'refund'
end
end

context "via site payment (Chargify::Transaction)" do
before :each do
@site_payment = Chargify::Transaction.find(:first)
end

it "creates a refund" do
lambda{
@site_payment.refund :amount => 7, :memo => 'Refunding One Time Charge'
}.should change{@subscription.reload.transactions.size}.by(1)
@subscription.transactions.first.amount_in_cents.should == 700
@subscription.transactions.first.transaction_type.should == 'refund'
end

it "creates a full refund" do
lambda{
@site_payment.full_refund :memo => 'Refunding One Time Charge'
}.should change{@subscription.reload.transactions.size}.by(1)
@subscription.transactions.first.amount_in_cents.should == 700
@subscription.transactions.first.transaction_type.should == 'refund'
end
end
end

def already_cleared_site_data?
Expand Down Expand Up @@ -467,4 +511,4 @@ def register_resource(type, hierarchy, resource)
end

end
end
end

0 comments on commit 0551c8e

Please sign in to comment.