Sha256: 4849351927592af6611100f235358beffb3ea73df7f504de158355eeb106ac33

Contents?: true

Size: 923 Bytes

Versions: 5

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

require "rails_helper_for_engine"

RSpec.describe Omniauth::Rails::AuthenticationConcern do
  controller(ApplicationController) do
    require_authentication

    def fake_action
      head :ok
    end
  end

  before do
    routes.draw do
      get "fake_action" => "anonymous#fake_action"
    end
  end

  describe "require_authentication" do
    before { get :fake_action }

    it "redirects" do
      expect(response).to redirect_to("#{OmniAuth.config.path_prefix}/sign_in")
    end

    context "dev_mode is enabled" do
      around(:each) do |example|
        original_value = Omniauth::Rails::Configuration.dev_mode
        Omniauth::Rails::Configuration.dev_mode = true
        example.run
        Omniauth::Rails::Configuration.dev_mode = original_value
      end

      it "responds with a 200" do
        expect(response).to have_http_status(:success)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
omniauth-rails-0.6.0 spec/controllers/authentication_concern_spec.rb
omniauth-rails-0.5.0 spec/controllers/authentication_concern_spec.rb
omniauth-rails-0.4.0 spec/controllers/authentication_concern_spec.rb
omniauth-rails-0.3.0 spec/controllers/authentication_concern_spec.rb
omniauth-rails-0.2.0 spec/controllers/authentication_concern_spec.rb