spec for application_helper#page_title, with default text
This commit is contained in:
parent
3de3254826
commit
2c4954bac8
3 changed files with 32 additions and 8 deletions
|
|
@ -10,13 +10,9 @@ module ApplicationHelper
|
||||||
content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time
|
content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title text=nil
|
def page_title(text=nil)
|
||||||
title = ""
|
return text unless text.blank?
|
||||||
if text.blank?
|
current_user ? current_user.name : t("application.helper.diaspora_alpha")
|
||||||
title = "#{current_user.name}" if current_user
|
|
||||||
else
|
|
||||||
title = "#{text}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspects_with_post aspects, post
|
def aspects_with_post aspects, post
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ en:
|
||||||
unknown_person: "unknown person"
|
unknown_person: "unknown person"
|
||||||
video_title:
|
video_title:
|
||||||
unknown: "Unknown Video Title"
|
unknown: "Unknown Video Title"
|
||||||
|
diaspora_alpha: "DIASPORA* ALPHA"
|
||||||
aspects:
|
aspects:
|
||||||
zero: "no aspects"
|
zero: "no aspects"
|
||||||
one: "1 aspect"
|
one: "1 aspect"
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ describe ApplicationHelper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "markdownify" do
|
describe "#markdownify" do
|
||||||
describe "autolinks" do
|
describe "autolinks" do
|
||||||
it "should not allow basic XSS/HTML" do
|
it "should not allow basic XSS/HTML" do
|
||||||
markdownify("<script>alert('XSS is evil')</script>").should == "<script>alert('XSS is evil')</script>"
|
markdownify("<script>alert('XSS is evil')</script>").should == "<script>alert('XSS is evil')</script>"
|
||||||
|
|
@ -301,4 +301,31 @@ describe ApplicationHelper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#page_title" do
|
||||||
|
before do
|
||||||
|
def current_user
|
||||||
|
@current_user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "passed blank text" do
|
||||||
|
it "returns current_user.name if logged in" do
|
||||||
|
@current_user = @user
|
||||||
|
page_title.should == @user.name
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns default title if not logged in" do
|
||||||
|
@current_user = nil
|
||||||
|
page_title.should == I18n.t("application.helper.diaspora_alpha")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "passed text" do
|
||||||
|
it "returns the text" do
|
||||||
|
text = "This is the title"
|
||||||
|
page_title(text).should == text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue