Skip to content

Commit 7d22296

Browse files
committed
Use plugin generator to fix the scaffold. Copy some of the actionpack/test/base_unit.rb to make the test pass.
1 parent 8eac38f commit 7d22296

File tree

5 files changed

+86
-5
lines changed

5 files changed

+86
-5
lines changed

Diff for: MIT-LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2010 David Heinemeier Hansson
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: Rakefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
require 'rake'
22
require 'rake/testtask'
33
require 'rake/rdoctask'
4-
4+
55
desc 'Default: run unit tests.'
66
task :default => :test
7-
7+
88
desc 'Test the verification plugin.'
99
Rake::TestTask.new(:test) do |t|
1010
t.libs << 'lib'
11+
t.libs << 'test'
1112
t.pattern = 'test/**/*_test.rb'
12-
t.verbose = true
1313
end
14-
14+
1515
desc 'Generate documentation for the verification plugin.'
1616
Rake::RDocTask.new(:rdoc) do |rdoc|
1717
rdoc.rdoc_dir = 'rdoc'

Diff for: init.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# Include hook code here
2+
13
require 'action_controller/verification'

Diff for: test/test_helper.rb

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require 'rubygems'
2+
require 'test/unit'
3+
require 'active_support'
4+
require 'action_controller'
5+
require File.dirname(__FILE__) + '/../lib/action_controller/verification'
6+
7+
# Extracted this code from action_controller/abstract_unit.rb
8+
module SetupOnce
9+
extend ActiveSupport::Concern
10+
11+
included do
12+
cattr_accessor :setup_once_block
13+
self.setup_once_block = nil
14+
15+
setup :run_setup_once
16+
end
17+
18+
module ClassMethods
19+
def setup_once(&block)
20+
self.setup_once_block = block
21+
end
22+
end
23+
24+
private
25+
def run_setup_once
26+
if self.setup_once_block
27+
self.setup_once_block.call
28+
self.setup_once_block = nil
29+
end
30+
end
31+
end
32+
33+
class ActiveSupport::TestCase
34+
include SetupOnce
35+
36+
# Hold off drawing routes until all the possible controller classes
37+
# have been loaded.
38+
setup_once do
39+
ActionController::Routing::Routes.draw do |map|
40+
match ':controller(/:action(/:id))'
41+
end
42+
end
43+
end
44+
45+
class ActionController::IntegrationTest < ActiveSupport::TestCase
46+
def self.build_app(routes = nil)
47+
ActionDispatch::Flash
48+
ActionDispatch::MiddlewareStack.new { |middleware|
49+
middleware.use "ActionDispatch::ShowExceptions"
50+
middleware.use "ActionDispatch::Callbacks"
51+
middleware.use "ActionDispatch::ParamsParser"
52+
middleware.use "ActionDispatch::Cookies"
53+
middleware.use "ActionDispatch::Flash"
54+
middleware.use "ActionDispatch::Head"
55+
}.build(routes || ActionController::Routing::Routes)
56+
end
57+
58+
self.app = build_app
59+
end

Diff for: test/verification_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'abstract_unit'
1+
require 'test_helper'
22

33
class VerificationTest < ActionController::TestCase
44
class TestController < ActionController::Base

0 commit comments

Comments
 (0)