Sha256: 0d14452ff6a7398f3cb4bc5d5346101b501daeebdedc42a08f0b59e2f7918909

Contents?: true

Size: 946 Bytes

Versions: 18

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true
module Alchemy
  module TestSupport
    # Helpers for integration specs
    #
    # This file is included in spec_helper.rb
    #
    module IntegrationHelpers
      # Used to stub the current_alchemy_user
      #
      # Pass either a user object or a symbol in the format of ':as_admin'.
      # The browser language is set to english ('en')
      #
      def authorize_user(user_or_role = nil)
        if user_or_role.is_a?(Alchemy.user_class)
          user = user_or_role
        else
          user = build(:alchemy_dummy_user, user_or_role)
        end
        set_phantomjs_browser_language("en")
        allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
      end

      def set_phantomjs_browser_language(lang = nil)
        if Capybara.current_driver == :poltergeist
          page.driver.headers = {"Accept-Language" => lang}
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
alchemy_cms-5.0.10 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.9 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.8 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.7 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.6 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.5 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.4 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.3 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.2 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.1.0.rc1 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.1.0.beta2 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.1.0.beta1 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.1 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.0 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.0.rc2 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.0.rc1 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.0.beta2 lib/alchemy/test_support/integration_helpers.rb
alchemy_cms-5.0.0.beta1 lib/alchemy/test_support/integration_helpers.rb