decidim-dev/lib/decidim/dev/test/rspec_support/warden.rb in decidim-0.3.2 vs decidim-dev/lib/decidim/dev/test/rspec_support/warden.rb in decidim-0.4.0
- old
+ new
@@ -1,8 +1,24 @@
# frozen_string_literal: true
+module Decidim
+ module WardenTestHelpers
+ include Warden::Test::Helpers
+
+ #
+ # Utility method to login in the middle of a test as a different user from
+ # the current one.
+ #
+ def relogin_as(user, scope: :user)
+ logout scope
+
+ login_as user, scope: scope
+ end
+ end
+end
+
RSpec.configure do |config|
- config.include Warden::Test::Helpers, type: :feature
+ config.include Decidim::WardenTestHelpers, type: :feature
config.include Devise::Test::ControllerHelpers, type: :controller
config.after :each, type: :feature do
Warden.test_reset!
end