From fbad882075e745ab7afbe5f89c67544fb3c607c3 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 18 Aug 2016 11:00:16 +0200 Subject: respond_to on a per controller basis If you inherit respond to and call it again in your controller it will not overwrite the previous but add to it. Since we always have some exceptions from the rules it's probably easiest to be explicit in the controllers that require it themselves. --- test/support/api_integration_test.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'test/support/api_integration_test.rb') diff --git a/test/support/api_integration_test.rb b/test/support/api_integration_test.rb index cea480c..7942558 100644 --- a/test/support/api_integration_test.rb +++ b/test/support/api_integration_test.rb @@ -7,13 +7,8 @@ class ApiIntegrationTest < ActionDispatch::IntegrationTest 2 end - setup do - @testcode = InviteCode.new - @testcode.save! - end - def login(user = nil) - @user ||= user ||= FactoryGirl.create(:user, :invite_code => @testcode.invite_code) + @user ||= user ||= create_invited_user # DUMMY_TOKEN will be frozen. So let's use a dup @token ||= DUMMY_TOKEN.dup # make sure @token is up to date if it already exists @@ -23,6 +18,13 @@ class ApiIntegrationTest < ActionDispatch::IntegrationTest @token.save end + def create_invited_user(options = {}) + @testcode = InviteCode.new + @testcode.save! + options.reverse_merge! invite_code: @testcode.invite_code + FactoryGirl.create :user, options + end + teardown do if @user && @user.persisted? @user.destroy_identities -- cgit v1.2.3