active_metadata 0.7.9 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/active_metadata/attachment.rb +6 -6
- data/app/models/active_metadata/history.rb +1 -0
- data/app/views/active_metadata/attachments/_attachment.html.erb +1 -1
- data/db/migrate/01_active_metadata_migrations.rb +15 -15
- data/lib/active_metadata/base.rb +1 -0
- data/lib/active_metadata/persistence/attachment.rb +3 -3
- data/lib/active_metadata/persistence/history.rb +2 -2
- data/lib/active_metadata/persistence/note.rb +3 -3
- data/lib/active_metadata/persistence/watcher.rb +5 -5
- data/lib/active_metadata/value_formatter.rb +12 -0
- data/lib/active_metadata/version.rb +1 -1
- data/spec/dummy/db/schema.rb +50 -17
- data/spec/lib/attachments_spec.rb +2 -2
- data/spec/lib/history_spec.rb +3 -3
- data/spec/lib/notes_spec.rb +3 -3
- data/spec/lib/watchers_spec.rb +2 -2
- data/spec/models/history_spec.rb +30 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/migrations.rb +3 -0
- metadata +7 -4
@@ -6,19 +6,19 @@ module ActiveMetadata
|
|
6
6
|
include ::Paperclip::Glue
|
7
7
|
|
8
8
|
has_attached_file :attach,
|
9
|
-
:path => "#{ActiveMetadata::CONFIG['attachment_base_path']}/:
|
10
|
-
:url => "#{ActiveMetadata::CONFIG['attachment_base_url']}/:
|
9
|
+
:path => "#{ActiveMetadata::CONFIG['attachment_base_path']}/:model_class/:model_id/:label/:id/:basename.:extension",
|
10
|
+
:url => "#{ActiveMetadata::CONFIG['attachment_base_url']}/:model_class/:model_id/:label/:id/"
|
11
11
|
|
12
|
-
Paperclip.interpolates :
|
13
|
-
attachment.instance.
|
12
|
+
Paperclip.interpolates :model_id do |attachment, style|
|
13
|
+
attachment.instance.model_id
|
14
14
|
end
|
15
15
|
|
16
16
|
Paperclip.interpolates :label do |attachment, style|
|
17
17
|
attachment.instance.label
|
18
18
|
end
|
19
19
|
|
20
|
-
Paperclip.interpolates :
|
21
|
-
attachment.instance.
|
20
|
+
Paperclip.interpolates :model_class do |attachment, style|
|
21
|
+
attachment.instance.model_class
|
22
22
|
end
|
23
23
|
class << self
|
24
24
|
|
@@ -3,5 +3,5 @@
|
|
3
3
|
<%= "Path: #{attachment.attach.path}"%>
|
4
4
|
<%= "Size: #{attachment.attach.size}"%>
|
5
5
|
<%= "Updated at: #{attachment.attach.instance_read(:updated_at)}"%> <br/>
|
6
|
-
<%= link_to "Elimina", active_metadata_destroy_attachment_path(attachment.
|
6
|
+
<%= link_to "Elimina", active_metadata_destroy_attachment_path(attachment.model_class, attachment.model_id,attachment.label,attachment.id), :method => :delete, :remote => true %>
|
7
7
|
</li>
|
@@ -4,8 +4,8 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
|
|
4
4
|
create_table :active_metadata_notes do |t|
|
5
5
|
t.text :note
|
6
6
|
t.string :label
|
7
|
-
t.string :
|
8
|
-
t.integer :
|
7
|
+
t.string :model_class
|
8
|
+
t.integer :model_id
|
9
9
|
t.integer :created_by
|
10
10
|
t.integer :updated_by
|
11
11
|
t.boolean :starred
|
@@ -13,29 +13,29 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
|
|
13
13
|
t.timestamps
|
14
14
|
end
|
15
15
|
|
16
|
-
add_index :active_metadata_notes, :
|
16
|
+
add_index :active_metadata_notes, :model_id
|
17
17
|
add_index :active_metadata_notes, :label
|
18
18
|
add_index :active_metadata_notes, :updated_at
|
19
|
-
add_index :active_metadata_notes, :
|
19
|
+
add_index :active_metadata_notes, :model_class
|
20
20
|
|
21
21
|
create_table :active_metadata_histories do |t|
|
22
22
|
t.text :value
|
23
23
|
t.string :label
|
24
|
-
t.string :
|
25
|
-
t.integer :
|
24
|
+
t.string :model_class
|
25
|
+
t.integer :model_id
|
26
26
|
t.integer :created_by
|
27
27
|
t.timestamps
|
28
28
|
end
|
29
29
|
|
30
|
-
add_index :active_metadata_histories, :
|
30
|
+
add_index :active_metadata_histories, :model_id
|
31
31
|
add_index :active_metadata_histories, :label
|
32
32
|
add_index :active_metadata_histories, :created_at
|
33
|
-
add_index :active_metadata_histories, :
|
33
|
+
add_index :active_metadata_histories, :model_class
|
34
34
|
|
35
35
|
create_table :active_metadata_attachments do |t|
|
36
36
|
t.string :label
|
37
|
-
t.integer :
|
38
|
-
t.string :
|
37
|
+
t.integer :model_id
|
38
|
+
t.string :model_class
|
39
39
|
t.integer :created_by
|
40
40
|
t.integer :updated_by
|
41
41
|
t.integer :counter
|
@@ -48,20 +48,20 @@ class ActiveMetadataMigrations < ActiveRecord::Migration
|
|
48
48
|
t.timestamps
|
49
49
|
end
|
50
50
|
|
51
|
-
add_index :active_metadata_attachments, :
|
51
|
+
add_index :active_metadata_attachments, :model_id
|
52
52
|
add_index :active_metadata_attachments, :label
|
53
53
|
add_index :active_metadata_attachments, :attach_updated_at
|
54
|
-
add_index :active_metadata_attachments, :
|
54
|
+
add_index :active_metadata_attachments, :model_class
|
55
55
|
|
56
56
|
create_table :active_metadata_watchers do |t|
|
57
57
|
t.integer :owner_id
|
58
58
|
t.string :label
|
59
|
-
t.string :
|
60
|
-
t.integer :
|
59
|
+
t.string :model_class
|
60
|
+
t.integer :model_id
|
61
61
|
t.timestamps
|
62
62
|
end
|
63
63
|
|
64
|
-
add_index :active_metadata_watchers, :
|
64
|
+
add_index :active_metadata_watchers, :model_id
|
65
65
|
add_index :active_metadata_watchers, :label
|
66
66
|
add_index :active_metadata_watchers, :owner_id
|
67
67
|
add_index :active_metadata_watchers, :created_at
|
data/lib/active_metadata/base.rb
CHANGED
@@ -8,8 +8,8 @@ module ActiveMetadata::Persistence::Attachment
|
|
8
8
|
|
9
9
|
def save_attachment_for(field, file, starred=false, group=nil)
|
10
10
|
attachment = ActiveMetadata::Attachment.create!(
|
11
|
-
:
|
12
|
-
:
|
11
|
+
:model_class => metadata_class,
|
12
|
+
:model_id => metadata_id,
|
13
13
|
:label => field,
|
14
14
|
:attach => file,
|
15
15
|
:starred => !!starred,
|
@@ -100,7 +100,7 @@ module ActiveMetadata::Persistence::Attachment
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def fetch_attachments_for(field, starred=nil, order_by="updated_at DESC")
|
103
|
-
conditions = {:
|
103
|
+
conditions = {:model_class => metadata_class, :model_id => metadata_id}
|
104
104
|
conditions[:label] = field unless field.nil?
|
105
105
|
conditions[:starred] = starred unless starred.nil?
|
106
106
|
ActiveMetadata::Attachment.all(:conditions => conditions, :order => order_by)
|
@@ -10,7 +10,7 @@ module ActiveMetadata::Persistence::History
|
|
10
10
|
return if ActiveMetadata.skip_history?
|
11
11
|
self.changes.each do |key, value|
|
12
12
|
next if ActiveMetadata::CONFIG['history_skip_fields'].include?(key)
|
13
|
-
ActiveMetadata::History.create! :value => value[1],:
|
13
|
+
ActiveMetadata::History.create! :value => value[1],:model_class => metadata_class, :model_id => metadata_id,:label => key.to_s, :created_by => current_user_id
|
14
14
|
invalidate_history_cache_for key.to_s
|
15
15
|
self.send(:send_notification, key, value[0], value[1], :history_message, current_user_id)
|
16
16
|
end
|
@@ -29,7 +29,7 @@ module ActiveMetadata::Persistence::History
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def fetch_histories_for field, order
|
32
|
-
ActiveMetadata::History.all(:conditions => {:
|
32
|
+
ActiveMetadata::History.all(:conditions => {:model_class => metadata_class, :model_id => metadata_id,:label => field}, :order => order)
|
33
33
|
end
|
34
34
|
|
35
35
|
|
@@ -8,8 +8,8 @@ module ActiveMetadata::Persistence::Note
|
|
8
8
|
|
9
9
|
def create_note_for(field, note, starred=nil, group=nil)
|
10
10
|
ActiveMetadata::Note.create!(
|
11
|
-
:
|
12
|
-
:
|
11
|
+
:model_id => metadata_id,
|
12
|
+
:model_class => metadata_class,
|
13
13
|
:label => field.to_s,
|
14
14
|
:note => note,
|
15
15
|
:created_by => current_user_id,
|
@@ -108,7 +108,7 @@ module ActiveMetadata::Persistence::Note
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def fetch_notes_for(field, starred=nil, order_by="updated_at DESC")
|
111
|
-
conditions = {:
|
111
|
+
conditions = {:model_class => metadata_class, :model_id => metadata_id}
|
112
112
|
conditions[:label] = field unless field.nil?
|
113
113
|
conditions[:starred] = starred unless starred.nil?
|
114
114
|
ActiveMetadata::Note.all(:conditions => conditions, :order => order_by)
|
@@ -7,7 +7,7 @@ module ActiveMetadata::Persistence::Watcher
|
|
7
7
|
module InstanceMethods
|
8
8
|
def create_watcher_for(field, owner)
|
9
9
|
raise RuntimeError, "The object id MUST be valued" unless self.id
|
10
|
-
ActiveMetadata::Watcher.create! :
|
10
|
+
ActiveMetadata::Watcher.create! :model_class => metadata_class, :model_id => metadata_id, :label => field, :owner_id => owner.id
|
11
11
|
end
|
12
12
|
|
13
13
|
# return all the watches related to a passed field.
|
@@ -15,19 +15,19 @@ module ActiveMetadata::Persistence::Watcher
|
|
15
15
|
# matches are returned grouped by owner and contains records that define or not a particular model instance watching
|
16
16
|
def watchers_for(field)
|
17
17
|
ActiveMetadata::Watcher.select("distinct(owner_id)").where(
|
18
|
-
"
|
19
|
-
{ :
|
18
|
+
"model_class = :model_class AND label = :label AND (model_id = :model_id OR model_id IS NULL)",
|
19
|
+
{ :model_class => metadata_class, :label => field, :model_id => metadata_id }
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
23
|
def delete_watcher_for(field, owner)
|
24
|
-
ActiveMetadata::Watcher.where(:
|
24
|
+
ActiveMetadata::Watcher.where(:model_id => metadata_id, :label => field, :owner_id => owner.id).each do |watcher|
|
25
25
|
watcher.destroy
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def is_watched_by(field,owner)
|
30
|
-
ActiveMetadata::Watcher.where(:
|
30
|
+
ActiveMetadata::Watcher.where(:model_class => metadata_class, :model_id => metadata_id, :label => field, :owner_id => owner.id).empty? ? false : true
|
31
31
|
end
|
32
32
|
|
33
33
|
def send_notification(field, old_value, new_value, type=:default_message, created_by=nil)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ActiveMetadata::ValueFormatter
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
def value
|
5
|
+
instance = model_class.constantize.new
|
6
|
+
return read_attribute(:value).to_s unless instance.respond_to?(label.to_sym)
|
7
|
+
instance.send :write_attribute, label.to_sym, read_attribute(:value)
|
8
|
+
instance.send label
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -15,8 +15,8 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
15
15
|
|
16
16
|
create_table "active_metadata_attachments", :force => true do |t|
|
17
17
|
t.string "label"
|
18
|
-
t.integer "
|
19
|
-
t.string "
|
18
|
+
t.integer "model_id"
|
19
|
+
t.string "model_class"
|
20
20
|
t.integer "created_by"
|
21
21
|
t.integer "updated_by"
|
22
22
|
t.integer "counter"
|
@@ -31,30 +31,30 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
add_index "active_metadata_attachments", ["attach_updated_at"], :name => "index_active_metadata_attachments_on_attach_updated_at"
|
34
|
-
add_index "active_metadata_attachments", ["
|
35
|
-
add_index "active_metadata_attachments", ["
|
34
|
+
add_index "active_metadata_attachments", ["model_class"], :name => "index_active_metadata_attachments_on_model_class"
|
35
|
+
add_index "active_metadata_attachments", ["model_id"], :name => "index_active_metadata_attachments_on_model_id"
|
36
36
|
add_index "active_metadata_attachments", ["label"], :name => "index_active_metadata_attachments_on_label"
|
37
37
|
|
38
38
|
create_table "active_metadata_histories", :force => true do |t|
|
39
39
|
t.text "value"
|
40
40
|
t.string "label"
|
41
|
-
t.string "
|
42
|
-
t.integer "
|
41
|
+
t.string "model_class"
|
42
|
+
t.integer "model_id"
|
43
43
|
t.integer "created_by"
|
44
|
-
t.datetime "created_at",
|
45
|
-
t.datetime "updated_at",
|
44
|
+
t.datetime "created_at", :null => false
|
45
|
+
t.datetime "updated_at", :null => false
|
46
46
|
end
|
47
47
|
|
48
48
|
add_index "active_metadata_histories", ["created_at"], :name => "index_active_metadata_histories_on_created_at"
|
49
|
-
add_index "active_metadata_histories", ["document_class"], :name => "index_active_metadata_histories_on_document_class"
|
50
|
-
add_index "active_metadata_histories", ["document_id"], :name => "index_active_metadata_histories_on_document_id"
|
51
49
|
add_index "active_metadata_histories", ["label"], :name => "index_active_metadata_histories_on_label"
|
50
|
+
add_index "active_metadata_histories", ["model_class"], :name => "index_active_metadata_histories_on_model_class"
|
51
|
+
add_index "active_metadata_histories", ["model_id"], :name => "index_active_metadata_histories_on_model_id"
|
52
52
|
|
53
53
|
create_table "active_metadata_notes", :force => true do |t|
|
54
54
|
t.text "note"
|
55
55
|
t.string "label"
|
56
|
-
t.string "
|
57
|
-
t.integer "
|
56
|
+
t.string "model_class"
|
57
|
+
t.integer "model_id"
|
58
58
|
t.integer "created_by"
|
59
59
|
t.integer "updated_by"
|
60
60
|
t.boolean "starred"
|
@@ -63,23 +63,56 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
63
63
|
t.datetime "updated_at", :null => false
|
64
64
|
end
|
65
65
|
|
66
|
-
add_index "active_metadata_notes", ["
|
67
|
-
add_index "active_metadata_notes", ["
|
66
|
+
add_index "active_metadata_notes", ["model_class"], :name => "index_active_metadata_notes_on_model_class"
|
67
|
+
add_index "active_metadata_notes", ["model_id"], :name => "index_active_metadata_notes_on_model_id"
|
68
68
|
add_index "active_metadata_notes", ["label"], :name => "index_active_metadata_notes_on_label"
|
69
69
|
add_index "active_metadata_notes", ["updated_at"], :name => "index_active_metadata_notes_on_updated_at"
|
70
70
|
|
71
71
|
create_table "active_metadata_watchers", :force => true do |t|
|
72
72
|
t.integer "owner_id"
|
73
73
|
t.string "label"
|
74
|
-
t.string "
|
75
|
-
t.integer "
|
74
|
+
t.string "model_class"
|
75
|
+
t.integer "model_id"
|
76
76
|
t.datetime "created_at", :null => false
|
77
77
|
t.datetime "updated_at", :null => false
|
78
78
|
end
|
79
79
|
|
80
80
|
add_index "active_metadata_watchers", ["created_at"], :name => "index_active_metadata_watchers_on_created_at"
|
81
|
-
add_index "active_metadata_watchers", ["
|
81
|
+
add_index "active_metadata_watchers", ["model_id"], :name => "index_active_metadata_watchers_on_model_id"
|
82
82
|
add_index "active_metadata_watchers", ["label"], :name => "index_active_metadata_watchers_on_label"
|
83
83
|
add_index "active_metadata_watchers", ["owner_id"], :name => "index_active_metadata_watchers_on_owner_id"
|
84
84
|
|
85
|
+
create_table "chapters", :force => true do |t|
|
86
|
+
t.string "title"
|
87
|
+
t.datetime "created_at", :null => false
|
88
|
+
t.datetime "updated_at", :null => false
|
89
|
+
end
|
90
|
+
|
91
|
+
create_table "documents", :force => true do |t|
|
92
|
+
t.string "name"
|
93
|
+
t.string "surname"
|
94
|
+
t.boolean "keep_alive"
|
95
|
+
t.datetime "date"
|
96
|
+
t.decimal "price", :precision => 6, :scale => 2
|
97
|
+
t.decimal "average", :precision => 6, :scale => 3
|
98
|
+
t.datetime "created_at", :null => false
|
99
|
+
t.datetime "updated_at", :null => false
|
100
|
+
end
|
101
|
+
|
102
|
+
create_table "sections", :force => true do |t|
|
103
|
+
t.string "title"
|
104
|
+
t.integer "model_id"
|
105
|
+
t.integer "chapter_id"
|
106
|
+
t.datetime "created_at", :null => false
|
107
|
+
t.datetime "updated_at", :null => false
|
108
|
+
end
|
109
|
+
|
110
|
+
create_table "users", :force => true do |t|
|
111
|
+
t.string "email"
|
112
|
+
t.string "firstname"
|
113
|
+
t.string "lastname"
|
114
|
+
t.datetime "created_at", :null => false
|
115
|
+
t.datetime "updated_at", :null => false
|
116
|
+
end
|
117
|
+
|
85
118
|
end
|
@@ -25,7 +25,7 @@ describe ActiveMetadata do
|
|
25
25
|
|
26
26
|
it "should verify that the attachment metadata id refers to the correct self id" do
|
27
27
|
@document.save_attachment_for(:name, @attachment)
|
28
|
-
@document.attachments_for(:name).last.
|
28
|
+
@document.attachments_for(:name).last.model_id.should eq @document.id
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should verify that the attachment file name is correctly saved" do
|
@@ -51,7 +51,7 @@ describe ActiveMetadata do
|
|
51
51
|
it "should verify that the document has been saved in the correct position on filesystem" do
|
52
52
|
@document.save_attachment_for(:name, @attachment)
|
53
53
|
att = @document.attachments_for(:name).first
|
54
|
-
expected_path = File.expand_path "#{ActiveMetadata::CONFIG['attachment_base_path']}/#{att.
|
54
|
+
expected_path = File.expand_path "#{ActiveMetadata::CONFIG['attachment_base_path']}/#{att.model_class}/#{@document.id}/#{:name.to_s}/#{att.id}/#{@attachment.original_filename}"
|
55
55
|
File.exists?(expected_path).should be_true
|
56
56
|
end
|
57
57
|
|
data/spec/lib/history_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe ActiveMetadata do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should verify that histories are created for the correct model" do
|
22
|
-
@document.history_for(:name)[0].
|
22
|
+
@document.history_for(:name)[0].model_class.should eq(@document.class.to_s)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should save the craeted_at datetime anytime an history entry is created" do
|
@@ -46,10 +46,10 @@ describe ActiveMetadata do
|
|
46
46
|
|
47
47
|
# expectations
|
48
48
|
@document.history_for(:name).count.should eq(1)
|
49
|
-
@document.history_for(:name).last.
|
49
|
+
@document.history_for(:name).last.model_id.should eq @document.id
|
50
50
|
|
51
51
|
@section.history_for(:title).count.should eq(1)
|
52
|
-
@section.history_for(:title).last.
|
52
|
+
@section.history_for(:title).last.model_id.should eq @document.id
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should verify that history_for sort by created_at descending" do
|
data/spec/lib/notes_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe ActiveMetadata do
|
|
24
24
|
|
25
25
|
it "should verify that notes are created for the correct model" do
|
26
26
|
@document.create_note_for(:name, "Very important note!")
|
27
|
-
@document.notes_for(:name).last.
|
27
|
+
@document.notes_for(:name).last.model_class.should eq(@document.class.to_s)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should verify the created_by of a note created" do
|
@@ -101,8 +101,8 @@ describe ActiveMetadata do
|
|
101
101
|
@section.create_note_for(:title, "Very important note for section!")
|
102
102
|
|
103
103
|
# expectations
|
104
|
-
@document.notes_for(:name).last.
|
105
|
-
@section.notes_for(:title).last.
|
104
|
+
@document.notes_for(:name).last.model_id.should eq @document.id
|
105
|
+
@section.notes_for(:title).last.model_id.should eq @document.id
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should delete a note id" do
|
data/spec/lib/watchers_spec.rb
CHANGED
@@ -65,7 +65,7 @@ describe ActiveMetadata do
|
|
65
65
|
@user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
66
66
|
@another_user = User.create!(:email => "email2@email.it", :firstname => 'George', :lastname => 'Washington' )
|
67
67
|
@document.create_watcher_for(:name, @user)
|
68
|
-
ActiveMetadata::Watcher.create! :
|
68
|
+
ActiveMetadata::Watcher.create! :model_class => "Document", :label => :name, :owner_id => @another_user.id
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should return all the records that match model/field" do
|
@@ -75,7 +75,7 @@ describe ActiveMetadata do
|
|
75
75
|
|
76
76
|
it "should group result by owner" do
|
77
77
|
@document.create_watcher_for(:name, @another_user)
|
78
|
-
ActiveMetadata::Watcher.create! :
|
78
|
+
ActiveMetadata::Watcher.create! :model_class => "Document", :label => :name, :owner_id => @user.id
|
79
79
|
docs = @document.watchers_for(:name)
|
80
80
|
docs.count.should eq 2
|
81
81
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
|
4
|
+
describe ActiveMetadata::History do
|
5
|
+
|
6
|
+
describe "#value" do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@h1 = ActiveMetadata::History.create! model_class: "Document", label: "name", value: "nome"
|
10
|
+
@h2 = ActiveMetadata::History.create! model_class: "Document", label: "keep_alive", value: true
|
11
|
+
@h3 = ActiveMetadata::History.create! model_class: "Document", label: "date", value: Time.now
|
12
|
+
@h4 = ActiveMetadata::History.create! model_class: "Document", label: "price", value: 10.12
|
13
|
+
@h5 = ActiveMetadata::History.create! model_class: "Document", label: "average", value: 10.123
|
14
|
+
@h6 = ActiveMetadata::History.create! model_class: "Document", label: "does_not_exists", value: "pippo"
|
15
|
+
@h7 = ActiveMetadata::History.create! model_class: "Document", label: "keep_alive", value: nil
|
16
|
+
end
|
17
|
+
|
18
|
+
specify{ @h1.value.should eq "nome" }
|
19
|
+
specify{ @h2.value.should eq true }
|
20
|
+
specify{ @h3.value.should be_kind_of ActiveSupport::TimeWithZone }
|
21
|
+
specify{ @h4.value.should be_kind_of BigDecimal }
|
22
|
+
specify{ @h4.value.to_s.should eq "10.12" }
|
23
|
+
specify{ @h5.value.should be_kind_of BigDecimal }
|
24
|
+
specify{ @h5.value.to_s.should eq "10.123" }
|
25
|
+
specify{ @h6.value.to_s.should eq "pippo" }
|
26
|
+
specify{ @h7.value.should eq nil }
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/migrations.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- lib/active_metadata/persistence/persistence.rb
|
177
177
|
- lib/active_metadata/persistence/watcher.rb
|
178
178
|
- lib/active_metadata/stream.rb
|
179
|
+
- lib/active_metadata/value_formatter.rb
|
179
180
|
- lib/active_metadata/version.rb
|
180
181
|
- lib/active_metadata.rb
|
181
182
|
- lib/tasks/active_metadata_tasks.rake
|
@@ -235,6 +236,7 @@ files:
|
|
235
236
|
- spec/lib/notes_spec.rb
|
236
237
|
- spec/lib/stream_spec.rb
|
237
238
|
- spec/lib/watchers_spec.rb
|
239
|
+
- spec/models/history_spec.rb
|
238
240
|
- spec/routing/active_metadata/stream_controller_routing_spec.rb
|
239
241
|
- spec/spec_helper.rb
|
240
242
|
- spec/support/chapter.rb
|
@@ -261,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
261
263
|
version: '0'
|
262
264
|
segments:
|
263
265
|
- 0
|
264
|
-
hash:
|
266
|
+
hash: -3806434619195871137
|
265
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
268
|
none: false
|
267
269
|
requirements:
|
@@ -270,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
272
|
version: '0'
|
271
273
|
segments:
|
272
274
|
- 0
|
273
|
-
hash:
|
275
|
+
hash: -3806434619195871137
|
274
276
|
requirements: []
|
275
277
|
rubyforge_project: active_metadata
|
276
278
|
rubygems_version: 1.8.19
|
@@ -331,6 +333,7 @@ test_files:
|
|
331
333
|
- spec/lib/notes_spec.rb
|
332
334
|
- spec/lib/stream_spec.rb
|
333
335
|
- spec/lib/watchers_spec.rb
|
336
|
+
- spec/models/history_spec.rb
|
334
337
|
- spec/routing/active_metadata/stream_controller_routing_spec.rb
|
335
338
|
- spec/spec_helper.rb
|
336
339
|
- spec/support/chapter.rb
|