From 7eab7e33730e12eeb460d2b3965a8712320aff54 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 30 Apr 2013 14:12:08 -0700 Subject: Very rough start to tests, which still doesn't really use FakeBraintree. --- .../test/functional/payments_controller_test.rb | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 billing/test/functional/payments_controller_test.rb (limited to 'billing/test/functional/payments_controller_test.rb') diff --git a/billing/test/functional/payments_controller_test.rb b/billing/test/functional/payments_controller_test.rb new file mode 100644 index 0000000..c8ef205 --- /dev/null +++ b/billing/test/functional/payments_controller_test.rb @@ -0,0 +1,55 @@ +require 'test_helper' + +class PaymentsControllerTest < ActionController::TestCase + + setup do + FakeBraintree.clear! + @user = FactoryGirl.create :user + @other_user = FactoryGirl.create :user + FakeBraintree.clear! + FakeBraintree.verify_all_cards! + testid = 'testid' + FakeBraintree::Customer.new({:credit_cards => [{:number=>"5105105105105100", :expiration_date=>"05/2013"}]}, {:id => testid, :merchant_id => Braintree::Configuration.merchant_id}) + # any reason to call the create instance method on the FakeBraintree::Customer ? + @customer = Customer.new(:user_id => @other_user.id) + @customer.braintree_customer_id = testid + @customer.save + end + + teardown do + @user.destroy + @other_user.destroy + @customer.destroy + end + + test "payment when unauthorized" do + get :new + assert_not_nil assigns(:tr_data) + assert_response :success + end + + test "authenticated user must create account before making payment" do + login @user + get :new + assert_response :redirect + assert_equal new_customer_url, response.header['Location'] + end + + test "payment when authenticated as customer" do + get :new + assert_not_nil assigns(:tr_data) + assert_response :success + #TODO check more here + end + + # what would we test with something like this? + test "fake transaction" do + transaction = FakeBraintree.generate_transaction(:amount => '20.00', + #:status => Braintree::Transaction::Status::Settled, + #:subscription_id => 'foobar', + ) + + end + + +end -- cgit v1.2.3