active_metadata 0.6.0 → 0.6.1
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/README.md +5 -0
- data/lib/active_metadata/base.rb +1 -0
- data/lib/active_metadata/version.rb +1 -1
- data/spec/{active_metadata_yml.rb → config/active_metadata_yml_spec.rb} +0 -0
- data/spec/lib/active_metadata_spec.rb +37 -0
- data/spec/{attachments_spec.rb → lib/attachments_spec.rb} +2 -2
- data/spec/{concurrency_spec.rb → lib/concurrency_spec.rb} +0 -0
- data/spec/lib/history_spec.rb +81 -0
- data/spec/{notes_spec.rb → lib/notes_spec.rb} +0 -0
- data/spec/{streamable_spec.rb → lib/streamable_spec.rb} +0 -0
- data/spec/lib/watchers_spec.rb +60 -0
- metadata +36 -34
- data/spec/active_metadata_spec.rb +0 -159
- data/spec/dummy/db/test.sqlite3 +0 -0
data/README.md
CHANGED
data/lib/active_metadata/base.rb
CHANGED
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "rack/test/uploaded_file"
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
describe ActiveMetadata do
|
6
|
+
|
7
|
+
context "model methods" do
|
8
|
+
|
9
|
+
it "should exist a method acts_as_metadata in the model" do
|
10
|
+
Document.respond_to?(:acts_as_metadata).should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should find the active_metadata_ancestors if no active_metadata_ancestors params has been provided" do
|
14
|
+
@document = Document.create! { |d| d.name = "John" }
|
15
|
+
@document.metadata_id.should eq @document.id
|
16
|
+
@document.metadata_class.should eq @document.class.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should find the metadata_root.id if an active_metadata_ancestors params has been specified" do
|
20
|
+
@document = Document.create! { |d| d.name = "John" }
|
21
|
+
@section = @document.create_section :title => "new section"
|
22
|
+
@section.metadata_id.should eq @document.id
|
23
|
+
@section.metadata_class.should eq @document.class.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "saving a child object before active_metadata_ancestors" do
|
29
|
+
|
30
|
+
it "should raise an exception cause ancestor id is not defined" do
|
31
|
+
lambda{Section.create! :title => 'section title'}.should raise_error(RuntimeError,"[active_metdata] - Ancestor model is not yet persisted")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
@@ -9,9 +9,9 @@ describe ActiveMetadata do
|
|
9
9
|
before(:each) do
|
10
10
|
@document = Document.create! { |d| d.name = "John" }
|
11
11
|
@document.reload
|
12
|
-
doc = File.expand_path('
|
12
|
+
doc = File.expand_path('../../support/pdf_test.pdf', __FILE__)
|
13
13
|
@attachment = Rack::Test::UploadedFile.new(doc, "application/pdf")
|
14
|
-
doc2 = File.expand_path('
|
14
|
+
doc2 = File.expand_path('../../support/pdf_test_2.pdf', __FILE__)
|
15
15
|
@attachment2 = Rack::Test::UploadedFile.new(doc2, "application/pdf")
|
16
16
|
end
|
17
17
|
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "time"
|
3
|
+
|
4
|
+
describe ActiveMetadata do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@document = Document.create! { |d| d.name = "John" }
|
8
|
+
@document.reload
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "history" do
|
12
|
+
|
13
|
+
it "should create history when a document is created" do
|
14
|
+
@document.history_for(:name).should have(1).record
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should create history for a defined field when a document is created" do
|
18
|
+
@document.history_for(:name)[0].value.should eq(@document.name)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should verify that histories are created for the correct model" do
|
22
|
+
@document.history_for(:name)[0].document_class.should eq(@document.class.to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should save the craeted_at datetime anytime an history entry is created" do
|
26
|
+
@document.history_for(:name)[0].created_at.should be_a_kind_of Time
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should verify that history return records only for the self document" do
|
30
|
+
# fixtures
|
31
|
+
@another_doc = Document.create :name => "Andrea"
|
32
|
+
@another_doc.reload
|
33
|
+
|
34
|
+
# expectations
|
35
|
+
@document.history_for(:name).count.should eq(1)
|
36
|
+
@another_doc.history_for(:name).count.should eq(1)
|
37
|
+
|
38
|
+
@document.history_for(:name).last.value.should eq @document.name
|
39
|
+
@another_doc.history_for(:name).last.value.should eq @another_doc.name
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should verify that history is saved with the correct model id if metadata_id_from is defined" do
|
43
|
+
# fixtures
|
44
|
+
@section = @document.create_section :title => "new section"
|
45
|
+
@section.reload
|
46
|
+
|
47
|
+
# expectations
|
48
|
+
@document.history_for(:name).count.should eq(1)
|
49
|
+
@document.history_for(:name).last.document_id.should eq @document.id
|
50
|
+
|
51
|
+
@section.history_for(:title).count.should eq(1)
|
52
|
+
@section.history_for(:title).last.document_id.should eq @document.id
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should verify that history_for sort by created_at descending" do
|
56
|
+
#fixtures
|
57
|
+
3.times do |i|
|
58
|
+
sleep 0.1.seconds
|
59
|
+
@document.name = "name #{i}"
|
60
|
+
@document.save
|
61
|
+
end
|
62
|
+
|
63
|
+
#expectations
|
64
|
+
@document.history_for(:name).first.value.should eq "name 2"
|
65
|
+
@document.history_for(:name).last.value.should eq "John"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should verify that no history is craeted for the skipped field defined in the config file" do
|
69
|
+
@document.history_for(:name).should have(1).record
|
70
|
+
@document.history_for(:id).should have(0).record
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should save the correct creator when a history is created" do
|
74
|
+
current_user = User.current
|
75
|
+
history = @document.history_for(:name).first
|
76
|
+
history.created_by.should eq current_user.id
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "time"
|
3
|
+
|
4
|
+
describe ActiveMetadata do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@document = Document.create! { |d| d.name = "John" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "watchers" do
|
11
|
+
|
12
|
+
it "should create a watcher for a given field" do
|
13
|
+
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
14
|
+
@document.create_watcher_for(:name, user)
|
15
|
+
@document.watchers_for(:name).should have(1).record
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should delete a watcher for a given field" do
|
19
|
+
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
20
|
+
@document.create_watcher_for(:name, user)
|
21
|
+
@document.watchers_for(:name).should have(1).record
|
22
|
+
|
23
|
+
@document.delete_watcher_for :name, user
|
24
|
+
@document.watchers_for(:name).should have(0).record
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return false if field is not watched by the passed user" do
|
28
|
+
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
29
|
+
another_user = User.create!(:email => "email2@email.it", :firstname => 'George', :lastname => 'Washington' )
|
30
|
+
|
31
|
+
@document.create_watcher_for(:name, user)
|
32
|
+
@document.is_watched_by(:name,user).should be_true
|
33
|
+
@document.is_watched_by(:name,another_user).should be_false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
it "should create an unread message by default" do
|
38
|
+
pending "to be moved in virgilio project"
|
39
|
+
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
40
|
+
@document.create_watcher_for(:name, user)
|
41
|
+
@document.update_attribute(:name, 'new_value')
|
42
|
+
|
43
|
+
|
44
|
+
user.inbox.messages.should have(1).record
|
45
|
+
user.inbox.messages.first.read.should be_false
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should read an unread message" do
|
49
|
+
pending "to be moved in virgilio project"
|
50
|
+
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
51
|
+
@document.create_watcher_for(:name, user)
|
52
|
+
@document.update_attribute(:name, 'new_value')
|
53
|
+
alert_message = user.inbox.messages.first
|
54
|
+
alert_message.mark_as_read
|
55
|
+
user.inbox.messages.first.read.should be_true
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-02 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
-
requirement: &
|
17
|
+
requirement: &70232523285620 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.2.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70232523285620
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: sqlite3
|
28
|
-
requirement: &
|
28
|
+
requirement: &70232534468540 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70232534468540
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec-rails
|
39
|
-
requirement: &
|
39
|
+
requirement: &70232534468080 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70232534468080
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: sqlite3
|
50
|
-
requirement: &
|
50
|
+
requirement: &70232534467660 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70232534467660
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: sqlite3-ruby
|
61
|
-
requirement: &
|
61
|
+
requirement: &70232534467240 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70232534467240
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: cucumber-rails
|
72
|
-
requirement: &
|
72
|
+
requirement: &70232534466820 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70232534466820
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: ci_reporter
|
83
|
-
requirement: &
|
83
|
+
requirement: &70232534466400 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70232534466400
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: paperclip
|
94
|
-
requirement: &
|
94
|
+
requirement: &70232534465980 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :runtime
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70232534465980
|
103
103
|
description: First implementation will write metadata on mongodb
|
104
104
|
email:
|
105
105
|
- acampolonghi@gmail.com
|
@@ -166,10 +166,7 @@ files:
|
|
166
166
|
- features/supports/file.txt
|
167
167
|
- features/supports/updated_file.txt
|
168
168
|
- features/trigger_alert_on_modify.feature
|
169
|
-
- spec/
|
170
|
-
- spec/active_metadata_yml.rb
|
171
|
-
- spec/attachments_spec.rb
|
172
|
-
- spec/concurrency_spec.rb
|
169
|
+
- spec/config/active_metadata_yml_spec.rb
|
173
170
|
- spec/controllers/active_metadata/attachments_controller_spec.rb
|
174
171
|
- spec/controllers/active_metadata/notes_controller_spec.rb
|
175
172
|
- spec/controllers/active_metadata/stream_controller_spec.rb
|
@@ -200,7 +197,6 @@ files:
|
|
200
197
|
- spec/dummy/config/routes.rb
|
201
198
|
- spec/dummy/db/development.sqlite3
|
202
199
|
- spec/dummy/db/schema.rb
|
203
|
-
- spec/dummy/db/test.sqlite3
|
204
200
|
- spec/dummy/lib/assets/.gitkeep
|
205
201
|
- spec/dummy/log/.gitkeep
|
206
202
|
- spec/dummy/public/404.html
|
@@ -209,10 +205,15 @@ files:
|
|
209
205
|
- spec/dummy/public/favicon.ico
|
210
206
|
- spec/dummy/script/rails
|
211
207
|
- spec/helpers/active_metadata/stream_helpers_spec.rb
|
212
|
-
- spec/
|
208
|
+
- spec/lib/active_metadata_spec.rb
|
209
|
+
- spec/lib/attachments_spec.rb
|
210
|
+
- spec/lib/concurrency_spec.rb
|
211
|
+
- spec/lib/history_spec.rb
|
212
|
+
- spec/lib/notes_spec.rb
|
213
|
+
- spec/lib/streamable_spec.rb
|
214
|
+
- spec/lib/watchers_spec.rb
|
213
215
|
- spec/routing/active_metadata/stream_controller_routing_spec.rb
|
214
216
|
- spec/spec_helper.rb
|
215
|
-
- spec/streamable_spec.rb
|
216
217
|
- spec/support/document.rb
|
217
218
|
- spec/support/pdf_test.pdf
|
218
219
|
- spec/support/pdf_test_1.pdf
|
@@ -235,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
236
|
version: '0'
|
236
237
|
segments:
|
237
238
|
- 0
|
238
|
-
hash:
|
239
|
+
hash: 2230512507408660016
|
239
240
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
241
|
none: false
|
241
242
|
requirements:
|
@@ -244,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
245
|
version: '0'
|
245
246
|
segments:
|
246
247
|
- 0
|
247
|
-
hash:
|
248
|
+
hash: 2230512507408660016
|
248
249
|
requirements: []
|
249
250
|
rubyforge_project: active_metadata
|
250
251
|
rubygems_version: 1.8.10
|
@@ -259,10 +260,7 @@ test_files:
|
|
259
260
|
- features/supports/file.txt
|
260
261
|
- features/supports/updated_file.txt
|
261
262
|
- features/trigger_alert_on_modify.feature
|
262
|
-
- spec/
|
263
|
-
- spec/active_metadata_yml.rb
|
264
|
-
- spec/attachments_spec.rb
|
265
|
-
- spec/concurrency_spec.rb
|
263
|
+
- spec/config/active_metadata_yml_spec.rb
|
266
264
|
- spec/controllers/active_metadata/attachments_controller_spec.rb
|
267
265
|
- spec/controllers/active_metadata/notes_controller_spec.rb
|
268
266
|
- spec/controllers/active_metadata/stream_controller_spec.rb
|
@@ -293,7 +291,6 @@ test_files:
|
|
293
291
|
- spec/dummy/config/routes.rb
|
294
292
|
- spec/dummy/db/development.sqlite3
|
295
293
|
- spec/dummy/db/schema.rb
|
296
|
-
- spec/dummy/db/test.sqlite3
|
297
294
|
- spec/dummy/lib/assets/.gitkeep
|
298
295
|
- spec/dummy/log/.gitkeep
|
299
296
|
- spec/dummy/public/404.html
|
@@ -302,10 +299,15 @@ test_files:
|
|
302
299
|
- spec/dummy/public/favicon.ico
|
303
300
|
- spec/dummy/script/rails
|
304
301
|
- spec/helpers/active_metadata/stream_helpers_spec.rb
|
305
|
-
- spec/
|
302
|
+
- spec/lib/active_metadata_spec.rb
|
303
|
+
- spec/lib/attachments_spec.rb
|
304
|
+
- spec/lib/concurrency_spec.rb
|
305
|
+
- spec/lib/history_spec.rb
|
306
|
+
- spec/lib/notes_spec.rb
|
307
|
+
- spec/lib/streamable_spec.rb
|
308
|
+
- spec/lib/watchers_spec.rb
|
306
309
|
- spec/routing/active_metadata/stream_controller_routing_spec.rb
|
307
310
|
- spec/spec_helper.rb
|
308
|
-
- spec/streamable_spec.rb
|
309
311
|
- spec/support/document.rb
|
310
312
|
- spec/support/pdf_test.pdf
|
311
313
|
- spec/support/pdf_test_1.pdf
|
@@ -1,159 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "rack/test/uploaded_file"
|
3
|
-
require "time"
|
4
|
-
|
5
|
-
describe ActiveMetadata do
|
6
|
-
|
7
|
-
context "model methods" do
|
8
|
-
|
9
|
-
it "should exist a method acts_as_metadata in the model" do
|
10
|
-
Document.respond_to?(:acts_as_metadata).should be_true
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should find the active_metadata_ancestors if no active_metadata_ancestors params has been provided" do
|
14
|
-
@document = Document.create! { |d| d.name = "John" }
|
15
|
-
@document.reload
|
16
|
-
@document.metadata_id.should eq @document.id
|
17
|
-
@document.metadata_class.should eq @document.class.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should find the metadata_root.id if an active_metadata_ancestors params has been specified" do
|
21
|
-
@document = Document.create! { |d| d.name = "John" }
|
22
|
-
@document.reload
|
23
|
-
@section = @document.create_section :title => "new section"
|
24
|
-
@section.reload
|
25
|
-
@section.metadata_id.should eq @document.id
|
26
|
-
@section.metadata_class.should eq @document.class.to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
context "history" do
|
32
|
-
|
33
|
-
before(:each) do
|
34
|
-
@document = Document.create! { |d| d.name = "John" }
|
35
|
-
@document.reload
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should create history when a document is created" do
|
39
|
-
@document.history_for(:name).should have(1).record
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should create history for a defined field when a document is created" do
|
43
|
-
@document.history_for(:name)[0].value.should eq(@document.name)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should verify that histories are created for the correct model" do
|
47
|
-
@document.history_for(:name)[0].document_class.should eq(@document.class.to_s)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should save the craeted_at datetime anytime an history entry is created" do
|
51
|
-
@document.history_for(:name)[0].created_at.should be_a_kind_of Time
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should verify that history return records only for the self document" do
|
55
|
-
# fixtures
|
56
|
-
@another_doc = Document.create :name => "Andrea"
|
57
|
-
@another_doc.reload
|
58
|
-
|
59
|
-
# expectations
|
60
|
-
@document.history_for(:name).count.should eq(1)
|
61
|
-
@another_doc.history_for(:name).count.should eq(1)
|
62
|
-
|
63
|
-
@document.history_for(:name).last.value.should eq @document.name
|
64
|
-
@another_doc.history_for(:name).last.value.should eq @another_doc.name
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should verify that history is saved with the correct model id if metadata_id_from is defined" do
|
68
|
-
# fixtures
|
69
|
-
@section = @document.create_section :title => "new section"
|
70
|
-
@section.reload
|
71
|
-
|
72
|
-
# expectations
|
73
|
-
@document.history_for(:name).count.should eq(1)
|
74
|
-
@document.history_for(:name).last.document_id.should eq @document.id
|
75
|
-
|
76
|
-
@section.history_for(:title).count.should eq(1)
|
77
|
-
@section.history_for(:title).last.document_id.should eq @document.id
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should verify that history_for sort by created_at descending" do
|
81
|
-
#fixtures
|
82
|
-
3.times do |i|
|
83
|
-
sleep 0.1.seconds
|
84
|
-
@document.name = "name #{i}"
|
85
|
-
@document.save
|
86
|
-
end
|
87
|
-
|
88
|
-
#expectations
|
89
|
-
@document.history_for(:name).first.value.should eq "name 2"
|
90
|
-
@document.history_for(:name).last.value.should eq "John"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should verify that no history is craeted for the skipped field defined in the config file" do
|
94
|
-
@document.history_for(:name).should have(1).record
|
95
|
-
@document.history_for(:id).should have(0).record
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should save the correct creator when a history is created" do
|
99
|
-
current_user = User.current
|
100
|
-
history = @document.history_for(:name).first
|
101
|
-
history.created_by.should eq current_user.id
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
context "watchers" do
|
107
|
-
before(:each) do
|
108
|
-
@document = Document.create! { |d| d.name = "John" }
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should create a watcher for a given field" do
|
112
|
-
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
113
|
-
@document.create_watcher_for(:name, user)
|
114
|
-
@document.watchers_for(:name).should have(1).record
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should delete a watcher for a given field" do
|
118
|
-
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
119
|
-
@document.create_watcher_for(:name, user)
|
120
|
-
@document.watchers_for(:name).should have(1).record
|
121
|
-
|
122
|
-
@document.delete_watcher_for :name, user
|
123
|
-
@document.watchers_for(:name).should have(0).record
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should return false if field is not watched by the passed user" do
|
127
|
-
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
128
|
-
another_user = User.create!(:email => "email2@email.it", :firstname => 'George', :lastname => 'Washington' )
|
129
|
-
|
130
|
-
@document.create_watcher_for(:name, user)
|
131
|
-
@document.is_watched_by(:name,user).should be_true
|
132
|
-
@document.is_watched_by(:name,another_user).should be_false
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
it "should create an unread message by default" do
|
137
|
-
pending "to be moved in virgilio project"
|
138
|
-
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
139
|
-
@document.create_watcher_for(:name, user)
|
140
|
-
@document.update_attribute(:name, 'new_value')
|
141
|
-
|
142
|
-
|
143
|
-
user.inbox.messages.should have(1).record
|
144
|
-
user.inbox.messages.first.read.should be_false
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should read an unread message" do
|
148
|
-
pending "to be moved in virgilio project"
|
149
|
-
user = User.create!(:email => "email@email.it", :firstname => 'John', :lastname => 'smith' )
|
150
|
-
@document.create_watcher_for(:name, user)
|
151
|
-
@document.update_attribute(:name, 'new_value')
|
152
|
-
alert_message = user.inbox.messages.first
|
153
|
-
alert_message.mark_as_read
|
154
|
-
user.inbox.messages.first.read.should be_true
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
data/spec/dummy/db/test.sqlite3
DELETED
Binary file
|