Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/dashboard/app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def save
return false unless valid?(:create)

if @project_dir.empty?
errors.add(:save, "I18n.t('dashboard.jobs_project_directory_error')")
errors.add(:save, I18n.t('dashboard.jobs_project_directory_error'))
return false
end

Expand Down
10 changes: 8 additions & 2 deletions apps/dashboard/test/models/workflow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class WorkflowsTest < ActiveSupport::TestCase
assert_equal '0', workflow.sync_key_enabled
end

test 'save without project_dir returns translated error message' do
workflow = Workflow.new(name: 'test', launcher_ids: ['sample'])
assert_not workflow.save
assert_equal I18n.t('dashboard.jobs_project_directory_error'), workflow.errors[:save].first
end

test 'create workflow validation' do
Dir.mktmpdir do |tmp|
# add error in workflow save if project_dir is not valid
Expand Down Expand Up @@ -66,7 +72,7 @@ class WorkflowsTest < ActiveSupport::TestCase
launcher_ids: ['sample']
)

assert workflow.errors.inspect
assert_empty workflow.errors
assert Dir.entries("#{project_dir}/.ondemand/workflows").include?("#{workflow_id}.yml")
assert_equal workflow_id, workflow.id
assert_equal 'MyLocalName', workflow.name
Expand All @@ -86,7 +92,7 @@ class WorkflowsTest < ActiveSupport::TestCase
sync_key_enabled: '1'
)

assert workflow.errors.inspect
assert_empty workflow.errors
manifest_file = Pathname.new("#{project_dir}/.ondemand/workflows/#{workflow.id}.yml")
assert_equal manifest_file, workflow.manifest_file
assert File.file?(manifest_file)
Expand Down