Permalink
Browse files

Add "link text" metadata and Page#link_text method.

  • Loading branch information...
MicahChalmer committed Apr 6, 2012
1 parent 9d5505c commit 2d541db3fd91c4435bbd6cb84c4188e5e91d002f
Showing with 15 additions and 1 deletion.
  1. +4 −0 lib/nesta/models.rb
  2. +11 −1 spec/models_spec.rb
View
@@ -217,6 +217,10 @@ def heading
markup =~ regex
Regexp.last_match(1)
end
+
+ def link_text
+ metadata('link text') || heading
+ end
def title
if metadata('title')
View
@@ -350,6 +350,10 @@ def create_page(options)
it "should parse heading correctly" do
@article.to_html.should have_tag("h1", "My article")
end
+
+ it "should use heading as link text" do
+ @article.link_text.should == "My article"
+ end
it "should have default read more link text" do
@article.read_more.should == "Continue reading"
@@ -374,6 +378,7 @@ def create_page(options)
@summary = 'Multiline\n\nsummary'
@read_more = 'Continue at your leisure'
@skillz = 'ruby, guitar, bowstaff'
+ @link_text = 'Link to stuff page'
@article = create_article(:metadata => {
'date' => @date.gsub('September', 'Sep'),
'description' => @description,
@@ -383,7 +388,8 @@ def create_page(options)
'read more' => @read_more,
'skillz' => @skillz,
'summary' => @summary,
- 'template' => @template
+ 'template' => @template,
+ 'link text' => @link_text,
})
end
@@ -459,6 +465,10 @@ def create_page(options)
it "should know whether or not it's a draft" do
@article.should be_draft
end
+
+ it "should allow link text to be specified explicitly" do
+ @article.link_text.should == @link_text
+ end
end
describe "when checking last modification time" do

0 comments on commit 2d541db

Please sign in to comment.