Sha256: f2067b09b766de5951af78d3a1034961b793656b91c65bb5dfa3e46376a43bd8

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

require 'spec_helper'

class ApisController < ActionController::Base
  include Clearance::Controller

  before_filter :authorize

  respond_to :js

  def show
    render text: 'response'
  end

  protected

  def authorize
    deny_access 'Access denied.'
  end
end

describe ApisController do
  before do
    Rails.application.routes.draw do
      resource :api, only: [:show]
    end
  end

  after do
    Rails.application.reload_routes!
  end

  it 'responds with HTTP status code 401 when denied' do
    get :show, format: :js
    subject.should respond_with(:unauthorized)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clearance-1.0.1 spec/controllers/apis_controller_spec.rb
clearance-1.0.0 spec/controllers/apis_controller_spec.rb
clearance-1.0.0.rc8 spec/controllers/apis_controller_spec.rb