diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 778e43355..de84b804e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,13 +10,9 @@ module ApplicationHelper content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time end - def page_title text=nil - title = "" - if text.blank? - title = "#{current_user.name}" if current_user - else - title = "#{text}" - end + def page_title(text=nil) + return text unless text.blank? + current_user ? current_user.name : t("application.helper.diaspora_alpha") end def aspects_with_post aspects, post diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 0d0d8af8d..af94f78da 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -74,6 +74,7 @@ en: unknown_person: "unknown person" video_title: unknown: "Unknown Video Title" + diaspora_alpha: "DIASPORA* ALPHA" aspects: zero: "no aspects" one: "1 aspect" diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 4a2ac74ce..005b3fd97 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -42,7 +42,7 @@ describe ApplicationHelper do end end - describe "markdownify" do + describe "#markdownify" do describe "autolinks" do it "should not allow basic XSS/HTML" do markdownify("").should == "<script>alert('XSS is evil')</script>" @@ -301,4 +301,31 @@ describe ApplicationHelper do 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