Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Manifest::Template subclass
Browse files Browse the repository at this point in the history
euler-room committed Jan 14, 2025
1 parent 8e9727b commit b66e132
Showing 2 changed files with 51 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apps/dashboard/app/apps/manifest.rb
Original file line number Diff line number Diff line change
@@ -233,4 +233,10 @@ def save(path)
false
end
end

class Template < Manifest
def files
manifest_options[:files] || []
end
end
end
46 changes: 45 additions & 1 deletion apps/dashboard/test/models/manifest_test.rb
Original file line number Diff line number Diff line change
@@ -138,7 +138,8 @@ class ManifestTest < ActiveSupport::TestCase
metadata: { some_key: 'value' },
new_window: false,
caption: 'some caption',
invalid_key: 'invalid value'
invalid_key: 'invalid value',
files: ['file1', 'file2']
}

valid_manifest = <<~HEREDOC
@@ -165,4 +166,47 @@ class ManifestTest < ActiveSupport::TestCase
assert_equal valid_manifest, File.read(path)
end
end

test 'Manifest::Template writes files entries' do
opts = { name: 'Ruby',
description: 'test hash',
icon: 'fas://cog',
url: '/some/location',
category: 'some category',
subcategory: 'some subcategory',
role: 'some role',
metadata: { some_key: 'value' },
new_window: false,
caption: 'some caption',
invalid_key: 'invalid value',
files: ['file1', 'file2']
}

valid_manifest = <<~HEREDOC
---
name: Ruby
description: test hash
icon: fas://cog
url: "/some/location"
category: some category
subcategory: some subcategory
role: some role
metadata:
some_key: value
new_window: false
caption: some caption
files:
- file1
- file2
HEREDOC

manifest = Manifest::Template.new(opts)

Dir.mktmpdir do |dir|
path = dir << '/manifest.yml'
manifest.save(path)

assert_equal valid_manifest, File.read(path)
end
end
end

0 comments on commit b66e132

Please sign in to comment.