Browse files

Some dup'ing was required.

  • Loading branch information...
1 parent 8cf7d9c commit 3c66129ba5f0f182fa25b0d2e181ce7b5c36e1ea @gabebw gabebw committed Jan 13, 2012
Showing with 19 additions and 11 deletions.
  1. +19 −11 lib/fake_braintree/subscription.rb
View
30 lib/fake_braintree/subscription.rb
@@ -5,13 +5,13 @@ class Subscription
def initialize(subscription_hash_from_params, options)
@subscription_hash = subscription_hash_from_params.merge("merchant_id" => options[:merchant_id],
"id" => options[:id])
+ set_subscription_id
+ set_subscription_status
end
def create
- hash = subscription_hash
- create_subscription_with(hash)
-
- response_for_created_subscription(hash)
+ create_subscription_with(subscription_hash)
+ response_for_created_subscription(subscription_hash)
end
def update
@@ -24,14 +24,14 @@ def update
end
def subscription_hash
- @subscription_hash["id"] ||= generate_new_subscription_id
- @subscription_hash["transactions"] = []
- @subscription_hash["add_ons"] = added_add_ons
- @subscription_hash["discounts"] = added_discounts
- @subscription_hash["next_billing_date"] = braintree_formatted_date(1.month.from_now)
- @subscription_hash["status"] ||= active_status
+ generated_subscription_hash = @subscription_hash.dup
- @subscription_hash
+ generated_subscription_hash["transactions"] = []
+ generated_subscription_hash["add_ons"] = added_add_ons
+ generated_subscription_hash["discounts"] = added_discounts
+ generated_subscription_hash["next_billing_date"] = braintree_formatted_date(1.month.from_now)
+
+ generated_subscription_hash
end
private
@@ -73,6 +73,14 @@ def added_discounts
end
end
+ def set_subscription_id
+ @subscription_hash["id"] ||= generate_new_subscription_id
+ end
+
+ def set_subscription_status
+ @subscription_hash["status"] ||= active_status
+ end
+
def subscription_id
subscription_hash["id"]
end

0 comments on commit 3c66129

Please sign in to comment.