typo 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/app/controllers/admin/feedback_controller.rb +6 -1
  2. data/app/controllers/articles_controller.rb +3 -1
  3. data/app/controllers/backend_controller.rb +2 -0
  4. data/app/helpers/admin/base_helper.rb +2 -2
  5. data/app/helpers/admin/feedback_helper.rb +6 -3
  6. data/app/models/article.rb +2 -1
  7. data/app/models/comment.rb +1 -1
  8. data/app/models/content_state/base.rb +4 -0
  9. data/app/models/content_state/ham.rb +6 -1
  10. data/app/models/content_state/just_marked_as_ham.rb +5 -0
  11. data/app/models/content_state/just_marked_as_spam.rb +1 -0
  12. data/app/models/content_state/just_presumed_ham.rb +1 -0
  13. data/app/models/content_state/presumed_ham.rb +5 -0
  14. data/app/models/content_state/presumed_spam.rb +1 -0
  15. data/app/models/content_state/spam.rb +5 -0
  16. data/app/models/feedback.rb +4 -0
  17. data/app/views/admin/categories/show.rhtml +1 -0
  18. data/app/views/admin/feedback/_item.rhtml +3 -1
  19. data/app/views/admin/feedback/list.rhtml +7 -5
  20. data/bin/typo +1 -0
  21. data/db/migrate/050_add_status_confirmed_field_to_content.rb +19 -0
  22. data/db/schema.mysql-v3.sql +3 -2
  23. data/db/schema.mysql.sql +3 -2
  24. data/db/schema.postgresql.sql +3 -2
  25. data/db/schema.rb +2 -1
  26. data/db/schema.sqlite.sql +3 -2
  27. data/db/schema.sqlserver.sql +3 -2
  28. data/db/schema_version +1 -1
  29. data/lib/spam_protection.rb +1 -1
  30. data/lib/tasks/release.rake +2 -2
  31. data/lib/typo_version.rb +1 -1
  32. data/test/fixtures/contents.yml +53 -0
  33. data/test/functional/admin/feedback_controller_test.rb +36 -1
  34. data/test/functional/xml_controller_test.rb +4 -4
  35. data/test/unit/article_test.rb +2 -1
  36. data/test/unit/blog_test.rb +1 -1
  37. data/test/unit/comment_test.rb +21 -0
  38. data/test/unit/user_test.rb +3 -3
  39. data/vendor/akismet/akismet.rb +23 -14
  40. metadata +4 -4
  41. data/.DS_Store +0 -0
@@ -4,7 +4,7 @@ class Admin::FeedbackController < Admin::BaseController
4
4
  model :comment, :trackback
5
5
 
6
6
  def index
7
- conditions = ['1=1', {}]
7
+ conditions = ['blog_id = :blog_id', {:blog_id => Blog.default.id}]
8
8
 
9
9
  if params[:search]
10
10
  conditions.first << ' and (url like :pattern or author like :pattern or title like :pattern or ip like :pattern or email like :pattern)'
@@ -16,6 +16,11 @@ class Admin::FeedbackController < Admin::BaseController
16
16
  conditions.last.merge!(:published => false)
17
17
  end
18
18
 
19
+ if params[:confirmed] == 'f'
20
+ conditions.first << ' AND (status_confirmed = :status_confirmed)'
21
+ conditions.last.merge!(:status_confirmed => false)
22
+ end
23
+
19
24
  @pages, @feedback = paginate(:feedback,
20
25
  :order => 'contents.created_at desc',
21
26
  :conditions => conditions,
@@ -101,7 +101,9 @@ class ArticlesController < ContentController
101
101
  :user_agent => request.env['HTTP_USER_AGENT'],
102
102
  :referrer => request.env['HTTP_REFERER'],
103
103
  :permalink => this_blog.article_url(@article, false)})
104
- @comment = @article.comments.create!(params[:comment])
104
+ @comment = @article.comments.build(params[:comment])
105
+ @comment.author ||= 'Anonymous'
106
+ @comment.save!
105
107
  add_to_cookies(:author, @comment.author)
106
108
  add_to_cookies(:url, @comment.url)
107
109
 
@@ -3,6 +3,8 @@ class BackendController < ContentController
3
3
  session :off
4
4
 
5
5
  web_service_dispatching_mode :layered
6
+ web_service_exception_reporting false
7
+
6
8
  web_service(:metaWeblog) { MetaWeblogService.new(self) }
7
9
  web_service(:mt) { MovableTypeService.new(self) }
8
10
  web_service(:blogger) { BloggerService.new(self) }
@@ -26,9 +26,9 @@ module Admin::BaseHelper
26
26
 
27
27
  def current_user_notice
28
28
  unless session[:user]
29
- link_to "log in", :controller => "accounts", :action=>"login"
29
+ link_to "log in", :controller => "/accounts", :action=>"login"
30
30
  else
31
- link_to "log out", :controller => "accounts", :action=>"logout"
31
+ link_to "log out", :controller => "/accounts", :action=>"logout"
32
32
  end
33
33
  end
34
34
 
@@ -2,8 +2,11 @@ module Admin::FeedbackHelper
2
2
  def link_to_article_edit(article)
3
3
  link_to truncate(article.title, 60), :controller => 'content', :action => 'edit', :id => article.id
4
4
  end
5
-
5
+
6
6
  def task_showmod(title)
7
- content_tag :li, link_to(title, :published => 'f', :search => params[:search])
8
- end
7
+ content_tag :li,
8
+ link_to(title, :published => (title =~ /spam/ ? 'f' : ''),
9
+ :confirmed => (title =~ /unconfirmed/ ? 'f' : ''),
10
+ :search => params[:search])
11
+ end
9
12
  end
@@ -60,7 +60,8 @@ class Article < Content
60
60
  ping.send_pingback_or_trackback(articleurl)
61
61
  end
62
62
  end
63
- rescue
63
+ rescue Exception => e
64
+ logger.error(e)
64
65
  # in case the remote server doesn't respond or gives an error,
65
66
  # we should throw an xmlrpc error here.
66
67
  end
@@ -42,7 +42,7 @@ class Comment < Feedback
42
42
  end
43
43
 
44
44
  def body_html_postprocess(value, controller)
45
- sanitize(controller.send(:auto_link, value),'a href, b, br, i, p, em, strong, pre, code, ol, ul, li')
45
+ sanitize(controller.send(:auto_link, value),'a href, b, br, i, p, em, strong, pre, code, ol, ul, li, blockquote')
46
46
  end
47
47
 
48
48
  def default_text_filter_config_key
@@ -87,6 +87,10 @@ module ContentState
87
87
  false
88
88
  end
89
89
 
90
+ def status_confirmed?(content)
91
+ false
92
+ end
93
+
90
94
  def logger
91
95
  @logger ||= RAILS_DEFAULT_LOGGER || Logger.new(STDERR)
92
96
  end
@@ -5,13 +5,18 @@ module ContentState
5
5
 
6
6
  def enter_hook(content)
7
7
  super
8
- content[:published] = true
8
+ content[:published] = true
9
+ content[:status_confirmed] = true
9
10
  end
10
11
 
11
12
  def published?(content)
12
13
  true
13
14
  end
14
15
 
16
+ def status_confirmed?(content)
17
+ true
18
+ end
19
+
15
20
  def before_save(content)
16
21
  content.report_as_ham
17
22
  true
@@ -3,6 +3,11 @@ module ContentState
3
3
  include Reloadable
4
4
  include Singleton
5
5
 
6
+ def enter_hook(content)
7
+ super
8
+ content[:status_confirmed] = true
9
+ end
10
+
6
11
  def memento
7
12
  'ContentState::Ham'
8
13
  end
@@ -3,6 +3,7 @@ module ContentState
3
3
  def enter_hook(content)
4
4
  logger.debug("#{content} entering state Content::JustMarkedAsSpam")
5
5
  content[:published] = false
6
+ content[:status_confirmed] = true
6
7
  end
7
8
 
8
9
  def exit_hook(content, target_state)
@@ -10,6 +10,7 @@ module ContentState
10
10
  def enter_hook(content)
11
11
  logger.debug("#{content} entering state Content::JustPresumedHam")
12
12
  content[:published] = true
13
+ content[:status_confirmed] = false
13
14
  end
14
15
 
15
16
  def exit_hook(content, target_state)
@@ -6,6 +6,7 @@ module ContentState
6
6
  def enter_hook(content)
7
7
  super
8
8
  content[:published] = true
9
+ content[:status_confirmed] = false
9
10
  end
10
11
 
11
12
  def published?(content)
@@ -20,6 +21,10 @@ module ContentState
20
21
  content.mark_as_ham
21
22
  end
22
23
 
24
+ def mark_as_ham(content)
25
+ content.state = Factory.new(:ham)
26
+ end
27
+
23
28
  def to_s
24
29
  'Ham?'
25
30
  end
@@ -6,6 +6,7 @@ module ContentState
6
6
  def enter_hook(content)
7
7
  super
8
8
  content[:published] = false
9
+ content[:status_confirmed] = false
9
10
  end
10
11
 
11
12
  def is_spam?(content)
@@ -6,12 +6,17 @@ module ContentState
6
6
  def enter_hook(content)
7
7
  super
8
8
  content[:published] = false
9
+ content[:status_confirmed] = true
9
10
  end
10
11
 
11
12
  def is_spam?(content)
12
13
  true
13
14
  end
14
15
 
16
+ def status_confirmed?(content)
17
+ true
18
+ end
19
+
15
20
  def to_s
16
21
  'Spam'
17
22
  end
@@ -54,6 +54,10 @@ class Feedback < Content
54
54
  state.is_spam?(self)
55
55
  end
56
56
 
57
+ def status_confirmed?
58
+ state.status_confirmed?(self)
59
+ end
60
+
57
61
  # is_spam? checks to see if this is spam.
58
62
  #
59
63
  # options are passed on to Akismet. Recommended options (when available) are:
@@ -16,3 +16,4 @@
16
16
  <% end -%>
17
17
  </table>
18
18
  </div>
19
+ <%= end_form_tag %>
@@ -5,7 +5,9 @@
5
5
  <td class="field"><%= link_to_article_edit item.article %></td>
6
6
  <td class="field">
7
7
  <%=h (item.author || '(unknown)').slice(0,40) %><br/>
8
- <a href=<%=h item.url%>><%=h truncate(item.url.to_s)%></a><br/>
8
+ <% if item.url -%>
9
+ <%= link_to h(truncate(item.url.to_s)), item.url %><br/>
10
+ <% end -%>
9
11
  <%=h item.email.to_s.slice(0,40) %>
10
12
  </td>
11
13
  <td class="field"><%=h truncate(item.body,80)%></td>
@@ -1,13 +1,15 @@
1
1
  <% @page_heading = "Comments and Trackbacks for #{ this_blog.settings['blog_name'] }" %>
2
2
 
3
3
  <% content_for('tasks') do %>
4
- <%= task_showmod 'Show only unpublished feedback' %>
4
+ <%= task_showmod 'Limit to spam' %>
5
+ <%= task_showmod 'Limit to unconfirmed' %>
6
+ <%= task_showmod 'Limit to unconfirmed spam' %>
5
7
  <% end %>
6
8
 
7
- <div clas="search">
8
- <form>
9
- <label for="search">Feedback Search:</label><input type="text" id="search" name="search" value="<%=h params[:search] %>" size="15" />
10
- </form>
9
+ <div class="search">
10
+ <%= form_tag({:action => 'index'}, :method => :get) %>
11
+ <label for="search">Feedback Search:</label><input type="text" id="feedback_search" name="search" value="<%=h params[:search] %>" size="15" />
12
+ <%= end_form_tag %>
11
13
  </div>
12
14
 
13
15
  <div class="list">
data/bin/typo CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
3
4
  require 'rails-installer'
4
5
 
5
6
  class TypoInstaller < RailsInstaller
@@ -0,0 +1,19 @@
1
+ class AddStatusConfirmedFieldToContent < ActiveRecord::Migration
2
+ class Content < ActiveRecord::Base
3
+ include BareMigration
4
+ end
5
+
6
+ def self.up
7
+ modify_tables_and_update \
8
+ [:add_column, Content, :status_confirmed, :boolean] do |a|
9
+ if not $schema_generator
10
+ a.status_confirmed = (a.state =~ /ContentState::(Sp|H)am/ ? true : false)
11
+ a.save!
12
+ end
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ remove_column :contents, :status_confirmed
18
+ end
19
+ end
@@ -65,7 +65,8 @@ CREATE TABLE contents (
65
65
  `allow_comments` tinyint(1),
66
66
  `blog_id` int(11) NOT NULL,
67
67
  `published_at` datetime,
68
- `state` text
68
+ `state` text,
69
+ `status_confirmed` tinyint(1)
69
70
  ) TYPE=MyISAM;
70
71
 
71
72
  CREATE TABLE notifications (
@@ -214,4 +215,4 @@ CREATE TABLE schema_info (
214
215
  `version` int(11)
215
216
  ) TYPE=MyISAM;
216
217
 
217
- insert into schema_info (version) values (49);
218
+ insert into schema_info (version) values (50);
data/db/schema.mysql.sql CHANGED
@@ -65,7 +65,8 @@ CREATE TABLE contents (
65
65
  `allow_comments` tinyint(1),
66
66
  `blog_id` int(11) NOT NULL,
67
67
  `published_at` datetime,
68
- `state` text
68
+ `state` text,
69
+ `status_confirmed` tinyint(1)
69
70
  ) ENGINE=InnoDB;
70
71
 
71
72
  CREATE TABLE notifications (
@@ -214,4 +215,4 @@ CREATE TABLE schema_info (
214
215
  `version` int(11)
215
216
  ) ENGINE=InnoDB;
216
217
 
217
- insert into schema_info (version) values (49);
218
+ insert into schema_info (version) values (50);
@@ -65,7 +65,8 @@ CREATE TABLE contents (
65
65
  "allow_comments" boolean,
66
66
  "blog_id" integer NOT NULL,
67
67
  "published_at" timestamp,
68
- "state" text
68
+ "state" text,
69
+ "status_confirmed" boolean
69
70
  );
70
71
 
71
72
  CREATE TABLE notifications (
@@ -214,4 +215,4 @@ CREATE TABLE schema_info (
214
215
  "version" integer
215
216
  );
216
217
 
217
- insert into schema_info (version) values (49);
218
+ insert into schema_info (version) values (50);
data/db/schema.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # migrations feature of ActiveRecord to incrementally modify your database, and
3
3
  # then regenerate this schema definition.
4
4
 
5
- ActiveRecord::Schema.define(:version => 49) do
5
+ ActiveRecord::Schema.define(:version => 50) do
6
6
 
7
7
  create_table "articles_categories", :id => false, :force => true do |t|
8
8
  t.column "article_id", :integer
@@ -63,6 +63,7 @@ ActiveRecord::Schema.define(:version => 49) do
63
63
  t.column "blog_id", :integer, :null => false
64
64
  t.column "published_at", :datetime
65
65
  t.column "state", :text
66
+ t.column "status_confirmed", :boolean
66
67
  end
67
68
 
68
69
  add_index "contents", ["article_id"], :name => "contents_article_id_index"
data/db/schema.sqlite.sql CHANGED
@@ -65,7 +65,8 @@ CREATE TABLE contents (
65
65
  "allow_comments" boolean,
66
66
  "blog_id" integer NOT NULL,
67
67
  "published_at" datetime,
68
- "state" text
68
+ "state" text,
69
+ "status_confirmed" boolean
69
70
  );
70
71
 
71
72
  CREATE TABLE notifications (
@@ -214,4 +215,4 @@ CREATE TABLE schema_info (
214
215
  "version" integer
215
216
  );
216
217
 
217
- insert into schema_info (version) values (49);
218
+ insert into schema_info (version) values (50);
@@ -69,7 +69,8 @@ CREATE TABLE contents (
69
69
  [allow_comments] bit,
70
70
  [blog_id] int NOT NULL,
71
71
  [published_at] datetime,
72
- [state] text
72
+ [state] text,
73
+ [status_confirmed] bit
73
74
  );
74
75
 
75
76
  CREATE TABLE notifications (
@@ -228,4 +229,4 @@ CREATE TABLE schema_info (
228
229
  [version] int
229
230
  );
230
231
 
231
- insert into schema_info (version) values (49);
232
+ insert into schema_info (version) values (50);
data/db/schema_version CHANGED
@@ -1 +1 @@
1
- 49
1
+ 50
@@ -13,7 +13,7 @@ class SpamProtection
13
13
  def article_closed?(record)
14
14
  return false if this_blog.sp_article_auto_close.zero? or not record.new_record?
15
15
 
16
- if record.article.created_at.to_i < this_blog.sp_article_auto_close.days.ago.to_i
16
+ if record.article.published_at.to_i < this_blog.sp_article_auto_close.days.ago.to_i
17
17
  logger.info("[SP] Blocked interaction with #{record.article.title}")
18
18
  return true
19
19
  end
@@ -1,7 +1,7 @@
1
1
  require 'rake/gempackagetask'
2
2
  require 'rake/contrib/rubyforgepublisher'
3
3
 
4
- PKG_VERSION = "4.0.2"
4
+ PKG_VERSION = "4.0.3"
5
5
  PKG_NAME = "typo"
6
6
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
7
7
  RUBY_FORGE_PROJECT = 'typo'
@@ -34,7 +34,7 @@ spec = Gem::Specification.new do |s|
34
34
  s.add_dependency("mongrel", ">= 0.3.13.3")
35
35
  s.add_dependency("mongrel_cluster", ">= 0.2.0")
36
36
  s.add_dependency("sqlite3-ruby", ">= 1.1.0")
37
- s.add_dependency("rails-app-installer", ">= 0.1.2")
37
+ s.add_dependency("rails-app-installer", ">= 0.2.0")
38
38
  end
39
39
 
40
40
  Rake::GemPackageTask.new(spec) do |p|
data/lib/typo_version.rb CHANGED
@@ -1 +1 @@
1
- TYPO_VERSION = '4.0.2'
1
+ TYPO_VERSION = '4.0.3'
@@ -121,6 +121,7 @@ comment3:
121
121
  id: 12
122
122
  published: false
123
123
  state: ContentState::PresumedSpam
124
+ status_confirmed: false
124
125
  article_id: 1
125
126
  author: Foo Bar
126
127
  body: Zzzzzz
@@ -136,6 +137,7 @@ trackback1:
136
137
  article_id: 2
137
138
  published: false
138
139
  state: ContentState::PresumedSpam
140
+ status_confirmed: false
139
141
  blog_name: Trackback Blog
140
142
  title: Trackback Entry
141
143
  url: http://www.example.com
@@ -318,3 +320,54 @@ xmltest:
318
320
  guid: urn:uuid:0d676c66-4135-4a8b-9d65-b6a3248d3032
319
321
  published: true
320
322
  state: ContentState::Published
323
+
324
+ spammed_article:
325
+ type: Article
326
+ blog_id: 1
327
+ id: 19
328
+ title: C'mon Spam Me!
329
+ body: A bunch of innocuous content
330
+ body_html: <p>A bunch of innocuous content</p>
331
+ allow_comments: true
332
+ allow_pings: true
333
+ permalink: cmon-spam-me
334
+ created_at: 2001-01-01
335
+ updated_at: 2001-01-01
336
+ published_at: 2001-01-01
337
+ user_id: 1
338
+ author: Tobi
339
+ guid: urn:uuid:0d676c66-4135-4a8b-9d65-b6a3248d3023
340
+ published: true
341
+ state: ContentState::Published
342
+
343
+ probably_spam_comment:
344
+ type: Comment
345
+ blog_id: 1
346
+ id: 20
347
+ published: false
348
+ article_id: 19
349
+ author: Bob Foo
350
+ url: http://fakeurl.com
351
+ body: Test <a href="http://fakeurl.co.uk">body</a>
352
+ created_at: 2005-01-01 02:00:00
353
+ updated_at: 2005-01-01 02:00:00
354
+ published_at: 2005-01-01 02:00:00
355
+ guid: 12313123123123124
356
+ state: ContentState::PresumedSpam
357
+ status_confirmed: false
358
+
359
+ definitely_spam_comment:
360
+ type: Comment
361
+ blog_id: 1
362
+ id: 21
363
+ published: false
364
+ article_id: 19
365
+ author: Bob Foo
366
+ url: http://fakeurl.com
367
+ body: Test <a href="http://fakeurl.co.uk">body</a>
368
+ created_at: 2005-01-01 02:00:01
369
+ updated_at: 2005-01-01 02:00:01
370
+ published_at: 2005-01-01 02:00:01
371
+ guid: 12313123123123125
372
+ state: ContentState::Spam
373
+ status_confirmed: true
@@ -1,5 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
  require 'admin/feedback_controller'
3
+ require 'comment'
4
+ require 'trackback'
3
5
 
4
6
  # Re-raise errors caught by the controller.
5
7
  class Admin::FeedbackController; def rescue_action(e) raise e end; end
@@ -17,8 +19,41 @@ class Admin::FeedbackControllerTest < Test::Unit::TestCase
17
19
 
18
20
  def test_index
19
21
  get :index
20
-
22
+
21
23
  assert_success
22
24
  assert_rendered_file 'list'
25
+ assert_equal Feedback.count, assigns(:feedback).size
23
26
  end
27
+
28
+ def test_list_unconfirmed
29
+ get :index, :confirmed => 'f'
30
+
31
+ assert_success
32
+ assert_rendered_file 'list'
33
+
34
+ assert_equal(Feedback.count(['blog_id = 1 AND status_confirmed = ?', false]),
35
+ assigns(:feedback).size)
36
+
37
+ end
38
+
39
+ def test_list_spam
40
+ get :index, :published => 'f'
41
+
42
+ assert_success
43
+ assert_rendered_file 'list'
44
+
45
+ assert_equal(Feedback.count(['blog_id = 1 AND published = ?', false]),
46
+ assigns(:feedback).size)
47
+ end
48
+
49
+ def test_list_unconfirmed_spam
50
+ get :index, :published => 'f', :confirmed => 'f'
51
+
52
+ assert_success
53
+ assert_rendered_file 'list'
54
+
55
+ assert_equal(Feedback.count(['blog_id = 1 AND published = ? AND status_confirmed = ?', false, false]),
56
+ assigns(:feedback).size)
57
+ end
58
+
24
59
  end
@@ -87,7 +87,7 @@ class XmlControllerTest < Test::Unit::TestCase
87
87
  assert_xml @response.body
88
88
  assert_feedvalidator @response.body, :todo
89
89
 
90
- assert_rss20(6)
90
+ assert_rss20(7)
91
91
  end
92
92
 
93
93
  def test_feed_rss20_comments
@@ -145,7 +145,7 @@ class XmlControllerTest < Test::Unit::TestCase
145
145
  assert_equal(assigns(:items).sort { |a, b| b.created_at <=> a.created_at },
146
146
  assigns(:items))
147
147
 
148
- assert_atom10(6)
148
+ assert_atom10(7)
149
149
  end
150
150
 
151
151
  def test_feed_atom10_comments
@@ -338,11 +338,11 @@ class XmlControllerTest < Test::Unit::TestCase
338
338
  assert_xml @response.body
339
339
  assert_feedvalidator @response.body, :todo
340
340
  end
341
-
341
+
342
342
  # TODO(laird): make this more robust
343
343
  def test_sitemap
344
344
  get :feed, :format => 'googlesitemap', :type => 'sitemap'
345
-
345
+
346
346
  assert_response :success
347
347
  assert_xml @response.body
348
348
  end
@@ -137,7 +137,8 @@ class ArticleTest < Test::Unit::TestCase
137
137
  def test_find_published
138
138
  @articles = this_blog.articles.find_published
139
139
  assert_results_are(:search_target, :article1, :article2,
140
- :article3, :inactive_article,:xmltest)
140
+ :article3, :inactive_article,:xmltest,
141
+ :spammed_article)
141
142
 
142
143
  @articles = this_blog.articles.find_published(:all,
143
144
  :conditions => "title = 'Article 1!'")
@@ -35,7 +35,7 @@ class BlogTest < Test::Unit::TestCase
35
35
  assert articles = @blog.find_already_published(:articles)
36
36
  assert_kind_of Array, articles
37
37
  assert articles.all? { |a| a.is_a?(Article) }
38
- assert_equal 6, articles.size
38
+ assert_equal 7, articles.size
39
39
 
40
40
  assert comments = @blog.find_already_published(:comments)
41
41
  assert_kind_of Array, comments
@@ -34,6 +34,7 @@ class CommentTest < Test::Unit::TestCase
34
34
  c.ip = "212.42.230.206"
35
35
  end
36
36
  assert cmt.spam?
37
+ assert !cmt.status_confirmed?
37
38
  end
38
39
 
39
40
  def test_not_spam_but_rbl_lookup_succeeds
@@ -44,6 +45,7 @@ class CommentTest < Test::Unit::TestCase
44
45
  c.ip = "10.10.10.10"
45
46
  end
46
47
  assert !cmt.spam?
48
+ assert !cmt.status_confirmed?
47
49
  end
48
50
 
49
51
  def test_reject_spam_pattern
@@ -53,6 +55,7 @@ class CommentTest < Test::Unit::TestCase
53
55
  c.url = "http://texas.hold-em.us"
54
56
  end
55
57
  assert cmt.spam?
58
+ assert !cmt.status_confirmed?
56
59
  end
57
60
 
58
61
  def test_reject_spam_uri_limit
@@ -64,6 +67,7 @@ class CommentTest < Test::Unit::TestCase
64
67
  end
65
68
 
66
69
  assert c.spam?
70
+ assert !c.status_confirmed?
67
71
  end
68
72
 
69
73
  def test_reject_article_age
@@ -118,9 +122,11 @@ class CommentTest < Test::Unit::TestCase
118
122
  assert c.withdraw!
119
123
  assert ! c.published?
120
124
  assert c.spam?
125
+ assert c.status_confirmed?
121
126
  c.reload
122
127
  assert ! c.published?
123
128
  assert c.spam?
129
+ assert c.status_confirmed?
124
130
  end
125
131
 
126
132
  def test_published
@@ -139,4 +145,19 @@ class CommentTest < Test::Unit::TestCase
139
145
  a = Article.new(:title => 'foo', :blog_id => 1)
140
146
  assert_equal 0, a.published_comments.size
141
147
  end
148
+
149
+ def test_status_confirmed
150
+ a = contents(:spammed_article)
151
+ assert !a.comments[0].status_confirmed?
152
+ assert a.comments[1].status_confirmed?
153
+
154
+ a.reload
155
+ assert_equal 1,
156
+ a.comments.find_all_by_status_confirmed(true).size
157
+ assert_equal 1,
158
+ a.comments.find_all_by_status_confirmed(true).size
159
+ a.comments[0].withdraw!
160
+ assert_equal 2,
161
+ a.comments.find_all_by_status_confirmed(true).size
162
+ end
142
163
  end
@@ -10,9 +10,9 @@ class UserTest < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_articles_link
13
- assert_equal 7, User.find(1).articles.size
14
- assert_equal 6, User.find(1).articles.find_published.size
15
- assert_equal 6, User.find(1).articles.published.size
13
+ assert_equal 8, User.find(1).articles.size
14
+ assert_equal 7, User.find(1).articles.find_published.size
15
+ assert_equal 7, User.find(1).articles.published.size
16
16
 
17
17
  articles = User.find(1).articles.published
18
18
  assert_equal articles.sort_by { |a| a.created_at }.reverse, articles
@@ -7,9 +7,9 @@
7
7
  # Heavily modified for Typo by Scott Laird
8
8
  #
9
9
  class Akismet
10
-
11
10
  require 'net/http'
12
11
  require 'uri'
12
+ require 'timeout'
13
13
 
14
14
  STANDARD_HEADERS = {
15
15
  'User-Agent' => "Typo/#{TYPO_VERSION} | Akismet Ruby API/1.0",
@@ -97,24 +97,33 @@ class Akismet
97
97
  #options[:comment_content] = comment_content
98
98
 
99
99
  def callAkismet(akismet_function, options = {})
100
- http = Net::HTTP.new("#{@apiKey}.rest.akismet.com", 80, @proxyHost, @proxyPort)
101
- path = "/1.1/#{akismet_function}"
100
+ result = false
101
+ begin
102
+ Timeout.timeout(5) do
103
+ http = Net::HTTP.new("#{@apiKey}.rest.akismet.com", 80, @proxyHost, @proxyPort)
104
+ path = "/1.1/#{akismet_function}"
102
105
 
103
- options[:blog] = @blog
104
- params=[]
106
+ options[:blog] = @blog
107
+ params=[]
105
108
 
106
- options.each_key do |key|
107
- params.push "#{key}=#{CGI.escape(options[key].to_s)}"
108
- end
109
+ options.each_key do |key|
110
+ params.push "#{key}=#{CGI.escape(options[key].to_s)}"
111
+ end
109
112
 
110
- data = params.join('&')
111
- resp, data = http.post(path, data, STANDARD_HEADERS)
113
+ data = params.join('&')
114
+ resp, data = http.post(path, data, STANDARD_HEADERS)
112
115
 
113
- unless data == 'true' or data == 'false' or data == ''
114
- STDERR.puts "AKISMET error: #{data}"
115
- end
116
+ unless data == 'true' or data == 'false' or data == ''
117
+ STDERR.puts "AKISMET error: #{data}"
118
+ end
116
119
 
117
- return (data == "true" or data == '')
120
+ result = (data == "true" or data == '')
121
+ end
122
+ rescue => err
123
+ STDERR.puts "AKISMET exception: #{err}"
124
+ end
125
+
126
+ return result
118
127
  end
119
128
 
120
129
  protected :callAkismet
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: typo
5
5
  version: !ruby/object:Gem::Version
6
- version: 4.0.2
7
- date: 2006-08-10 00:00:00 -07:00
6
+ version: 4.0.3
7
+ date: 2006-08-17 00:00:00 -07:00
8
8
  summary: Modern weblog engine.
9
9
  require_paths:
10
10
  - .
@@ -29,7 +29,6 @@ post_install_message:
29
29
  authors:
30
30
  - Tobias Luetke
31
31
  files:
32
- - .DS_Store
33
32
  - app
34
33
  - bin
35
34
  - components
@@ -497,6 +496,7 @@ files:
497
496
  - db/migrate/047_add_content_state_field.rb
498
497
  - db/migrate/048_remove_count_caching.rb
499
498
  - db/migrate/049_move_feedback_to_new_state_machine.rb
499
+ - db/migrate/050_add_status_confirmed_field_to_content.rb
500
500
  - db/scripts/fix_permalinks.rb
501
501
  - db/updates/update.168.to.200.mysql.sql
502
502
  - db/updates/update.168.to.200.psql.sql
@@ -1050,5 +1050,5 @@ dependencies:
1050
1050
  requirements:
1051
1051
  - - ">="
1052
1052
  - !ruby/object:Gem::Version
1053
- version: 0.1.2
1053
+ version: 0.2.0
1054
1054
  version:
data/.DS_Store DELETED
Binary file