From fe79b34965145f1ece98644bf1537866880cc230 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 7 Oct 2013 15:39:56 -0700 Subject: Fix typo in test name. --- billing/test/functional/subsciptions_controller_test.rb | 16 ---------------- billing/test/functional/subscriptions_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 billing/test/functional/subsciptions_controller_test.rb create mode 100644 billing/test/functional/subscriptions_controller_test.rb (limited to 'billing/test') diff --git a/billing/test/functional/subsciptions_controller_test.rb b/billing/test/functional/subsciptions_controller_test.rb deleted file mode 100644 index a6a1057..0000000 --- a/billing/test/functional/subsciptions_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 diff --git a/billing/test/functional/subscriptions_controller_test.rb b/billing/test/functional/subscriptions_controller_test.rb new file mode 100644 index 0000000..a6a1057 --- /dev/null +++ b/billing/test/functional/subscriptions_controller_test.rb @@ -0,0 +1,16 @@ +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 -- cgit v1.2.3 From 8b378d916caeaf7fd4b1da2aea45eab4b0ccbb39 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 8 Oct 2013 10:44:50 -0700 Subject: Minor tweaks. --- billing/test/functional/customers_controller_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'billing/test') diff --git a/billing/test/functional/customers_controller_test.rb b/billing/test/functional/customers_controller_test.rb index d4881bf..46c33c9 100644 --- a/billing/test/functional/customers_controller_test.rb +++ b/billing/test/functional/customers_controller_test.rb @@ -7,10 +7,11 @@ class CustomersControllerTest < ActionController::TestCase setup do @user = FactoryGirl.create :user @other_user = FactoryGirl.create :user - FakeBraintree.clear! - FakeBraintree.verify_all_cards! + #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}) + #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 @@ -50,6 +51,7 @@ class CustomersControllerTest < ActionController::TestCase 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 -- cgit v1.2.3 From a6f32017f5c7802798f10e2f4041037fb5684def Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 15 Oct 2013 15:08:35 -0700 Subject: Add permissions to subscriptions index, and fix test to stub the subscription's balance. --- billing/test/integration/subscription_test.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'billing/test') diff --git a/billing/test/integration/subscription_test.rb b/billing/test/integration/subscription_test.rb index b893896..6356177 100644 --- a/billing/test/integration/subscription_test.rb +++ b/billing/test/integration/subscription_test.rb @@ -10,28 +10,34 @@ class SubscriptionTest < ActionDispatch::IntegrationTest setup do Warden.test_mode! - @admin = stub_record :user, :admin => true + @admin = User.find_by_login('admin') || FactoryGirl.create(:user, login: 'admin') @customer = stub_customer @braintree_customer = @customer.braintree_customer response = Braintree::Subscription.create plan_id: '5', - payment_method_token: @braintree_customer.credit_cards.first.token + payment_method_token: @braintree_customer.credit_cards.first.token, + price: '10' @subscription = response.subscription Capybara.current_driver = Capybara.javascript_driver end teardown do Warden.test_reset! + @admin.destroy end - test "admin can see subscription for another" do + test "admin can see all subscriptions for another" do login_as @admin @customer.stubs(:subscriptions).returns([@subscription]) + @subscription.stubs(:balance).returns 0 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 "user cannot see all subscriptions for other user" do + #end + #test "admin cannot add subscription for another" do #end -- cgit v1.2.3