-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue #80] Add an archive data structure to the Posts extension.
Now, in addition to `site.posts` the Posts extension provides a `site.posts_archive` method returning Archive::Extensions::Posts:Archive To get an array of all the posts for August of 2012, call `site.posts_archive.posts[2012][08]` which returns an array of posts sorted by date.
- Loading branch information
Showing
2 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'awestruct/extensions/posts' | ||
|
||
describe Awestruct::Extensions::Posts::Archive do | ||
|
||
it "should store pages by year and month" do | ||
archive = Awestruct::Extensions::Posts::Archive.new | ||
page = create_page( 2012, 8 ) | ||
archive << page | ||
archive.posts[2012].should_not be_nil | ||
archive.posts[2012][8][0].should == page | ||
end | ||
|
||
def create_page(year, month) | ||
page = mock | ||
page.stub_chain(:date, :year).and_return( year ) | ||
page.stub_chain(:date, :month).and_return( month ) | ||
page | ||
end | ||
|
||
end | ||
|
||
|