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_controller_test.rb | 2 +- test/support/api_integration_test.rb | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'test/support') diff --git a/test/support/api_controller_test.rb b/test/support/api_controller_test.rb index 06cb46a..97d86fc 100644 --- a/test/support/api_controller_test.rb +++ b/test/support/api_controller_test.rb @@ -17,7 +17,7 @@ class ApiControllerTest < ActionController::TestCase end def add_api_defaults(args) - add_defaults args, version: '2' + add_defaults args, version: '2', format: :json end def add_defaults(args, defaults) 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