Permalink
Browse files

Use plugin generator to fix the scaffold. Copy some of the actionpack…

…/test/base_unit.rb to make the test pass.
  • Loading branch information...
1 parent 8eac38f commit 7d2229623c9aa9e7d10ae878fa55e6944f19302d @sikachu committed Jan 22, 2010
Showing with 86 additions and 5 deletions.
  1. +20 −0 MIT-LICENSE
  2. +4 −4 Rakefile
  3. +2 −0 init.rb
  4. +59 −0 test/test_helper.rb
  5. +1 −1 test/verification_test.rb
View
@@ -0,0 +1,20 @@
+Copyright (c) 2010 David Heinemeier Hansson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,17 +1,17 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
-
+
desc 'Default: run unit tests.'
task :default => :test
-
+
desc 'Test the verification plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
+ t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
- t.verbose = true
end
-
+
desc 'Generate documentation for the verification plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
View
@@ -1 +1,3 @@
+# Include hook code here
+
require 'action_controller/verification'
View
@@ -0,0 +1,59 @@
+require 'rubygems'
+require 'test/unit'
+require 'active_support'
+require 'action_controller'
+require File.dirname(__FILE__) + '/../lib/action_controller/verification'
+
+# Extracted this code from action_controller/abstract_unit.rb
+module SetupOnce
+ extend ActiveSupport::Concern
+
+ included do
+ cattr_accessor :setup_once_block
+ self.setup_once_block = nil
+
+ setup :run_setup_once
+ end
+
+ module ClassMethods
+ def setup_once(&block)
+ self.setup_once_block = block
+ end
+ end
+
+ private
+ def run_setup_once
+ if self.setup_once_block
+ self.setup_once_block.call
+ self.setup_once_block = nil
+ end
+ end
+end
+
+class ActiveSupport::TestCase
+ include SetupOnce
+
+ # Hold off drawing routes until all the possible controller classes
+ # have been loaded.
+ setup_once do
+ ActionController::Routing::Routes.draw do |map|
+ match ':controller(/:action(/:id))'
+ end
+ end
+end
+
+class ActionController::IntegrationTest < ActiveSupport::TestCase
+ def self.build_app(routes = nil)
+ ActionDispatch::Flash
+ ActionDispatch::MiddlewareStack.new { |middleware|
+ middleware.use "ActionDispatch::ShowExceptions"
+ middleware.use "ActionDispatch::Callbacks"
+ middleware.use "ActionDispatch::ParamsParser"
+ middleware.use "ActionDispatch::Cookies"
+ middleware.use "ActionDispatch::Flash"
+ middleware.use "ActionDispatch::Head"
+ }.build(routes || ActionController::Routing::Routes)
+ end
+
+ self.app = build_app
+end
@@ -1,4 +1,4 @@
-require 'abstract_unit'
+require 'test_helper'
class VerificationTest < ActionController::TestCase
class TestController < ActionController::Base

0 comments on commit 7d22296

Please sign in to comment.