acts_as_metadata 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -19,6 +19,7 @@ class CreateMetadata < ActiveRecord::Migration
|
|
19
19
|
t.column :tag, :string
|
20
20
|
t.column :datatype, :string, :default => "string"
|
21
21
|
t.column :mandatory, :boolean, :default => false
|
22
|
+
t.column :multiple, :boolean, :default => false
|
22
23
|
t.column :format, :string
|
23
24
|
t.column :values, :text
|
24
25
|
t.column :models, :string, :default => '--- []'
|
@@ -5,8 +5,7 @@ class MetadataType < ActiveRecord::Base
|
|
5
5
|
:date => "date",
|
6
6
|
:datetime => "datetime",
|
7
7
|
:number => "number",
|
8
|
-
:boolean => "boolean"
|
9
|
-
:array => "array"
|
8
|
+
:boolean => "boolean"
|
10
9
|
}
|
11
10
|
|
12
11
|
serialize :default
|
@@ -17,7 +16,7 @@ class MetadataType < ActiveRecord::Base
|
|
17
16
|
before_destroy :refresh_metadata
|
18
17
|
attr_accessor :models_json, :values_json, :default_json
|
19
18
|
attr_accessible :tag, :name, :description, :models, :mandatory,
|
20
|
-
:default, :format, :datatype, :values,
|
19
|
+
:default, :format, :datatype, :values, :multiple,
|
21
20
|
:models_json, :values_json, :default_json
|
22
21
|
validates :tag, :presence => true, :format => {:with => /^[a-z]+[a-z0-9]*$/},
|
23
22
|
:exclusion => { :in => %w(format errors callback action categorie accept attributes host key layout notify open render save template type id parent_id lft rgt test select),
|
@@ -31,6 +30,7 @@ class MetadataType < ActiveRecord::Base
|
|
31
30
|
:name => "Sample",
|
32
31
|
:models => [:any],
|
33
32
|
:mandatory => false,
|
33
|
+
:multiple => false,
|
34
34
|
:default => 'default',
|
35
35
|
:datatype => "string",
|
36
36
|
:format => nil,
|
data/lib/metadata/version.rb
CHANGED
@@ -76,12 +76,12 @@ describe ActsAsMetadata do
|
|
76
76
|
mymodel.errors.count.should == 0
|
77
77
|
end
|
78
78
|
|
79
|
-
it 'creates multiple metadata items
|
79
|
+
it 'creates multiple metadata items' do
|
80
80
|
MetadataType.destroy_all
|
81
81
|
mt = MetadataType.default
|
82
82
|
mt.tag = :samplearray
|
83
83
|
mt.name = "Sample Array"
|
84
|
-
mt.
|
84
|
+
mt.multiple = true
|
85
85
|
mt.save!
|
86
86
|
mymodel = MyModel.new
|
87
87
|
mymodel.samplearray = ['aaa', 'bbb', 'ccc']
|
@@ -90,7 +90,7 @@ describe ActsAsMetadata do
|
|
90
90
|
mymodel.metadata.count.should == 3
|
91
91
|
end
|
92
92
|
|
93
|
-
it 'loads
|
93
|
+
it 'loads multiple metadata correctly' do
|
94
94
|
mymodel = MyModel.new
|
95
95
|
mymodel.samplearray = ['aaa', 'bbb', 'ccc']
|
96
96
|
mymodel.save
|
@@ -99,7 +99,7 @@ describe ActsAsMetadata do
|
|
99
99
|
mymodel.samplearray.count.should == 3
|
100
100
|
end
|
101
101
|
|
102
|
-
it 'checks presence validation for
|
102
|
+
it 'checks presence validation for multiple metadata' do
|
103
103
|
mt = MetadataType.first
|
104
104
|
mt.mandatory = true
|
105
105
|
mt.default = nil
|
@@ -112,7 +112,7 @@ describe ActsAsMetadata do
|
|
112
112
|
mymodel.errors.count.should == 0
|
113
113
|
end
|
114
114
|
|
115
|
-
it 'checks format validation for
|
115
|
+
it 'checks format validation for multiple metadata' do
|
116
116
|
mt = MetadataType.first
|
117
117
|
mt.mandatory = false
|
118
118
|
mt.format = '[a-z]*'
|
@@ -126,7 +126,7 @@ describe ActsAsMetadata do
|
|
126
126
|
mymodel.errors.count.should == 0
|
127
127
|
end
|
128
128
|
|
129
|
-
it 'checks values validation for
|
129
|
+
it 'checks values validation for multiple metadata' do
|
130
130
|
mt = MetadataType.first
|
131
131
|
mt.mandatory = false
|
132
132
|
mt.values = ['aaa', 'bbb', 'ccc']
|
data/spec/spec_helper.rb
CHANGED
@@ -43,6 +43,7 @@ ActiveRecord::Base.connection.create_table(:metadata_types) do |t|
|
|
43
43
|
t.string "tag"
|
44
44
|
t.string "datatype", :default => "string"
|
45
45
|
t.boolean "mandatory", :default => false
|
46
|
+
t.boolean "multiple", :default => false
|
46
47
|
t.string "format"
|
47
48
|
t.text "values"
|
48
49
|
t.string "models", :default => "--- []"
|