cirandas.net

ref: master

test/functional/doc_controller_test.rb


 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require_relative "../test_helper"

class DocControllerTest < ActionController::TestCase

  include Noosfero::DocTest

  def setup
    setup_doc_test
  end

  def tear_down
    tear_down_doc_test
  end

  should 'load toc in the root' do
    get :index
    assert_kind_of DocItem, assigns(:toc)
  end

  should 'display root document in the index' do
    get :index
    root = assigns(:index)
    assert_kind_of DocSection, root
  end

  should 'translate the index' do
    get :index
    assert_equal 'en', assigns(:index).language

    @controller.stubs(:language).returns('pt')
    get :index
    assert_equal 'pt', assigns(:index).language
  end

  should 'translate section' do
    get :section, :section => 'user'
    assert_equal 'en', assigns(:section).language

    @controller.stubs(:language).returns('pt')
    get :section, :section => 'user'
    assert_equal 'pt', assigns(:section).language
  end

  should 'translate topic' do
    get :topic, :section => 'user', :topic => 'accepting-friends'
    assert_equal 'en', assigns(:topic).language

    @controller.stubs(:language).returns('pt')
    get :topic, :section => 'user', :topic => 'accepting-friends'
    assert_equal 'pt', assigns(:topic).language
  end

  should 'use environment theme' do
    e = Environment.default
    e.theme = 'test-theme'
    e.save

    DocTopic.any_instance.expects(:html).with('test-theme')
    get :topic, :section => 'user', :topic => 'accepting-friends'
  end

end