ismasan-ar_publish_control 0.0.4 → 0.0.5

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.rdoc CHANGED
@@ -37,11 +37,11 @@ Adds published, unpublished and published_only(boolean) named_scopes to your mod
37
37
  <%= f.check_box :is_published %>
38
38
  </p>
39
39
  <p>
40
- <%= f.label :publisht_at, "From" %>
40
+ <%= f.label :publish_at, "From" %>
41
41
  <%= f.date_select :publish_at %>
42
42
  </p>
43
43
  <p>
44
- <%= f.label :unpublisht_at, "To" %>
44
+ <%= f.label :unpublish_at, "To" %>
45
45
  <%= f.date_select :unpublish_at %>
46
46
  </p>
47
47
  ...
@@ -54,6 +54,7 @@ Adds published, unpublished and published_only(boolean) named_scopes to your mod
54
54
 
55
55
  def show
56
56
  @post = Post.published.find(params[:id])
57
+ @post.published? # => true
57
58
  end
58
59
 
59
60
  # You can nest scopes:
@@ -65,10 +66,11 @@ Adds published, unpublished and published_only(boolean) named_scopes to your mod
65
66
  @posts = Post.unpublished
66
67
 
67
68
  # All posts if logged_in?, only published otherwise
68
- @posts = Post.published_only?( logged_in? ).paginate(:page => params[:page])
69
+ @posts = Post.published_only?( !logged_in? ).paginate(:page => params[:page])
69
70
 
70
71
  # Unpublish
71
72
  @post.unpublish!
73
+ @post.unpublished? # => true
72
74
 
73
75
  # You can access the ones marked as "published" but with a publish date in the future
74
76
  @upcoming_post = Post.upcoming
@@ -78,7 +80,7 @@ Adds published, unpublished and published_only(boolean) named_scopes to your mod
78
80
  @expired_posts = Post.expired
79
81
  @expired_posts.first.expired? # => true
80
82
 
81
- All of these named_scopes can be chain with other finder conditions and paginated with will_paginate
83
+ All of these named_scopes can be chained with other finder conditions and paginated with will_paginate
82
84
 
83
85
  == REQUIREMENTS:
84
86
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ar_publish_control}
5
- s.version = "0.0.4"
5
+ s.version = "0.0.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ismael Celis"]
@@ -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.4'
5
+ VERSION = '0.0.5'
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
  #
@@ -145,6 +145,10 @@ module ArPublishControl
145
145
 
146
146
  module InstanceMethods
147
147
 
148
+ def publish_at
149
+ read_attribute(:publish_at) || Time.now
150
+ end
151
+
148
152
  # Publish at is NOW if not set
149
153
  def init_publish_date
150
154
  write_attribute(:publish_at, Time.now) if publish_at.nil?
@@ -160,3 +160,12 @@ describe Post, 'expired' do
160
160
  Post.expired.size.should == 2
161
161
  end
162
162
  end
163
+
164
+ describe "new record" do
165
+ it "should default to Time.now" do
166
+ d = Time.now
167
+ Time.stub!(:now).and_return d
168
+ a = Article.new
169
+ a.publish_at.should == d
170
+ end
171
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ismasan-ar_publish_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis