mm-draft 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e1db6a6bf3c38fb8e5024fee979f5edd37174b8
4
- data.tar.gz: 4f1e604160432a5a8ef04efa74fe3f705fb2bd7f
3
+ metadata.gz: 73d13795e0d5e002fb08f837f432afd0b22d65c0
4
+ data.tar.gz: 1c978faf0f27857b7d14594879aed1b9d59ab8dd
5
5
  SHA512:
6
- metadata.gz: f85ba7db6bda0423638745931227cfe3514d05c20d5d24ea348c49f2b70a118a4a46152bbad205f6e3cdc29cd2c7738f496fbcec8d63870891638d56b5531558
7
- data.tar.gz: ac814e646bddfae8e3b0f9b432f8f0bd0ce0663a55f622a21d55929764fde6da46468216c7b7567f4ecbbee15271454fdd400514132d92479f4a1a8162f0a0b4
6
+ metadata.gz: aecee7907f69b0128c836469d9fd44939922e7e8de5939115d18888aed82a3f395bfbabd438f7e4526918c6f56e28bf4c7245c4e3957e761f2601d9e9ec13046
7
+ data.tar.gz: 1452006b11cd9ed6c52734bef6bc563f31c32dea2b8297910267351baef83de44022dcf2ccf5a567499fd62238a67b16bd8917137ab922e35b3a0fcd6040bfc6
@@ -62,6 +62,14 @@ module MongoMapper
62
62
  time_proc = lambda { Time.now.utc }
63
63
  live_record.created_at = time_proc.call
64
64
  end
65
+
66
+ if self.respond_to?("published_at")
67
+ time_proc = lambda { Time.now.utc }
68
+ tmp_time = time_proc.call
69
+ self.set(published_at: tmp_time)
70
+ live_record.published_at = tmp_time
71
+ end
72
+
65
73
  live_record.draft_record_published_id = nil
66
74
  live_record.draft = false
67
75
  live_record.save!
@@ -1,5 +1,5 @@
1
1
  module MongoMapper
2
2
  module Draft
3
- VERSION = '0.1.9'
3
+ VERSION = '0.1.10'
4
4
  end
5
5
  end
@@ -0,0 +1,11 @@
1
+ class Dog
2
+ include MongoMapper::Document
3
+ plugin MongoMapper::Plugins::Draft
4
+
5
+ attr_accessible :name
6
+
7
+ key :name, String
8
+ key :published_at, Time
9
+
10
+ timestamps!
11
+ end
@@ -3,7 +3,7 @@ class Monkey
3
3
  plugin MongoMapper::Plugins::Draft
4
4
 
5
5
  attr_accessible :name
6
-
6
+
7
7
  key :name, String
8
8
 
9
9
  timestamps!
@@ -118,6 +118,19 @@ class DraftTest < Test::Unit::TestCase
118
118
 
119
119
 
120
120
  end # context "draft monkey records" do
121
+ context "draft dog records with pubished_at" do
122
+ setup do
123
+ @monkey_1 = Dog.create(:name => "Chip")
124
+ end
125
+
126
+ should "should set published_at when publishing" do
127
+ @monkey_1.publish
128
+ @monkey_1.published_record.should_not == nil
129
+ @monkey_1.published_at.should_not == nil
130
+ @monkey_1.published_record.published_at.should_not == nil
131
+ @monkey_1.published_record.published_at.should == @monkey_1.published_at
132
+ end
133
+ end
121
134
 
122
135
  # context "tree-record" do
123
136
  # setup do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm-draft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leif Ringstad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -54,6 +54,7 @@ files:
54
54
  - lib/mongo_mapper/plugins/draft/draft.rb
55
55
  - lib/mongo_mapper/plugins/draft/keys.rb
56
56
  - lib/mongo_mapper/plugins/draft/version.rb
57
+ - test/models/dog.rb
57
58
  - test/models/monkey.rb
58
59
  - test/performance/models/monkey.rb
59
60
  - test/performance/models/monkey_no_draft.rb
@@ -85,6 +86,7 @@ signing_key:
85
86
  specification_version: 4
86
87
  summary: A MongoMapper extension adding draft/publishing support
87
88
  test_files:
89
+ - test/models/dog.rb
88
90
  - test/models/monkey.rb
89
91
  - test/test_helper.rb
90
92
  - test/performance/performance_helper.rb