summaryrefslogtreecommitdiff
path: root/test/functional/content_controller_test.rb
blob: 2e0ee0e61e7d56791afddac9c0e1ec2b4480a56f (plain)
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
63
64
65
66
require 'test_helper'

class ContentControllerTest < ActionController::TestCase

  def setup
    @root = Node.find(1)
    @first_child = Node.find(2)
    @second_child = Node.find(3)
    
    @user1 = User.create :login => 'demo', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar'
    @user2 = User.create :login => 'show', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar'
  end

  def test_custom_page_route
    assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'de', :page_path => ['foo', 'bar'] }, '/de/foo/bar')
    assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'en', :page_path => ['home'] }, '/en/home')
  end
  
  def test_render_404_when_no_page_was_found
    get :render_page, :language => 'de', :page_path => ["wrong_path"]
    assert_response 404
  end
  
  def test_rendering_a_page
    assert Node.valid?
    assert_not_nil first_child = Node.find_by_slug("first_child")
    page = first_child.pages.create :title => "First Child"
    first_child.head = page
    first_child.save!
    
    get :render_page, :language => 'de', :page_path => ["first_child"]
    assert_response :success
    assert_equal "layouts/application", @response.layout
  end
  
  def test_page_containing_aggregator
    assert_not_nil Node.root
    
    d1 = @first_child.find_or_create_draft @user1
    d1.title = "one"
    d1.tag_list = "update"
    d1.body = '<aggregate tags="update" limit="20" />'
    d1.save
    @first_child.publish_draft!
    
    d2 = @second_child.find_or_create_draft @user1
    d2.title = "two"
    d2.tag_list = "update"
    d2.save
    @second_child.publish_draft!
    
    get :render_page, :locale => 'de', :page_path => ["first_child"]
    assert_response :success
    
    assert_select("h2", "one")
    assert_select("h2", "two")
  end
  
  
  
  protected
  
    def create_update 
      
    end
end