Skip to content

Commit

Permalink
Merge pull request lokka#200 from morygonzalez/months-should-not-cont…
Browse files Browse the repository at this point in the history
…ain-draft

Lokka::Helpers.months should not contain draft entry
  • Loading branch information
komagata committed Jul 28, 2013
2 parents 1c1c3f9 + ecad5c9 commit ee002ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lokka/helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def comment_form

def months
ms = {}
Post.all.each do |post|
Post.published.each do |post|
m = post.created_at.strftime('%Y-%m')
if ms[m].nil?
ms[m] = 1
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
gravatar_image_url().should eql('http://www.gravatar.com/avatar/00000000000000000000000000000000')
end
end

context 'custom_permalink' do
before do
Option.permalink_enabled = true
Expand Down Expand Up @@ -50,4 +51,11 @@
end
end
end

describe 'months' do
subject { months }
before { FactoryGirl.create(:post, draft: true) }

it { subject.count.should == 0 }
end
end

0 comments on commit ee002ce

Please sign in to comment.