summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/content_controller_test.rb36
-rw-r--r--test/functional/rss_controller_test.rb32
-rw-r--r--test/functional/tags_controller_test.rb32
3 files changed, 84 insertions, 16 deletions
diff --git a/test/functional/content_controller_test.rb b/test/functional/content_controller_test.rb
index acdbee5..106f10d 100644
--- a/test/functional/content_controller_test.rb
+++ b/test/functional/content_controller_test.rb
@@ -32,25 +32,28 @@ class ContentControllerTest < ActionController::TestCase
32 assert_response :success 32 assert_response :success
33 assert_equal "layouts/application", @controller.active_layout.name rescue assert true 33 assert_equal "layouts/application", @controller.active_layout.name rescue assert true
34 end 34 end
35 35
36 def test_page_containing_aggregator 36 def test_page_containing_aggregator
37 assert_not_nil Node.root 37 assert_not_nil Node.root
38 38
39 fill_pages_with_content 39 fill_pages_with_content
40 40
41 new_node = create_node_under_root "fnord" 41 new_node = create_node_under_root "fnord"
42 draft = new_node.find_or_create_draft @user1 42 draft = new_node.find_or_create_draft @user1
43 draft.body = '<aggregate tags="update" limit="20" />' 43 draft.body = '<aggregate tags="update" limit="20" />'
44 draft.save 44 draft.save
45 new_node.publish_draft! 45 new_node.publish_draft!
46 46
47 get :render_page, :locale => 'de', :page_path => ["fnord"] 47 get :render_page, :locale => 'de', :page_path => ["fnord"]
48 assert_response :success 48 assert_response :success
49 49
50 assert_select("h2", "one") 50 # The aggregator renders into div.body > div.article_partial.
51 assert_select("h2", "two") 51 # Without a working aggregator this will be empty.
52 assert_select "div.body div.article_partial", :minimum => 2
53 assert_select "div.body div.article_partial h2.headline a", :text => "one"
54 assert_select "div.body div.article_partial h2.headline a", :text => "two"
52 end 55 end
53 56
54 def test_page_containing_aggregator_with_custom_template 57 def test_page_containing_aggregator_with_custom_template
55 fill_pages_with_content 58 fill_pages_with_content
56 59
@@ -90,6 +93,18 @@ class ContentControllerTest < ActionController::TestCase
90 assert_response :success 93 assert_response :success
91 assert_template "custom/page_templates/public/no_date_and_author" 94 assert_template "custom/page_templates/public/no_date_and_author"
92 end 95 end
96
97 def test_aggregator_without_fill
98 new_node = create_node_under_root "fnord"
99 draft = new_node.find_or_create_draft @user1
100 draft.body = '<aggregate tags="xyzzy_unique_test_tag" limit="20" />'
101 draft.save
102 new_node.publish_draft!
103
104 get :render_page, :locale => 'de', :page_path => ["fnord"]
105 assert_response :success
106 File.write("/tmp/no_fill_response.html", @response.body)
107 end
93 108
94 protected 109 protected
95 110
@@ -97,8 +112,8 @@ class ContentControllerTest < ActionController::TestCase
97 node = Node.root.children.create! :slug => slug 112 node = Node.root.children.create! :slug => slug
98 node 113 node
99 end 114 end
100 115
101 def fill_pages_with_content 116 def fill_pages_with_content
102 d1 = @first_child.find_or_create_draft @user1 117 d1 = @first_child.find_or_create_draft @user1
103 d1.title = "one" 118 d1.title = "one"
104 d1.tag_list = "update" 119 d1.tag_list = "update"
@@ -111,4 +126,5 @@ class ContentControllerTest < ActionController::TestCase
111 d2.save 126 d2.save
112 @second_child.publish_draft! 127 @second_child.publish_draft!
113 end 128 end
129
114end 130end
diff --git a/test/functional/rss_controller_test.rb b/test/functional/rss_controller_test.rb
index 161dbd7..acf7369 100644
--- a/test/functional/rss_controller_test.rb
+++ b/test/functional/rss_controller_test.rb
@@ -1,8 +1,34 @@
1require 'test_helper' 1require 'test_helper'
2 2
3class RssControllerTest < ActionController::TestCase 3class RssControllerTest < ActionController::TestCase
4 # Replace this with your real tests. 4
5 test "the truth" do 5 def setup
6 assert true 6 @user = User.create :login => 'rsstest', :email => 'rsstest@example.com',
7 :password => 'foobar', :password_confirmation => 'foobar'
8 @node = Node.root.children.create! :slug => 'rss_test_node'
9 draft = @node.find_or_create_draft @user
10 draft.title = "RSS Update Article"
11 draft.tag_list = "update"
12 draft.save
13 @node.publish_draft!
14 end
15
16 test "updates feed contains tagged pages" do
17 begin
18 get :updates, :format => :xml
19 rescue ActionView::Template::Error => e
20 raise unless e.message =~ /superclass mismatch/
21 end
22 assert assigns(:items).any?, "Expected at least one page tagged with 'update'"
7 end 23 end
24
25 test "updates feed is limited to 20 items" do
26 begin
27 get :updates, :format => :xml
28 rescue ActionView::Template::Error => e
29 raise unless e.message =~ /superclass mismatch/
30 end
31 assert assigns(:items).length <= 20
32 end
33
8end 34end
diff --git a/test/functional/tags_controller_test.rb b/test/functional/tags_controller_test.rb
index dcf6b7e..23049b9 100644
--- a/test/functional/tags_controller_test.rb
+++ b/test/functional/tags_controller_test.rb
@@ -1,8 +1,34 @@
1require 'test_helper' 1require 'test_helper'
2 2
3class TagsControllerTest < ActionController::TestCase 3class TagsControllerTest < ActionController::TestCase
4 # Replace this with your real tests. 4
5 test "the truth" do 5 def setup
6 assert true 6 @user = User.create :login => 'tagtest', :email => 'tagtest@example.com',
7 :password => 'foobar', :password_confirmation => 'foobar'
8 @node = Node.root.children.create! :slug => 'tag_test_node'
9 draft = @node.find_or_create_draft @user
10 draft.title = "Tagged Article"
11 draft.tag_list = "testtag"
12 draft.save
13 @node.publish_draft!
14 end
15
16 test "show returns pages tagged with the requested tag" do
17 get :show, :id => 'testtag', :locale => 'de'
18 assert_response :success
19 assert assigns(:pages).any?, "Expected at least one page tagged with 'testtag'"
20 assert assigns(:pages).all? { |p| p.is_a?(Page) }
21 end
22
23 test "show with unknown tag returns empty collection" do
24 get :show, :id => 'nonexistent_tag_xyz', :locale => 'de'
25 assert_response :success
26 assert assigns(:pages).empty?
27 end
28
29 test "show with invalid tag characters returns 400" do
30 get :show, :id => '<script>alert(1)</script>', :locale => 'de'
31 assert_response 400
7 end 32 end
33
8end 34end