air18n 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Air18n
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -9,7 +9,7 @@ module Air18n
9
9
  tags_b = normalize_tags(extract_tags(text_b))
10
10
  if has_dubious_escape_characters?(text_a) || has_dubious_escape_characters?(text_b)
11
11
  { :safe => false, :reason => 'Backslashes are not allowed' }
12
- elsif tags_a != tags_b
12
+ elsif tags_a.group_by{|t| t} != tags_b.group_by{|t| t}
13
13
  { :safe => false, :reason => "HTML tags don't match: #{tags_a.inspect} vs. #{tags_b.inspect}" }
14
14
  else
15
15
  { :safe => true }
data/make_gem CHANGED
@@ -1,5 +1,5 @@
1
1
  # Run this to push the new version of the gem to rubygems!
2
- v=0.1.9
2
+ v=0.1.10
3
3
  gem build air18n.gemspec
4
4
  gem push air18n-${v}.gem
5
5
 
@@ -42,6 +42,17 @@ describe Air18n::PhraseTranslation do
42
42
  translation.errors.should include :value
43
43
  translation.errors[:value].should include "Translation has 12 characters; maximum length 10 characters."
44
44
  end
45
+
46
+ it 'Should check variables' do
47
+ phrase = FactoryGirl.create(:phrase, :key => 'phone_number_not_revealed_time_zone', :value => "Your number won't be revealed. They can only call from 9am to 9pm %{time_zone}.")
48
+ translation = FactoryGirl.create(:phrase_translation, :phrase => phrase, :key => 'phone_number_not_revealed_time_zone', :value => '您的電話號碼將不會被透露。他們只能在上午9時至晚上9時%{time_zone}這段時間給您致電')
49
+ validated = translation.save
50
+ validated.should == true
51
+ translation.value = '您的電話號碼將不會被透露。他們只能在上午9時至晚上9時%{time_zon}這段時間給您致電'
52
+ translation.save.should be_false
53
+ translation.errors.should include :value
54
+ translation.errors[:value].should include "Var %{time_zone} missing from translation; Var %{time_zon} should not be in translation"
55
+ end
45
56
  end
46
57
 
47
58
  context 'helpers' do
@@ -25,12 +25,20 @@ describe Air18n::XssDetector do
25
25
  it "should detect tag mismatches" do
26
26
  Air18n::XssDetector::safe?("<tag>", "safe").should == { :safe => false, :reason => "HTML tags don't match: #{['<tag>'].inspect} vs. #{[].inspect}" }
27
27
  Air18n::XssDetector::safe?("safe", "<tag>").should == { :safe => false, :reason => "HTML tags don't match: #{[].inspect} vs. #{['<tag>'].inspect}" }
28
+ Air18n::XssDetector::safe?("<b>safe</b>", "<b>safe</b><b>").should == { :safe => false, :reason => "HTML tags don't match: #{['<b>', '</b>'].inspect} vs. #{['<b>', '</b>', '<b>'].inspect}" }
28
29
  end
29
30
 
30
31
  it "should allow quote mismatches in tags" do
31
32
  Air18n::XssDetector::safe?("<a href='/help/question/280' target='_blank'>Why is this required?</a>", "<a href='/help/question/280' target='_blank'>...</a>").should == { :safe => true }
32
33
  Air18n::XssDetector::safe?("<tag href='hi'>", "<tag href=\"hi\">").should == { :safe => true }
33
34
  end
35
+
36
+ it "should allow reordering tags" do
37
+ Air18n::XssDetector::safe?(
38
+ "<span class='count'>%{count}</span> %{pluralized_review} left in <a href='#listings/search/%{encoded_search}' class='search_link'>%{city}, %{state} %{country}</a>",
39
+ "in <a href='#listings/search/%{encoded_search}' class='search_link'>%{city}, %{state} %{country}</a> <span class='count'>%{count}</span> %{pluralized_review} left"
40
+ ).should == { :safe => true }
41
+ end
34
42
  end
35
43
 
36
44
  describe "extract_tags" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: air18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-09-06 00:00:00.000000000 Z
16
+ date: 2012-09-17 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: i18n