ismasan-ar_publish_control 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/ar_publish_control.gemspec +1 -1
- data/lib/ar_publish_control.rb +3 -8
- data/spec/ar_publish_control_spec.rb +3 -3
- metadata +1 -1
data/ar_publish_control.gemspec
CHANGED
data/lib/ar_publish_control.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
module ArPublishControl
|
5
|
-
VERSION = '0.0.
|
5
|
+
VERSION = '0.0.7'
|
6
6
|
# This is a gem version of http://github.com/avdgaag/acts_as_publishable ( a Rails plugin)
|
7
7
|
# Thanks to Avdaag for his awesome, super readable code which I ripped off for this gem.
|
8
8
|
#
|
@@ -100,7 +100,7 @@ module ArPublishControl
|
|
100
100
|
bool = (args.first.nil? ? true : (args.first)) # nil = true by default
|
101
101
|
bool ? {:conditions => published_conditions} : {}
|
102
102
|
}
|
103
|
-
|
103
|
+
|
104
104
|
validate :validate_publish_date_consistency
|
105
105
|
before_create :publish_by_default if options[:publish_by_default]
|
106
106
|
end
|
@@ -146,12 +146,7 @@ module ArPublishControl
|
|
146
146
|
|
147
147
|
module InstanceMethods
|
148
148
|
|
149
|
-
def
|
150
|
-
read_attribute(:publish_at) || Time.now
|
151
|
-
end
|
152
|
-
|
153
|
-
# Publish at is NOW if not set
|
154
|
-
def init_publish_date
|
149
|
+
def after_initialize
|
155
150
|
write_attribute(:publish_at, Time.now) if publish_at.nil?
|
156
151
|
end
|
157
152
|
|
@@ -163,9 +163,9 @@ end
|
|
163
163
|
|
164
164
|
describe "new record" do
|
165
165
|
it "should default to Time.now" do
|
166
|
-
d = Time.now
|
167
|
-
Time.stub!(:now).and_return d
|
166
|
+
# d = Time.now
|
167
|
+
# Time.stub!(:now).and_return d
|
168
168
|
a = Article.new
|
169
|
-
a.publish_at.
|
169
|
+
a.publish_at.should_not be_nil
|
170
170
|
end
|
171
171
|
end
|