Created
July 28, 2016 14:48
Revisions
-
csexton created this gist
Jul 28, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ class ApplicationController < ActionController::Base before_action :set_radius_user_cache_key # bunch-o-auth stuff goes here private def set_radius_user_cache_key if current_user cookies[:_radius_user_cache_key] = { value: current_user.cache_key, domain: :all, tld_length: 2 } else cookies[:_radius_user_cache_key] = { value: "none", domain: :all, tld_length: 2 } end end end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ require 'rails_helper' describe ApplicationController, :type => :controller do let(:centurion) { create(User) } def stub_sign_in(user) allow(controller).to receive(:current_user).and_return(user) sign_in user end controller do public :cookies def index render nothing: true end end describe "GET 'index'" do it "sets the user cache key cookie" do sign_in centurion allow(controller).to receive(:current_user).and_return(centurion) get 'index' key = controller.cookies[:_radius_user_cache_key] expect(key).to eq centurion.cache_key end end end