public
Fork of yannlugrin/globalize
Description: Globalize is a Ruby on Rails plugin designed to support multilingual applications (official repository).
Homepage: http://www.globalize-rails.org
Clone URL: git://github.com/heythisisnate/globalize.git
globalize / test / view_picking_test.rb
100644 46 lines (37 sloc) 1.265 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require File.dirname(__FILE__) + '/test_helper'
 
class ViewPickingTest < Test::Unit::TestCase
  include Globalize
  fixtures :globalize_languages, :globalize_countries
 
  class TestController < ActionView::Base
  end
 
  def setup
    Locale.set("en-US")
    @base_path = File.dirname(__FILE__) + '/views'
  end
 
  def test_first
    tc = TestController.new([@base_path])
    assert_match /English/, tc.render("test")
    assert_no_match /Hebrew/, tc.render("test")
    Locale.set("he-IL")
    assert_match /Hebrew/, tc.render("test")
    assert_no_match /English/, tc.render("test")
  end
 
  def test_non_full_path
    tc = TestController.new([@base_path])
    assert_match /English/, tc.render_file("#{@base_path}/test.rhtml", false)
  end
 
  def test_nil
    Locale.set(nil)
    tc = TestController.new([@base_path])
    assert_match /English/, tc.render("test")
    assert_no_match /Hebrew/, tc.render("test")
    Locale.set("he-IL")
    assert_match /Hebrew/, tc.render("test")
    assert_no_match /English/, tc.render("test")
  end
 
  def test_non_full_path_nil
    Locale.set(nil)
    tc = TestController.new([@base_path])
    assert_match /English/, tc.render_file("#{@base_path}/test.rhtml", false)
  end
 
end