summaryrefslogtreecommitdiff
path: root/billing/test
diff options
context:
space:
mode:
Diffstat (limited to 'billing/test')
-rw-r--r--billing/test/integration/customer_creation_test.rb36
1 files changed, 19 insertions, 17 deletions
diff --git a/billing/test/integration/customer_creation_test.rb b/billing/test/integration/customer_creation_test.rb
index 50116db..3ab2e4f 100644
--- a/billing/test/integration/customer_creation_test.rb
+++ b/billing/test/integration/customer_creation_test.rb
@@ -8,17 +8,32 @@ class CustomerCreationTest < ActionDispatch::IntegrationTest
setup do
Warden.test_mode!
+ @user = FactoryGirl.create(:user)
+ login_as @user
end
teardown do
Warden.test_reset!
end
+ # Let's test both steps together with capybara
+ #
+ # This test is nice and clean but also a bit fragil:
+ # RackTest assumes all requests to be local. So we need
+ # BraintreeTestApp for the braintree transparent redirect to work.
+ test "create customer with braintree" do
+ visit '/customer/new'
+ assert_difference("Customer.count") do
+ click_button 'Save Payment Info'
+ end
+
+ assert customer = Customer.find_by_user_id(@user.id)
+ assert customer.braintree_customer
+ end
+
# We only test the confirmation here.
- # The first request to Braintree is triggered outside of rails
+ # The request to Braintree is triggered outside of rails
test "successfully confirms customer creation" do
- user = FactoryGirl.create(:user)
- login_as user
response = post_transparent_redirect :create_customer_data,
customer: FactoryGirl.attributes_for(:braintree_customer),
redirect_url: confirm_customer_url
@@ -28,20 +43,7 @@ class CustomerCreationTest < ActionDispatch::IntegrationTest
end
assert_equal 200, status
- assert customer = Customer.find_by_user_id(user.id)
- assert customer.braintree_customer
- end
-
- # let's test both steps together with capybara
- test "create customer with braintree" do
- user = FactoryGirl.create(:user)
- login_as user
- visit '/customer/new'
- assert_difference("Customer.count") do
- click_button 'Save Payment Info'
- end
- assert_equal 200, status
- assert customer = Customer.find_by_user_id(user.id)
+ assert customer = Customer.find_by_user_id(@user.id)
assert customer.braintree_customer
end