Skip to content

Instantly share code, notes, and snippets.

@brandonhilkert
Created September 28, 2011 19:33
Show Gist options
  • Save brandonhilkert/1248988 to your computer and use it in GitHub Desktop.
Save brandonhilkert/1248988 to your computer and use it in GitHub Desktop.
require "spec_helper"
describe UsersController do
describe "authentication" do
let(:user) { FactoryGirl.create(:user) }
it "should properly log a user out" do
session[:user_id] == user.id
AnalyticLog.should_receive(:logout) <----- (<AnalyticLog (class)>).logout(any args) expected: 1 time received: 0 times
get :logout
session[:user_id].should == nil
response.should redirect_to(login_url)
end
end
end
class UsersController < ApplicationController
def logout
session[:user_id] = nil
AnalyticLog.logout(:user => user, :session => session)
redirect_to :controller => "sites", :action => "landing"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment