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:
- 7263 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, :feedback, :users, :categories, :resources, :text_filters, |
11 | :blogs, :categorizations |
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_template 'list' |
23 | end |
24 | |
25 | def test_list |
26 | get :list |
27 | assert_template 'list' |
28 | assert_template_has 'articles' |
29 | end |
30 | |
31 | def test_show |
32 | get :show, 'id' => 1 |
33 | assert_template 'show' |
34 | assert_template_has 'article' |
35 | assert_valid assigns(: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_template '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_response :redirect, :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_response :redirect, :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_response :redirect, :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(:body) |
121 | assert_equal "<p><strong>foo</strong></p>", new_article.html(: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_template 'edit' |
128 | assert_template_has 'article' |
129 | assert_valid assigns(: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_response :redirect, :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 | |
144 | assert_equal 0, emails.size |
145 | end |
146 | |
147 | def test_destroy |
148 | assert_not_nil Article.find(1) |
149 | |
150 | get :destroy, 'id' => 1 |
151 | assert_response :success |
152 | |
153 | post :destroy, 'id' => 1 |
154 | assert_response :redirect, :action => 'list' |
155 | |
156 | assert_raise(ActiveRecord::RecordNotFound) { |
157 | article = Article.find(1) |
158 | } |
159 | end |
160 | |
161 | def test_category_add |
162 | get :category_add, :id => 1, :category_id => 1 |
163 | |
164 | assert_template '_show_categories' |
165 | assert_valid assigns(:article) |
166 | assert_valid assigns(:category) |
167 | assert Article.find(1).categories.include?(Category.find(1)) |
168 | assert_not_nil assigns(:article) |
169 | assert_not_nil assigns(:category) |
170 | assert_not_nil assigns(:categories) |
171 | end |
172 | |
173 | def test_category_remove |
174 | get :category_remove, :id => 1, :category_id => 1 |
175 | |
176 | assert_template '_show_categories' |
177 | assert_valid assigns(:article) |
178 | assert_valid assigns(:category) |
179 | assert !Article.find(1).categories.include?(Category.find(1)) |
180 | assert_not_nil assigns(:article) |
181 | assert_not_nil assigns(:category) |
182 | assert_not_nil assigns(:categories) |
183 | end |
184 | |
185 | def test_resource_add |
186 | get :resource_add, :id => 1, :resource_id => 1 |
187 | |
188 | assert_template '_show_resources' |
189 | assert_valid assigns(:article) |
190 | assert_valid assigns(:resource) |
191 | assert Article.find(1).resources.include?(Resource.find(1)) |
192 | assert_not_nil assigns(:article) |
193 | assert_not_nil assigns(:resource) |
194 | assert_not_nil assigns(:resources) |
195 | end |
196 | |
197 | def test_resource_remove |
198 | get :resource_remove, :id => 1, :resource_id => 1 |
199 | |
200 | assert_template '_show_resources' |
201 | assert_valid assigns(:article) |
202 | assert_valid assigns(:resource) |
203 | assert !Article.find(1).resources.include?(Resource.find(1)) |
204 | assert_not_nil assigns(:article) |
205 | assert_not_nil assigns(:resource) |
206 | assert_not_nil assigns(:resources) |
207 | end |
208 | |
209 | def test_attachment_box_add |
210 | get :attachment_box_add, :id => 2 |
211 | assert_template '_attachment' |
212 | #assert_tag :tag => 'script' |
213 | end |
214 | |
215 | def test_resource_container |
216 | get :show, :id => contents(:article1).id # article without attachments |
217 | Resource.find(:all).each do |resource| |
218 | assert_tag( :tag => 'a', |
219 | :attributes =>{ |
220 | :onclick => |
221 | /^new Ajax.Updater\('resources/ |
222 | }, |
223 | :content => /[-+] #{resource.filename}/) |
224 | end |
225 | end |
226 | end |