require 'rails_helper'

RSpec.describe Admin::ApplicationController, type: :controller do
  controller do
    def new
      authorize Account
      render plain: "Hello world"
    end
  end

  it "allows admin users" do
    admin = create(:user, :admin)

    sign_in(admin)
    get :new

    expect(response).to be_successful
  end

  it "redirects non-admin users" do
    non_admin = create(:user, admin: false)

    sign_in(non_admin)
    get :new

    expect(response).to be_redirect
  end
end
