summaryrefslogtreecommitdiff
path: root/billing/test/integration
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-09-19 12:02:36 -0700
committerjessib <jessib@riseup.net>2013-09-19 12:02:36 -0700
commit890c9e170fc038eccb46eca3c1ddcf6f05eaa53f (patch)
tree2b1ab7c9e89f2aaae379938430f40e5b3babfbbf /billing/test/integration
parent16b8966a0df0104390ce95e35f1bb17f173f8d4d (diff)
parent7398048b0fa261cd3178cb5309858eb845d01c77 (diff)
Merge pull request #84 from azul/test/billing-sessions0.2.3
Test/billing subscriptions
Diffstat (limited to 'billing/test/integration')
-rw-r--r--billing/test/integration/subscription_test.rb28
1 files changed, 15 insertions, 13 deletions
diff --git a/billing/test/integration/subscription_test.rb b/billing/test/integration/subscription_test.rb
index 7410118..b893896 100644
--- a/billing/test/integration/subscription_test.rb
+++ b/billing/test/integration/subscription_test.rb
@@ -5,29 +5,31 @@ require 'capybara/rails'
class SubscriptionTest < ActionDispatch::IntegrationTest
include Warden::Test::Helpers
include Capybara::DSL
+ include CustomerTestHelper
+ include StubRecordHelper
setup do
Warden.test_mode!
- @admin = User.find_by_login('admin') || FactoryGirl.create(:user, login: 'admin')
- @customer = FactoryGirl.create(:customer)
- @braintree_customer = FactoryGirl.create(:braintree_customer)
- @customer.braintree_customer_id = @braintree_customer.id
- @customer.save
- @subscription = FakeBraintree::Subscription.new({:payment_method_token => @braintree_customer.credit_cards.first, :plan_id => '5'}, {:id => @braintree_customer.id, :merchant_id => Braintree::Configuration.merchant_id})
- # unfortunately @braintree_customer.credit_cards.first.subscriptions still returns empty array
+ @admin = stub_record :user, :admin => true
+ @customer = stub_customer
+ @braintree_customer = @customer.braintree_customer
+ response = Braintree::Subscription.create plan_id: '5',
+ payment_method_token: @braintree_customer.credit_cards.first.token
+ @subscription = response.subscription
+ Capybara.current_driver = Capybara.javascript_driver
end
teardown do
Warden.test_reset!
- @admin.destroy
- @customer.destroy
end
- test "admin can cancel subscription for another" do
- skip "not sure about testing admin cancelling subscription with fake_braintree"
+ test "admin can see subscription for another" do
login_as @admin
- #visit user_subscriptions_path(@customer.user_id)
- #delete :destroy, :id => @subscription.id
+ @customer.stubs(:subscriptions).returns([@subscription])
+ visit user_subscriptions_path(@customer.user_id)
+ assert page.has_content?("Subscriptions")
+ assert page.has_content?("Status: Active")
+ page.save_screenshot('/tmp/subscriptions.png')
end
#test "admin cannot add subscription for another" do