test/controllers/internal_helpers_test.rb in devise-3.5.10 vs test/controllers/internal_helpers_test.rb in devise-4.0.0.rc1
- old
+ new
@@ -1,11 +1,11 @@
require 'test_helper'
class MyController < DeviseController
end
-class HelpersTest < ActionController::TestCase
+class HelpersTest < Devise::ControllerTestCase
tests MyController
def setup
@mock_warden = OpenStruct.new
@controller.request.env['warden'] = @mock_warden
@@ -34,21 +34,19 @@
end
test 'get resource params from request params using resource name as key' do
user_params = {'email' => 'shirley@templar.com'}
- params = if Devise.rails4?
- # Stub controller name so strong parameters can filter properly.
- # DeviseController does not allow any parameters by default.
- @controller.stubs(:controller_name).returns(:sessions_controller)
+ # Stub controller name so strong parameters can filter properly.
+ # DeviseController does not allow any parameters by default.
+ @controller.stubs(:controller_name).returns(:sessions_controller)
- ActionController::Parameters.new({'user' => user_params})
- else
- HashWithIndifferentAccess.new({'user' => user_params})
- end
+ params = ActionController::Parameters.new({'user' => user_params})
+
@controller.stubs(:params).returns(params)
- assert_equal user_params, @controller.send(:resource_params)
+ res_params = @controller.send(:resource_params).permit!.to_h
+ assert_equal user_params, res_params
end
test 'resources methods are not controller actions' do
assert @controller.class.action_methods.delete_if { |m| m.include? 'commenter' }.empty?
end