Sha256: f1ee421d215fa3a0786600f64fa67884664182295b7bc053351dde8550247806

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe CASino::Listener::Logout do
  include Rails.application.routes.url_helpers
  let(:controller) { Struct.new(:cookies).new(cookies: {}) }
  let(:listener) { described_class.new(controller) }

  describe '#user_logged_out' do
    let(:url) { 'http://www.example.com/test' }
    it 'assigns the url' do
      listener.user_logged_out(url)
      controller.instance_variable_get(:@url).should == url
    end

    it 'deletes an existing ticket-granting ticket cookie' do
      controller.cookies = { tgt: 'TGT-12345' }
      listener.user_logged_out(url)
      controller.cookies[:tgt].should be_nil
    end

    context 'with redirect_immediately flag' do
      before(:each) do
        controller.stub(:redirect_to)
      end

      it 'tells the controller to redirect the client' do
        controller.should_receive(:redirect_to).with(url, status: :see_other)
        listener.user_logged_out(url, true)
      end

      it 'deletes an existing ticket-granting ticket cookie' do
        controller.cookies = { tgt: 'TGT-12345' }
        listener.user_logged_out(url, true)
        controller.cookies[:tgt].should be_nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
casino-1.3.2 spec/controllers/listener/logout_spec.rb
casino-1.3.1 spec/controllers/listener/logout_spec.rb
casino-1.3.0 spec/controllers/listener/logout_spec.rb