mm-draft 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +20 -20
- data/Rakefile +26 -36
- data/lib/locale/en.yml +6 -6
- data/lib/{draft.rb → mm-draft.rb} +2 -2
- data/lib/mongo_mapper/plugins/draft/callbacks.rb +12 -12
- data/lib/mongo_mapper/plugins/draft/draft.rb +129 -129
- data/lib/mongo_mapper/plugins/draft/keys.rb +13 -13
- data/lib/mongo_mapper/plugins/draft/version.rb +5 -5
- data/test/models/monkey.rb +10 -10
- data/test/performance/models/monkey.rb +9 -9
- data/test/performance/models/monkey_no_draft.rb +7 -7
- data/test/performance/performance_helper.rb +15 -15
- data/test/performance/test/read_write.rb +28 -28
- data/test/test_helper.rb +39 -39
- data/test/unit/test_draft.rb +194 -194
- metadata +3 -3
data/Gemfile
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
source :rubygems
|
2
|
-
|
3
|
-
gem 'rake'
|
4
|
-
gem 'bson_ext', '>= 1.6.4'
|
5
|
-
gem 'multi_json', '>= 1.3.6'
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'jnunemaker-matchy', '>= 0.4', :require => 'matchy'
|
9
|
-
gem 'shoulda', '>= 3.1.1'
|
10
|
-
gem 'mocha', '>= 0.12.3'
|
11
|
-
gem 'database_cleaner', '>= 0.8.0'
|
12
|
-
end
|
13
|
-
|
14
|
-
group :development do
|
15
|
-
gem "wirble"
|
16
|
-
gem "hirb"
|
17
|
-
gem "awesome_print"
|
18
|
-
end
|
19
|
-
|
20
|
-
gemspec
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'rake'
|
4
|
+
gem 'bson_ext', '>= 1.6.4'
|
5
|
+
gem 'multi_json', '>= 1.3.6'
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem 'jnunemaker-matchy', '>= 0.4', :require => 'matchy'
|
9
|
+
gem 'shoulda', '>= 3.1.1'
|
10
|
+
gem 'mocha', '>= 0.12.3'
|
11
|
+
gem 'database_cleaner', '>= 0.8.0'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :development do
|
15
|
+
gem "wirble"
|
16
|
+
gem "hirb"
|
17
|
+
gem "awesome_print"
|
18
|
+
end
|
19
|
+
|
20
|
+
gemspec
|
data/Rakefile
CHANGED
@@ -1,36 +1,26 @@
|
|
1
|
-
require
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
test.
|
11
|
-
test.
|
12
|
-
test.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
test.
|
19
|
-
test.
|
20
|
-
test.
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
task :build do
|
28
|
-
sh 'gem build mm-draft.gemspec'
|
29
|
-
Dir.mkdir('pkg') unless File.directory?('pkg')
|
30
|
-
sh "mv mm-draft-#{MongoMapper::Draft::VERSION}.gem pkg/mm-draft-#{MongoMapper::Draft::VERSION}.gem"
|
31
|
-
end
|
32
|
-
|
33
|
-
desc 'Builds and Installs the gem'
|
34
|
-
task :install => :build do
|
35
|
-
sh "gem install pkg/mm-draft-#{MongoMapper::Draft::VERSION}.gem"
|
36
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), 'lib', 'mongo_mapper', 'plugins', 'draft', 'version')
|
6
|
+
|
7
|
+
require 'rake/testtask'
|
8
|
+
namespace :test do
|
9
|
+
Rake::TestTask.new(:units) do |test|
|
10
|
+
test.libs << 'test'
|
11
|
+
test.ruby_opts << '-rubygems'
|
12
|
+
test.pattern = 'test/unit/**/test_*.rb'
|
13
|
+
test.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
#TODO Add performance
|
17
|
+
Rake::TestTask.new(:performance) do |test|
|
18
|
+
test.libs << 'test'
|
19
|
+
test.ruby_opts << '-rubygems'
|
20
|
+
test.pattern = 'test/performance/test/**/*.rb'
|
21
|
+
test.verbose = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
task :default => 'test:units'
|
26
|
+
|
data/lib/locale/en.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
en:
|
2
|
-
mongo_mapper:
|
3
|
-
errors:
|
4
|
-
messages:
|
5
|
-
draft:
|
6
|
-
todo: "TODO"
|
1
|
+
en:
|
2
|
+
mongo_mapper:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
draft:
|
6
|
+
todo: "TODO"
|
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'mongo_mapper'
|
2
|
-
require File.join(File.dirname(__FILE__), 'mongo_mapper/plugins/draft/draft')
|
1
|
+
require 'mongo_mapper'
|
2
|
+
require File.join(File.dirname(__FILE__), 'mongo_mapper/plugins/draft/draft')
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module MongoMapper
|
2
|
-
module Plugins
|
3
|
-
module Draft
|
4
|
-
module Callbacks
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
before_destroy :unpublish
|
8
|
-
end # included_do
|
9
|
-
end
|
10
|
-
end # Versioned
|
11
|
-
end # Module plugins
|
12
|
-
end # module MongoMapper
|
1
|
+
module MongoMapper
|
2
|
+
module Plugins
|
3
|
+
module Draft
|
4
|
+
module Callbacks
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
before_destroy :unpublish
|
8
|
+
end # included_do
|
9
|
+
end
|
10
|
+
end # Versioned
|
11
|
+
end # Module plugins
|
12
|
+
end # module MongoMapper
|
@@ -1,129 +1,129 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'callbacks')
|
2
|
-
require File.join(File.dirname(__FILE__), 'keys')
|
3
|
-
# I18n.load_path << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'locale', 'en.yml'), __FILE__)
|
4
|
-
|
5
|
-
module MongoMapper
|
6
|
-
module Plugins
|
7
|
-
module Draft
|
8
|
-
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
include MongoMapper::Plugins::Draft::Callbacks
|
12
|
-
include MongoMapper::Plugins::Draft::Keys
|
13
|
-
|
14
|
-
def draft?
|
15
|
-
self.draft
|
16
|
-
end
|
17
|
-
|
18
|
-
def published?
|
19
|
-
if draft?
|
20
|
-
return false if self.draft_record_published_id == nil # save a query and return false
|
21
|
-
return true if (self.class.find(self.draft_record_published_id) != nil)
|
22
|
-
else
|
23
|
-
return true
|
24
|
-
end
|
25
|
-
false
|
26
|
-
end
|
27
|
-
|
28
|
-
def publish
|
29
|
-
if (draft? == false) # don't publish non-drafts...
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
|
33
|
-
if (self.changed?) # save any changes, in case publish is called directly instead of save
|
34
|
-
return false if (self.save == false)
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
# if already published, keep some old data to update instead of insert
|
39
|
-
if (self.published?)
|
40
|
-
old_published_record = self.published_record
|
41
|
-
# support for mm-tree
|
42
|
-
# remove parents from previous published record
|
43
|
-
if (self.respond_to?("parent_id_field") && self.respond_to?("path_field") && self.respond_to?("depth_field"))
|
44
|
-
old_published_record.parent = nil
|
45
|
-
old_published_record.save
|
46
|
-
end
|
47
|
-
live_record = self.clone
|
48
|
-
live_record._id = self.published_record_id
|
49
|
-
live_record.created_at = old_published_record.created_at if self.respond_to?("created_at")
|
50
|
-
else
|
51
|
-
live_record = self.clone
|
52
|
-
live_record.created_at = Time.now.utc if self.respond_to?("created_at")
|
53
|
-
end
|
54
|
-
|
55
|
-
self.draft_record_published_id = live_record._id
|
56
|
-
self.class.skip_callback(:save, :before, :update_timestamps ) if self.respond_to?("updated_at")
|
57
|
-
self.save!
|
58
|
-
self.class.set_callback(:save, :before, :update_timestamps ) if self.respond_to?("updated_at")
|
59
|
-
|
60
|
-
if (self.respond_to?("parent_id_field") && self.respond_to?("path_field") && self.respond_to?("depth_field"))
|
61
|
-
# if so, remove the current parent (should have already been don)
|
62
|
-
# set parent to nil for live_record before setting "real" parent.
|
63
|
-
# live_record.parent = nil
|
64
|
-
|
65
|
-
if (self.parent != nil)
|
66
|
-
# no need to copy order value, as it's copied in the clone process
|
67
|
-
# check draft.parent.published_record != nil, and set as parent
|
68
|
-
if (self.parent != nil)
|
69
|
-
if (self.parent.published_record != nil)
|
70
|
-
live_record.parent = self.parent.published_record
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
live_record.draft = false;
|
77
|
-
live_record.updated_at = Time.now.utc if self.respond_to?("updated_at")
|
78
|
-
live_record.save!
|
79
|
-
return true
|
80
|
-
end
|
81
|
-
|
82
|
-
def published_record
|
83
|
-
if draft?
|
84
|
-
return nil if self.draft_record_published_id == nil # save a query and return nil of draft_record_published_id == nil
|
85
|
-
self.class.find(self.draft_record_published_id)
|
86
|
-
else
|
87
|
-
self
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def published_record_id
|
92
|
-
if draft?
|
93
|
-
self.draft_record_published_id
|
94
|
-
else
|
95
|
-
self._id
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def draft_record
|
100
|
-
if draft?
|
101
|
-
self
|
102
|
-
else
|
103
|
-
self.class.all(:conditions => { :draft => true, :draft_record_published_id => self._id }).first
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def unpublish
|
108
|
-
published_rec = self.published_record
|
109
|
-
draft_rec = self.draft_record
|
110
|
-
|
111
|
-
self.class.skip_callback(:destroy, :before, :unpublish)
|
112
|
-
published_rec.destroy if published_rec != nil # destroy published record
|
113
|
-
self.class.set_callback(:destroy, :before, :unpublish)
|
114
|
-
|
115
|
-
draft_rec.draft_record_published_id = nil if draft_rec != nil # update draft record
|
116
|
-
draft_rec.save! if draft_rec != nil
|
117
|
-
# if draft?
|
118
|
-
# published = self.class.find(self.draft_record_published_id)
|
119
|
-
# published.destroy if (published != nil)
|
120
|
-
# self.draft_record_published_id = nil
|
121
|
-
# self.save! # remove draft_record_published_id
|
122
|
-
# else
|
123
|
-
# self.draft_record.unpublish
|
124
|
-
# end
|
125
|
-
end
|
126
|
-
|
127
|
-
end # Module Draft
|
128
|
-
end # Module plugins
|
129
|
-
end # module MongoMapper
|
1
|
+
require File.join(File.dirname(__FILE__), 'callbacks')
|
2
|
+
require File.join(File.dirname(__FILE__), 'keys')
|
3
|
+
# I18n.load_path << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'locale', 'en.yml'), __FILE__)
|
4
|
+
|
5
|
+
module MongoMapper
|
6
|
+
module Plugins
|
7
|
+
module Draft
|
8
|
+
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
include MongoMapper::Plugins::Draft::Callbacks
|
12
|
+
include MongoMapper::Plugins::Draft::Keys
|
13
|
+
|
14
|
+
def draft?
|
15
|
+
self.draft
|
16
|
+
end
|
17
|
+
|
18
|
+
def published?
|
19
|
+
if draft?
|
20
|
+
return false if self.draft_record_published_id == nil # save a query and return false
|
21
|
+
return true if (self.class.find(self.draft_record_published_id) != nil)
|
22
|
+
else
|
23
|
+
return true
|
24
|
+
end
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def publish
|
29
|
+
if (draft? == false) # don't publish non-drafts...
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
if (self.changed?) # save any changes, in case publish is called directly instead of save
|
34
|
+
return false if (self.save == false)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# if already published, keep some old data to update instead of insert
|
39
|
+
if (self.published?)
|
40
|
+
old_published_record = self.published_record
|
41
|
+
# support for mm-tree
|
42
|
+
# remove parents from previous published record
|
43
|
+
if (self.respond_to?("parent_id_field") && self.respond_to?("path_field") && self.respond_to?("depth_field"))
|
44
|
+
old_published_record.parent = nil
|
45
|
+
old_published_record.save
|
46
|
+
end
|
47
|
+
live_record = self.clone
|
48
|
+
live_record._id = self.published_record_id
|
49
|
+
live_record.created_at = old_published_record.created_at if self.respond_to?("created_at")
|
50
|
+
else
|
51
|
+
live_record = self.clone
|
52
|
+
live_record.created_at = Time.now.utc if self.respond_to?("created_at")
|
53
|
+
end
|
54
|
+
|
55
|
+
self.draft_record_published_id = live_record._id
|
56
|
+
self.class.skip_callback(:save, :before, :update_timestamps ) if self.respond_to?("updated_at")
|
57
|
+
self.save!
|
58
|
+
self.class.set_callback(:save, :before, :update_timestamps ) if self.respond_to?("updated_at")
|
59
|
+
|
60
|
+
if (self.respond_to?("parent_id_field") && self.respond_to?("path_field") && self.respond_to?("depth_field"))
|
61
|
+
# if so, remove the current parent (should have already been don)
|
62
|
+
# set parent to nil for live_record before setting "real" parent.
|
63
|
+
# live_record.parent = nil
|
64
|
+
|
65
|
+
if (self.parent != nil)
|
66
|
+
# no need to copy order value, as it's copied in the clone process
|
67
|
+
# check draft.parent.published_record != nil, and set as parent
|
68
|
+
if (self.parent != nil)
|
69
|
+
if (self.parent.published_record != nil)
|
70
|
+
live_record.parent = self.parent.published_record
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
live_record.draft = false;
|
77
|
+
live_record.updated_at = Time.now.utc if self.respond_to?("updated_at")
|
78
|
+
live_record.save!
|
79
|
+
return true
|
80
|
+
end
|
81
|
+
|
82
|
+
def published_record
|
83
|
+
if draft?
|
84
|
+
return nil if self.draft_record_published_id == nil # save a query and return nil of draft_record_published_id == nil
|
85
|
+
self.class.find(self.draft_record_published_id)
|
86
|
+
else
|
87
|
+
self
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def published_record_id
|
92
|
+
if draft?
|
93
|
+
self.draft_record_published_id
|
94
|
+
else
|
95
|
+
self._id
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def draft_record
|
100
|
+
if draft?
|
101
|
+
self
|
102
|
+
else
|
103
|
+
self.class.all(:conditions => { :draft => true, :draft_record_published_id => self._id }).first
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def unpublish
|
108
|
+
published_rec = self.published_record
|
109
|
+
draft_rec = self.draft_record
|
110
|
+
|
111
|
+
self.class.skip_callback(:destroy, :before, :unpublish)
|
112
|
+
published_rec.destroy if published_rec != nil # destroy published record
|
113
|
+
self.class.set_callback(:destroy, :before, :unpublish)
|
114
|
+
|
115
|
+
draft_rec.draft_record_published_id = nil if draft_rec != nil # update draft record
|
116
|
+
draft_rec.save! if draft_rec != nil
|
117
|
+
# if draft?
|
118
|
+
# published = self.class.find(self.draft_record_published_id)
|
119
|
+
# published.destroy if (published != nil)
|
120
|
+
# self.draft_record_published_id = nil
|
121
|
+
# self.save! # remove draft_record_published_id
|
122
|
+
# else
|
123
|
+
# self.draft_record.unpublish
|
124
|
+
# end
|
125
|
+
end
|
126
|
+
|
127
|
+
end # Module Draft
|
128
|
+
end # Module plugins
|
129
|
+
end # module MongoMapper
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module MongoMapper
|
2
|
-
module Plugins
|
3
|
-
module Draft
|
4
|
-
module Keys
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
key :draft, Boolean, :default => true
|
8
|
-
key :draft_record_published_id, ObjectId # points to the live page version if draft == true. else NIL
|
9
|
-
end # included_do
|
10
|
-
end # Keys
|
11
|
-
end # Versioned
|
12
|
-
end # Module plugins
|
13
|
-
end # module MongoMapper
|
1
|
+
module MongoMapper
|
2
|
+
module Plugins
|
3
|
+
module Draft
|
4
|
+
module Keys
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
key :draft, Boolean, :default => true
|
8
|
+
key :draft_record_published_id, ObjectId # points to the live page version if draft == true. else NIL
|
9
|
+
end # included_do
|
10
|
+
end # Keys
|
11
|
+
end # Versioned
|
12
|
+
end # Module plugins
|
13
|
+
end # module MongoMapper
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module MongoMapper
|
2
|
-
module Draft
|
3
|
-
VERSION = '0.1.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module MongoMapper
|
2
|
+
module Draft
|
3
|
+
VERSION = '0.1.7'
|
4
|
+
end
|
5
|
+
end
|
data/test/models/monkey.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
class Monkey
|
2
|
-
include MongoMapper::Document
|
3
|
-
plugin MongoMapper::Plugins::Draft
|
4
|
-
|
5
|
-
attr_accessible :name
|
6
|
-
|
7
|
-
key :name, String
|
8
|
-
|
9
|
-
timestamps!
|
10
|
-
end
|
1
|
+
class Monkey
|
2
|
+
include MongoMapper::Document
|
3
|
+
plugin MongoMapper::Plugins::Draft
|
4
|
+
|
5
|
+
attr_accessible :name
|
6
|
+
|
7
|
+
key :name, String
|
8
|
+
|
9
|
+
timestamps!
|
10
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
class Monkey
|
2
|
-
include MongoMapper::Document
|
3
|
-
plugin MongoMapper::Plugins::Draft
|
4
|
-
|
5
|
-
attr_accessible :name, :age
|
6
|
-
|
7
|
-
key :name, String
|
8
|
-
key :age, Integer
|
9
|
-
end
|
1
|
+
class Monkey
|
2
|
+
include MongoMapper::Document
|
3
|
+
plugin MongoMapper::Plugins::Draft
|
4
|
+
|
5
|
+
attr_accessible :name, :age
|
6
|
+
|
7
|
+
key :name, String
|
8
|
+
key :age, Integer
|
9
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class MonkeyNoVersion
|
2
|
-
include MongoMapper::Document
|
3
|
-
attr_accessible :name, :age
|
4
|
-
|
5
|
-
key :name, String
|
6
|
-
key :age, Integer
|
7
|
-
end
|
1
|
+
class MonkeyNoVersion
|
2
|
+
include MongoMapper::Document
|
3
|
+
attr_accessible :name, :age
|
4
|
+
|
5
|
+
key :name, String
|
6
|
+
key :age, Integer
|
7
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
5
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
-
require 'draft'
|
7
|
-
|
8
|
-
Bundler.require(:default, :test)
|
9
|
-
|
10
|
-
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
11
|
-
MongoMapper.database = "mm-draft-performance"
|
12
|
-
|
13
|
-
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each {|file| require file}
|
14
|
-
|
15
|
-
DatabaseCleaner.strategy = :truncation
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
require 'draft'
|
7
|
+
|
8
|
+
Bundler.require(:default, :test)
|
9
|
+
|
10
|
+
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
11
|
+
MongoMapper.database = "mm-draft-performance"
|
12
|
+
|
13
|
+
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each {|file| require file}
|
14
|
+
|
15
|
+
DatabaseCleaner.strategy = :truncation
|
@@ -1,28 +1,28 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'performance_helper'))
|
2
|
-
|
3
|
-
require 'benchmark'
|
4
|
-
|
5
|
-
DatabaseCleaner.start
|
6
|
-
|
7
|
-
Benchmark.bm(22) do |x|
|
8
|
-
ids_draft = []
|
9
|
-
ids_no_draft = []
|
10
|
-
|
11
|
-
# Write performance
|
12
|
-
x.report("write without draft ") do
|
13
|
-
500.times { |i| ids_no_draft << MonkeyNodraft.create(:name => "Baboo", :age => 12, ).id }
|
14
|
-
end
|
15
|
-
x.report("write with draft ") do
|
16
|
-
500.times { |i| ids_draft << Monkey.create(:name => "Baboo", :age => 12, ).id }
|
17
|
-
end
|
18
|
-
|
19
|
-
# Read performance
|
20
|
-
x.report("read with draft ") do
|
21
|
-
ids_draft.each { |id| Monkey.first(:id => id) }
|
22
|
-
end
|
23
|
-
x.report("read without draft ") do
|
24
|
-
ids_no_draft.each { |id| MonkeyNodraft.first(:id => id) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
DatabaseCleaner.clean
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'performance_helper'))
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
DatabaseCleaner.start
|
6
|
+
|
7
|
+
Benchmark.bm(22) do |x|
|
8
|
+
ids_draft = []
|
9
|
+
ids_no_draft = []
|
10
|
+
|
11
|
+
# Write performance
|
12
|
+
x.report("write without draft ") do
|
13
|
+
500.times { |i| ids_no_draft << MonkeyNodraft.create(:name => "Baboo", :age => 12, ).id }
|
14
|
+
end
|
15
|
+
x.report("write with draft ") do
|
16
|
+
500.times { |i| ids_draft << Monkey.create(:name => "Baboo", :age => 12, ).id }
|
17
|
+
end
|
18
|
+
|
19
|
+
# Read performance
|
20
|
+
x.report("read with draft ") do
|
21
|
+
ids_draft.each { |id| Monkey.first(:id => id) }
|
22
|
+
end
|
23
|
+
x.report("read without draft ") do
|
24
|
+
ids_no_draft.each { |id| MonkeyNodraft.first(:id => id) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
DatabaseCleaner.clean
|
data/test/test_helper.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
-
require 'draft'
|
7
|
-
|
8
|
-
Bundler.require(:default, :test)
|
9
|
-
|
10
|
-
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
11
|
-
MongoMapper.database = "mm-draft-test"
|
12
|
-
|
13
|
-
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each {|file| require file}
|
14
|
-
|
15
|
-
DatabaseCleaner.strategy = :truncation
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
# Drop all collections after each test case.
|
19
|
-
def setup
|
20
|
-
DatabaseCleaner.start
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
DatabaseCleaner.clean
|
25
|
-
end
|
26
|
-
|
27
|
-
# Make sure that each test case has a teardown
|
28
|
-
# method to clear the db after each test.
|
29
|
-
def inherited(base)
|
30
|
-
base.define_method setup do
|
31
|
-
super
|
32
|
-
end
|
33
|
-
|
34
|
-
base.define_method teardown do
|
35
|
-
super
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
require 'mm-draft'
|
7
|
+
|
8
|
+
Bundler.require(:default, :test)
|
9
|
+
|
10
|
+
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
11
|
+
MongoMapper.database = "mm-draft-test"
|
12
|
+
|
13
|
+
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each {|file| require file}
|
14
|
+
|
15
|
+
DatabaseCleaner.strategy = :truncation
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
# Drop all collections after each test case.
|
19
|
+
def setup
|
20
|
+
DatabaseCleaner.start
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
DatabaseCleaner.clean
|
25
|
+
end
|
26
|
+
|
27
|
+
# Make sure that each test case has a teardown
|
28
|
+
# method to clear the db after each test.
|
29
|
+
def inherited(base)
|
30
|
+
base.define_method setup do
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
base.define_method teardown do
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/test/unit/test_draft.rb
CHANGED
@@ -1,194 +1,194 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DraftTest < Test::Unit::TestCase
|
4
|
-
context "draft monkey records" do
|
5
|
-
setup do
|
6
|
-
@monkey_1 = Monkey.create(:name => "Chip")
|
7
|
-
@monkey_2 = Monkey.create(:name => "Unaton")
|
8
|
-
@monkey_1.publish
|
9
|
-
end
|
10
|
-
|
11
|
-
should "have same name as draft" do
|
12
|
-
@monkey_1.name.should == "Chip"
|
13
|
-
@monkey_1.published_record.name.should == "Chip"
|
14
|
-
@monkey_1.published_record.name.should == @monkey_1.name
|
15
|
-
end
|
16
|
-
|
17
|
-
should "be published" do
|
18
|
-
@monkey_1.published_record.should_not == nil
|
19
|
-
end
|
20
|
-
|
21
|
-
should "not have same created time as draft" do
|
22
|
-
@monkey_1.unpublish
|
23
|
-
@monkey_1.publish
|
24
|
-
@monkey_1.created_at.should_not == @monkey_1.published_record.created_at
|
25
|
-
end
|
26
|
-
|
27
|
-
should "not be published" do
|
28
|
-
@monkey_2.published?.should_not == true
|
29
|
-
@monkey_2.published_record.should == nil
|
30
|
-
end
|
31
|
-
|
32
|
-
should "not be draft" do
|
33
|
-
@monkey_1.published_record.draft?.should_not == true
|
34
|
-
end
|
35
|
-
|
36
|
-
should "be draft" do
|
37
|
-
@monkey_2.draft?.should == true
|
38
|
-
end
|
39
|
-
|
40
|
-
should "rename draft only" do
|
41
|
-
@monkey_1.name = "Sagofon"
|
42
|
-
@monkey_1.published_record.should_not == nil
|
43
|
-
@monkey_1.name.should_not == @monkey_1.published_record.name
|
44
|
-
end
|
45
|
-
|
46
|
-
should "rename both draft and published record" do
|
47
|
-
@monkey_1.name = "Sagofon"
|
48
|
-
@monkey_1.publish
|
49
|
-
@monkey_1.published_record.should_not == nil
|
50
|
-
@monkey_1.name.should == @monkey_1.published_record.name
|
51
|
-
end
|
52
|
-
|
53
|
-
should "have updated updated_at both published record" do
|
54
|
-
@monkey_1.name ="Kake"
|
55
|
-
@monkey_1.save
|
56
|
-
@monkey_1.publish
|
57
|
-
@monkey_1.published_record.updated_at.should_not == @monkey_1.updated_at
|
58
|
-
end
|
59
|
-
|
60
|
-
should "unpublish draft record" do
|
61
|
-
@monkey_1.unpublish
|
62
|
-
assert !@monkey_1.published?
|
63
|
-
@monkey_1.published_record_id.should == nil
|
64
|
-
@monkey_1.published_record.should == nil
|
65
|
-
end
|
66
|
-
|
67
|
-
should "unpublish published record directly" do
|
68
|
-
# It is recommended to unpublish a draft record instead of unpublising a published record
|
69
|
-
@monkey_1.publish # publish record again...
|
70
|
-
@monkey_1.published_record.unpublish
|
71
|
-
# reload monkey_1
|
72
|
-
@monkey_1.reload
|
73
|
-
@monkey_1.published?.should_not == true
|
74
|
-
@monkey_1.published_record_id.should == nil
|
75
|
-
@monkey_1.published_record.should == nil
|
76
|
-
end
|
77
|
-
|
78
|
-
should "destroy published record only" do
|
79
|
-
@monkey_2.publish
|
80
|
-
tmp_id = @monkey_2.published_record_id
|
81
|
-
@monkey_2.published_record.destroy
|
82
|
-
@monkey_2.reload
|
83
|
-
@monkey_2.published_record_id.should == nil
|
84
|
-
@monkey_2.published_record.should == nil
|
85
|
-
@monkey_2.name.should == "Unaton" # make sure we didn't loose the draft
|
86
|
-
@monkey_2.published?.should_not == true
|
87
|
-
@monkey_2.draft?.should == true
|
88
|
-
Monkey.find(tmp_id).should == nil
|
89
|
-
end
|
90
|
-
|
91
|
-
should "destroy draft and published record" do
|
92
|
-
@monkey_2.publish # publish record again...
|
93
|
-
tmp_draft_id = @monkey_2._id
|
94
|
-
tmp_published_id = @monkey_2.published_record_id
|
95
|
-
@monkey_2.destroy
|
96
|
-
# keep ID's in order to check that they are destroyed!
|
97
|
-
Monkey.find(tmp_draft_id).should == nil
|
98
|
-
Monkey.find(tmp_published_id).should == nil
|
99
|
-
end
|
100
|
-
|
101
|
-
end # context "draft monkey records" do
|
102
|
-
|
103
|
-
# context "tree-record" do
|
104
|
-
# setup do
|
105
|
-
# @root_1 = Dog.create(:name => "Atmel")
|
106
|
-
# @child_1 = Dog.create(:name => "ATmega644P", :parent => @root_1)
|
107
|
-
# @child_2 = Dog.create(:name => "ATmega2561", :parent => @root_1)
|
108
|
-
# @child_2_1 = Dog.create(:name => "ATtiny24", :parent => @child_2)
|
109
|
-
|
110
|
-
# @root_2 = Dog.create(:name => "ST Ericsson")
|
111
|
-
# @child_3 = Dog.create(:name => "ISP1181B", :parent => @root_2)
|
112
|
-
|
113
|
-
# @root_1.publish
|
114
|
-
# @child_1.publish
|
115
|
-
# @child_2.publish
|
116
|
-
# @child_2_1.publish
|
117
|
-
# @root_2.publish
|
118
|
-
# end
|
119
|
-
|
120
|
-
# should "test draft record parents" do
|
121
|
-
# assert_equal(@root_2, @child_3.parent)
|
122
|
-
# assert_equal(@child_2, @child_2_1.parent)
|
123
|
-
# end
|
124
|
-
|
125
|
-
# should "test parents for published records" do
|
126
|
-
# assert_equal(@root_1.published_record, @child_1.published_record.parent)
|
127
|
-
# assert_equal(@root_1.published_record, @child_2.published_record.parent)
|
128
|
-
# assert_equal(@child_2.published_record, @child_2_1.published_record.parent)
|
129
|
-
# end
|
130
|
-
|
131
|
-
# should "move draft record to new parent, but keep published at old parent" do
|
132
|
-
# @child_2.parent = @root_2
|
133
|
-
|
134
|
-
# assert !@root_2.is_or_is_ancestor_of?(@child_2_1)
|
135
|
-
# assert !@child_2_1.is_or_is_descendant_of?(@root_2)
|
136
|
-
# assert !@root_2.descendants.include?(@child_2_1)
|
137
|
-
|
138
|
-
# @child_2.save
|
139
|
-
# @child_2_1.reload
|
140
|
-
|
141
|
-
# assert @root_2.is_or_is_ancestor_of?(@child_2_1)
|
142
|
-
# assert @child_2_1.is_or_is_descendant_of?(@root_2)
|
143
|
-
# assert @root_2.descendants.include?(@child_2_1)
|
144
|
-
|
145
|
-
# # test published against root_1
|
146
|
-
# assert @root_1.published_record.is_or_is_ancestor_of?(@child_2_1.published_record)
|
147
|
-
# assert @child_2_1.published_record.is_or_is_descendant_of?(@root_1.published_record)
|
148
|
-
# assert @root_1.published_record.descendants.include?(@child_2_1.published_record)
|
149
|
-
# end
|
150
|
-
|
151
|
-
# should "move both draft and published record to new parent" do
|
152
|
-
# @child_2.parent = @root_2
|
153
|
-
|
154
|
-
# assert !@root_2.is_or_is_ancestor_of?(@child_2_1)
|
155
|
-
# assert !@child_2_1.is_or_is_descendant_of?(@root_2)
|
156
|
-
# assert !@root_2.descendants.include?(@child_2_1)
|
157
|
-
|
158
|
-
# # can only test published after saving and publishing
|
159
|
-
# @child_2.save
|
160
|
-
# @child_2.publish # will also save
|
161
|
-
# @child_2.reload
|
162
|
-
# @child_2_1.reload
|
163
|
-
|
164
|
-
# assert @root_2.is_or_is_ancestor_of?(@child_2_1)
|
165
|
-
# assert @child_2_1.is_or_is_descendant_of?(@root_2)
|
166
|
-
# assert @root_2.descendants.include?(@child_2_1)
|
167
|
-
|
168
|
-
# assert @root_2.published_record.is_or_is_ancestor_of?(@child_2_1.published_record)
|
169
|
-
# assert @child_2_1.published_record.is_or_is_descendant_of?(@root_2.published_record)
|
170
|
-
# assert @root_2.published_record.descendants.include?(@child_2_1.published_record)
|
171
|
-
# end
|
172
|
-
|
173
|
-
# should "set a record as a root and check for ancestor" do
|
174
|
-
# @child_2.parent = nil
|
175
|
-
|
176
|
-
# assert !@root_2.is_or_is_ancestor_of?(@child_2_1)
|
177
|
-
# assert !@child_2_1.is_or_is_descendant_of?(@root_2)
|
178
|
-
# assert !@root_2.descendants.include?(@child_2_1)
|
179
|
-
|
180
|
-
# # can only test published after saving and publishing
|
181
|
-
# @child_2.save
|
182
|
-
# @child_2.publish # will also save
|
183
|
-
# @child_2.reload
|
184
|
-
# @child_2_1.reload
|
185
|
-
|
186
|
-
# assert @child_2.root?
|
187
|
-
# assert @child_2.published_record.root?
|
188
|
-
# assert @child_2_1.is_or_is_descendant_of?(@child_2)
|
189
|
-
|
190
|
-
# assert !@root_1.published_record.is_or_is_ancestor_of?(@child_2_1.published_record)
|
191
|
-
# assert !@child_2_1.published_record.is_or_is_descendant_of?(@root_1.published_record)
|
192
|
-
# assert !@root_1.published_record.descendants.include?(@child_2_1.published_record)
|
193
|
-
# end
|
194
|
-
end
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DraftTest < Test::Unit::TestCase
|
4
|
+
context "draft monkey records" do
|
5
|
+
setup do
|
6
|
+
@monkey_1 = Monkey.create(:name => "Chip")
|
7
|
+
@monkey_2 = Monkey.create(:name => "Unaton")
|
8
|
+
@monkey_1.publish
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have same name as draft" do
|
12
|
+
@monkey_1.name.should == "Chip"
|
13
|
+
@monkey_1.published_record.name.should == "Chip"
|
14
|
+
@monkey_1.published_record.name.should == @monkey_1.name
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be published" do
|
18
|
+
@monkey_1.published_record.should_not == nil
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not have same created time as draft" do
|
22
|
+
@monkey_1.unpublish
|
23
|
+
@monkey_1.publish
|
24
|
+
@monkey_1.created_at.should_not == @monkey_1.published_record.created_at
|
25
|
+
end
|
26
|
+
|
27
|
+
should "not be published" do
|
28
|
+
@monkey_2.published?.should_not == true
|
29
|
+
@monkey_2.published_record.should == nil
|
30
|
+
end
|
31
|
+
|
32
|
+
should "not be draft" do
|
33
|
+
@monkey_1.published_record.draft?.should_not == true
|
34
|
+
end
|
35
|
+
|
36
|
+
should "be draft" do
|
37
|
+
@monkey_2.draft?.should == true
|
38
|
+
end
|
39
|
+
|
40
|
+
should "rename draft only" do
|
41
|
+
@monkey_1.name = "Sagofon"
|
42
|
+
@monkey_1.published_record.should_not == nil
|
43
|
+
@monkey_1.name.should_not == @monkey_1.published_record.name
|
44
|
+
end
|
45
|
+
|
46
|
+
should "rename both draft and published record" do
|
47
|
+
@monkey_1.name = "Sagofon"
|
48
|
+
@monkey_1.publish
|
49
|
+
@monkey_1.published_record.should_not == nil
|
50
|
+
@monkey_1.name.should == @monkey_1.published_record.name
|
51
|
+
end
|
52
|
+
|
53
|
+
should "have updated updated_at both published record" do
|
54
|
+
@monkey_1.name ="Kake"
|
55
|
+
@monkey_1.save
|
56
|
+
@monkey_1.publish
|
57
|
+
@monkey_1.published_record.updated_at.should_not == @monkey_1.updated_at
|
58
|
+
end
|
59
|
+
|
60
|
+
should "unpublish draft record" do
|
61
|
+
@monkey_1.unpublish
|
62
|
+
assert !@monkey_1.published?
|
63
|
+
@monkey_1.published_record_id.should == nil
|
64
|
+
@monkey_1.published_record.should == nil
|
65
|
+
end
|
66
|
+
|
67
|
+
should "unpublish published record directly" do
|
68
|
+
# It is recommended to unpublish a draft record instead of unpublising a published record
|
69
|
+
@monkey_1.publish # publish record again...
|
70
|
+
@monkey_1.published_record.unpublish
|
71
|
+
# reload monkey_1
|
72
|
+
@monkey_1.reload
|
73
|
+
@monkey_1.published?.should_not == true
|
74
|
+
@monkey_1.published_record_id.should == nil
|
75
|
+
@monkey_1.published_record.should == nil
|
76
|
+
end
|
77
|
+
|
78
|
+
should "destroy published record only" do
|
79
|
+
@monkey_2.publish
|
80
|
+
tmp_id = @monkey_2.published_record_id
|
81
|
+
@monkey_2.published_record.destroy
|
82
|
+
@monkey_2.reload
|
83
|
+
@monkey_2.published_record_id.should == nil
|
84
|
+
@monkey_2.published_record.should == nil
|
85
|
+
@monkey_2.name.should == "Unaton" # make sure we didn't loose the draft
|
86
|
+
@monkey_2.published?.should_not == true
|
87
|
+
@monkey_2.draft?.should == true
|
88
|
+
Monkey.find(tmp_id).should == nil
|
89
|
+
end
|
90
|
+
|
91
|
+
should "destroy draft and published record" do
|
92
|
+
@monkey_2.publish # publish record again...
|
93
|
+
tmp_draft_id = @monkey_2._id
|
94
|
+
tmp_published_id = @monkey_2.published_record_id
|
95
|
+
@monkey_2.destroy
|
96
|
+
# keep ID's in order to check that they are destroyed!
|
97
|
+
Monkey.find(tmp_draft_id).should == nil
|
98
|
+
Monkey.find(tmp_published_id).should == nil
|
99
|
+
end
|
100
|
+
|
101
|
+
end # context "draft monkey records" do
|
102
|
+
|
103
|
+
# context "tree-record" do
|
104
|
+
# setup do
|
105
|
+
# @root_1 = Dog.create(:name => "Atmel")
|
106
|
+
# @child_1 = Dog.create(:name => "ATmega644P", :parent => @root_1)
|
107
|
+
# @child_2 = Dog.create(:name => "ATmega2561", :parent => @root_1)
|
108
|
+
# @child_2_1 = Dog.create(:name => "ATtiny24", :parent => @child_2)
|
109
|
+
|
110
|
+
# @root_2 = Dog.create(:name => "ST Ericsson")
|
111
|
+
# @child_3 = Dog.create(:name => "ISP1181B", :parent => @root_2)
|
112
|
+
|
113
|
+
# @root_1.publish
|
114
|
+
# @child_1.publish
|
115
|
+
# @child_2.publish
|
116
|
+
# @child_2_1.publish
|
117
|
+
# @root_2.publish
|
118
|
+
# end
|
119
|
+
|
120
|
+
# should "test draft record parents" do
|
121
|
+
# assert_equal(@root_2, @child_3.parent)
|
122
|
+
# assert_equal(@child_2, @child_2_1.parent)
|
123
|
+
# end
|
124
|
+
|
125
|
+
# should "test parents for published records" do
|
126
|
+
# assert_equal(@root_1.published_record, @child_1.published_record.parent)
|
127
|
+
# assert_equal(@root_1.published_record, @child_2.published_record.parent)
|
128
|
+
# assert_equal(@child_2.published_record, @child_2_1.published_record.parent)
|
129
|
+
# end
|
130
|
+
|
131
|
+
# should "move draft record to new parent, but keep published at old parent" do
|
132
|
+
# @child_2.parent = @root_2
|
133
|
+
|
134
|
+
# assert !@root_2.is_or_is_ancestor_of?(@child_2_1)
|
135
|
+
# assert !@child_2_1.is_or_is_descendant_of?(@root_2)
|
136
|
+
# assert !@root_2.descendants.include?(@child_2_1)
|
137
|
+
|
138
|
+
# @child_2.save
|
139
|
+
# @child_2_1.reload
|
140
|
+
|
141
|
+
# assert @root_2.is_or_is_ancestor_of?(@child_2_1)
|
142
|
+
# assert @child_2_1.is_or_is_descendant_of?(@root_2)
|
143
|
+
# assert @root_2.descendants.include?(@child_2_1)
|
144
|
+
|
145
|
+
# # test published against root_1
|
146
|
+
# assert @root_1.published_record.is_or_is_ancestor_of?(@child_2_1.published_record)
|
147
|
+
# assert @child_2_1.published_record.is_or_is_descendant_of?(@root_1.published_record)
|
148
|
+
# assert @root_1.published_record.descendants.include?(@child_2_1.published_record)
|
149
|
+
# end
|
150
|
+
|
151
|
+
# should "move both draft and published record to new parent" do
|
152
|
+
# @child_2.parent = @root_2
|
153
|
+
|
154
|
+
# assert !@root_2.is_or_is_ancestor_of?(@child_2_1)
|
155
|
+
# assert !@child_2_1.is_or_is_descendant_of?(@root_2)
|
156
|
+
# assert !@root_2.descendants.include?(@child_2_1)
|
157
|
+
|
158
|
+
# # can only test published after saving and publishing
|
159
|
+
# @child_2.save
|
160
|
+
# @child_2.publish # will also save
|
161
|
+
# @child_2.reload
|
162
|
+
# @child_2_1.reload
|
163
|
+
|
164
|
+
# assert @root_2.is_or_is_ancestor_of?(@child_2_1)
|
165
|
+
# assert @child_2_1.is_or_is_descendant_of?(@root_2)
|
166
|
+
# assert @root_2.descendants.include?(@child_2_1)
|
167
|
+
|
168
|
+
# assert @root_2.published_record.is_or_is_ancestor_of?(@child_2_1.published_record)
|
169
|
+
# assert @child_2_1.published_record.is_or_is_descendant_of?(@root_2.published_record)
|
170
|
+
# assert @root_2.published_record.descendants.include?(@child_2_1.published_record)
|
171
|
+
# end
|
172
|
+
|
173
|
+
# should "set a record as a root and check for ancestor" do
|
174
|
+
# @child_2.parent = nil
|
175
|
+
|
176
|
+
# assert !@root_2.is_or_is_ancestor_of?(@child_2_1)
|
177
|
+
# assert !@child_2_1.is_or_is_descendant_of?(@root_2)
|
178
|
+
# assert !@root_2.descendants.include?(@child_2_1)
|
179
|
+
|
180
|
+
# # can only test published after saving and publishing
|
181
|
+
# @child_2.save
|
182
|
+
# @child_2.publish # will also save
|
183
|
+
# @child_2.reload
|
184
|
+
# @child_2_1.reload
|
185
|
+
|
186
|
+
# assert @child_2.root?
|
187
|
+
# assert @child_2.published_record.root?
|
188
|
+
# assert @child_2_1.is_or_is_descendant_of?(@child_2)
|
189
|
+
|
190
|
+
# assert !@root_1.published_record.is_or_is_ancestor_of?(@child_2_1.published_record)
|
191
|
+
# assert !@child_2_1.published_record.is_or_is_descendant_of?(@root_1.published_record)
|
192
|
+
# assert !@root_1.published_record.descendants.include?(@child_2_1.published_record)
|
193
|
+
# end
|
194
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mm-draft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -50,8 +50,8 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
-
- lib/draft.rb
|
54
53
|
- lib/locale/en.yml
|
54
|
+
- lib/mm-draft.rb
|
55
55
|
- lib/mongo_mapper/plugins/draft/callbacks.rb
|
56
56
|
- lib/mongo_mapper/plugins/draft/draft.rb
|
57
57
|
- lib/mongo_mapper/plugins/draft/keys.rb
|