diff options
author | Azul <azul@leap.se> | 2013-08-31 15:15:53 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-09-03 08:54:25 +0200 |
commit | 214ef762a970989e09be1960c5551c0a4d3f4421 (patch) | |
tree | ab3f296496071937d0bb51aa55eacbee989065fe /billing/test/functional | |
parent | 859b79d0dcd53c85bb57e3db888a1af702802987 (diff) |
do not leave behind users in billing unit and functional tests
Diffstat (limited to 'billing/test/functional')
-rw-r--r-- | billing/test/functional/customer_controller_test.rb | 13 | ||||
-rw-r--r-- | billing/test/functional/payments_controller_test.rb | 4 |
2 files changed, 13 insertions, 4 deletions
diff --git a/billing/test/functional/customer_controller_test.rb b/billing/test/functional/customer_controller_test.rb index d62ee95..878ed48 100644 --- a/billing/test/functional/customer_controller_test.rb +++ b/billing/test/functional/customer_controller_test.rb @@ -21,7 +21,9 @@ class CustomerControllerTest < ActionController::TestCase end test "edit uses params[:id]" do - customer = FactoryGirl.create :customer_with_payment_info + user = find_record :user + customer = stub_record :customer_with_payment_info, user: user + Customer.stubs(:find_by_user_id).with(user.id).returns(customer) login customer.user get :edit, id: customer.user.id @@ -50,7 +52,10 @@ class CustomerControllerTest < ActionController::TestCase end test "customer update" do - customer = FactoryGirl.create :customer_with_payment_info + user = find_record :user + customer = stub_record :customer_with_payment_info, user: user + customer.expects(:save) + Customer.stubs(:find_by_user_id).with(user.id).returns(customer) login customer.user Braintree::TransparentRedirect.expects(:confirm). returns(success_response(customer)) @@ -91,7 +96,9 @@ class CustomerControllerTest < ActionController::TestCase end test "failed user update with stubbing" do - customer = FactoryGirl.create :customer_with_payment_info + user = find_record :user + customer = stub_record :customer_with_payment_info, user: user + Customer.stubs(:find_by_user_id).with(user.id).returns(customer) login customer.user Braintree::TransparentRedirect.expects(:confirm).returns(failure_response) post :confirm, bla: :blub diff --git a/billing/test/functional/payments_controller_test.rb b/billing/test/functional/payments_controller_test.rb index 8f3bfe7..055a990 100644 --- a/billing/test/functional/payments_controller_test.rb +++ b/billing/test/functional/payments_controller_test.rb @@ -17,7 +17,9 @@ class PaymentsControllerTest < ActionController::TestCase end test "payment when authenticated as customer" do - customer = FactoryGirl.create :customer_with_payment_info + user = find_record :user + customer = stub_record :customer_with_payment_info, user: user + Customer.stubs(:find_by_user_id).with(user.id).returns(customer) login customer.user get :new assert_not_nil assigns(:tr_data) |