Permalink
Browse files

Switch the test site to use unicorn instead of ruby-style and mongrel

Also, bump supported versions of Rails, Camping, and Ramaze.

Additionally, remove some of the demo site stuff now that that lives
in a separate app.
  • Loading branch information...
1 parent 9cb7bd5 commit 7c5b7a90a61688423a2dd2036eb62241279d70f4 @jeremyevans committed Aug 24, 2010
Showing with 2,526 additions and 216 deletions.
  1. +3 −3 README
  2. +1 −2 test_site/bootstrap.rb
  3. +1 −3 test_site/{cse.rb → config-camping.ru}
  4. +7 −1 test_site/{merb_setup.rb → config-merb.ru}
  5. +1 −8 test_site/{rack_se.rb → config-rack.ru}
  6. +6 −0 test_site/config-rails.ru
  7. +4 −2 test_site/{start.rb → config-ramaze.ru}
  8. +1 −8 test_site/{sinatra_se.rb → config-sinatra.ru}
  9. +1 −1 test_site/config/environment.rb
  10. +0 −8 test_site/config/style.camping.yaml
  11. +0 −8 test_site/config/style.merb.yaml
  12. +0 −8 test_site/config/style.rack.yaml
  13. +0 −10 test_site/config/style.rails.yaml
  14. +0 −8 test_site/config/style.ramaze.yaml
  15. +0 −6 test_site/config/style.se_demo.yaml
  16. +0 −8 test_site/config/style.sinatra.yaml
  17. +5 −5 test_site/run_tests.sh
  18. +0 −28 test_site/se_demo.rb
  19. +5 −0 test_site/unicorn-camping.conf
  20. +5 −0 test_site/unicorn-merb.conf
  21. +5 −0 test_site/unicorn-rack.conf
  22. +5 −0 test_site/unicorn-rails.conf
  23. +5 −0 test_site/unicorn-ramaze.conf
  24. +5 −0 test_site/unicorn-sinatra.conf
  25. +3 −3 test_site/vendor/plugins/rails_xss/README.markdown
  26. +5 −12 test_site/vendor/plugins/rails_xss/init.rb
  27. +0 −1 test_site/vendor/plugins/rails_xss/install.rb
  28. +0 −17 test_site/vendor/plugins/rails_xss/lib/av_patch.rb
  29. +3 −39 test_site/vendor/plugins/rails_xss/lib/rails_xss.rb
  30. +87 −0 test_site/vendor/plugins/rails_xss/lib/rails_xss/action_view.rb
  31. +33 −0 test_site/vendor/plugins/rails_xss/lib/rails_xss/erubis.rb
  32. +52 −0 test_site/vendor/plugins/rails_xss/lib/rails_xss/string_ext.rb
  33. +0 −20 test_site/vendor/plugins/rails_xss/lib/rails_xss_escaping.rb
  34. 0 test_site/vendor/plugins/rails_xss/{ → lib}/tasks/rails_xss_tasks.rake
  35. +74 −0 test_site/vendor/plugins/rails_xss/test/active_record_helper_test.rb
  36. +49 −0 test_site/vendor/plugins/rails_xss/test/asset_tag_helper_test.rb
  37. +43 −0 test_site/vendor/plugins/rails_xss/test/caching_test.rb
  38. +29 −0 test_site/vendor/plugins/rails_xss/test/date_helper_test.rb
  39. +112 −0 test_site/vendor/plugins/rails_xss/test/deprecated_output_safety_test.rb
  40. +36 −0 test_site/vendor/plugins/rails_xss/test/erb_util_test.rb
  41. +1,447 −0 test_site/vendor/plugins/rails_xss/test/form_helper_test.rb
  42. +354 −0 test_site/vendor/plugins/rails_xss/test/form_tag_helper_test.rb
  43. +115 −0 test_site/vendor/plugins/rails_xss/test/output_safety_test.rb
  44. +2 −3 test_site/vendor/plugins/rails_xss/test/rails_xss_test.rb
  45. +5 −3 test_site/vendor/plugins/rails_xss/test/test_helper.rb
  46. +17 −0 test_site/vendor/plugins/rails_xss/test/text_helper_test.rb
  47. +0 −1 test_site/vendor/plugins/rails_xss/uninstall.rb
View
6 README
@@ -21,9 +21,9 @@ to better suit your needs.
Scaffolding Extensions currently supports:
* Web Frameworks
- * Rails 2.3.5 (with or without RailsXss plugin)
- * Ramaze 2010.04.04
- * Camping 2.0
+ * Rails 2.3.8 (with or without RailsXss plugin)
+ * Ramaze 2010.06.18
+ * Camping 2.1
* Sinatra 1.0
* Merb 1.0.4
* Rack 1.1.0
View
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require 'rubygems'
-FRAMEWORKS=%w'ramaze camping sinatra merb'
+FRAMEWORKS=%w'ramaze camping sinatra merb rack'
ORMS=%w'active_record sequel datamapper'
SE_TEST_FRAMEWORK='rails'
# Make log and tmp directories
@@ -16,4 +16,3 @@
DataMapper.auto_migrate!
# Copy the Rails databases to the other frameworks
FRAMEWORKS.each{|f| ORMS.each{|o| system "cp db/#{SE_TEST_FRAMEWORK}.#{o}.sqlite3 db/#{f}.#{o}.sqlite3"}}
-system "cp db/#{SE_TEST_FRAMEWORK}.sequel.sqlite3 db/se_demo.sequel.sqlite3"
@@ -35,8 +35,6 @@ def service(*args)
ActiveRecord::Base.clear_active_connections!
r
end
-
- puts "** Starting Mongrel on 0.0.0.0:7977"
- Rack::Handler::Mongrel.run(self, :Port => 7977, :Host => '0.0.0.0')
end
+run Cse
@@ -11,6 +11,8 @@
use_template_engine :erb
Merb::Config.use { |c|
+ c[:merb_root] = File.expand_path(File.dirname(__FILE__))
+ c[:environment] = ENV['RACK_ENV']
c[:session_store] = 'cookie'
c[:session_secret_key] = 'cookie'*10
c[:exception_details] = true
@@ -49,4 +51,8 @@ class Dm < Merb::Controller
scaffold_all_models :only =>[DmEmployee, DmGroup, DmPosition]
end
Merb.disable(:initfile)
-Merb.start(%w'-a mongrel')
+Merb.environment = Merb::Config[:environment]
+Merb.root = Merb::Config[:merb_root]
+Merb::BootLoader.run
+
+run Merb::Rack::Application.new
@@ -43,11 +43,4 @@ class DatamapperRack < ScaffoldingExtensions::RackController
run DatamapperRack
end
end
-
-puts "ScaffoldingExtensions::Rack started on port 7974"
-Rack::Handler.get('mongrel').run(app, :Host=>'0.0.0.0', :Port=>7974) do |server|
- trap(:INT) do
- server.stop
- puts "\nScaffoldingExtensions::Rack shutdown"
- end
-end
+run app
@@ -0,0 +1,6 @@
+ENV["RAILS_ENV"] ||= ENV["RACK_ENV"]
+require "config/environment"
+require 'action_controller/rack_lint_patch'
+use Rails::Rack::Static
+run ActionController::Dispatcher.new
+
@@ -12,5 +12,7 @@ class String
require 'controller/main'
require 'ar_garbage'
-#Ramaze::Inform.loggers = []
-Ramaze.start(:adapter => :mongrel, :port => 7978, :mode => :live){|m| m.use CleanUpARGarbage; m.run Ramaze::AppMap}
+Ramaze.options.mode = :live
+use CleanUpARGarbage
+Ramaze.start(:root => File.dirname(File.expand_path(__FILE__)), :started => true)
+run Ramaze
@@ -51,11 +51,4 @@ class DatamapperController < Sinatra::Base
run DatamapperController
end
end
-
-puts "== Sinatra/#{Sinatra::VERSION} has taken the stage on 7976 with backup from Mongrel"
-Rack::Handler.get('mongrel').run(app, :Host=>'0.0.0.0', :Port=>7976) do |server|
- trap(:INT) do
- server.stop
- puts "\n== Sinatra has ended his set (crowd applauds)"
- end
-end
+run app
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@@ -1,8 +0,0 @@
----
-:bind: 0.0.0.0
-:port: 7977
-:unsupervised: 1
-:adapter: cse
-:handler: mongrel
-:logfile: log/style-camping.log
-:pidfile: log/style-camping.pid
@@ -1,8 +0,0 @@
----
-:bind: 0.0.0.0
-:port: 7975
-:unsupervised: 1
-:adapter: merb_setup
-:handler: mongrel
-:logfile: log/style-merb.log
-:pidfile: log/style-merb.pid
@@ -1,8 +0,0 @@
----
-:bind: 0.0.0.0
-:port: 7974
-:unsupervised: 1
-:adapter: rack_se
-:handler: mongrel
-:logfile: log/style-rack.log
-:pidfile: log/style-rack.pid
@@ -1,10 +0,0 @@
----
-:bind: 0.0.0.0
-:port: 7979
-:unsupervised: 1
-:adapter: rails
-:handler: mongrel
-:logfile: log/style-rails.log
-:pidfile: log/style-rails.pid
-:adapter_config:
- :environment: production
@@ -1,8 +0,0 @@
----
-:bind: 0.0.0.0
-:port: 7978
-:unsupervised: 1
-:adapter: start
-:handler: mongrel
-:logfile: log/style-ramaze.log
-:pidfile: log/style-ramaze.pid
@@ -1,6 +0,0 @@
----
-:port: 7980
-:adapter: se_demo
-:handler: mongrel
-:logfile: log/style-se_demo.log
-:pidfile: log/style-se_demo.pid
@@ -1,8 +0,0 @@
----
-:bind: 0.0.0.0
-:port: 7976
-:unsupervised: 1
-:adapter: sinatra_se
-:handler: mongrel
-:logfile: log/style-sinatra.log
-:pidfile: log/style-sinatra.pid
View
@@ -1,6 +1,6 @@
#!/bin/sh
-WAITTIME=5
-frameworks="rails ramaze camping sinatra merb"
+WAITTIME=2
+frameworks="rails ramaze camping sinatra merb rack"
fw=""
orm=""
if [ $# != 0 ]; then
@@ -13,10 +13,10 @@ if [ $# != 0 ]; then
fi
./clear_logs
for framework in $frameworks; do
- style -c config/style.$framework.yaml start
- sleep $WAITTIME
+ unicorn -c unicorn-$framework.conf -D config-$framework.ru
+ sleep $WAITTIME
done
ruby test.rb $fw $orm
for framework in $frameworks; do
- style -c config/style.$framework.yaml stop
+ kill `cat log/unicorn-$framework.pid`
done
View
@@ -1,28 +0,0 @@
-require 'rubygems'
-require 'sinatra'
-SE_TEST_FRAMEWORK='se_demo'
-require 'sequel_setup'
-require 'se_setup'
-ScaffoldingExtensions.javascript_library = 'JQuery'
-set :port=>7980
-enable :sessions, :run
-disable :clean_trace, :reload
-
-helpers do
- def scaffold_set_flash(notice)
- session[:flash] = notice
- end
- def scaffold_get_flash
- @flash
- end
-end
-
-before do
- @flash = session.delete(:flash)
-end
-
-get '/' do
- erb :index
-end
-
-Sinatra::Application.send(:scaffold_all_models, :only=>[SqEmployee, SqGroup, SqMeeting, SqOfficer, SqPosition])
@@ -0,0 +1,5 @@
+ENV['RAILS_ENV'] = 'production'
+listen 7977
+pid 'log/unicorn-camping.pid'
+stderr_path 'log/unicorn-camping.log'
+stdout_path 'log/unicorn-camping.log'
@@ -0,0 +1,5 @@
+ENV['RAILS_ENV'] = 'production'
+listen 7975
+pid 'log/unicorn-merb.pid'
+stderr_path 'log/unicorn-merb.log'
+stdout_path 'log/unicorn-merb.log'
@@ -0,0 +1,5 @@
+ENV['RAILS_ENV'] = 'production'
+listen 7974
+pid 'log/unicorn-rack.pid'
+stderr_path 'log/unicorn-rack.log'
+stdout_path 'log/unicorn-rack.log'
@@ -0,0 +1,5 @@
+ENV['RAILS_ENV'] = 'production'
+listen 7979
+pid 'log/unicorn-rails.pid'
+stderr_path 'log/unicorn-rails.log'
+stdout_path 'log/unicorn-rails.log'
@@ -0,0 +1,5 @@
+ENV['RAILS_ENV'] = 'production'
+listen 7978
+pid 'log/unicorn-ramaze.pid'
+stderr_path 'log/unicorn-ramaze.log'
+stdout_path 'log/unicorn-ramaze.log'
@@ -0,0 +1,5 @@
+ENV['RAILS_ENV'] = 'production'
+listen 7976
+pid 'log/unicorn-sinatra.pid'
+stderr_path 'log/unicorn-sinatra.log'
+stdout_path 'log/unicorn-sinatra.log'
@@ -25,7 +25,7 @@ With this plugin installed, the html will be escaped. So you will need to do on
def some_helper
(1..5).map do |i|
"<li>#{i}</li>"
- end.join("\n").html_safe!
+ end.join("\n").html_safe
end
3) Use the safe_helper meta programming method:
@@ -82,9 +82,9 @@ This is intended functionality and can't be fixed.
Getting Started
===============
-1. Install rails 2.3.5 or higher, or freeze rails from 2-3-stable.
+1. Install rails 2.3.8 or higher, or freeze rails from 2-3-stable.
2. Install erubis (gem install erubis)
-3. Install this plugin (ruby script/plugin install git://github.com/NZKoz/rails_xss.git)
+3. Install this plugin (ruby script/plugin install git://github.com/rails/rails_xss.git)
4. Report anything that breaks.
Copyright (c) 2009 Koziarski Software Ltd, released under the MIT license. For full details see MIT-LICENSE included in this distribution.
@@ -1,14 +1,7 @@
-# Include hook code here
unless $gems_rake_task
- require 'erubis/helpers/rails_helper'
- require 'rails_xss'
-
- Erubis::Helpers::RailsHelper.engine_class = RailsXss::Erubis
-
- Module.class_eval do
- include RailsXss::SafeHelpers
+ if Rails.version <= "2.3.7"
+ $stderr.puts "rails_xss requires Rails 2.3.8 or later. Please upgrade to enable automatic HTML safety."
+ else
+ require 'rails_xss'
end
-
- require 'rails_xss_escaping'
- require 'av_patch'
-end
+end
@@ -1 +0,0 @@
-# Install hook code here
@@ -1,17 +0,0 @@
-module AvPatch
- # Rails version of with_output_buffer uses '' as the default buf
- def with_output_buffer(buf = ActionView::SafeBuffer.new) #:nodoc:
- super(buf)
- end
-end
-
-ActionView::Base.send :include, AvPatch
-
-
-module ActionView
- class Base
- def self.xss_safe?
- true
- end
- end
-end
@@ -1,39 +1,3 @@
-# RailsXss
-module RailsXss
- class Erubis < ::Erubis::Eruby
- def add_preamble(src)
- src << "@output_buffer = ActionView::SafeBuffer.new;\n"
- end
-
- def add_text(src, text)
- src << "@output_buffer << ('" << escape_text(text) << "'.html_safe!);"
- end
-
- def add_expr_literal(src, code)
- src << '@output_buffer << ((' << code << ').to_s);'
- end
-
- def add_expr_escaped(src, code)
- src << '@output_buffer << ' << escaped_expr(code) << ';'
- end
-
- def add_postamble(src)
- src << '@output_buffer.to_s'
- end
-
- end
-
- module SafeHelpers
- def safe_helper(*names)
- names.each do |helper_method_name|
- aliased_target, punctuation = helper_method_name.to_s.sub(/([?!=])$/, ''), $1
- module_eval <<-END
- def #{aliased_target}_with_xss_safety#{punctuation}(*args, &block)
- raw(#{aliased_target}_without_xss_safety#{punctuation}(*args, &block))
- end
- END
- alias_method_chain helper_method_name, :xss_safety
- end
- end
- end
-end
+require 'rails_xss/erubis'
+require 'rails_xss/action_view'
+require 'rails_xss/string_ext'
Oops, something went wrong.

0 comments on commit 7c5b7a9

Please sign in to comment.