diff options
author | Azul <azul@leap.se> | 2014-04-11 10:03:19 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-04-11 10:07:23 +0200 |
commit | 636692f9921bd695d726695d2d46c91f5a6e56f3 (patch) | |
tree | a7cc0b89007bd273ae7719f31c16e052a141fec7 /billing/test/functional | |
parent | 32136605ddd405a0bf47f3b795b22fd4b49465b5 (diff) |
move engines into engines directory
Also renamed help to support so it's harder to confuse it with documentation
Diffstat (limited to 'billing/test/functional')
4 files changed, 0 insertions, 251 deletions
diff --git a/billing/test/functional/customer_controller_test.rb b/billing/test/functional/customer_controller_test.rb deleted file mode 100644 index d943e23..0000000 --- a/billing/test/functional/customer_controller_test.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'test_helper' -require 'fake_braintree' - -class CustomerControllerTest < ActionController::TestCase - include CustomerTestHelper - - test "new assigns redirect url" do - login - get :new - - assert_response :success - assert assigns(:tr_data) - tr_data = Braintree::Util.parse_query_string(assigns(:tr_data)) - assert_equal confirm_customer_url, tr_data[:redirect_url] - end - - test "new requires login" do - get :new - - assert_response :redirect - assert_redirected_to login_path - end - - test "edit uses params[:id]" do - customer = stub_customer - login customer.user - get :edit, id: customer.user.id - - assert_response :success - assert assigns(:tr_data) - tr_data = Braintree::Util.parse_query_string(assigns(:tr_data)) - assert_equal customer.braintree_customer_id, tr_data[:customer_id] - assert_equal confirm_customer_url, tr_data[:redirect_url] - end - - test "confirm customer creation" do - login - Braintree::TransparentRedirect.expects(:confirm).returns(success_response) - # to_confirm = prepare_confirmation :create_customer_data, - # customer: FactoryGirl.attributes_for(:braintree_customer), - # redirect_url: confirm_customer_url - - assert_difference("Customer.count") do - post :confirm, braintree: :query - end - - assert_response :success - assert result = assigns(:result) - assert result.success? - assert result.customer.id - end - - test "customer update" do - customer = stub_customer - customer.expects(:save) - login customer.user - Braintree::TransparentRedirect.expects(:confirm). - returns(success_response(customer)) - - assert_no_difference("Customer.count") do - post :confirm, query: :from_braintree - end - - assert_response :success - assert result = assigns(:result) - assert result.success? - assert_equal customer.braintree_customer, result.customer - end - - test "failed customer creation" do - skip "can't get customer creation to fail" - login - FakeBraintree.decline_all_cards! - # what is prepare_confirmation ?? this method isn't found - to_confirm = prepare_confirmation :create_customer_data, - customer: FactoryGirl.attributes_for(:broken_customer), - redirect_url: confirm_customer_url - post :confirm, to_confirm - - FakeBraintree.clear! - assert_response :success - assert result = assigns(:result) - assert !result.success? - end - - test "failed customer creation with stubbing" do - login - Braintree::TransparentRedirect.expects(:confirm).returns(failure_response) - post :confirm, bla: :blub - - assert_response :success - assert_template :new - end - - test "failed customer update with stubbing" do - customer = stub_customer - login customer.user - Braintree::TransparentRedirect.expects(:confirm).returns(failure_response) - post :confirm, bla: :blub - - assert_response :success - assert_template :edit - end - - def failure_response - stub success?: false, - errors: stub(for: nil, size: 0), - params: {} - end - - def success_response(customer = nil) - stub success?: true, - customer: braintree_customer(customer) - end - - def braintree_customer(customer) - if customer - customer.braintree_customer - else - FactoryGirl.build :braintree_customer - end - end - -end diff --git a/billing/test/functional/customers_controller_test.rb b/billing/test/functional/customers_controller_test.rb deleted file mode 100644 index 46c33c9..0000000 --- a/billing/test/functional/customers_controller_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test_helper' -require 'fake_braintree' - -class CustomersControllerTest < ActionController::TestCase - tests CustomerController - - setup do - @user = FactoryGirl.create :user - @other_user = FactoryGirl.create :user - #FakeBraintree.clear! - #FakeBraintree.verify_all_cards! - testid = 'testid' - #this wasn't actually being used - #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 "no access if not logged in" do - get :new - assert_access_denied(true, false) - get :show, :id => @customer.braintree_customer_id - assert_access_denied(true, false) - get :edit, :id => @customer.braintree_customer_id - assert_access_denied(true, false) - end - - - test "should get new if logged in and not customer" do - login @user - get :new - assert_not_nil assigns(:tr_data) - assert_response :success - end - - test "new should direct edit if user is already a customer" do - login @other_user - get :new - assert_response :redirect - assert_equal edit_customer_url(@customer.user), response.header['Location'] - end - - - test "show" do - skip "show customer" - login @other_user - # Below will fail, as when we go to fetch the customer data, Braintree::Customer.find(params[:id]) won't find the customer as it is a FakeBraintree customer. - #get :show, :id => @customer.braintree_customer_id - - end - -end diff --git a/billing/test/functional/payments_controller_test.rb b/billing/test/functional/payments_controller_test.rb deleted file mode 100644 index 90b7582..0000000 --- a/billing/test/functional/payments_controller_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'test_helper' -require 'fake_braintree' - -class PaymentsControllerTest < ActionController::TestCase - include CustomerTestHelper - - test "payment when unauthorized" do - get :new - assert_not_nil assigns(:tr_data) - assert_response :success - end - - test "successful confirmation renders confirm" do - Braintree::TransparentRedirect.expects(:confirm).returns(success_response) - get :confirm - - assert_response :success - assert_template :confirm - end - - test "failed confirmation renders new" do - Braintree::TransparentRedirect.expects(:confirm).returns(failure_response) - get :confirm - - assert_response :success - assert_not_nil assigns(:tr_data) - assert_template :new - end - - def failure_response - stub success?: false, - errors: stub(for: nil, size: 0), - params: {}, - transaction: stub(status: nil) - end - - def success_response - stub success?: true, - transaction: stub_transaction - end - - # that's what you get when not following the law of demeter... - def stub_transaction - stub amount: "100.00", - id: "ASDF", - customer_details: FactoryGirl.build(:braintree_customer), - credit_card_details: FactoryGirl.build(:braintree_customer).credit_cards.first - end - -end diff --git a/billing/test/functional/subscriptions_controller_test.rb b/billing/test/functional/subscriptions_controller_test.rb deleted file mode 100644 index a6a1057..0000000 --- a/billing/test/functional/subscriptions_controller_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'test_helper' -require 'fake_braintree' - -class SubscriptionsControllerTest < ActionController::TestCase - include CustomerTestHelper - - test "destroy cancels subscription" do - customer = stub_customer - login customer.user - result = Braintree::Subscription.create plan_id: 'my_plan', - payment_method_token: customer.braintree_customer.credit_cards.first.token - subscription = result.subscription - delete :destroy, id: subscription.id, user_id: customer.user.id - assert_equal "Canceled", Braintree::Subscription.find(subscription.id).status - end -end |