Skip to content

Commit 29822fd

Browse files
committed
feat: added definition_source to module
1 parent db59e74 commit 29822fd

8 files changed

Lines changed: 22 additions & 1 deletion

File tree

app/models/runtime_module.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RuntimeModule < ApplicationRecord
2222
validates :documentation, length: { maximum: 200 }, exclusion: { in: [nil] }
2323
validates :author, length: { maximum: 200 }, exclusion: { in: [nil] }
2424
validates :icon, length: { maximum: 100 }
25+
validates :definition_source, length: { maximum: 50 }
2526

2627
validate :validate_version
2728

app/services/runtimes/grpc/modules/update_service.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def update_modules(t)
5757
module_record.author = grpc_module.author
5858
module_record.icon = grpc_module.icon
5959
module_record.version = grpc_module.version
60+
module_record.definition_source = grpc_module.definition_source
6061
module_record.names = update_translations(grpc_module.name, module_record.names)
6162
module_record.descriptions = update_translations(grpc_module.description, module_record.descriptions)
6263

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class AddDefinitionSourceToRuntimeModules < Code0::ZeroTrack::Database::Migration[1.0]
4+
def change
5+
add_column :runtime_modules, :definition_source, :text, limit: 50
6+
end
7+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
541adfd19676c98dbebc7109fbc7f86f0fda1e2243b8ecf40275d4b8efb271d5

db/structure.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,10 @@ CREATE TABLE runtime_modules (
956956
version text NOT NULL,
957957
created_at timestamp with time zone NOT NULL,
958958
updated_at timestamp with time zone NOT NULL,
959+
definition_source text,
959960
CONSTRAINT check_1a843f8ec6 CHECK ((char_length(identifier) <= 50)),
960961
CONSTRAINT check_3f8395fc6a CHECK ((char_length(icon) <= 100)),
962+
CONSTRAINT check_436ae79860 CHECK ((char_length(definition_source) <= 50)),
961963
CONSTRAINT check_59e12f7f02 CHECK ((char_length(author) <= 200)),
962964
CONSTRAINT check_d169c23c07 CHECK ((char_length(documentation) <= 200))
963965
);

spec/factories/runtime_modules.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
author { '' }
1111
icon { nil }
1212
version { '0.0.0' }
13+
definition_source { 'taurus' }
1314
end
1415
end

spec/models/runtime_module_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
it { is_expected.to validate_length_of(:documentation).is_at_most(200) }
2626
it { is_expected.to validate_length_of(:author).is_at_most(200) }
2727
it { is_expected.to validate_length_of(:icon).is_at_most(100) }
28+
it { is_expected.to validate_length_of(:definition_source).is_at_most(50) }
2829

2930
describe '#validate_version' do
3031
it 'adds an error if version is blank' do

spec/requests/grpc/sagittarius/module_service_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
author: 'Code0',
2020
icon: 'taurus-icon',
2121
version: '1.2.3',
22+
definition_source: 'taurus',
2223
definition_data_types: [
2324
{
2425
identifier: 'TEXT',
@@ -147,7 +148,8 @@
147148
documentation: 'Module documentation',
148149
author: 'Code0',
149150
icon: 'taurus-icon',
150-
version: '1.2.3'
151+
version: '1.2.3',
152+
definition_source: 'taurus'
151153
)
152154
expect(runtime_module.names.first.content).to eq('Taurus')
153155
expect(runtime_module.descriptions.first.content).to eq('Core module')
@@ -156,22 +158,27 @@
156158
text_list = DataType.find_by!(runtime: runtime, identifier: 'TEXT_LIST')
157159
expect(text.runtime_module).to eq(runtime_module)
158160
expect(text_list.runtime_module).to eq(runtime_module)
161+
expect(text).to have_attributes(definition_source: 'taurus')
162+
expect(text_list).to have_attributes(definition_source: 'taurus')
159163
expect(text_list.referenced_data_types).to contain_exactly(text)
160164

161165
runtime_flow_type = RuntimeFlowType.find_by!(runtime: runtime, identifier: 'RUNTIME_FORM')
162166
expect(runtime_flow_type.runtime_module).to eq(runtime_module)
167+
expect(runtime_flow_type.definition_source).to eq('taurus')
163168
expect(runtime_flow_type.runtime_flow_type_settings.first.identifier).to eq('title')
164169
expect(runtime_flow_type.runtime_flow_type_settings.first).to have_attributes(optional: true, hidden: true)
165170
expect(runtime_flow_type.referenced_data_types).to contain_exactly(text, text_list)
166171

167172
flow_type = FlowType.find_by!(runtime: runtime, identifier: 'FORM')
168173
expect(flow_type.runtime_module).to eq(runtime_module)
174+
expect(flow_type.definition_source).to eq('taurus')
169175
expect(flow_type.runtime_flow_type).to eq(runtime_flow_type)
170176
expect(flow_type.flow_type_settings.first).to have_attributes(optional: true, hidden: true)
171177
expect(flow_type.referenced_data_types).to contain_exactly(text, text_list)
172178

173179
runtime_function = RuntimeFunctionDefinition.find_by!(runtime: runtime, runtime_name: 'std::text::split')
174180
expect(runtime_function.runtime_module).to eq(runtime_module)
181+
expect(runtime_function.definition_source).to eq('taurus')
175182
expect(runtime_function.design).to eq('runtime-design')
176183
expect(runtime_function.referenced_data_types).to contain_exactly(text, text_list)
177184
expect(runtime_function.parameters.first.runtime_name).to eq('text')

0 commit comments

Comments
 (0)