aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/i18n_interpolation.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-02-14 18:56:16 +0000
committerLouise Crow <louise.crow@gmail.com>2013-02-14 19:03:40 +0000
commitbc0cc811e80143d0255d86433a80a823d1141dd0 (patch)
tree0c5005b2b03e540d8ab562da06539414709fbc18 /spec/lib/i18n_interpolation.rb
parent6fa9c17c7cd5551489a77f6e89543b7886be51d4 (diff)
parent2c5749d4d92e6601856cef6f7e2201d06d885183 (diff)
Merge branch 'release/0.7'0.7.00.7
Diffstat (limited to 'spec/lib/i18n_interpolation.rb')
-rw-r--r--spec/lib/i18n_interpolation.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/lib/i18n_interpolation.rb b/spec/lib/i18n_interpolation.rb
index 6b745059c..e8d046757 100644
--- a/spec/lib/i18n_interpolation.rb
+++ b/spec/lib/i18n_interpolation.rb
@@ -8,5 +8,43 @@ describe "when using i18n" do
result = _('Hello {{dip}}', :dip => 'hummus')
result.should == 'Hello hummus'
end
+
+ it "should assume that simple translations are always html safe" do
+ _("Hello").should be_html_safe
+ end
+
end
+describe "gettext_interpolate" do
+ context "html unsafe string" do
+ let(:string) { "Hello {{a}}" }
+
+ it "should give an unsafe result" do
+ result = gettext_interpolate(string, :a => "foo")
+ result.should == "Hello foo"
+ result.should_not be_html_safe
+ end
+
+ it "should give an unsafe result" do
+ result = gettext_interpolate(string, :a => "foo".html_safe)
+ result.should == "Hello foo"
+ result.should_not be_html_safe
+ end
+ end
+
+ context "html safe string" do
+ let(:string) { "Hello {{a}}".html_safe }
+
+ it "should quote the input if it's unsafe" do
+ result = gettext_interpolate(string, :a => "foo&")
+ result.should == "Hello foo&amp;"
+ result.should be_html_safe
+ end
+
+ it "should not quote the input if it's safe" do
+ result = gettext_interpolate(string, :a => "foo&".html_safe)
+ result.should == "Hello foo&"
+ result.should be_html_safe
+ end
+ end
+end