Skip to content

Commit a173816

Browse files
authored
Merge pull request #873 from code0-tech/853-ensure-a-project-always-has-a-primary-runtime-if-it-contains-flows
Ensure project has primary runtime is containing flows
2 parents 239aeb8 + d1517f2 commit a173816

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

app/models/namespace_project.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class NamespaceProject < ApplicationRecord
2929

3030
before_validation :strip_whitespace
3131

32+
validates :primary_runtime, presence: true, if: -> { flows.any? }
3233
validate :validate_primary_runtime, if: :primary_runtime_changed?
3334

3435
def validate_primary_runtime

spec/models/namespace_project_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,15 @@
5252
project.primary_runtime = runtime
5353
is_expected.to be_valid
5454
end
55+
56+
it 'requires primary runtime if containing flows' do
57+
is_expected.to be_valid
58+
59+
create(:flow, project: project)
60+
is_expected.not_to be_valid
61+
62+
project.primary_runtime = create(:runtime, namespace: nil)
63+
is_expected.to be_valid
64+
end
5565
end
5666
end

0 commit comments

Comments
 (0)