Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/workflow_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class WorkflowStep < ApplicationRecord
validates :version, presence: true
validates :repository, presence: true
validates :status, inclusion: { in: %w[waiting completed queued error skipped] }
validates :process, uniqueness: { scope: %w[version workflow druid] }

scope :lifecycle, -> { where.not(lifecycle: nil) }
scope :incomplete, -> { where.not(status: %w[completed skipped]) }
Expand Down
14 changes: 14 additions & 0 deletions spec/models/workflow_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
expect(subject.valid?).to be false
end
end
context 'duplicate step for the same process/version' do
it 'is not valid if the step already exists for the same druid/workflow/version' do
dupe_step = described_class.new(
druid: subject.druid,
workflow: subject.workflow,
process: subject.process,
version: subject.version,
status: 'completed',
repository: 'dor'
)
expect(dupe_step.valid?).to be false
expect(dupe_step.errors.messages).to include(process: ['has already been taken'])
end
end
describe '#as_milestone' do
builder = {}
before do
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/workflows/destroy_all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
let!(:item2) do
FactoryBot.create(:workflow_step,
repository: 'sdr',
process: 'publish',
Copy link
Copy Markdown
Contributor Author

@peetucket peetucket Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

necessary for tests to continue to work with our new validation that prevents dupe steps from being added ... doesn't need to be "publish" but needs to be different than :item1 and :item3

druid: druid)
end

let!(:item3) do
FactoryBot.create(:workflow_step)
FactoryBot.create(:workflow_step, process: 'shelve')
Copy link
Copy Markdown
Contributor Author

@peetucket peetucket Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

necessary for tests to continue to work with our new validation that prevents dupe steps from being added ... doesn't need to be "shelve" but needs to be different than :item1 and :item2

end

let(:druid) { item1.druid }
Expand Down