Sha256: ef0a8c96ab7773d1b567795eed393cf1442228a6e48247e0c8888a572df53c34

Contents?: true

Size: 808 Bytes

Versions: 32

Compression:

Stored size: 808 Bytes

Contents

module Clearance
  module Testing
    # Provides helpers to your view and helper specs.
    # Using these helpers makes `current_user`, `signed_in?` and `signed_out?`
    # behave properly in view and helper specs.
    module ViewHelpers
      # Sets current_user on the view under test to a new instance of your user
      # model.
      def sign_in
        view.current_user = Clearance.configuration.user_model.new
      end

      # Sets current_user on the view under test to the supplied user.
      def sign_in_as(user)
        view.current_user = user
      end

      # @api private
      module CurrentUser
        attr_accessor :current_user

        def signed_in?
          current_user.present?
        end

        def signed_out?
          !signed_in?
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
clearance-2.9.3 lib/clearance/testing/view_helpers.rb
clearance-2.9.2 lib/clearance/testing/view_helpers.rb
clearance-2.9.1 lib/clearance/testing/view_helpers.rb
clearance-2.9.0 lib/clearance/testing/view_helpers.rb
clearance-2.8.0 lib/clearance/testing/view_helpers.rb
clearance-2.7.2 lib/clearance/testing/view_helpers.rb
clearance-2.7.0 lib/clearance/testing/view_helpers.rb
clearance-2.6.2 lib/clearance/testing/view_helpers.rb
clearance-2.6.1 lib/clearance/testing/view_helpers.rb
clearance-2.6.0 lib/clearance/testing/view_helpers.rb
clearance-2.5.0 lib/clearance/testing/view_helpers.rb
clearance-2.4.0 lib/clearance/testing/view_helpers.rb
clearance-2.3.1 lib/clearance/testing/view_helpers.rb
clearance-2.3.0 lib/clearance/testing/view_helpers.rb
clearance-2.2.1 lib/clearance/testing/view_helpers.rb
clearance-2.2.0 lib/clearance/testing/view_helpers.rb
clearance-2.1.0 lib/clearance/testing/view_helpers.rb
clearance-2.0.0 lib/clearance/testing/view_helpers.rb
clearance-2.0.0.beta2 lib/clearance/testing/view_helpers.rb
clearance-2.0.0.beta1 lib/clearance/testing/view_helpers.rb