Sha256: 9a919e22f4dd1fa51ad5ce90ee54e916ea1c06252f134f3481c9d76092ca8c98

Contents?: true

Size: 1.83 KB

Versions: 10

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

RSpec.describe Hyrax::WorkflowPresenter, no_clean: true do
  let(:solr_document) { SolrDocument.new(attributes) }
  let(:attributes) do
    { "id" => '888888',
      "has_model_ssim" => ["GenericWork"] }
  end

  let(:user) { create(:user) }
  let(:ability) { Ability.new(user) }
  let(:presenter) { described_class.new(solr_document, ability) }
  let(:entity) { instance_double(Sipity::Entity) }

  describe "#actions" do
    let(:workflow) { create(:workflow, name: 'testing') }
    subject { presenter.actions }
    context 'with a Sipity::Entity' do
      before do
        allow(Hyrax::Workflow::PermissionQuery).to receive(:scope_permitted_workflow_actions_available_for_current_state).and_return([Sipity::WorkflowAction.new(name: "complete", workflow: workflow)])
        allow(presenter).to receive(:sipity_entity).and_return(entity)
      end
      it "is an Array of Sipity::Action#name and translated names" do
        allow(I18n).to receive(:t).with('hyrax.workflow.testing.complete', default: 'Complete').and_return("Approve")
        is_expected.to eq [['complete', 'Approve']]
      end
    end
    context 'without a Sipity::Entity' do
      before do
        allow(presenter).to receive(:sipity_entity).and_return(nil)
      end
      it { is_expected.to eq [] }
    end
  end

  describe "#comments" do
    subject { presenter.comments }
    context 'with a Sipity::Entity' do
      let(:comment) { instance_double(Sipity::Comment) }
      before do
        allow(entity).to receive(:comments).and_return([comment])
        allow(presenter).to receive(:sipity_entity).and_return(entity)
      end
      it { is_expected.to eq [comment] }
    end
    context 'without a Sipity::Entity' do
      before do
        allow(presenter).to receive(:sipity_entity).and_return(nil)
      end
      it { is_expected.to eq [] }
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.1.0 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.5 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.4 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.3 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.2 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.1 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.0.rc2 spec/presenters/hyrax/workflow_presenter_spec.rb
hyrax-1.0.0.rc1 spec/presenters/hyrax/workflow_presenter_spec.rb
test_hyrax-0.0.1.alpha spec/presenters/hyrax/workflow_presenter_spec.rb