Sha256: 1556adb7951f8c72c91a6ada8460700494b564d0f73892e32b313a18b2e4005f

Contents?: true

Size: 1.88 KB

Versions: 10

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe CASino::ProcessorConcern::ServiceTickets do
  let(:class_with_mixin) {
    Class.new do
      include CASino::ProcessorConcern::ServiceTickets
    end
  }
  subject {
    class_with_mixin.new
  }

  describe '#acquire_service_ticket' do
    let(:ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket }
    let(:service) { 'http://www.example.com/' }

    context 'with a ticket-granting ticket with existing service tickets' do
      let!(:service_ticket) { FactoryGirl.create :service_ticket, ticket_granting_ticket: ticket_granting_ticket, service: service }
      let!(:other_service_ticket) { FactoryGirl.create :service_ticket, ticket_granting_ticket: ticket_granting_ticket }

      it 'does not change the service tickets count' do
        expect do
          subject.acquire_service_ticket(ticket_granting_ticket, service)
        end.to_not change(CASino::ServiceTicket, :count)
      end

      it 'deletes the old service ticket' do
        subject.acquire_service_ticket(ticket_granting_ticket, service)
        expect { service_ticket.reload }.to raise_error(ActiveRecord::RecordNotFound)
      end
    end

    context 'with a service url another ticket-granting ticket has a service ticket for' do
      let!(:service_ticket) { FactoryGirl.create :service_ticket, ticket_granting_ticket: ticket_granting_ticket, service: service }
      let!(:other_ticket_granting_ticket) { FactoryGirl.create :ticket_granting_ticket }

      it 'does change the service tickets count' do
        expect do
          subject.acquire_service_ticket(other_ticket_granting_ticket, service)
        end.to change(CASino::ServiceTicket, :count).by(1)
      end

      it 'does not delete the other service ticket' do
        subject.acquire_service_ticket(other_ticket_granting_ticket, service)
        expect { service_ticket.reload }.not_to raise_error
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
casino-3.0.4 spec/processor/processor_concern/service_tickets_spec.rb
casino-2.0.7 spec/processor/processor_concern/service_tickets_spec.rb
casino-3.0.3 spec/processor/processor_concern/service_tickets_spec.rb
casino-3.0.2 spec/processor/processor_concern/service_tickets_spec.rb
casino-3.0.1 spec/processor/processor_concern/service_tickets_spec.rb
casino-3.0.0 spec/processor/processor_concern/service_tickets_spec.rb
casino-3.0.0.pre.2 spec/processor/processor_concern/service_tickets_spec.rb
casino-3.0.0.pre.1 spec/processor/processor_concern/service_tickets_spec.rb
casino-2.0.6 spec/processor/processor_concern/service_tickets_spec.rb
casino-2.0.5 spec/processor/processor_concern/service_tickets_spec.rb