Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 7589 Bytes
1 | require File.dirname(__FILE__) + '/../../test_helper' |
2 | require 'admin/content_controller' |
3 | |
4 | require 'http_mock' |
5 | |
6 | # Re-raise errors caught by the controller. |
7 | class Admin::ContentController; def rescue_action(e) raise e end; end |
8 | |
9 | class Admin::ContentControllerTest < Test::Unit::TestCase |
10 | fixtures :contents, :users, :categories, :resources, :text_filters, |
11 | :blogs, :articles_categories |
12 | |
13 | def setup |
14 | @controller = Admin::ContentController.new |
15 | @request = ActionController::TestRequest.new |
16 | @response = ActionController::TestResponse.new |
17 | @request.session = { :user => users(:tobi) } |
18 | end |
19 | |
20 | def test_index |
21 | get :index |
22 | assert_rendered_file 'list' |
23 | end |
24 | |
25 | def test_list |
26 | get :list |
27 | assert_rendered_file 'list' |
28 | assert_template_has 'articles' |
29 | end |
30 | |
31 | def test_show |
32 | get :show, 'id' => 1 |
33 | assert_rendered_file 'show' |
34 | assert_template_has 'article' |
35 | assert_valid_record 'article' |
36 | assert_not_nil assigns(:article) |
37 | assert_not_nil assigns(:categories) |
38 | assert_not_nil assigns(:resources) |
39 | end |
40 | |
41 | def test_new |
42 | get :new |
43 | assert_rendered_file 'new' |
44 | assert_template_has 'article' |
45 | end |
46 | |
47 | def test_create_no_comments |
48 | post(:new, 'article' => { :title => "posted via tests!", :body => "You can't comment", |
49 | :keywords => "tagged", |
50 | :allow_comments => '0', :allow_pings => '1' }, |
51 | 'categories' => [1]) |
52 | assert !assigns(:article).allow_comments? |
53 | assert assigns(:article).allow_pings? |
54 | assert assigns(:article).published? |
55 | end |
56 | |
57 | def test_create_with_no_pings |
58 | post(:new, 'article' => { :title => "posted via tests!", :body => "You can't ping!", |
59 | :keywords => "tagged", |
60 | :allow_comments => '1', :allow_pings => '0' }, |
61 | 'categories' => [1]) |
62 | assert assigns(:article).allow_comments? |
63 | assert !assigns(:article).allow_pings? |
64 | assert assigns(:article).published? |
65 | end |
66 | |
67 | def test_create |
68 | num_articles = this_blog.published_articles.size |
69 | emails = ActionMailer::Base.deliveries |
70 | emails.clear |
71 | tags = ['foo', 'bar', 'baz bliz', 'gorp gack gar'] |
72 | post :new, 'article' => { :title => "posted via tests!", :body => "Foo", :keywords => "foo bar 'baz bliz' \"gorp gack gar\""}, 'categories' => [1] |
73 | assert_redirected_to :action => 'show' |
74 | |
75 | assert_equal num_articles + 1, this_blog.published_articles.size |
76 | |
77 | new_article = Article.find(:first, :order => "id DESC") |
78 | assert_equal users(:tobi), new_article.user |
79 | assert_equal 1, new_article.categories.size |
80 | assert_equal [1], new_article.categories.collect {|c| c.id} |
81 | assert_equal 4, new_article.tags.size |
82 | |
83 | assert_equal(1, emails.size) |
84 | assert_equal('randomuser@example.com', emails.first.to[0]) |
85 | end |
86 | |
87 | def test_create_future_article |
88 | num_articles = this_blog.published_articles.size |
89 | post(:new, |
90 | :article => { :title => "News from the future!", |
91 | :body => "The future's cool!", |
92 | :published_at => Time.now + 1.hour }) |
93 | assert_redirected_to :action => 'show' |
94 | assert ! assigns(:article).published? |
95 | assert_equal num_articles, this_blog.published_articles.size |
96 | assert_equal 1, Trigger.count |
97 | end |
98 | |
99 | def test_request_fires_triggers |
100 | art = this_blog.articles.create!(:title => 'future article', |
101 | :body => 'content', |
102 | :published_at => Time.now + 2.seconds, |
103 | :published => true) |
104 | assert !art.published? |
105 | sleep 3 |
106 | get(:show, :id => art.id) |
107 | assert assigns(:article).published? |
108 | end |
109 | |
110 | def test_create_filtered |
111 | body = "body via *textile*" |
112 | extended="*foo*" |
113 | post :new, 'article' => { :title => "another test", :body => body, :extended => extended} |
114 | assert_redirected_to :action => 'show' |
115 | |
116 | new_article = Article.find(:first, :order => "created_at DESC") |
117 | assert_equal body, new_article.body |
118 | assert_equal extended, new_article.extended |
119 | assert_equal "textile", new_article.text_filter.name |
120 | assert_equal "<p>body via <strong>textile</strong></p>", new_article.html(@controller, :body) |
121 | assert_equal "<p><strong>foo</strong></p>", new_article.html(@controller, :extended) |
122 | end |
123 | |
124 | def test_edit |
125 | get :edit, 'id' => 1 |
126 | assert_equal assigns(:selected), Article.find(1).categories.collect {|c| c.id} |
127 | assert_rendered_file 'edit' |
128 | assert_template_has 'article' |
129 | assert_valid_record 'article' |
130 | end |
131 | |
132 | def test_update |
133 | emails = ActionMailer::Base.deliveries |
134 | emails.clear |
135 | |
136 | body = "another *textile* test" |
137 | post :edit, 'id' => 1, 'article' => {:body => body, :text_filter => 'textile'} |
138 | assert_redirected_to :action => 'show', :id => 1 |
139 | |
140 | article = Article.find(1) |
141 | assert_equal "textile", article.text_filter.name |
142 | assert_equal body, article.body |
143 | # Deliberately *not* using the mediating protocol, we want to ensure that the |
144 | # body_html got reset to nil. |
145 | assert_nil article.body_html |
146 | |
147 | assert_equal 0, emails.size |
148 | end |
149 | |
150 | def test_destroy |
151 | assert_not_nil Article.find(1) |
152 | |
153 | get :destroy, 'id' => 1 |
154 | assert_success |
155 | |
156 | post :destroy, 'id' => 1 |
157 | assert_redirected_to :action => 'list' |
158 | |
159 | assert_raise(ActiveRecord::RecordNotFound) { |
160 | article = Article.find(1) |
161 | } |
162 | end |
163 | |
164 | def test_category_add |
165 | get :category_add, :id => 1, :category_id => 1 |
166 | |
167 | assert_rendered_file '_show_categories' |
168 | assert_valid_record 'article' |
169 | assert_valid_record 'category' |
170 | assert Article.find(1).categories.include?(Category.find(1)) |
171 | assert_not_nil assigns(:article) |
172 | assert_not_nil assigns(:category) |
173 | assert_not_nil assigns(:categories) |
174 | end |
175 | |
176 | def test_category_remove |
177 | get :category_remove, :id => 1, :category_id => 1 |
178 | |
179 | assert_rendered_file '_show_categories' |
180 | assert_valid_record 'article' |
181 | assert_valid_record 'category' |
182 | assert !Article.find(1).categories.include?(Category.find(1)) |
183 | assert_not_nil assigns(:article) |
184 | assert_not_nil assigns(:category) |
185 | assert_not_nil assigns(:categories) |
186 | end |
187 | |
188 | def test_resource_add |
189 | get :resource_add, :id => 1, :resource_id => 1 |
190 | |
191 | assert_rendered_file '_show_resources' |
192 | assert_valid_record 'article' |
193 | assert_valid_record 'resource' |
194 | assert Article.find(1).resources.include?(Resource.find(1)) |
195 | assert_not_nil assigns(:article) |
196 | assert_not_nil assigns(:resource) |
197 | assert_not_nil assigns(:resources) |
198 | end |
199 | |
200 | def test_resource_remove |
201 | get :resource_remove, :id => 1, :resource_id => 1 |
202 | |
203 | assert_rendered_file '_show_resources' |
204 | assert_valid_record 'article' |
205 | assert_valid_record 'resource' |
206 | assert !Article.find(1).resources.include?(Resource.find(1)) |
207 | assert_not_nil assigns(:article) |
208 | assert_not_nil assigns(:resource) |
209 | assert_not_nil assigns(:resources) |
210 | end |
211 | |
212 | def test_attachment_box_add |
213 | get :attachment_box_add, :id => 2 |
214 | assert_rendered_file '_attachment' |
215 | #assert_tag :tag => 'script' |
216 | end |
217 | |
218 | def test_attachment_box_remove |
219 | get :attachment_box_remove, :id => 1 |
220 | assert_tag :tag => 'script', :attributes => {:type => 'text/javascript'} |
221 | end |
222 | |
223 | def test_resource_container |
224 | get :show, :id => contents(:article1).id # article without attachments |
225 | Resource.find(:all).each do |resource| |
226 | assert_tag( :tag => 'a', |
227 | :attributes =>{ |
228 | :onclick => |
229 | /^new Ajax.Updater\('resources/ |
230 | }, |
231 | :content => /[-+] #{resource.filename}/) |
232 | end |
233 | end |
234 | end |