From 8b5665b857edc460ef6105c3ba0f106dd99a25d5 Mon Sep 17 00:00:00 2001 From: ankonym Date: Thu, 13 Aug 2015 17:24:31 +0200 Subject: Fix test based on actual invite code validation --- engines/billing/test/functional/customers_controller_test.rb | 1 + engines/support/test/unit/account_extension_test.rb | 4 ++++ engines/support/test/unit/ticket_test.rb | 4 ++++ 3 files changed, 9 insertions(+) (limited to 'engines') diff --git a/engines/billing/test/functional/customers_controller_test.rb b/engines/billing/test/functional/customers_controller_test.rb index cc82fc1..0dafe72 100644 --- a/engines/billing/test/functional/customers_controller_test.rb +++ b/engines/billing/test/functional/customers_controller_test.rb @@ -5,6 +5,7 @@ class CustomersControllerTest < ActionController::TestCase tests CustomerController setup do + InviteCodeValidator.any_instance.stubs(:not_existent?).returns(false) @user = FactoryGirl.create :user @other_user = FactoryGirl.create :user #FakeBraintree.clear! diff --git a/engines/support/test/unit/account_extension_test.rb b/engines/support/test/unit/account_extension_test.rb index aba162c..dd7e77d 100644 --- a/engines/support/test/unit/account_extension_test.rb +++ b/engines/support/test/unit/account_extension_test.rb @@ -2,6 +2,10 @@ require 'test_helper' class AccountExtensionTest < ActiveSupport::TestCase + setup do + InviteCodeValidator.any_instance.stubs(:not_existent?).returns(false) + end + test "destroying an account triggers ticket destruction" do t = FactoryGirl.create :ticket_with_creator u = t.created_by_user diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index c64e8f4..7727650 100644 --- a/engines/support/test/unit/ticket_test.rb +++ b/engines/support/test/unit/ticket_test.rb @@ -2,6 +2,10 @@ require 'test_helper' class TicketTest < ActiveSupport::TestCase + setup do + InviteCodeValidator.any_instance.stubs(:not_existent?).returns(false) + end + test "ticket with default attribs is valid" do t = FactoryGirl.build :ticket assert t.valid? -- cgit v1.2.3 From c48e921c101d49bf68fa1af489b8012517b1a105 Mon Sep 17 00:00:00 2001 From: ankonym Date: Tue, 1 Sep 2015 10:48:25 +0200 Subject: Fix several test failures by stubbing invite code validation --- engines/billing/test/functional/customers_controller_test.rb | 2 +- engines/support/test/unit/account_extension_test.rb | 2 +- engines/support/test/unit/ticket_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/billing/test/functional/customers_controller_test.rb b/engines/billing/test/functional/customers_controller_test.rb index 0dafe72..4d84fb0 100644 --- a/engines/billing/test/functional/customers_controller_test.rb +++ b/engines/billing/test/functional/customers_controller_test.rb @@ -5,7 +5,7 @@ class CustomersControllerTest < ActionController::TestCase tests CustomerController setup do - InviteCodeValidator.any_instance.stubs(:not_existent?).returns(false) + InviteCodeValidator.any_instance.stubs(:validate) @user = FactoryGirl.create :user @other_user = FactoryGirl.create :user #FakeBraintree.clear! diff --git a/engines/support/test/unit/account_extension_test.rb b/engines/support/test/unit/account_extension_test.rb index dd7e77d..0ecb1aa 100644 --- a/engines/support/test/unit/account_extension_test.rb +++ b/engines/support/test/unit/account_extension_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class AccountExtensionTest < ActiveSupport::TestCase setup do - InviteCodeValidator.any_instance.stubs(:not_existent?).returns(false) + InviteCodeValidator.any_instance.stubs(:validate) end test "destroying an account triggers ticket destruction" do diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index 7727650..7b5281f 100644 --- a/engines/support/test/unit/ticket_test.rb +++ b/engines/support/test/unit/ticket_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TicketTest < ActiveSupport::TestCase setup do - InviteCodeValidator.any_instance.stubs(:not_existent?).returns(false) + InviteCodeValidator.any_instance.stubs(:validate) end test "ticket with default attribs is valid" do -- cgit v1.2.3 From 2f7d085c5747a1a68afc0d854fa087ffbb46f8e7 Mon Sep 17 00:00:00 2001 From: ankonym Date: Wed, 2 Sep 2015 17:01:16 +0200 Subject: Fix the remaining failures/errors in our tests Handing freshly generated invite codes to Factory Girl to make the tests pass --- engines/support/test/integration/create_ticket_test.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb index 90e9a8a..00f9a6b 100644 --- a/engines/support/test/integration/create_ticket_test.rb +++ b/engines/support/test/integration/create_ticket_test.rb @@ -2,6 +2,11 @@ require 'test_helper' class CreateTicketTest < BrowserIntegrationTest + setup do + @testcode = InviteCode.new + @testcode.save! + end + test "can submit ticket anonymously" do visit '/' click_on 'Get Help' @@ -29,7 +34,7 @@ class CreateTicketTest < BrowserIntegrationTest end test "prefills fields" do - login FactoryGirl.create(:premium_user) + login FactoryGirl.create(:premium_user, :invite_code => @testcode.invite_code) visit '/' click_on "Support Tickets" click_on "New Ticket" @@ -48,7 +53,7 @@ class CreateTicketTest < BrowserIntegrationTest end test "cleared email field should remain clear" do - login FactoryGirl.create(:premium_user) + login FactoryGirl.create(:premium_user, :invite_code => @testcode.invite_code) visit '/' click_on "Support Tickets" click_on "New Ticket" -- cgit v1.2.3