Sha256: 1336ffd6c6718192d870dce489c4cad5152f8b6020c2b19f3eb3c40a050fcd62

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

require 'rails_helper'

class BaseController < ApplicationController
  before_action :authorize
end

describe BaseController, type: :controller do
  let!(:current_user)   { FactoryGirl.create(:user) }

  before do
    setup_authorization(current_user, "base", "index")
  end

  controller do
    def index
      @success = true
      render nothing: true
    end

    def new; end
  end

  before do
    login_user current_user
  end

  context "when user not have authorization" do
    it "redirect to root_path" do
      get :new
      expect(flash[:notice]).to eq "Sem autorização"
    end
  end

  context "when user have authorization" do
    it "user access the resource" do
      get :index
      expect(response).to be_success
      expect(response).to have_http_status(200)
    end
  end 
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curupira-0.1.7 spec/controllers/controller_spec.rb
curupira-0.1.6 spec/controllers/controller_spec.rb