Sha256: 74d4259a892b730e880f192bf40c12aeb9d36731716fec4f622ff41c57898fdf

Contents?: true

Size: 1.97 KB

Versions: 12

Compression:

Stored size: 1.97 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Dor::Workflow::Client::LifecycleRoutes do
  let(:requestor) { instance_double(Dor::Workflow::Client::Requestor, request: response) }
  let(:response) { '<xml />' }
  let(:routes) { described_class.new(requestor: requestor) }
  let(:repo) { 'dor' }
  let(:druid) { 'druid:gv054hp4128' }

  describe '#milestones' do
    subject(:milestones) { routes.milestones(druid: druid) }

    let(:ng_xml) { Nokogiri::XML(xml) }
    let(:xml) do
      '<?xml version="1.0" encoding="UTF-8"?><lifecycle objectId="druid:gv054hp4128"><milestone date="2012-01-26T21:06:54-0800" version="2">published</milestone></lifecycle>'
    end

    before do
      allow(routes).to receive(:query_lifecycle).and_return(ng_xml)
    end

    it 'includes the version in with the milestones' do
      expect(milestones.first[:milestone]).to eq('published')
      expect(milestones.first[:version]).to eq('2')
    end
  end

  describe '#lifecycle' do
    context 'without version' do
      subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted') }

      it 'make the request' do
        lifecycle
        expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
      end
    end

    context 'with version' do
      subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }

      it 'makes the request with the version' do
        lifecycle
        expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3')
      end
    end
  end

  describe '#active_lifecycle' do
    context 'with kwargs' do
      subject(:active_lifecycle) { routes.active_lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }

      it 'makes the request with the version' do
        active_lifecycle
        expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dor-workflow-client-7.7.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.6.1 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.6.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.5.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.4.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.3.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.2.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.1.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.0.2 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.0.1 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-7.0.0 spec/dor/workflow/client/lifecycle_routes_spec.rb
dor-workflow-client-6.0.0 spec/dor/workflow/client/lifecycle_routes_spec.rb