Sha256: 055be7d032fa1f4562bb1f928939e89d3e60176632dc8fb700ac6d3ff7db72cf

Contents?: true

Size: 1.32 KB

Versions: 13

Compression:

Stored size: 1.32 KB

Contents

require "spec_helper"

module CurationConcerns
  module Workflow
    RSpec.describe WorkflowPermissionsGenerator do
      let(:workflow) { Sipity::Workflow.new(name: 'Hello') }
      let(:workflow_permissions_configuration) do
        [
          { role: "work_submitting" },
          { role: "etd_reviewing" }
        ]
      end
      before do
        workflow_permissions_configuration.each do |config|
          Sipity::Role.find_or_create_by!(name: config.fetch(:role))
        end
      end

      it 'exposes .call as a convenience method' do
        expect_any_instance_of(described_class).to receive(:call)
        described_class.call(workflow: workflow, workflow_permissions_configuration: workflow_permissions_configuration)
      end

      subject { described_class.new(workflow: workflow, workflow_permissions_configuration: workflow_permissions_configuration) }
      it 'will create groups and assign permissions accordingly' do
        allow_any_instance_of(PermissionGenerator).to receive(:call)
        subject.call

        # And it won't keep creating things
        [:update_attribute, :update_attributes, :update_attributes!, :save, :save!, :update, :update!].each do |method_names|
          expect_any_instance_of(ActiveRecord::Base).to_not receive(method_names)
        end
        subject.call
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.7 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-2.0.0 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-2.0.0.rc2 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.6 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.5 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.4 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.3 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.2 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-2.0.0.rc1 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.1 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.0 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb
curation_concerns-1.7.0.beta1 spec/services/curation_concerns/workflow/workflow_permissions_generator_spec.rb