mdd 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/mdwa/mdwa_controller.rb +2 -1
- data/app/controllers/mdwa/requirements_controller.rb +2 -1
- data/app/helpers/mdwa_helper.rb +19 -5
- data/app/views/template/mdwa/_autocomplete_multiple_tag.html.erb +2 -2
- data/app/views/template/mdwa/_autocomplete_remote_multiple_tag.html.erb +49 -0
- data/app/views/template/mdwa/_autocomplete_remote_tag.html.erb +24 -0
- data/app/views/template/mdwa/_autocomplete_tag.html.erb +1 -1
- data/app/views/template/mdwa/_crud_error.html.erb +1 -1
- data/app/views/template/mdwa/_login_text.html.erb +4 -3
- data/app/views/template/mdwa/_notice.html.erb +3 -3
- data/lib/extensions/string.rb +2 -2
- data/lib/generators/mdwa/entity/entity_generator.rb +1 -1
- data/lib/generators/mdwa/entity/templates/entity.rb +1 -1
- data/lib/generators/mdwa/from_requirements/from_requirements_generator.rb +2 -2
- data/lib/generators/mdwa/requirement/templates/requirement.rb +2 -3
- data/lib/generators/mdwa/sandbox/sandbox_generator.rb +2 -1
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/blank.gif +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/fancybox_loading.gif +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/fancybox_overlay.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/fancybox_sprite.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.fancybox.js +45 -31
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.mousewheel.js +12 -12
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/login_manifest.js +1 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/all_pages.js +6 -3
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/mdwa/template/pagination.js +6 -2
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/jquery-ui-1.10.0.custom.css +1174 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/{jquery.fancybox.css → jquery.fancybox.css.erb} +94 -71
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/login/login.css +67 -60
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/system_manifest.css +1 -7
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/backend.css.erb +35 -66
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/template.css.erb +372 -34
- data/lib/generators/mdwa/sandbox/templates/config/locales/mdwa.en.yml +4 -0
- data/lib/generators/mdwa/scaffold/templates/controllers/ajax_controller.rb +1 -1
- data/lib/generators/mdwa/scaffold/templates/controllers/controller.rb +1 -1
- data/lib/generators/mdwa/scaffold/templates/specs/routing.rb +1 -1
- data/lib/generators/mdwa/templates/templates/general/routes.rb +2 -1
- data/lib/generators/mdwa/templates/templates/scaffold/controller.erb +51 -37
- data/lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb +2 -2
- data/lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb +10 -9
- data/lib/generators/mdwa/templates/templates/scaffold/views/create.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/destroy.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/index.html.erb +46 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/index.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/update.js.erb +1 -1
- data/lib/generators/mdwa/templates/templates_generator.rb +1 -1
- data/lib/generators/mdwa/transform/transform_generator.rb +81 -73
- data/lib/generators/mdwa/user/templates/user.rb +1 -1
- data/lib/generators/mdwa/user_scaffold/templates/migrate.erb +12 -4
- data/lib/generators/mdwa/user_scaffold/user_scaffold_generator.rb +9 -2
- data/lib/mdwa/dsl/entity.rb +11 -10
- data/lib/mdwa/dsl/entity_association.rb +11 -3
- data/lib/mdwa/dsl/entity_attribute.rb +8 -1
- data/lib/mdwa/dsl/process.rb +2 -0
- data/lib/mdwa/dsl/process_detail.rb +2 -0
- data/lib/mdwa/dsl/process_detail_next_action.rb +3 -1
- data/lib/mdwa/dsl/requirement.rb +6 -3
- data/lib/mdwa/dsl/requirements.rb +1 -1
- data/lib/mdwa/dsl/workflow.rb +1 -1
- data/lib/mdwa/generators/model.rb +8 -0
- data/lib/mdwa/generators/model_association.rb +9 -0
- data/lib/mdwa/generators/model_attribute.rb +46 -24
- data/lib/mdwa/version.rb +1 -1
- data/mdd.gemspec +1 -1
- data/test/entity_attributes_options_test.rb +43 -0
- data/test/entity_test.rb +6 -6
- data/test/process_test.rb +31 -31
- data/test/requirements_test.rb +3 -5
- metadata +36 -57
- data/lib/generators/mdwa/sandbox/templates/app/assets/images/mdwa/button_submit.gif +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/javascripts/jquery/jquery.bgiframe.js +0 -10
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/jquery/jquery-ui-theme1.css +0 -573
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/leftbar.css.erb +0 -0
- data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/visualization.css +0 -3
@@ -2,9 +2,13 @@
|
|
2
2
|
class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers < ActiveRecord::Migration
|
3
3
|
|
4
4
|
def self.up
|
5
|
-
<%- @model.
|
6
|
-
<%- if
|
5
|
+
<%- @model.attributes.each do |attr| -%>
|
6
|
+
<%- if attr.type.to_sym != :file -%>
|
7
|
+
<%- if attr.belongs_to? or attr.nested_one? -%>
|
8
|
+
add_column :users, :<%= attr.name %>, :integer
|
9
|
+
<%- elsif !attr.references? -%>
|
7
10
|
add_column :users, :<%= attr.name %>, :<%= attr.migration_field %>
|
11
|
+
<%- end -%>
|
8
12
|
<%- else -%>
|
9
13
|
add_column :users, :<%= attr.name %>_file_name, :string
|
10
14
|
add_column :users, :<%= attr.name %>_content_type, :string
|
@@ -15,9 +19,13 @@ class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers <
|
|
15
19
|
end
|
16
20
|
|
17
21
|
def self.down
|
18
|
-
<%- @model.
|
19
|
-
<%- if
|
22
|
+
<%- @model.attributes.each do |attr| -%>
|
23
|
+
<%- if attr.type.to_sym != :file -%>
|
24
|
+
<%- if attr.belongs_to? or attr.nested_one? -%>
|
20
25
|
remove_column :users, :<%= attr.name %>
|
26
|
+
<%- elsif !attr.references? -%>
|
27
|
+
remove_column :users, :<%= attr.name %>
|
28
|
+
<%- end -%>
|
21
29
|
<%- else -%>
|
22
30
|
remove_column :users, :<%= attr.name %>_file_name
|
23
31
|
remove_column :users, :<%= attr.name %>_content_type
|
@@ -52,7 +52,10 @@ module Mdwa
|
|
52
52
|
|
53
53
|
# sets the model attributes
|
54
54
|
attributes.each do |attribute|
|
55
|
-
|
55
|
+
attr_name = attribute.split(':').first
|
56
|
+
if !User.accessible_attributes.to_a.include?( attr_name )
|
57
|
+
@model.add_attribute MDWA::Generators::ModelAttribute.new( attribute )
|
58
|
+
end
|
56
59
|
end
|
57
60
|
|
58
61
|
unless options.only_diff_migration
|
@@ -72,7 +75,11 @@ module Mdwa
|
|
72
75
|
# add to model attributes
|
73
76
|
# if it's not predefined in devise
|
74
77
|
# if it's a belongs_to or nested_one association
|
75
|
-
if (!attr.references? and !@predefined_fields.include?(
|
78
|
+
if (!attr.references? and !@predefined_fields.include?(attribute.split(':').first)) or
|
79
|
+
(
|
80
|
+
(attr.belongs_to? or attr.nested_one?) and
|
81
|
+
User.column_names.to_a.select {|user_attr| user_attr == attr.name.foreign_key}.count.zero?
|
82
|
+
)
|
76
83
|
@model.add_attribute attr
|
77
84
|
end
|
78
85
|
end
|
data/lib/mdwa/dsl/entity.rb
CHANGED
@@ -33,7 +33,7 @@ module MDWA
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def scaffold_name
|
36
|
-
return (@scaffold_name.blank? ? name : @scaffold_name)
|
36
|
+
return (@scaffold_name.blank? ? name.underscore : @scaffold_name)
|
37
37
|
end
|
38
38
|
|
39
39
|
def model_name
|
@@ -72,15 +72,16 @@ module MDWA
|
|
72
72
|
#
|
73
73
|
def after_declaration
|
74
74
|
|
75
|
+
# include rails default attributes
|
76
|
+
self.attribute('id', 'integer') if self.attributes['id'].blank?
|
77
|
+
self.attribute('created_at', 'datetime') if self.attributes['created_at'].blank?
|
78
|
+
self.attribute('updated_at', 'datetime') if self.attributes['updated_at'].blank?
|
75
79
|
# if it's a user and have no attributes, include "name" to prevent errors
|
76
|
-
self.attribute('id', 'integer')
|
77
|
-
self.attribute('created_at', 'datetime')
|
78
|
-
self.attribute('updated_at', 'datetime')
|
79
80
|
if user?
|
80
|
-
self.attribute('name', 'string')
|
81
|
-
self.attribute('email', 'string')
|
82
|
-
self.attribute('password', 'password')
|
83
|
-
self.attribute('password_confirmation', 'password')
|
81
|
+
self.attribute('name', 'string') if self.attributes['name'].blank?
|
82
|
+
self.attribute('email', 'string') if self.attributes['email'].blank?
|
83
|
+
self.attribute('password', 'password') if self.attributes['password'].blank?
|
84
|
+
self.attribute('password_confirmation', 'password') if self.attributes['password_confirmation'].blank?
|
84
85
|
end
|
85
86
|
|
86
87
|
end
|
@@ -91,8 +92,8 @@ module MDWA
|
|
91
92
|
attr = EntityAttribute.new(self)
|
92
93
|
attr.name = name
|
93
94
|
attr.type = type
|
94
|
-
attr.default = options
|
95
|
-
attr.
|
95
|
+
attr.default = true if options.include?(:default) and options[:default]
|
96
|
+
attr.options = options
|
96
97
|
attr.raise_errors_if_invalid!
|
97
98
|
self.attributes[attr.name] = attr
|
98
99
|
end
|
@@ -5,7 +5,7 @@ module MDWA
|
|
5
5
|
class EntityAssociation
|
6
6
|
|
7
7
|
attr_accessor :source, :destination, :destination_view
|
8
|
-
attr_accessor :name, :type, :composition, :description, :skip_views, :
|
8
|
+
attr_accessor :name, :type, :composition, :description, :skip_views, :options
|
9
9
|
|
10
10
|
ACCEPTED_TYPES = [:one_to_many, :many_to_one, :one_to_one, :one_to_one_not_navigable, :many_to_many]
|
11
11
|
|
@@ -13,6 +13,7 @@ module MDWA
|
|
13
13
|
self.source = source
|
14
14
|
self.composition = false
|
15
15
|
self.skip_views = false
|
16
|
+
self.options = {}
|
16
17
|
end
|
17
18
|
|
18
19
|
#
|
@@ -20,7 +21,7 @@ module MDWA
|
|
20
21
|
# Sets the name if not set yet.
|
21
22
|
#
|
22
23
|
def destination=(value)
|
23
|
-
self.name = value.
|
24
|
+
self.name = value.underscore if self.name.blank?
|
24
25
|
@destination = value
|
25
26
|
end
|
26
27
|
|
@@ -31,7 +32,14 @@ module MDWA
|
|
31
32
|
def skip_views!
|
32
33
|
self.skip_views = true
|
33
34
|
end
|
34
|
-
|
35
|
+
|
36
|
+
#
|
37
|
+
# Return the model association generator.
|
38
|
+
#
|
39
|
+
def to_model_association
|
40
|
+
self.source.generator_model.associations.select{ |m_assoc| m_assoc.model2.name.underscore == self.name.underscore }.first
|
41
|
+
end
|
42
|
+
|
35
43
|
#
|
36
44
|
# Return the mapped type for the code generation.
|
37
45
|
#
|
@@ -6,7 +6,7 @@ module MDWA
|
|
6
6
|
|
7
7
|
class EntityAttribute
|
8
8
|
|
9
|
-
attr_accessor :entity, :name, :type, :default, :
|
9
|
+
attr_accessor :entity, :name, :type, :default, :options
|
10
10
|
|
11
11
|
ACCEPTED_TYPES = MDWA::Generators::ModelAttribute::STATIC_TYPES
|
12
12
|
|
@@ -40,6 +40,13 @@ module MDWA
|
|
40
40
|
"#{name}:#{type}"
|
41
41
|
end
|
42
42
|
|
43
|
+
#
|
44
|
+
# Return the model attribute generator.
|
45
|
+
#
|
46
|
+
def to_model_attribute
|
47
|
+
self.entity.generator_model.attributes.select{ |m_attr| m_attr.name == self.name }.first
|
48
|
+
end
|
49
|
+
|
43
50
|
end
|
44
51
|
|
45
52
|
end
|
data/lib/mdwa/dsl/process.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
require 'extensions/string'
|
3
|
+
|
2
4
|
module MDWA
|
3
5
|
module DSL
|
4
6
|
|
@@ -7,7 +9,7 @@ module MDWA
|
|
7
9
|
attr_accessor :alias, :method, :request, :redirect, :render, :when
|
8
10
|
|
9
11
|
def initialize(next_action_alias)
|
10
|
-
self.alias = next_action_alias
|
12
|
+
self.alias = next_action_alias.to_alias
|
11
13
|
end
|
12
14
|
|
13
15
|
end
|
data/lib/mdwa/dsl/requirement.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
require 'extensions/string'
|
3
|
+
|
2
4
|
module MDWA
|
3
5
|
module DSL
|
4
6
|
|
@@ -12,9 +14,10 @@ module MDWA
|
|
12
14
|
self.users = []
|
13
15
|
self.entities = []
|
14
16
|
end
|
15
|
-
|
16
|
-
def
|
17
|
-
@
|
17
|
+
|
18
|
+
def summary=(summary)
|
19
|
+
@summary = summary
|
20
|
+
@alias = summary.to_alias unless summary.nil?
|
18
21
|
end
|
19
22
|
|
20
23
|
def non_functional?
|
data/lib/mdwa/dsl/workflow.rb
CHANGED
@@ -107,10 +107,18 @@ module MDWA
|
|
107
107
|
model_attribute.model = self
|
108
108
|
end
|
109
109
|
|
110
|
+
def add_association(model_association)
|
111
|
+
self.associations << model_association
|
112
|
+
end
|
113
|
+
|
110
114
|
def simple_attributes
|
111
115
|
attributes.select{ |a| !a.references? }
|
112
116
|
end
|
113
117
|
|
118
|
+
def to_sym
|
119
|
+
self.name.to_sym
|
120
|
+
end
|
121
|
+
|
114
122
|
private
|
115
123
|
def namespace_scope
|
116
124
|
return "#{namespace}::" if namespace?
|
@@ -84,6 +84,15 @@ module MDWA
|
|
84
84
|
def has_and_belongs_to_many?
|
85
85
|
return (relation == 'has_and_belongs_to_many')
|
86
86
|
end
|
87
|
+
|
88
|
+
|
89
|
+
def filter_input(destination_field)
|
90
|
+
input = []
|
91
|
+
input << "render '/template/mdwa/autocomplete_tag', :dom_element => '##{self.model2.name.underscore}', :dom_element_id => '##{self.model2.name.underscore}_id', :data => #{model2.klass}.all, :field_name => '#{destination_field}'"
|
92
|
+
input << "text_field_tag :#{self.model2.name.underscore}"
|
93
|
+
input << "hidden_field_tag :#{self.model2.name.underscore}_id"
|
94
|
+
return input
|
95
|
+
end
|
87
96
|
|
88
97
|
end
|
89
98
|
|
@@ -52,33 +52,55 @@ module MDWA
|
|
52
52
|
|
53
53
|
def migration_field
|
54
54
|
@migration_field ||= case self.type.to_s.to_sym
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
when :string, :password then 'string'
|
56
|
+
when :boolean then 'boolean'
|
57
|
+
when :date then 'date'
|
58
|
+
when :datetime then 'datetime'
|
59
|
+
when :decimal, :float then 'decimal'
|
60
|
+
when :text then 'text'
|
61
|
+
when :time then 'time'
|
62
|
+
when :timestamp then 'timestamp'
|
63
|
+
when :file then 'attachment'
|
64
|
+
else
|
65
|
+
'integer'
|
66
|
+
end
|
66
67
|
end
|
67
68
|
|
68
69
|
def form_field
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
70
|
+
@form_field ||= case self.type.to_s.to_sym
|
71
|
+
when :integer then 'number_field'
|
72
|
+
when :float, :decimal then 'text_field'
|
73
|
+
when :file then 'file_field'
|
74
|
+
when :time then 'time_select'
|
75
|
+
when :datetime, :timestamp then 'datetime_select'
|
76
|
+
when :date then 'date_select'
|
77
|
+
when :text then 'text_area'
|
78
|
+
when :boolean then 'check_box'
|
79
|
+
when :password then 'password_field'
|
80
|
+
else
|
81
|
+
'text_field'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def filter_input
|
86
|
+
input = []
|
87
|
+
case self.type.to_s.to_sym
|
88
|
+
when :text, :string then
|
89
|
+
input << "text_field_tag :#{self.name}"
|
90
|
+
when :integer, :float, :decimal then
|
91
|
+
input << "text_field_tag :#{self.name}, '', :onkeypress => \"mascara(this, checaNumero)\", :maxlength => 10"
|
92
|
+
when :file, :password then
|
93
|
+
input << 'No possible filter for file or password.'
|
94
|
+
when :time then
|
95
|
+
input << 'time_select'
|
96
|
+
when :datetime, :timestamp, :date then
|
97
|
+
input << "text_field_tag :#{self.name}_0, '', :class => :datepicker, :onkeypress => \"mascara(this, checaData)\", :maxlength => 10"
|
98
|
+
input << "text_field_tag :#{self.name}_1, '', :class => :datepicker, :onkeypress => \"mascara(this, checaData)\", :maxlength => 10"
|
99
|
+
when :boolean then
|
100
|
+
input << "select_tag :#{self.name}, options_for_select([[t('system.yes'), 1], [t('system.no'), 0]]), :prompt => t('system.both')"
|
101
|
+
else
|
102
|
+
input << "text_field_tag :#{self.name}"
|
103
|
+
end
|
82
104
|
end
|
83
105
|
|
84
106
|
def belongs_to?
|
data/lib/mdwa/version.rb
CHANGED
data/mdd.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = "mdd"
|
15
15
|
|
16
|
-
s.add_dependency 'rails', '>= 3.2.
|
16
|
+
s.add_dependency 'rails', '>= 3.2.8'
|
17
17
|
s.add_dependency 'jquery-rails', '>= 2.2.0'
|
18
18
|
s.add_dependency 'devise', '>= 2.1'
|
19
19
|
s.add_dependency 'cancan', '>= 1.6'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'mdwa/dsl'
|
3
|
+
|
4
|
+
require 'minitest/spec'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
describe MDWA::DSL::EntityAttribute do
|
8
|
+
|
9
|
+
before do
|
10
|
+
# create product entity
|
11
|
+
MDWA::DSL.entities.register "Pessoa" do |e|
|
12
|
+
e.resource = true
|
13
|
+
e.ajax = true
|
14
|
+
|
15
|
+
e.attribute 'nome', 'string', default: true, filtered: true
|
16
|
+
e.attribute 'documento', 'string', filtered: true
|
17
|
+
e.attribute 'endereco', 'string'
|
18
|
+
e.attribute 'campo', 'string', filtered: false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should store attributes correctly" do
|
23
|
+
entidade = MDWA::DSL.entity('Pessoa')
|
24
|
+
|
25
|
+
entidade.attributes.count.must_equal 7
|
26
|
+
entidade.attributes['nome'].options.count.must_equal 2
|
27
|
+
entidade.attributes['nome'].default.must_equal true
|
28
|
+
entidade.attributes['nome'].options[:filtered].must_equal true
|
29
|
+
entidade.attributes['nome'].options[:outro].must_equal nil
|
30
|
+
|
31
|
+
entidade.attributes['documento'].options.count.must_equal 1
|
32
|
+
entidade.attributes['documento'].default.must_equal false
|
33
|
+
entidade.attributes['documento'].options[:filtered].must_equal true
|
34
|
+
entidade.attributes['documento'].options[:outro].must_equal nil
|
35
|
+
|
36
|
+
entidade.attributes['endereco'].options.count.must_equal 0
|
37
|
+
entidade.attributes['endereco'].default.must_equal false
|
38
|
+
entidade.attributes['endereco'].options[:filtered].must_equal nil
|
39
|
+
|
40
|
+
entidade.attributes.values.select{|attr| attr.options[:filtered]}.count.must_equal 2
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/entity_test.rb
CHANGED
@@ -90,7 +90,7 @@ describe MDWA::DSL::Entities do
|
|
90
90
|
product.ajax.must_equal true
|
91
91
|
product.associations.must_be_instance_of Hash
|
92
92
|
product.attributes.must_be_instance_of Hash
|
93
|
-
product.model_name.must_equal( "
|
93
|
+
product.model_name.must_equal( "product" )
|
94
94
|
|
95
95
|
category = MDWA::DSL.entity("Category")
|
96
96
|
category.must_be_instance_of MDWA::DSL::Entity
|
@@ -109,7 +109,7 @@ describe MDWA::DSL::Entities do
|
|
109
109
|
it "must store attributes" do
|
110
110
|
product = MDWA::DSL.entity("Product")
|
111
111
|
|
112
|
-
product.attributes.count.must_equal
|
112
|
+
product.attributes.count.must_equal 7
|
113
113
|
product.attributes['name'].type.must_equal 'string'
|
114
114
|
product.attributes['name'].name.must_equal 'name'
|
115
115
|
product.attributes['category'].type.must_equal 'integer'
|
@@ -122,7 +122,7 @@ describe MDWA::DSL::Entities do
|
|
122
122
|
product.default_attribute.name.must_equal 'name'
|
123
123
|
|
124
124
|
category = MDWA::DSL.entity("Category")
|
125
|
-
category.attributes.count.must_equal
|
125
|
+
category.attributes.count.must_equal 4
|
126
126
|
category.default_attribute.name.must_equal 'name'
|
127
127
|
end
|
128
128
|
|
@@ -182,8 +182,8 @@ describe MDWA::DSL::Entities do
|
|
182
182
|
project.scaffold_name.must_equal 'a/project'
|
183
183
|
project.model_name.must_equal 'a/project'
|
184
184
|
|
185
|
-
project.generate.must_equal "mdwa:scaffold a/project nome:string ativo:boolean situacao_atual:text group:a/group:nome:belongs_to --ajax"
|
186
|
-
group.generate.must_equal "mdwa:scaffold a/group nome:string ativo:boolean --ajax --force"
|
185
|
+
project.generate.must_equal "mdwa:scaffold a/project nome:string ativo:boolean situacao_atual:text id:integer created_at:datetime updated_at:datetime group:a/group:nome:belongs_to --ajax"
|
186
|
+
group.generate.must_equal "mdwa:scaffold a/group nome:string ativo:boolean id:integer created_at:datetime updated_at:datetime --ajax --force"
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should not generate non-resource entities" do
|
@@ -209,7 +209,7 @@ describe MDWA::DSL::Entities do
|
|
209
209
|
end
|
210
210
|
|
211
211
|
team_member = MDWA::DSL.entity('TeamMember')
|
212
|
-
team_member.attributes.count.must_equal
|
212
|
+
team_member.attributes.count.must_equal 7
|
213
213
|
team_member.attributes['name'].name.must_equal 'name'
|
214
214
|
team_member.attributes['name'].type.must_equal 'string'
|
215
215
|
end
|