Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 9608 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | require 'backend_controller' |
3 | require 'blogger_service' |
4 | require 'digest/sha1' |
5 | require 'base64' |
6 | |
7 | # Re-raise errors caught by the controller. |
8 | class BackendController; def rescue_action(e) raise e end; end |
9 | |
10 | class BackendControllerTest < Test::Unit::TestCase |
11 | fixtures :contents, :categories, :blogs, :users, :categorizations, :text_filters |
12 | |
13 | def setup |
14 | @controller = BackendController.new |
15 | @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new |
16 | @protocol = :xmlrpc |
17 | end |
18 | |
19 | # BloggerApi Tests |
20 | def test_blogger_delete_post |
21 | args = [ 'foo', 3, 'tobi', 'whatever', 1 ] |
22 | |
23 | result = invoke_layered :blogger, :deletePost, *args |
24 | assert_raise(ActiveRecord::RecordNotFound) { Article.find(3) } |
25 | end |
26 | |
27 | def test_blogger_get_users_blogs |
28 | args = [ 'foo', 'tobi', 'whatever' ] |
29 | |
30 | result = invoke_layered :blogger, :getUsersBlogs, *args |
31 | assert_equal result.first['blogName'], 'test blog' |
32 | end |
33 | |
34 | def test_blogger_get_user_info |
35 | args = [ 'foo', 'tobi', 'whatever' ] |
36 | |
37 | result = invoke_layered :blogger, :getUserInfo, *args |
38 | assert_equal 'tobi', result['userid'] |
39 | end |
40 | |
41 | def test_blogger_new_post |
42 | args = [ 'foo', '1', 'tobi', 'whatever', '<title>new post title</title>new post *body*', 1] |
43 | |
44 | result = invoke_layered :blogger, :newPost, *args |
45 | assert_not_nil result |
46 | new_post = Article.find(result) |
47 | assert_equal "new post title", new_post.title |
48 | assert_equal "new post *body*", new_post.body |
49 | assert_equal "<p>new post <strong>body</strong></p>", new_post.html(:body) |
50 | assert_equal "textile", new_post.text_filter.name |
51 | assert_equal users(:tobi), new_post.user |
52 | assert_equal this_blog.id, new_post.blog_id |
53 | assert new_post.published? |
54 | assert new_post[:published_at] |
55 | end |
56 | |
57 | def test_blogger_new_post_no_title |
58 | args = [ 'foo', '1', 'tobi', 'whatever', 'new post body for post without title but with a lenghty body', 1] |
59 | |
60 | result = invoke_layered :blogger, :newPost, *args |
61 | assert_not_nil result |
62 | new_post = Article.find(result) |
63 | assert_equal "new post body for post without", new_post.title |
64 | assert_equal "new post body for post without title but with a lenghty body", new_post.body |
65 | assert_equal "<p>new post body for post without title but with a lenghty body</p>", new_post.html(:body) |
66 | end |
67 | |
68 | def test_blogger_new_post_with_categories |
69 | args = [ 'foo', '1', 'tobi', 'whatever', '<title>new post title</title><category>Software, Hardware</category>new post body', 1] |
70 | |
71 | result = invoke_layered :blogger, :newPost, *args |
72 | assert_not_nil result |
73 | new_post = Article.find(result) |
74 | assert_equal "new post title", new_post.title |
75 | assert_equal "new post body", new_post.body |
76 | assert_equal [categories(:software), categories(:hardware)], new_post.categories.sort_by { |c| c.id } |
77 | assert_equal this_blog.id, new_post.blog_id |
78 | assert new_post.published? |
79 | end |
80 | |
81 | def test_blogger_new_post_with_non_existing_categories |
82 | args = [ 'foo', '1', 'tobi', 'whatever', '<title>new post title</title><category>Idontexist, Hardware</category>new post body', 1] |
83 | |
84 | result = invoke_layered :blogger, :newPost, *args |
85 | assert_not_nil result |
86 | new_post = Article.find(result) |
87 | assert_equal [categories(:hardware)], new_post.categories |
88 | assert_equal this_blog.id, new_post.blog_id |
89 | end |
90 | |
91 | def test_blogger_fail_authentication |
92 | args = [ 'foo', 'tobi', 'using a wrong password' ] |
93 | # This will be a little more useful with the upstream changes in [1093] |
94 | assert_raise(XMLRPC::FaultException) { invoke_layered :blogger, :getUsersBlogs, *args } |
95 | end |
96 | |
97 | # Meta Weblog Tests |
98 | def test_meta_weblog_get_categories |
99 | args = [ 1, 'tobi', 'whatever' ] |
100 | |
101 | result = invoke_layered :metaWeblog, :getCategories, *args |
102 | assert_equal 'Software', result.first |
103 | end |
104 | |
105 | def test_meta_weblog_get_post |
106 | args = [ 1, 'tobi', 'whatever' ] |
107 | |
108 | result = invoke_layered :metaWeblog, :getPost, *args |
109 | assert_equal result['title'], 'Article 1!' |
110 | end |
111 | |
112 | def test_meta_weblog_get_recent_posts |
113 | args = [ 1, 'tobi', 'whatever', 2 ] |
114 | |
115 | result = invoke_layered :metaWeblog, :getRecentPosts, *args |
116 | assert_equal result.size, 2 |
117 | assert_equal result.last['title'], 'Article 1!' |
118 | end |
119 | |
120 | def test_meta_weblog_delete_post |
121 | args = [ 1, 2, 'tobi', 'whatever', 1 ] |
122 | |
123 | result = invoke_layered :metaWeblog, :deletePost, *args |
124 | assert_raise(ActiveRecord::RecordNotFound) { Article.find(2) } |
125 | end |
126 | |
127 | def test_meta_weblog_edit_post |
128 | article = Article.find(1) |
129 | article.title = "Modified!" |
130 | article.body = "this is a *test*" |
131 | article.text_filter = TextFilter.find_by_name("textile") |
132 | article.published_at = Time.now.midnight |
133 | |
134 | args = [ 1, 'tobi', 'whatever', MetaWeblogService.new(@controller).article_dto_from(article), 1 ] |
135 | |
136 | result = invoke_layered :metaWeblog, :editPost, *args |
137 | assert result |
138 | |
139 | new_article = Article.find(1) |
140 | |
141 | assert_equal article.title, new_article.title |
142 | assert_equal article.body, new_article.body |
143 | assert_equal "<p>this is a <strong>test</strong></p>", new_article.html(:body) |
144 | assert_equal Time.now.midnight.to_s, new_article.published_at.to_s |
145 | assert_equal this_blog.id, new_article.blog_id |
146 | end |
147 | |
148 | def test_meta_weblog_new_post |
149 | article = Article.new |
150 | article.title = "Posted via Test" |
151 | article.body = "body" |
152 | article.extended = "extend me" |
153 | article.text_filter = TextFilter.find_by_name("textile") |
154 | article.published_at = Time.now.midnight |
155 | |
156 | args = [ 1, 'tobi', 'whatever', MetaWeblogService.new(@controller).article_dto_from(article), 1 ] |
157 | |
158 | result = invoke_layered :metaWeblog, :newPost, *args |
159 | assert result |
160 | new_post = Article.find(result) |
161 | |
162 | assert_equal "Posted via Test", new_post.title |
163 | assert_equal "textile", new_post.text_filter.name |
164 | assert_equal article.body, new_post.body |
165 | assert_equal "<p>body</p>", new_post.html(:body) |
166 | assert_equal article.extended, new_post.extended |
167 | assert_equal "<p>extend me</p>", new_post.html(:extended) |
168 | assert_equal Time.now.midnight.to_s, new_post.published_at.to_s |
169 | assert_equal this_blog.id, new_post.blog_id |
170 | end |
171 | |
172 | def test_meta_weblog_new_media_object |
173 | media_object = MetaWeblogStructs::MediaObject.new( |
174 | "name" => Digest::SHA1.hexdigest("upload-test--#{Time.now}--") + ".jpg", |
175 | "type" => "image/jpeg", |
176 | "bits" => Base64.encode64(File.open(File.expand_path(RAILS_ROOT) + "/public/images/header.jpg", "rb") { |f| f.read }) |
177 | ) |
178 | |
179 | args = [ 1, 'tobi', 'whatever', media_object ] |
180 | |
181 | result = invoke_layered :metaWeblog, :newMediaObject, *args |
182 | assert result['url'] =~ /#{media_object['name']}/ |
183 | assert File.unlink(File.expand_path(RAILS_ROOT) + "/public/files/#{media_object['name']}") |
184 | end |
185 | |
186 | def test_meta_weblog_fail_authentication |
187 | args = [ 1, 'tobi', 'using a wrong password', 2 ] |
188 | # This will be a little more useful with the upstream changes in [1093] |
189 | assert_raise(XMLRPC::FaultException) { invoke_layered :metaWeblog, :getRecentPosts, *args } |
190 | end |
191 | |
192 | # Movable Type Tests |
193 | |
194 | def test_mt_get_category_list |
195 | args = [ 1, 'tobi', 'whatever' ] |
196 | |
197 | result = invoke_layered :mt, :getCategoryList, *args |
198 | assert result.map { |c| c['categoryName'] }.include?('Software') |
199 | end |
200 | |
201 | def test_mt_get_post_categories |
202 | article = Article.find(1) |
203 | article.categories << categories(:software) |
204 | |
205 | args = [ 1, 'tobi', 'whatever' ] |
206 | |
207 | result = invoke_layered :mt, :getPostCategories, *args |
208 | assert_equal result.first['categoryName'], article.categories.first['name'] |
209 | end |
210 | |
211 | def test_mt_get_recent_post_titles |
212 | args = [ 1, 'tobi', 'whatever', 2 ] |
213 | |
214 | result = invoke_layered :mt, :getRecentPostTitles, *args |
215 | assert_equal result.first['title'], Article.find(2).title |
216 | end |
217 | |
218 | def test_mt_set_post_categories |
219 | args = [ 2, 'tobi', 'whatever', |
220 | [MovableTypeStructs::CategoryPerPost.new('categoryName' => 'personal', 'categoryId' => 3, 'isPrimary' => 1)] ] |
221 | |
222 | result = invoke_layered :mt, :setPostCategories, *args |
223 | assert_equal [categories(:personal)], Article.find(2).categories |
224 | |
225 | args = [ 2, 'tobi', 'whatever', |
226 | [MovableTypeStructs::CategoryPerPost.new('categoryName' => 'Software', 'categoryId' => 1, 'isPrimary' => 1), |
227 | MovableTypeStructs::CategoryPerPost.new('categoryName' => 'Hardware', 'categoryId' => 2, 'isPrimary' => 0) ]] |
228 | |
229 | result = invoke_layered :mt, :setPostCategories, *args |
230 | |
231 | assert Article.find(2).categories.include?(categories(:hardware)) |
232 | |
233 | end |
234 | |
235 | def test_mt_supported_text_filters |
236 | result = invoke_layered :mt, :supportedTextFilters |
237 | assert result.map {|f| f['label']}.include?('Markdown') |
238 | assert result.map {|f| f['label']}.include?('Textile') |
239 | end |
240 | |
241 | def test_mt_supported_methods |
242 | result = invoke_layered :mt, :supportedMethods |
243 | assert_equal 8, result.size |
244 | assert result.include?("publishPost") |
245 | end |
246 | |
247 | def test_mt_get_trackback_pings |
248 | args = [ 1 ] |
249 | |
250 | result = invoke_layered :mt, :getTrackbackPings, *args |
251 | |
252 | assert_equal result.first['pingTitle'], 'Trackback Entry' |
253 | end |
254 | |
255 | def test_mt_publish_post |
256 | args = [ 4, 'tobi', 'whatever' ] |
257 | |
258 | assert (not Article.find(4).published?) |
259 | |
260 | result = invoke_layered :mt, :publishPost, *args |
261 | |
262 | assert result |
263 | assert Article.find(4).published? |
264 | assert Article.find(4)[:published_at] |
265 | end |
266 | |
267 | def test_mt_fail_authentication |
268 | args = [ 1, 'tobi', 'using a wrong password', 2 ] |
269 | # This will be a little more useful with the upstream changes in [1093] |
270 | assert_raise(XMLRPC::FaultException) { invoke_layered :mt, :getRecentPostTitles, *args } |
271 | end |
272 | |
273 | end |