Sha256: 72619c18f46b07dfdfe8f41518c37c6793d56c1f45edfb6d8bfb1051b202bf5e

Contents?: true

Size: 833 Bytes

Versions: 13

Compression:

Stored size: 833 Bytes

Contents

module Alchemy
  module TestSupport

    # Helpers for integration specs
    #
    # This file is included in rspec integration/request tests.
    #
    module IntegrationHelpers

      # Used in Capybara features specs. Stubs the current_alchemy_user
      #
      # It mocks an admin user, but you can pass in a user object that would be used as stub.
      #
      def authorize_as_admin(user=nil)
        # Ensure that phantomjs has always the same browser language.
        if Capybara.current_driver == :poltergeist
          page.driver.headers = { 'Accept-Language' => 'en' }
        end
        if !user
          user = mock_model('DummyUser', alchemy_roles: %w(admin), language: 'en')
        end
        allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
      end
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
alchemy_cms-3.1.3 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.2.0.beta lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.1 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.rc3 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.rc2 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.rc1 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.beta6 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.beta5 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.beta4 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.beta3 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.beta2 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-3.1.0.beta1 lib/alchemy/test_support/integration_helpers.rb