Sha256: a7bb8bbf69b65e4459f7f4ec6f81edddb3a647e30bd5669df0155d380d1c6ed7

Contents?: true

Size: 759 Bytes

Versions: 11

Compression:

Stored size: 759 Bytes

Contents

require "logger"

RSpec.describe Rails::Auth::ACL::Middleware do
  let(:request)     { Rack::MockRequest.env_for("https://www.example.com") }
  let(:app)         { ->(env) { [200, env, "Hello, world!"] } }
  let(:acl)         { instance_double(Rails::Auth::ACL, match: authorized) }
  let(:middleware)  { described_class.new(app, acl: acl) }

  context "authorized" do
    let(:authorized) { true }

    it "allows authorized requests" do
      expect(middleware.call(request)[0]).to eq 200
    end
  end

  context "unauthorized" do
    let(:authorized) { false }

    it "raises Rails::Auth::NotAuthorizedError for unauthorized requests" do
      expect { expect(middleware.call(request)) }.to raise_error(Rails::Auth::NotAuthorizedError)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails-auth-1.0.0 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.5.3 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.5.2 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.5.1 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.5.0 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.4.1 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.4.0 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.3.0 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.2.0 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.1.0 spec/rails/auth/acl/middleware_spec.rb
rails-auth-0.0.1 spec/rails/auth/acl/middleware_spec.rb