Permalink
Browse files

Got tests passing with new rails. Updated deprecated methods.

  • Loading branch information...
1 parent e36a0db commit 1948b587c49aada07d25691a9632034f57d7c642 Mark Dunkley committed with jstorimer Sep 3, 2009
View
@@ -14,4 +14,6 @@ tmp/*
database.yml
recaptcha.yml
-deploy.rb
+deploy.rb
+
+db/*.sqlite3
@@ -6,7 +6,7 @@ def show
@topic_pages = Paginator.new(self, @category.topics.count, 20, params[:page])
@topics = @category.topics.find(:all, :limit => 20, :offset => @topic_pages.current.offset, :order => "(status = 'sticky') DESC, updated_at DESC")
@recent_posts = @category.posts.find(:all, :limit => 20, :order => 'id DESC')
- @rss = formatted_category_url(@category, 'xml')
+ @rss = category_url(@category, :format => 'xml')
respond_to do |accepts|
accepts.html
@@ -7,7 +7,7 @@ def show
@category_pages = Paginator.new(self, @forum.categories.count(:all, :conditions => access_conditions), 20, params[:page])
@categories = @forum.categories.find(:all, :limit => 20, :conditions => access_conditions, :offset => @category_pages.current.offset, :order => 'id ASC')
- @rss = formatted_forum_url(@forum, 'xml')
+ @rss = forum_url(@forum, :format => 'xml')
today, yesterday = Time.now.to_date, Time.now.yesterday.to_date
@recent_posts = @forum.posts.find(:all, :limit => 20, :conditions => ['category_id in (?)', Category.ids_matching(access_conditions)], :order => 'id DESC')
@@ -4,7 +4,7 @@ class PostsController < ApplicationController
def show
@topic = @post = Topic.find(params[:id])
- @rss = formatted_category_post_url(@topic.category, @topic, 'xml')
+ @rss = category_post_url(@topic.category, @topic, :format => 'xml')
respond_to do |accepts|
accepts.html
@@ -57,7 +57,7 @@
<% end %>
- <p class="c green-link"><a href="#comments">Jump to comment form</a> | <%= link_to "subscribe to this topic", formatted_category_post_url(@topic.category, @topic, 'xml') %></p>
+ <p class="c green-link"><a href="#comments">Jump to comment form</a> | <%= link_to "subscribe to this topic", category_post_url(@topic.category, @topic, :format => 'xml') %></p>
</td>
</tr>
</table>
View
@@ -51,8 +51,6 @@
# See Rails::Configuration for more options
end
-HtmlEngine.default = [:textile, :whitelist_html, :autolink, :sanitize]
-
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
@@ -62,8 +60,11 @@
# inflect.uncountable %w( fish sheep )
# end
+HtmlEngine.default = [:textile, :whitelist_html, :autolink, :sanitize]
+
# Include your application configuration below
require 'dash_string'
+Dir[RAILS_ROOT + '/lib/extensions/*.rb'].each { |file| require file }
# Opinion supports the www.recaptcha.com captcha service. Sign up and provide a
# config/recaptcha.yml file with your private and public key information.
View
@@ -1,5 +1,5 @@
# This file is auto-generated from the current state of the database. Instead of editing this file,
-# please use the migrations feature of ActiveRecord to incrementally modify your database, and
+# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
@@ -14,18 +14,18 @@
create_table "categories", :force => true do |t|
t.string "title"
t.integer "forum_id"
- t.text "body"
- t.text "body_html"
+ t.text "body", :limit => 255
+ t.text "body_html", :limit => 255
t.string "subtitle"
- t.integer "access_level", :default => 0
+ t.integer "access_level", :default => 0
end
add_index "categories", ["forum_id"], :name => "index_categories_on_area_id_and_title_dashed"
create_table "forums", :force => true do |t|
t.string "title"
- t.boolean "anonymous_posts", :default => false
- t.text "body"
+ t.boolean "anonymous_posts", :default => false
+ t.text "body", :limit => 255
end
create_table "images", :force => true do |t|
@@ -39,8 +39,8 @@
t.integer "height"
end
- add_index "images", ["post_id"], :name => "index_images_on_post_id"
add_index "images", ["parent_id"], :name => "index_images_on_parent_id"
+ add_index "images", ["post_id"], :name => "index_images_on_post_id"
create_table "posts", :force => true do |t|
t.integer "category_id"
@@ -65,7 +65,7 @@
t.integer "level"
t.string "token", :limit => 32
t.string "title"
- t.text "signature"
+ t.text "signature", :limit => 255
end
end
@@ -1,5 +0,0 @@
-class String
- def to_html
- RedCloth.new(self).to_html
- end
-end
@@ -1,5 +1,4 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require 'accounts_controller'
+require 'test_helper'
# Re-raise errors caught by the controller.
class AccountsController; def rescue_action(e) raise e end; end
@@ -12,9 +11,7 @@ def verify_recaptcha(model = nil)
end
end
-class AccountsControllerTest < Test::Unit::TestCase
- fixtures :forums, :users
-
+class AccountsControllerTest < ActionController::TestCase
def setup
@controller = AccountsController.new
@request = ActionController::TestRequest.new
@@ -4,7 +4,7 @@
# Re-raise errors caught by the controller.
class AdminController; def rescue_action(e) raise e end; end
-class AdminControllerTest < Test::Unit::TestCase
+class AdminControllerTest < ActionController::TestCase
def setup
@controller = AdminController.new
@request = ActionController::TestRequest.new
@@ -4,9 +4,7 @@
# Re-raise errors caught by the controller.
class CategoriesController; def rescue_action(e) raise e end; end
-class CategoriesControllerTest < Test::Unit::TestCase
- fixtures :forums, :categories, :users
-
+class CategoriesControllerTest < ActionController::TestCase
def setup
@controller = CategoriesController.new
@request = ActionController::TestRequest.new
@@ -16,12 +14,12 @@ def setup
def test_show_valid
get :show, :id => 1
- assert_tag
+ assert_response :ok
end
def test_show_secret_with_access
get :show, :id => 3
- assert_tag
+ assert_response :ok
end
def test_show_secret_without_access
@@ -4,9 +4,7 @@
# Re-raise errors caught by the controller.
class ForumsController; def rescue_action(e) raise e end; end
-class ForumsControllerTest < Test::Unit::TestCase
- fixtures :forums, :users
-
+class ForumsControllerTest < ActionController::TestCase
def setup
@controller = ForumsController.new
@request = ActionController::TestRequest.new
@@ -16,7 +14,7 @@ def setup
def test_show_valid
get :show, :id => 1
- assert_tag
+ assert_response :ok
end
def test_create_new_forum
@@ -4,7 +4,7 @@
# Re-raise errors caught by the controller.
class ImagesController; def rescue_action(e) raise e end; end
-class ImagesControllerTest < Test::Unit::TestCase
+class ImagesControllerTest < ActionController::TestCase
def setup
@controller = ImagesController.new
@request = ActionController::TestRequest.new
@@ -4,7 +4,7 @@
# Re-raise errors caught by the controller.
class LegacyRoutesController; def rescue_action(e) raise e end; end
-class LegacyRoutesControllerTest < Test::Unit::TestCase
+class LegacyRoutesControllerTest < ActionController::TestCase
def setup
@controller = LegacyRoutesController.new
@request = ActionController::TestRequest.new
@@ -4,9 +4,7 @@
# Re-raise errors caught by the controller.
class PostsController; def rescue_action(e) raise e end; end
-class PostsControllerTest < Test::Unit::TestCase
- fixtures :forums, :categories, :posts, :users
-
+class PostsControllerTest < ActionController::TestCase
def setup
@controller = PostsController.new
@request = ActionController::TestRequest.new
@@ -17,22 +15,22 @@ def setup
def test_show_valid
get :show, :category_id => 1, :id => 1
- assert_tag
+ assert_response :ok
end
def test_new_valid
get :new, :category_id => 1
- assert_tag
+ assert_response :ok
end
-
+
def test_edit_valid
get :edit, :category_id => 1, :id => 1
- assert_tag
+ assert_response :ok
end
def test_show_secret_with_access
get :show, :category_id => 3, :id => 4
- assert_tag
+ assert_response :ok
end
def test_show_secret_without_access
@@ -4,9 +4,7 @@
# Re-raise errors caught by the controller.
class SearchController; def rescue_action(e) raise e end; end
-class SearchControllerTest < Test::Unit::TestCase
- fixtures :posts, :forums
-
+class SearchControllerTest < ActionController::TestCase
def setup
@controller = SearchController.new
@request = ActionController::TestRequest.new
@@ -4,7 +4,7 @@
# Re-raise errors caught by the controller.
class ToolsController; def rescue_action(e) raise e end; end
-class ToolsControllerTest < Test::Unit::TestCase
+class ToolsControllerTest < ActionController::TestCase
def setup
@controller = ToolsController.new
@request = ActionController::TestRequest.new
@@ -15,7 +15,7 @@ def setup
def test_preview_textile
@request.env['RAW_POST_DATA'] = "I am a *bold*\n\ntwo paragraph phrase."
get :preview_textile
- assert_equal "<p>I am a <strong>bold</strong></p>\n\n\n\t<p>two paragraph phrase.</p>", @response.body
+ assert_equal "<p>I am a <strong>bold</strong></p>\n<p>two paragraph phrase.</p>", @response.body
end
end
@@ -4,9 +4,7 @@
# Re-raise errors caught by the controller.
class UsersController; def rescue_action(e) raise e end; end
-class UsersControllerTest < Test::Unit::TestCase
- fixtures :users
-
+class UsersControllerTest < ActionController::TestCase
def setup
@controller = UsersController.new
@request = ActionController::TestRequest.new
View
@@ -14,7 +14,7 @@ def test_script_tags
end
assert_equal "Tag Test", @post.title
- assert_equal "&lt;script&gt;alert(&#8216;hi&#8217;)&lt;/script&gt;", @post.body_html
+ assert_equal "&lt;script&gt;alert('hi')&lt;/script&gt;", @post.body_html
end
def test_pre_tags
@@ -34,7 +34,7 @@ def test_surrounded_tags
end
assert_equal "Tag Test", @post.title
- assert_equal "&lt;script&gt;alert(&#8216;hi&#8217;)&lt;/script&gt;<pre>&lt;anytag&gt;text&lt;/anytag&gt;</pre>&lt;script&gt;alert(&#8216;hi&#8217;)&lt;/script&gt;", @post.body_html
+ assert_equal "&lt;script&gt;alert('hi')&lt;/script&gt;<pre>&lt;anytag&gt;text&lt;/anytag&gt;</pre>&lt;script&gt;alert('hi')&lt;/script&gt;", @post.body_html
end
@@ -8,25 +8,27 @@
begin
rails_filters = Class.new do
+ def self.white_list_sanitizer
+ @white_list_sanitizer ||= HTML::WhiteListSanitizer.new
+ end
+
include ActionView::Helpers::TextHelper
include ActionView::Helpers::TagHelper
- include ActionView::Helpers::SanitizeHelper
+ include ActionView::Helpers::SanitizeHelper
end.new
HtmlEngine.register(:autolink) { |text| rails_filters.auto_link(text) }
HtmlEngine.register(:sanitize) { |text| rails_filters.sanitize(text) }
HtmlEngine.register(:simple) { |text| rails_filters.simple_format(text) }
- ERLAUBT_TAGS = ['pre', 'code', 'img', 'a', 'strong', 'em', 'span', 'b', 'br', 'i', 'p', 'embed', 'object', 'blockquote', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5']
-
HtmlEngine.register(:whitelist_html) do |html|
if html.index("<")
tokenizer = HTML::Tokenizer.new(html)
new_text = []
while token = tokenizer.next
node = HTML::Node.parse(nil, 0, 0, token, false)
- new_text << if not node.is_a? HTML::Tag or ERLAUBT_TAGS.include?(node.name)
+ new_text << if not node.is_a? HTML::Tag or HtmlEngine::ERLAUBT_TAGS.include?(node.name)
node.to_s
else
node.to_s.gsub(/</, "&lt;").gsub(/>/, "&gt;")
@@ -2,7 +2,8 @@
# Different modules can be registered using the register method
# By default textile is used as transformation engine
module HtmlEngine
-
+ ERLAUBT_TAGS = ['pre', 'code', 'img', 'a', 'strong', 'em', 'span', 'b', 'br', 'i', 'p', 'embed', 'object', 'blockquote', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5']
+
# Access a hash of all supported engines
mattr_accessor :supported_engines
@@supported_engines = {}
@@ -42,6 +43,7 @@ def self.transform(source, *engines)
end
end
rescue => e
+ puts e.backtrace
"Transformation error in engine(s): #{engines.join(" ")} -- #{e.message}"
end
end
Oops, something went wrong.

0 comments on commit 1948b58

Please sign in to comment.