Sha256: a09103918ab49cbe8c66f4c9d96a578158783a460857f51e9c86e06ef07cbb59

Contents?: true

Size: 667 Bytes

Versions: 3

Compression:

Stored size: 667 Bytes

Contents

module Clearance
  module Testing
    module Helpers
      def setup_controller_request_and_response
        super
        @request.env[:clearance] = Clearance::Session.new(@request.env)
      end

      def sign_in
        unless defined?(FactoryGirl)
          raise(
            RuntimeError,
            "Clearance's `sign_in` helper requires factory_girl"
          )
        end

        factory = Clearance.configuration.user_model.to_s.underscore.to_sym
        sign_in_as FactoryGirl.create(factory)
      end

      def sign_in_as(user)
        @controller.sign_in user
      end

      def sign_out
        @controller.sign_out
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clearance-1.3.0 lib/clearance/testing/helpers.rb
clearance-1.2.1 lib/clearance/testing/helpers.rb
clearance-1.2.0 lib/clearance/testing/helpers.rb