Created
August 28, 2016 03:02
-
-
Save staycreativedesign/47f389962209b917a7e6ef8ea0416f47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
describe Admin::PanelController do | |
describe "GET index" do | |
context "user has access" do | |
it "renders admin panel" do | |
set_user_session("admin") | |
get :index | |
expect(response).to render_template(:index) | |
end | |
end | |
context "user does not have access" do | |
it "redirects him to login page" do | |
set_user_session("user") | |
get :index | |
expect(response).to redirect_to login_path | |
end | |
end | |
end | |
def set_user_session(access_level) | |
ben = build_stubbed(:user, access_level: access_level) | |
session[:user_id] = ben.id | |
expect(User).to receive(:find).and_return(ben) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment