Sha256: 19821cd012c3610298c88b05144c7d4ae62172794f22ae294efa1e8f3dc4e57d
Contents?: true
Size: 1.63 KB
Versions: 13
Compression:
Stored size: 1.63 KB
Contents
require 'spec_helper' module CurationConcerns RSpec.describe Workflow::StateMachineGenerator, :no_clean do let(:workflow) { Sipity::Workflow.create!(name: 'hello') } let(:action_name) { 'do_it' } before do class ConfirmSubmission end end after { CurationConcerns.send(:remove_const, :ConfirmSubmission) } it 'exposes .generate_from_schema as a convenience method' do expect_any_instance_of(described_class).to receive(:call) described_class.generate_from_schema(workflow: workflow, name: action_name, config: {}) end let(:config) do { from_states: [ { names: ["pending_student_completion"], roles: ['creating_user'] }, { names: ["pending_advisor_completion"], roles: ['advising'] } ], transition_to: :under_review, notifications: [ { notification_type: 'email', name: 'CurationConcerns::ConfirmSubmission', to: 'creating_user', cc: 'advising' } ] } end context '#call' do subject { described_class.new(workflow: workflow, action_name: action_name, config: config) } it 'will generate the various data entries (but only once)' do expect do subject.call end.to change { Sipity::Notification.count } .and change { Sipity::WorkflowAction.count } # It can be called repeatedly without updating 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