From 4bafab9d837bced1c384fe1c8d3653b3b6768e81 Mon Sep 17 00:00:00 2001 From: Pius Uzamere Date: Fri, 29 Jan 2010 08:29:55 -0500 Subject: [PATCH] API level protection against users deactivating too many choice to have a valid prompt --- app/controllers/choices_controller.rb | 13 +++++++------ config/environment.rb | 1 + lib/tasks/hoptoad_notifier_tasks.rake | 5 +++++ vendor/plugins/hoptoad_notifier/.yardopts | 3 --- vendor/plugins/hoptoad_notifier/INSTALL | 25 ------------------------- vendor/plugins/hoptoad_notifier/MIT-LICENSE | 22 ---------------------- vendor/plugins/hoptoad_notifier/README.rdoc | 227 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/Rakefile | 29 ----------------------------- vendor/plugins/hoptoad_notifier/TESTING.rdoc | 8 -------- vendor/plugins/hoptoad_notifier/ginger_scenarios.rb | 31 ------------------------------- vendor/plugins/hoptoad_notifier/init.rb | 1 - vendor/plugins/hoptoad_notifier/install.rb | 1 - vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb | 150 ------------------------------------------------------------------------------------------------------------------------------------------------------ vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb | 99 --------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb | 95 ----------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb | 229 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb | 295 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb | 63 --------------------------------------------------------------- vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb | 37 ------------------------------------- vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb | 91 ------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/rails/init.rb | 8 -------- vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb | 24 ------------------------ vendor/plugins/hoptoad_notifier/script/integration_test.rb | 38 -------------------------------------- vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake | 89 ----------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/backtrace_test.rb | 94 ---------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/catcher_test.rb | 314 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/configuration_test.rb | 199 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/helper.rb | 238 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/hoptoad_2_0.xsd | 76 ---------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb | 138 ------------------------------------------------------------------------------------------------------------------------------------------ vendor/plugins/hoptoad_notifier/test/logger_test.rb | 85 ------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/notice_test.rb | 363 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/test/notifier_test.rb | 222 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ vendor/plugins/hoptoad_notifier/test/sender_test.rb | 123 --------------------------------------------------------------------------------------------------------------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore | 1 - vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE | 20 -------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile | 50 -------------------------------------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile | 57 --------------------------------------------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger | 42 ------------------------------------------ vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec | 33 --------------------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb | 21 --------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb | 20 -------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb | 56 -------------------------------------------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb | 24 ------------------------ vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb | 7 ------- vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb | 7 ------- vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb | 50 -------------------------------------------------- vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb | 14 -------------- vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb | 7 ------- 49 files changed, 13 insertions(+), 3832 deletions(-) create mode 100644 lib/tasks/hoptoad_notifier_tasks.rake delete mode 100644 vendor/plugins/hoptoad_notifier/.yardopts delete mode 100644 vendor/plugins/hoptoad_notifier/INSTALL delete mode 100644 vendor/plugins/hoptoad_notifier/MIT-LICENSE delete mode 100644 vendor/plugins/hoptoad_notifier/README.rdoc delete mode 100644 vendor/plugins/hoptoad_notifier/Rakefile delete mode 100644 vendor/plugins/hoptoad_notifier/TESTING.rdoc delete mode 100644 vendor/plugins/hoptoad_notifier/ginger_scenarios.rb delete mode 100644 vendor/plugins/hoptoad_notifier/init.rb delete mode 100644 vendor/plugins/hoptoad_notifier/install.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb delete mode 100644 vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb delete mode 100644 vendor/plugins/hoptoad_notifier/rails/init.rb delete mode 100644 vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb delete mode 100755 vendor/plugins/hoptoad_notifier/script/integration_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake delete mode 100644 vendor/plugins/hoptoad_notifier/test/backtrace_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/catcher_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/configuration_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/helper.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/hoptoad_2_0.xsd delete mode 100644 vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/logger_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/notice_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/notifier_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/test/sender_test.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb delete mode 100644 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb diff --git a/app/controllers/choices_controller.rb b/app/controllers/choices_controller.rb index 65c75b9..28971dd 100644 --- a/app/controllers/choices_controller.rb +++ b/app/controllers/choices_controller.rb @@ -25,7 +25,7 @@ class ChoicesController < InheritedResources::Base end end index! do |format| - format.xml { render :xml => @choices.to_xml(:only => [ :data, :score, :id ])} + format.xml { render :xml => @choices.to_xml(:only => [ :data, :score, :id, :active ])} end end @@ -97,17 +97,20 @@ class ChoicesController < InheritedResources::Base def deactivate_from_abroad authenticate - expire_page :action => :index @question = current_user.questions.find(params[:question_id]) @choice = @question.choices.find(params[:id]) respond_to do |format| - if @choice.deactivate! + if @question.choices.active.size < 3 + logger.info "will not deactivate choice because that would lead to fewer than two active choices for the question, #{@question.name}" + format.xml { render(:xml => false) and return} + format.json { render :json => false } + elsif @choice.deactivate! logger.info "successfully deactivated choice #{@choice.inspect}" format.xml { render :xml => true } format.json { render :json => true } else - logger.info "failed to deactivate choice #{@choice.inspect}" + logger.info "failed to deactivate choice #{@choice.inspect}" format.xml { render :xml => @choice.to_xml(:methods => [:data, :votes_count, :wins_plus_losses])} format.json { render :json => @choice.to_json(:methods => [:data])} end @@ -116,7 +119,6 @@ class ChoicesController < InheritedResources::Base def activate authenticate - expire_page :action => :index @question = current_user.questions.find(params[:question_id]) @choice = @question.choices.find(params[:id]) respond_to do |format| @@ -133,7 +135,6 @@ class ChoicesController < InheritedResources::Base def suspend authenticate - expire_page :action => :index @question = current_user.questions.find(params[:question_id]) @choice = @question.choices.find(params[:id]) respond_to do |format| diff --git a/config/environment.rb b/config/environment.rb index 11bf005..900e106 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -14,6 +14,7 @@ Rails::Initializer.run do |config| #config.action_mailer.delivery_method = :smtp config.action_mailer.delivery_method = :sendmail + config.gem 'hoptoad_notifier' config.gem "ambethia-smtp-tls", :lib => "smtp-tls", :version => "1.1.2", diff --git a/lib/tasks/hoptoad_notifier_tasks.rake b/lib/tasks/hoptoad_notifier_tasks.rake new file mode 100644 index 0000000..da2f45f --- /dev/null +++ b/lib/tasks/hoptoad_notifier_tasks.rake @@ -0,0 +1,5 @@ +Dir[File.join(RAILS_ROOT, 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier| + $: << File.join(vendored_notifier, 'lib') +end + +require 'hoptoad_notifier/tasks' diff --git a/vendor/plugins/hoptoad_notifier/.yardopts b/vendor/plugins/hoptoad_notifier/.yardopts deleted file mode 100644 index 485046d..0000000 --- a/vendor/plugins/hoptoad_notifier/.yardopts +++ /dev/null @@ -1,3 +0,0 @@ -- -TESTING.rdoc -MIT-LICENSE diff --git a/vendor/plugins/hoptoad_notifier/INSTALL b/vendor/plugins/hoptoad_notifier/INSTALL deleted file mode 100644 index 39f7fb2..0000000 --- a/vendor/plugins/hoptoad_notifier/INSTALL +++ /dev/null @@ -1,25 +0,0 @@ -=== Configuration - -You should have something like this in config/initializers/hoptoad.rb. - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - end - -(Please note that this configuration should be in a global configuration, and -is *not* environment-specific. Hoptoad is smart enough to know what errors are -caused by what environments, so your staging errors don't get mixed in with -your production errors.) - -You can test that Hoptoad is working in your production environment by using -this rake task (from RAILS_ROOT): - - rake hoptoad:test - -If everything is configured properly, that task will send a notice to Hoptoad -which will be visible immediately. - -NOTE FOR RAILS 1.2.* USERS: - -You will need to copy the hoptoad_notifier_tasks.rake file into your -RAILS_ROOT/lib/tasks directory in order for the rake hoptoad:test task to work. diff --git a/vendor/plugins/hoptoad_notifier/MIT-LICENSE b/vendor/plugins/hoptoad_notifier/MIT-LICENSE deleted file mode 100644 index 54830f0..0000000 --- a/vendor/plugins/hoptoad_notifier/MIT-LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc. - -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. diff --git a/vendor/plugins/hoptoad_notifier/README.rdoc b/vendor/plugins/hoptoad_notifier/README.rdoc deleted file mode 100644 index 9dfdf8d..0000000 --- a/vendor/plugins/hoptoad_notifier/README.rdoc +++ /dev/null @@ -1,227 +0,0 @@ -= HoptoadNotifier - -This is the notifier plugin for integrating apps with Hoptoad. - -When an uncaught exception occurs, HoptoadNotifier will POST the relevant data -to the Hoptoad server specified in your environment. - -== Help - -* {IRC}[irc://irc.freenode.net/thoughtbot] -* {mailing list}[http://groups.google.com/group/hoptoad-notifier-dev] - -== Installation - -=== Remove exception_notifier - -in your ApplicationController, REMOVE this line: - - include ExceptionNotifiable - -In your config/environment* files, remove all references to ExceptionNotifier - -Remove the vendor/plugins/exception_notifier directory. - -=== Install hoptoad_notifier - -from your project's RAILS_ROOT, run: - - script/plugin install -f git://github.com/thoughtbot/hoptoad_notifier.git - -=== Configuration - -You should have something like this in config/initializers/hoptoad.rb. - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - end - -(Please note that this configuration should be in a global configuration, and -is *not* environment-specific. Hoptoad is smart enough to know what errors are -caused by what environments, so your staging errors don't get mixed in with -your production errors.) - -After adding to your config/initializers like this you must restart your -server. This will not affect the rake task but it bears stating. - -That should be it! Now all exceptions will be logged to Hoptoad where they can -be aggregated, filtered, sorted, analyzed, massaged, and searched. In previous -releases you had to include HoptoadNotifier::Catcher into your -ApplicationController, but the plugin takes care of that now. - -You can test that Hoptoad is working in your production environment by using -this rake task (from RAILS_ROOT): - - rake hoptoad:test - -If everything is configured properly, that task will send a notice to Hoptoad -which will be visible immediately. - -=== NOTE FOR RAILS 1.2.* USERS: - -You will need to copy the hoptoad_notifier_tasks.rake file into your -RAILS_ROOT/lib/tasks directory in order for the rake hoptoad:test task to work. - -== Usage - -for the most part, Hoptoad works for itself. Once you've included the notifier -in your ApplicationController (which is now done automatically by the plugin), -all errors will be rescued by the #rescue_action_in_public provided by the plugin. - -If you want to log arbitrary things which you've rescued yourself from a -controller, you can do something like this: - - ... - rescue => ex - notify_hoptoad(ex) - flash[:failure] = 'Encryptions could not be rerouted, try again.' - end - ... - -The #notify_hoptoad call will send the notice over to Hoptoad for later analysis. While in your controllers you use the notify_hoptoad method, anywhere else in your code, use HoptoadNotifier.notify. - -To perform custom error processing after Hoptoad has been notified, define the instance method #rescue_action_in_public_without_hoptoad(exception) in your controller. - -== Tracking deployments in Hoptoad - -Paying Hoptoad plans support the ability to track deployments of your application in Hoptoad. -By notifying Hoptoad of your application deployments, all errors are resolved when a deploy occurs, -so that you'll be notified again about any errors that reoccur after a deployment. - -Additionally, it's possible to review the errors in Hoptoad that occurred before and after a deploy. - -When Hoptoad is installed as a plugin this functionality is loaded automatically (if you have Capistrano version 2.0.0 or greater). - -When Hoptoad is installed as a gem, you need to add - - require 'hoptoad_notifier/recipes/hoptoad' - -to your deploy.rb - -== Going beyond exceptions - -You can also pass a hash to notify_hoptoad method and store whatever you want, not just an exception. And you can also use it anywhere, not just in controllers: - - begin - params = { - # params that you pass to a method that can throw an exception - } - my_unpredicable_method(params) - rescue => e - HoptoadNotifier.notify( - :error_class => "Special Error", - :error_message => "Special Error: #{e.message}", - :parameters => params - ) - end - -While in your controllers you use the notify_hoptoad method, anywhere else in your code, use HoptoadNotifier.notify. Hoptoad will get all the information about the error itself. As for a hash, these are the keys you should pass: - -* :error_class – Use this to group similar errors together. When Hoptoad catches an exception it sends the class name of that exception object. -* :error_message – This is the title of the error you see in the errors list. For exceptions it is "#{exception.class.name}: #{exception.message}" -* :parameters – While there are several ways to send additional data to Hoptoad, passing a Hash as :parameters as in the example above is the most common use case. When Hoptoad catches an exception in a controller, the actual HTTP client request parameters are sent using this key. - -Hoptoad merges the hash you pass with these default options: - - { - :api_key => HoptoadNotifier.api_key, - :error_message => 'Notification', - :backtrace => caller, - :parameters => {}, - :session => {} - } - -You can override any of those parameters. - -== Filtering - -You can specify a whitelist of errors, that Hoptoad will not report on. Use -this feature when you are so apathetic to certain errors that you don't want -them even logged. - -This filter will only be applied to automatic notifications, not manual -notifications (when #notify is called directly). - -Hoptoad ignores the following exceptions by default: - - ActiveRecord::RecordNotFound - ActionController::RoutingError - ActionController::InvalidAuthenticityToken - ActionController::UnknownAction - CGI::Session::CookieStore::TamperedWithCookie - -To ignore errors in addition to those, specify their names in your Hoptoad -configuration block. - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - config.ignore << ActiveRecord::IgnoreThisError - end - -To ignore *only* certain errors (and override the defaults), use the -#ignore_only attribute. - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - config.ignore_only = [ActiveRecord::IgnoreThisError] - end - -To ignore certain user agents, add in the #ignore_user_agent attribute as a -string or regexp: - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - config.ignore_user_agent << /Ignored/ - config.ignore_user_agent << 'IgnoredUserAgent' - end - -To ignore exceptions based on other conditions, use #ignore_by_filter: - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - config.ignore_by_filter do |exception_data| - true if exception_data[:error_class] == "RuntimeError" - end - end - -To replace sensitive information sent to the Hoptoad service with [FILTERED] use #params_filters: - - HoptoadNotifier.configure do |config| - config.api_key = '1234567890abcdef' - config.params_filters << "credit_card_number" - end - -Note that, when rescuing exceptions within an ActionController method, -hoptoad_notifier will reuse filters specified by #filter_params_logging. - -== Testing - -When you run your tests, you might notice that the Hoptoad service is recording -notices generated using #notify when you don't expect it to. You can -use code like this in your test_helper.rb to redefine that method so those -errors are not reported while running tests. - - module HoptoadNotifier::Catcher - def notify(thing) - # do nothing. - end - end - -== Supported rails versions - -the notifier currently supports the following versions of Rails: - -* 1.2.6 -* 2.0.2 -* 2.1.0 -* 2.1.2 -* 2.2.2 -* 2.3.2 -* 2.3.3 -* 2.3.4 - -Please open up a support ticket on Tender ( http://help.hoptoadapp.com ) if you're using a version of Rails that is not listed above and the notifier is not working properly. - -== Thanks - -Thanks to Eugene Bolshakov for the excellent write-up on GOING BEYOND EXCEPTIONS, which we have included above. diff --git a/vendor/plugins/hoptoad_notifier/Rakefile b/vendor/plugins/hoptoad_notifier/Rakefile deleted file mode 100644 index 42962d7..0000000 --- a/vendor/plugins/hoptoad_notifier/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the hoptoad_notifier plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Run ginger tests' -task :ginger do - $LOAD_PATH << File.join(*%w[vendor ginger lib]) - ARGV.clear - ARGV << 'test' - load File.join(*%w[vendor ginger bin ginger]) -end - -begin - require 'yard' - YARD::Rake::YardocTask.new do |t| - t.files = ['lib/**/*.rb', 'TESTING.rdoc'] - end -rescue LoadError -end diff --git a/vendor/plugins/hoptoad_notifier/TESTING.rdoc b/vendor/plugins/hoptoad_notifier/TESTING.rdoc deleted file mode 100644 index 90ff40f..0000000 --- a/vendor/plugins/hoptoad_notifier/TESTING.rdoc +++ /dev/null @@ -1,8 +0,0 @@ -= For Maintainers: - -When developing the Hoptoad Notifier, be sure to use the integration test -against an existing project on staging before pushing to master. - -+./script/integration_test.rb + - -+./script/integration_test.rb secure+ diff --git a/vendor/plugins/hoptoad_notifier/ginger_scenarios.rb b/vendor/plugins/hoptoad_notifier/ginger_scenarios.rb deleted file mode 100644 index 31de18f..0000000 --- a/vendor/plugins/hoptoad_notifier/ginger_scenarios.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'ginger' - -def create_scenario(version) - scenario = Ginger::Scenario.new - scenario[/^active_?support$/] = version - scenario[/^active_?record$/] = version - scenario[/^action_?pack$/] = version - scenario[/^action_?controller$/] = version - scenario -end - -Ginger.configure do |config| - config.aliases["active_record"] = "activerecord" - config.aliases["active_support"] = "activesupport" - config.aliases["action_controller"] = "actionpack" - - rails_1_2_6 = Ginger::Scenario.new - rails_1_2_6[/^active_?support$/] = "1.4.4" - rails_1_2_6[/^active_?record$/] = "1.15.6" - rails_1_2_6[/^action_?pack$/] = "1.13.6" - rails_1_2_6[/^action_?controller$/] = "1.13.6" - - config.scenarios << rails_1_2_6 - config.scenarios << create_scenario("2.0.2") - config.scenarios << create_scenario("2.1.2") - config.scenarios << create_scenario("2.2.2") - config.scenarios << create_scenario("2.3.2") - # Rails 2.3.3 has broken params filtering - # config.scenarios << create_scenario("2.3.3") - config.scenarios << create_scenario("2.3.4") -end diff --git a/vendor/plugins/hoptoad_notifier/init.rb b/vendor/plugins/hoptoad_notifier/init.rb deleted file mode 100644 index 6dbfa4c..0000000 --- a/vendor/plugins/hoptoad_notifier/init.rb +++ /dev/null @@ -1 +0,0 @@ -require File.join(File.dirname(__FILE__), 'rails', 'init') diff --git a/vendor/plugins/hoptoad_notifier/install.rb b/vendor/plugins/hoptoad_notifier/install.rb deleted file mode 100644 index 692ee9f..0000000 --- a/vendor/plugins/hoptoad_notifier/install.rb +++ /dev/null @@ -1 +0,0 @@ -puts IO.read(File.join(File.dirname(__FILE__), 'INSTALL')) diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb deleted file mode 100644 index 6dfc8c5..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'net/http' -require 'net/https' -require 'rubygems' -require 'active_support' -require 'hoptoad_notifier/configuration' -require 'hoptoad_notifier/notice' -require 'hoptoad_notifier/sender' -require 'hoptoad_notifier/catcher' -require 'hoptoad_notifier/backtrace' - -# Plugin for applications to automatically post errors to the Hoptoad of their choice. -module HoptoadNotifier - - VERSION = "2.0.18" - API_VERSION = "2.0" - LOG_PREFIX = "** [Hoptoad] " - - HEADERS = { - 'Content-type' => 'text/xml', - 'Accept' => 'text/xml, application/xml' - } - - class << self - # The sender object is responsible for delivering formatted data to the Hoptoad server. - # Must respond to #send_to_hoptoad. See HoptoadNotifier::Sender. - attr_accessor :sender - - # A Hoptoad configuration object. Must act like a hash and return sensible - # values for all Hoptoad configuration options. See HoptoadNotifier::Configuration. - attr_accessor :configuration - - # Tell the log that the Notifier is good to go - def report_ready - write_verbose_log("Notifier #{VERSION} ready to catch errors") - end - - # Prints out the environment info to the log for debugging help - def report_environment_info - write_verbose_log("Environment Info: #{environment_info}") - end - - # Prints out the response body from Hoptoad for debugging help - def report_response_body(response) - write_verbose_log("Response from Hoptoad: \n#{response}") - end - - # Returns the Ruby version, Rails version, and current Rails environment - def environment_info - info = "[Ruby: #{RUBY_VERSION}]" - info << " [Rails: #{::Rails::VERSION::STRING}]" if defined?(Rails) - info << " [Env: #{configuration.environment_name}]" - end - - # Writes out the given message to the #logger - def write_verbose_log(message) - logger.info LOG_PREFIX + message if logger - end - - # Look for the Rails logger currently defined - def logger - if defined?(Rails.logger) - Rails.logger - elsif defined?(RAILS_DEFAULT_LOGGER) - RAILS_DEFAULT_LOGGER - end - end - - # Call this method to modify defaults in your initializers. - # - # @example - # HoptoadNotifier.configure do |config| - # config.api_key = '1234567890abcdef' - # config.secure = false - # end - def configure(silent = false) - self.configuration ||= Configuration.new - yield(configuration) - self.sender = Sender.new(configuration) - report_ready unless silent - end - - # Sends an exception manually using this method, even when you are not in a controller. - # - # @param [Exception] exception The exception you want to notify Hoptoad about. - # @param [Hash] opts Data that will be sent to Hoptoad. - # - # @option opts [String] :api_key The API key for this project. The API key is a unique identifier that Hoptoad uses for identification. - # @option opts [String] :error_message The error returned by the exception (or the message you want to log). - # @option opts [String] :backtrace A backtrace, usually obtained with +caller+. - # @option opts [String] :request The controller's request object. - # @option opts [String] :session The contents of the user's session. - # @option opts [String] :environment ENV merged with the contents of the request's environment. - def notify(exception, opts = {}) - send_notice(build_notice_for(exception, opts)) - end - - # Sends the notice unless it is one of the default ignored exceptions - # @see HoptoadNotifier.notify - def notify_or_ignore(exception, opts = {}) - notice = build_notice_for(exception, opts) - send_notice(notice) unless notice.ignore? - end - - def build_lookup_hash_for(exception, options = {}) - notice = build_notice_for(exception, options) - - result = {} - result[:action] = notice.action rescue nil - result[:component] = notice.component rescue nil - result[:error_class] = notice.error_class if notice.error_class - result[:environment_name] = 'production' - - unless notice.backtrace.lines.empty? - result[:file] = notice.backtrace.lines.first.file - result[:line_number] = notice.backtrace.lines.first.number - end - - result - end - - private - - def send_notice(notice) - if configuration.public? - sender.send_to_hoptoad(notice.to_xml) - end - end - - def build_notice_for(exception, opts = {}) - exception = unwrap_exception(exception) - if exception.respond_to?(:to_hash) - opts = opts.merge(exception) - else - opts = opts.merge(:exception => exception) - end - Notice.new(configuration.merge(opts)) - end - - def unwrap_exception(exception) - if exception.respond_to?(:original_exception) - exception.original_exception - elsif exception.respond_to?(:continued_exception) - exception.continued_exception - else - exception - end - end - end -end - diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb deleted file mode 100644 index 617fd3c..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb +++ /dev/null @@ -1,99 +0,0 @@ -module HoptoadNotifier - # Front end to parsing the backtrace for each notice - class Backtrace - - # Handles backtrace parsing line by line - class Line - - INPUT_FORMAT = %r{^([^:]+):(\d+)(?::in `([^']+)')?$}.freeze - - # The file portion of the line (such as app/models/user.rb) - attr_reader :file - - # The line number portion of the line - attr_reader :number - - # The method of the line (such as index) - attr_reader :method - - # Parses a single line of a given backtrace - # @param [String] unparsed_line The raw line from +caller+ or some backtrace - # @return [Line] The parsed backtrace line - def self.parse(unparsed_line) - _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a - new(file, number, method) - end - - def initialize(file, number, method) - self.file = file - self.number = number - self.method = method - end - - # Reconstructs the line in a readable fashion - def to_s - "#{file}:#{number}:in `#{method}'" - end - - def ==(other) - to_s == other.to_s - end - - def inspect - "" - end - - private - - attr_writer :file, :number, :method - end - - # holder for an Array of Backtrace::Line instances - attr_reader :lines - - def self.parse(ruby_backtrace, opts = {}) - ruby_lines = split_multiline_backtrace(ruby_backtrace) - - filters = opts[:filters] || [] - filtered_lines = ruby_lines.to_a.map do |line| - filters.inject(line) do |line, proc| - proc.call(line) - end - end.compact - - lines = filtered_lines.collect do |unparsed_line| - Line.parse(unparsed_line) - end - - instance = new(lines) - end - - def initialize(lines) - self.lines = lines - end - - def inspect - "" - end - - def ==(other) - if other.respond_to?(:lines) - lines == other.lines - else - false - end - end - - private - - attr_writer :lines - - def self.split_multiline_backtrace(backtrace) - if backtrace.to_a.size == 1 - backtrace.to_a.first.split(/\n\s*/) - else - backtrace - end - end - end -end diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb deleted file mode 100644 index 3e7c66c..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb +++ /dev/null @@ -1,95 +0,0 @@ -module HoptoadNotifier - # Include this module in Controllers in which you want to be notified of errors. - module Catcher - - # Sets up an alias chain to catch exceptions when Rails does - def self.included(base) #:nodoc: - if base.instance_methods.map(&:to_s).include? 'rescue_action_in_public' and !base.instance_methods.map(&:to_s).include? 'rescue_action_in_public_without_hoptoad' - base.send(:alias_method, :rescue_action_in_public_without_hoptoad, :rescue_action_in_public) - base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_hoptoad) - base.send(:alias_method, :rescue_action_locally_without_hoptoad, :rescue_action_locally) - base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_hoptoad) - end - end - - private - - # Overrides the rescue_action method in ActionController::Base, but does not inhibit - # any custom processing that is defined with Rails 2's exception helpers. - def rescue_action_in_public_with_hoptoad(exception) - unless hoptoad_ignore_user_agent? - HoptoadNotifier.notify_or_ignore(exception, hoptoad_request_data) - end - rescue_action_in_public_without_hoptoad(exception) - end - - def rescue_action_locally_with_hoptoad(exception) - result = rescue_action_locally_without_hoptoad(exception) - - if HoptoadNotifier.configuration.development_lookup - path = File.join(File.dirname(__FILE__), '..', 'templates', 'rescue.erb') - notice = HoptoadNotifier.build_lookup_hash_for(exception, hoptoad_request_data) - - result << @template.render( - :file => path, - :use_full_path => false, - :locals => { :host => HoptoadNotifier.configuration.host, - :api_key => HoptoadNotifier.configuration.api_key, - :notice => notice }) - end - - result - end - - # This method should be used for sending manual notifications while you are still - # inside the controller. Otherwise it works like HoptoadNotifier.notify. - def notify_hoptoad(hash_or_exception) - unless consider_all_requests_local || local_request? - HoptoadNotifier.notify(hash_or_exception, hoptoad_request_data) - end - end - - def hoptoad_ignore_user_agent? #:nodoc: - # Rails 1.2.6 doesn't have request.user_agent, so check for it here - user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"] - HoptoadNotifier.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent } - end - - def hoptoad_request_data - { :parameters => hoptoad_filter_if_filtering(params.to_hash), - :session_data => hoptoad_session_data, - :controller => params[:controller], - :action => params[:action], - :url => hoptoad_request_url, - :cgi_data => hoptoad_filter_if_filtering(request.env), - :environment_vars => hoptoad_filter_if_filtering(ENV) } - end - - def hoptoad_filter_if_filtering(hash) - if respond_to?(:filter_parameters) - filter_parameters(hash) rescue hash - else - hash - end - end - - def hoptoad_session_data - if session.respond_to?(:to_hash) - session.to_hash - else - session.data - end - end - - def hoptoad_request_url - url = "#{request.protocol}#{request.host}" - - unless [80, 443].include?(request.port) - url << ":#{request.port}" - end - - url << request.request_uri - url - end - end -end diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb deleted file mode 100644 index 3091594..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb +++ /dev/null @@ -1,229 +0,0 @@ -module HoptoadNotifier - # Used to set up and modify settings for the notifier. - class Configuration - - OPTIONS = [:api_key, :backtrace_filters, :development_environments, - :development_lookup, :environment_name, :host, - :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters, - :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version, - :params_filters, :project_root, :port, :protocol, :proxy_host, - :proxy_pass, :proxy_port, :proxy_user, :secure].freeze - - # The API key for your project, found on the project edit form. - attr_accessor :api_key - - # The host to connect to (defaults to hoptoadapp.com). - attr_accessor :host - - # The port on which your Hoptoad server runs (defaults to 443 for secure - # connections, 80 for insecure connections). - attr_accessor :port - - # +true+ for https connections, +false+ for http connections. - attr_accessor :secure - - # The HTTP open timeout in seconds (defaults to 2). - attr_accessor :http_open_timeout - - # The HTTP read timeout in seconds (defaults to 5). - attr_accessor :http_read_timeout - - # The hostname of your proxy server (if using a proxy) - attr_accessor :proxy_host - - # The port of your proxy server (if using a proxy) - attr_accessor :proxy_port - - # The username to use when logging into your proxy server (if using a proxy) - attr_accessor :proxy_user - - # The password to use when logging into your proxy server (if using a proxy) - attr_accessor :proxy_pass - - # A list of parameters that should be filtered out of what is sent to Hoptoad. - # By default, all "password" attributes will have their contents replaced. - attr_reader :params_filters - - # A list of filters for cleaning and pruning the backtrace. See #filter_backtrace. - attr_reader :backtrace_filters - - # A list of filters for ignoring exceptions. See #ignore_by_filter. - attr_reader :ignore_by_filters - - # A list of exception classes to ignore. The array can be appended to. - attr_reader :ignore - - # A list of user agents that are being ignored. The array can be appended to. - attr_reader :ignore_user_agent - - # A list of environments in which notifications should not be sent. - attr_accessor :development_environments - - # +true+ if you want to check for production errors matching development errors, +false+ otherwise. - attr_accessor :development_lookup - - # The name of the environment the application is running in - attr_accessor :environment_name - - # The path to the project in which the error occurred, such as the RAILS_ROOT - attr_accessor :project_root - - # The name of the notifier library being used to send notifications (such as "Hoptoad Notifier") - attr_accessor :notifier_name - - # The version of the notifier library being used to send notifications (such as "1.0.2") - attr_accessor :notifier_version - - # The url of the notifier library being used to send notifications - attr_accessor :notifier_url - - DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze - - DEFAULT_BACKTRACE_FILTERS = [ - lambda { |line| - if defined?(HoptoadNotifier.configuration.project_root) - line.gsub(/#{HoptoadNotifier.configuration.project_root}/, "[PROJECT_ROOT]") - else - line - end - }, - lambda { |line| line.gsub(/^\.\//, "") }, - lambda { |line| - if defined?(Gem) - Gem.path.inject(line) do |line, path| - line.gsub(/#{path}/, "[GEM_ROOT]") - end - end - }, - lambda { |line| line if line !~ %r{lib/hoptoad_notifier} } - ].freeze - - IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound', - 'ActionController::RoutingError', - 'ActionController::InvalidAuthenticityToken', - 'CGI::Session::CookieStore::TamperedWithCookie', - 'ActionController::UnknownAction'] - - # Some of these don't exist for Rails 1.2.*, so we have to consider that. - IGNORE_DEFAULT.map!{|e| eval(e) rescue nil }.compact! - IGNORE_DEFAULT.freeze - - alias_method :secure?, :secure - - def initialize - @secure = false - @host = 'hoptoadapp.com' - @http_open_timeout = 2 - @http_read_timeout = 5 - @params_filters = DEFAULT_PARAMS_FILTERS.dup - @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup - @ignore_by_filters = [] - @ignore = IGNORE_DEFAULT.dup - @ignore_user_agent = [] - @development_environments = %w(development test cucumber) - @development_lookup = true - @notifier_name = 'Hoptoad Notifier' - @notifier_version = VERSION - @notifier_url = 'http://hoptoadapp.com' - end - - # Takes a block and adds it to the list of backtrace filters. When the filters - # run, the block will be handed each line of the backtrace and can modify - # it as necessary. - # - # @example - # config.filter_bracktrace do |line| - # line.gsub(/^#{Rails.root}/, "[RAILS_ROOT]") - # end - # - # @param [Proc] block The new backtrace filter. - # @yieldparam [String] line A line in the backtrace. - def filter_backtrace(&block) - self.backtrace_filters << block - end - - # Takes a block and adds it to the list of ignore filters. - # When the filters run, the block will be handed the exception. - # @example - # config.ignore_by_filter do |exception_data| - # true if exception_data[:error_class] == "RuntimeError" - # end - # - # @param [Proc] block The new ignore filter - # @yieldparam [Hash] data The exception data given to +HoptoadNotifier.notify+ - # @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by hoptoad. - def ignore_by_filter(&block) - self.ignore_by_filters << block - end - - # Overrides the list of default ignored errors. - # - # @param [Array] names A list of exceptions to ignore. - def ignore_only=(names) - @ignore = [names].flatten - end - - # Overrides the list of default ignored user agents - # - # @param [Array] A list of user agents to ignore - def ignore_user_agent_only=(names) - @ignore_user_agent = [names].flatten - end - - # Allows config options to be read like a hash - # - # @param [Symbol] option Key for a given attribute - def [](option) - send(option) - end - - # Returns a hash of all configurable options - def to_hash - OPTIONS.inject({}) do |hash, option| - hash.merge(option.to_sym => send(option)) - end - end - - # Returns a hash of all configurable options merged with +hash+ - # - # @param [Hash] hash A set of configuration options that will take precedence over the defaults - def merge(hash) - to_hash.merge(hash) - end - - # Determines if the notifier will send notices. - # @return [Boolean] Returns +false+ if in a development environment, +true+ otherwise. - def public? - !development_environments.include?(environment_name) - end - - def port - @port || default_port - end - - def protocol - if secure? - 'https' - else - 'http' - end - end - - def environment_filters - warn 'config.environment_filters has been deprecated and has no effect.' - [] - end - - private - - def default_port - if secure? - 443 - else - 80 - end - end - - end - -end diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb deleted file mode 100644 index 1336f68..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb +++ /dev/null @@ -1,295 +0,0 @@ -module HoptoadNotifier - class Notice - - # The exception that caused this notice, if any - attr_reader :exception - - # The API key for the project to which this notice should be sent - attr_reader :api_key - - # The backtrace from the given exception or hash. - attr_reader :backtrace - - # The name of the class of error (such as RuntimeError) - attr_reader :error_class - - # The name of the server environment (such as "production") - attr_reader :environment_name - - # CGI variables such as HTTP_METHOD - attr_reader :cgi_data - - # The message from the exception, or a general description of the error - attr_reader :error_message - - # See Configuration#backtrace_filters - attr_reader :backtrace_filters - - # See Configuration#params_filters - attr_reader :params_filters - - # A hash of parameters from the query string or post body. - attr_reader :parameters - alias_method :params, :parameters - - # The component (if any) which was used in this request (usually the controller) - attr_reader :component - alias_method :controller, :component - - # The action (if any) that was called in this request - attr_reader :action - - # A hash of session data from the request - attr_reader :session_data - - # The path to the project that caused the error (usually RAILS_ROOT) - attr_reader :project_root - - # The URL at which the error occurred (if any) - attr_reader :url - - # See Configuration#ignore - attr_reader :ignore - - # See Configuration#ignore_by_filters - attr_reader :ignore_by_filters - - # The name of the notifier library sending this notice, such as "Hoptoad Notifier" - attr_reader :notifier_name - - # The version number of the notifier library sending this notice, such as "2.1.3" - attr_reader :notifier_version - - # A URL for more information about the notifier library sending this notice - attr_reader :notifier_url - - def initialize(args) - self.args = args - self.exception = args[:exception] - self.api_key = args[:api_key] - self.project_root = args[:project_root] - self.url = args[:url] - - self.notifier_name = args[:notifier_name] - self.notifier_version = args[:notifier_version] - self.notifier_url = args[:notifier_url] - - self.ignore = args[:ignore] || [] - self.ignore_by_filters = args[:ignore_by_filters] || [] - self.backtrace_filters = args[:backtrace_filters] || [] - self.params_filters = args[:params_filters] || [] - self.parameters = args[:parameters] || {} - self.component = args[:component] || args[:controller] - self.action = args[:action] - - self.environment_name = args[:environment_name] - self.cgi_data = args[:cgi_data] - self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller)) - self.error_class = exception_attribute(:error_class) {|exception| exception.class.name } - self.error_message = exception_attribute(:error_message, 'Notification') do |exception| - "#{exception.class.name}: #{exception.message}" - end - - find_session_data - clean_params - end - - # Converts the given notice to XML - def to_xml - builder = Builder::XmlMarkup.new - builder.instruct! - xml = builder.notice(:version => HoptoadNotifier::API_VERSION) do |notice| - notice.tag!("api-key", api_key) - notice.notifier do |notifier| - notifier.name(notifier_name) - notifier.version(notifier_version) - notifier.url(notifier_url) - end - notice.error do |error| - error.tag!('class', error_class) - error.message(error_message) - error.backtrace do |backtrace| - self.backtrace.lines.each do |line| - backtrace.line(:number => line.number, - :file => line.file, - :method => line.method) - end - end - end - if url || - controller || - action || - !parameters.blank? || - !cgi_data.blank? || - !session_data.blank? - notice.request do |request| - request.url(url) - request.component(controller) - request.action(action) - unless parameters.blank? - request.params do |params| - xml_vars_for(params, parameters) - end - end - unless session_data.blank? - request.session do |session| - xml_vars_for(session, session_data) - end - end - unless cgi_data.blank? - request.tag!("cgi-data") do |cgi_datum| - xml_vars_for(cgi_datum, cgi_data) - end - end - end - end - notice.tag!("server-environment") do |env| - env.tag!("project-root", project_root) - env.tag!("environment-name", environment_name) - end - end - xml.to_s - end - - # Determines if this notice should be ignored - def ignore? - ignored_class_names.include?(error_class) || - ignore_by_filters.any? {|filter| filter.call(self) } - end - - # Allows properties to be accessed using a hash-like syntax - # - # @example - # notice[:error_message] - # @param [String] method The given key for an attribute - # @return The attribute value, or self if given +:request+ - def [](method) - case method - when :request - self - else - send(method) - end - end - - private - - attr_writer :exception, :api_key, :backtrace, :error_class, :error_message, - :backtrace_filters, :parameters, :params_filters, - :environment_filters, :session_data, :project_root, :url, :ignore, - :ignore_by_filters, :notifier_name, :notifier_url, :notifier_version, - :component, :action, :cgi_data, :environment_name - - # Arguments given in the initializer - attr_accessor :args - - # Gets a property named +attribute+ of an exception, either from an actual - # exception or a hash. - # - # If an exception is available, #from_exception will be used. Otherwise, - # a key named +attribute+ will be used from the #args. - # - # If no exception or hash key is available, +default+ will be used. - def exception_attribute(attribute, default = nil, &block) - (exception && from_exception(attribute, &block)) || args[attribute] || default - end - - # Gets a property named +attribute+ from an exception. - # - # If a block is given, it will be used when getting the property from an - # exception. The block should accept and exception and return the value for - # the property. - # - # If no block is given, a method with the same name as +attribute+ will be - # invoked for the value. - def from_exception(attribute) - if block_given? - yield(exception) - else - exception.send(attribute) - end - end - - # Removes non-serializable data from the given attribute. - # See #clean_unserializable_data - def clean_unserializable_data_from(attribute) - self.send(:"#{attribute}=", clean_unserializable_data(send(attribute))) - end - - # Removes non-serializable data. Allowed data types are strings, arrays, - # and hashes. All other types are converted to strings. - # TODO: move this onto Hash - def clean_unserializable_data(data) - if data.respond_to?(:to_hash) - data.to_hash.inject({}) do |result, (key, value)| - result.merge(key => clean_unserializable_data(value)) - end - elsif data.respond_to?(:to_ary) - data.collect do |value| - clean_unserializable_data(value) - end - else - data.to_s - end - end - - # Replaces the contents of params that match params_filters. - # TODO: extract this to a different class - def clean_params - clean_unserializable_data_from(:parameters) - filter(parameters) - if cgi_data - clean_unserializable_data_from(:cgi_data) - filter(cgi_data) - end - if session_data - clean_unserializable_data_from(:session_data) - end - end - - def filter(hash) - if params_filters - hash.each do |key, value| - if filter_key?(key) - hash[key] = "[FILTERED]" - elsif value.respond_to?(:to_hash) - filter(hash[key]) - end - end - end - end - - def filter_key?(key) - params_filters.any? do |filter| - key.to_s.include?(filter) - end - end - - def find_session_data - self.session_data = args[:session_data] || args[:session] || {} - self.session_data = session_data[:data] if session_data[:data] - end - - # Converts the mixed class instances and class names into just names - # TODO: move this into Configuration or another class - def ignored_class_names - ignore.collect do |string_or_class| - if string_or_class.respond_to?(:name) - string_or_class.name - else - string_or_class - end - end - end - - def xml_vars_for(builder, hash) - hash.each do |key, value| - if value.respond_to?(:to_hash) - builder.var(:key => key){|b| xml_vars_for(b, value.to_hash) } - else - builder.var(value.to_s, :key => key) - end - end - end - end -end diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb deleted file mode 100644 index 94bb3f0..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb +++ /dev/null @@ -1,63 +0,0 @@ -module HoptoadNotifier - # Sends out the notice to Hoptoad - class Sender - - NOTICES_URI = '/notifier_api/v2/notices/'.freeze - - def initialize(options = {}) - [:proxy_host, :proxy_port, :proxy_user, :proxy_pass, :protocol, - :host, :port, :secure, :http_open_timeout, :http_read_timeout].each do |option| - instance_variable_set("@#{option}", options[option]) - end - end - - # Sends the notice data off to Hoptoad for processing. - # - # @param [String] data The XML notice to be sent off - def send_to_hoptoad(data) - logger.debug { "Sending request to #{url.to_s}:\n#{data}" } - - http = - Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass). - new(url.host, url.port) - - http.read_timeout = http_read_timeout - http.open_timeout = http_open_timeout - http.use_ssl = secure - - response = begin - http.post(url.path, data, HEADERS) - rescue TimeoutError => e - log :error, "Timeout while contacting the Hoptoad server." - nil - end - - case response - when Net::HTTPSuccess then - log :info, "Success: #{response.class}", response - else - log :error, "Failure: #{response.class}", response - end - end - - private - - attr_reader :proxy_host, :proxy_port, :proxy_user, :proxy_pass, :protocol, - :host, :port, :secure, :http_open_timeout, :http_read_timeout - - def url - URI.parse("#{protocol}://#{host}:#{port}").merge(NOTICES_URI) - end - - def log(level, message, response = nil) - logger.send level, LOG_PREFIX + message if logger - HoptoadNotifier.report_environment_info - HoptoadNotifier.report_response_body(response.body) if response && response.respond_to?(:body) - end - - def logger - HoptoadNotifier.logger - end - - end -end diff --git a/vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb b/vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb deleted file mode 100644 index 0cb7213..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'net/http' -require 'uri' -require 'active_support' - -# Capistrano tasks for notifying Hoptoad of deploys -module HoptoadTasks - - # Alerts Hoptoad of a deploy. - # - # @param [Hash] opts Data about the deploy that is set to Hoptoad - # - # @option opts [String] :rails_env Environment of the deploy (production, staging) - # @option opts [String] :scm_revision The given revision/sha that is being deployed - # @option opts [String] :scm_repository Address of your repository to help with code lookups - # @option opts [String] :local_username Who is deploying - def self.deploy(opts = {}) - if HoptoadNotifier.configuration.api_key.blank? - puts "I don't seem to be configured with an API key. Please check your configuration." - return false - end - - if opts[:rails_env].blank? - puts "I don't know to which Rails environment you are deploying (use the TO=production option)." - return false - end - - params = {'api_key' => opts.delete(:api_key) || - HoptoadNotifier.configuration.api_key} - opts.each {|k,v| params["deploy[#{k}]"] = v } - - url = URI.parse("http://#{HoptoadNotifier.configuration.host || 'hoptoadapp.com'}/deploys.txt") - response = Net::HTTP.post_form(url, params) - puts response.body - return Net::HTTPSuccess === response - end -end - diff --git a/vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb b/vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb deleted file mode 100644 index fe5919e..0000000 --- a/vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb +++ /dev/null @@ -1,91 +0,0 @@ - - - diff --git a/vendor/plugins/hoptoad_notifier/rails/init.rb b/vendor/plugins/hoptoad_notifier/rails/init.rb deleted file mode 100644 index e21fb62..0000000 --- a/vendor/plugins/hoptoad_notifier/rails/init.rb +++ /dev/null @@ -1,8 +0,0 @@ -if defined?(ActionController::Base) && !ActionController::Base.include?(HoptoadNotifier::Catcher) - ActionController::Base.send(:include, HoptoadNotifier::Catcher) -end - -HoptoadNotifier.configure(true) do |config| - config.environment_name = RAILS_ENV - config.project_root = RAILS_ROOT -end diff --git a/vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb b/vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb deleted file mode 100644 index c196c21..0000000 --- a/vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb +++ /dev/null @@ -1,24 +0,0 @@ -# When Hoptoad is installed as a plugin this is loaded automatically. -# -# When Hoptoad installed as a gem, you need to add -# require 'hoptoad_notifier/recipes/hoptoad' -# to your deploy.rb -# -# Defines deploy:notify_hoptoad which will send information about the deploy to Hoptoad. -# -after "deploy", "deploy:notify_hoptoad" -after "deploy:migrations", "deploy:notify_hoptoad" - -namespace :deploy do - desc "Notify Hoptoad of the deployment" - task :notify_hoptoad, :except => { :no_release => true } do - rails_env = fetch(:hoptoad_env, fetch(:rails_env, "production")) - local_user = ENV['USER'] || ENV['USERNAME'] - executable = RUBY_PLATFORM.downcase.include?('mswin') ? 'rake.bat' : 'rake' - notify_command = "#{executable} hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}" - notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY'] - puts "Notifying Hoptoad of Deploy (#{notify_command})" - `#{notify_command}` - puts "Hoptoad Notification Complete." - end -end diff --git a/vendor/plugins/hoptoad_notifier/script/integration_test.rb b/vendor/plugins/hoptoad_notifier/script/integration_test.rb deleted file mode 100755 index b5f76bc..0000000 --- a/vendor/plugins/hoptoad_notifier/script/integration_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env ruby - -require 'logger' -require 'fileutils' - -RAILS_ENV = "production" -RAILS_ROOT = FileUtils.pwd -RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) - -$: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'hoptoad_notifier' -require 'rails/init' - -fail "Please supply an API Key as the first argument" if ARGV.empty? - -host = ARGV[1] -host ||= "hoptoadapp.com" - -secure = (ARGV[2] == "secure") - -exception = begin - raise "Testing hoptoad notifier with secure = #{secure}. If you can see this, it works." - rescue => foo - foo - end - -HoptoadNotifier.configure do |config| - config.secure = secure - config.host = host - config.api_key = ARGV.first -end -puts "Configuration:" -HoptoadNotifier.configuration.to_hash.each do |key, value| - puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55)) -end -puts "Sending #{secure ? "" : "in"}secure notification to project with key #{ARGV.first}" -HoptoadNotifier.notify(exception) - diff --git a/vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake b/vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake deleted file mode 100644 index ececd35..0000000 --- a/vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake +++ /dev/null @@ -1,89 +0,0 @@ -namespace :hoptoad do - desc "Notify Hoptoad of a new deploy." - task :deploy => :environment do - require 'hoptoad_tasks' - HoptoadTasks.deploy(:rails_env => ENV['TO'], - :scm_revision => ENV['REVISION'], - :scm_repository => ENV['REPO'], - :local_username => ENV['USER'], - :api_key => ENV['API_KEY']) - end - - task :log_stdout do - require 'logger' - RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) - end - - desc "Verify your plugin installation by sending a test exception to the hoptoad service" - task :test => ['hoptoad:log_stdout', :environment] do - RAILS_DEFAULT_LOGGER.level = Logger::DEBUG - - require 'action_controller/test_process' - require 'app/controllers/application' if File.exists?('app/controllers/application.rb') - - request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - - class HoptoadTestingException < RuntimeError; end - - unless HoptoadNotifier.configuration.api_key - puts "Hoptoad needs an API key configured! Check the README to see how to add it." - exit - end - - HoptoadNotifier.configuration.development_environments = [] - - in_controller = ApplicationController.included_modules.include? HoptoadNotifier::Catcher - in_base = ActionController::Base.included_modules.include? HoptoadNotifier::Catcher - if !in_controller || !in_base - puts "HoptoadNotifier::Catcher must be included inside your ApplicationController class." - exit - end - - puts "Configuration:" - HoptoadNotifier.configuration.to_hash.each do |key, value| - puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55)) - end - - puts 'Setting up the Controller.' - class ApplicationController - # This is to bypass any filters that may prevent access to the action. - prepend_before_filter :test_hoptoad - def test_hoptoad - puts "Raising '#{exception_class.name}' to simulate application failure." - raise exception_class.new, 'Testing hoptoad via "rake hoptoad:test". If you can see this, it works.' - end - - def rescue_action exception - rescue_action_in_public exception - end - - # Ensure we actually have an action to go to. - def verify; end - - def consider_all_requests_local - false - end - - def local_request? - false - end - - def exception_class - exception_name = ENV['EXCEPTION'] || "HoptoadTestingException" - Object.const_get(exception_name) - rescue - Object.const_set(exception_name, Class.new(Exception)) - end - - def logger - nil - end - end - - puts 'Processing request.' - class HoptoadVerificationController < ApplicationController; end - HoptoadVerificationController.new.process(request, response) - end -end - diff --git a/vendor/plugins/hoptoad_notifier/test/backtrace_test.rb b/vendor/plugins/hoptoad_notifier/test/backtrace_test.rb deleted file mode 100644 index a31f510..0000000 --- a/vendor/plugins/hoptoad_notifier/test/backtrace_test.rb +++ /dev/null @@ -1,94 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class BacktraceTest < Test::Unit::TestCase - - should "parse a backtrace into lines" do - array = [ - "app/models/user.rb:13:in `magic'", - "app/controllers/users_controller.rb:8:in `index'" - ] - - backtrace = HoptoadNotifier::Backtrace.parse(array) - - line = backtrace.lines.first - assert_equal '13', line.number - assert_equal 'app/models/user.rb', line.file - assert_equal 'magic', line.method - - line = backtrace.lines.last - assert_equal '8', line.number - assert_equal 'app/controllers/users_controller.rb', line.file - assert_equal 'index', line.method - end - - should "be equal with equal lines" do - one = build_backtrace_array - two = one.dup - assert_equal one, two - - assert_equal HoptoadNotifier::Backtrace.parse(one), HoptoadNotifier::Backtrace.parse(two) - end - - should "parse massive one-line exceptions into multiple lines" do - original_backtrace = HoptoadNotifier::Backtrace. - parse(["one:1:in `one'\n two:2:in `two'\n three:3:in `three`"]) - expected_backtrace = HoptoadNotifier::Backtrace. - parse(["one:1:in `one'", "two:2:in `two'", "three:3:in `three`"]) - - assert_equal expected_backtrace, original_backtrace - end - - context "with a project root" do - setup do - @project_root = '/some/path' - HoptoadNotifier.configure {|config| config.project_root = @project_root } - end - - teardown do - reset_config - end - - should "filter out the project root" do - backtrace_with_root = HoptoadNotifier::Backtrace.parse( - ["#{@project_root}/app/models/user.rb:7:in `latest'", - "#{@project_root}/app/controllers/users_controller.rb:13:in `index'", - "/lib/something.rb:41:in `open'"], - :filters => default_filters) - backtrace_without_root = HoptoadNotifier::Backtrace.parse( - ["[PROJECT_ROOT]/app/models/user.rb:7:in `latest'", - "[PROJECT_ROOT]/app/controllers/users_controller.rb:13:in `index'", - "/lib/something.rb:41:in `open'"]) - - assert_equal backtrace_without_root, backtrace_with_root - end - end - - should "remove notifier trace" do - inside_notifier = ['lib/hoptoad_notifier.rb:13:in `voodoo`'] - outside_notifier = ['users_controller:8:in `index`'] - - without_inside = HoptoadNotifier::Backtrace.parse(outside_notifier) - with_inside = HoptoadNotifier::Backtrace.parse(inside_notifier + outside_notifier, - :filters => default_filters) - - assert_equal without_inside, with_inside - end - - should "run filters on the backtrace" do - filters = [lambda { |line| line.sub('foo', 'bar') }] - input = HoptoadNotifier::Backtrace.parse(["foo:13:in `one'", "baz:14:in `two'"], - :filters => filters) - expected = HoptoadNotifier::Backtrace.parse(["bar:13:in `one'", "baz:14:in `two'"]) - assert_equal expected, input - end - - def build_backtrace_array - ["app/models/user.rb:13:in `magic'", - "app/controllers/users_controller.rb:8:in `index'"] - end - - def default_filters - HoptoadNotifier::Configuration::DEFAULT_BACKTRACE_FILTERS - end - -end diff --git a/vendor/plugins/hoptoad_notifier/test/catcher_test.rb b/vendor/plugins/hoptoad_notifier/test/catcher_test.rb deleted file mode 100644 index 0905f27..0000000 --- a/vendor/plugins/hoptoad_notifier/test/catcher_test.rb +++ /dev/null @@ -1,314 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class CatcherTest < Test::Unit::TestCase - - include DefinesConstants - - def setup - super - reset_config - HoptoadNotifier.sender = CollectingSender.new - define_constant('RAILS_ROOT', '/path/to/rails/root') - end - - def ignore(exception_class) - HoptoadNotifier.configuration.ignore << exception_class - end - - def build_controller_class(&definition) - returning Class.new(ActionController::Base) do |klass| - klass.__send__(:include, HoptoadNotifier::Catcher) - klass.class_eval(&definition) if definition - define_constant('HoptoadTestController', klass) - end - end - - def assert_sent_hash(hash, xpath) - hash.each do |key, value| - element_xpath = "#{xpath}/var[@key = '#{key}']" - if value.respond_to?(:to_hash) - assert_sent_hash value.to_hash, element_xpath - else - assert_sent_element value.to_s, element_xpath - end - end - end - - def assert_sent_element(value, xpath) - assert_valid_node last_sent_notice_document, xpath, value - end - - def assert_sent_request_info_for(request) - params = request.parameters.to_hash - assert_sent_hash params, '/notice/request/params' - assert_sent_element params['controller'], '/notice/request/component' - assert_sent_element params['action'], '/notice/request/action' - assert_sent_element url_from_request(request), '/notice/request/url' - assert_sent_hash request.env, '/notice/request/cgi-data' - end - - def url_from_request(request) - url = "#{request.protocol}#{request.host}" - - unless [80, 443].include?(request.port) - url << ":#{request.port}" - end - - url << request.request_uri - url - end - - def sender - HoptoadNotifier.sender - end - - def last_sent_notice_xml - sender.collected.last - end - - def last_sent_notice_document - assert_not_nil xml = last_sent_notice_xml, "No xml was sent" - Nokogiri::XML.parse(xml) - end - - def process_action(opts = {}, &action) - opts[:request] ||= ActionController::TestRequest.new - opts[:response] ||= ActionController::TestResponse.new - klass = build_controller_class do - cattr_accessor :local - define_method(:index, &action) - def local_request? - local - end - end - if opts[:filters] - klass.filter_parameter_logging *opts[:filters] - end - if opts[:user_agent] - if opts[:request].respond_to?(:user_agent=) - opts[:request].user_agent = opts[:user_agent] - else - opts[:request].env["HTTP_USER_AGENT"] = opts[:user_agent] - end - end - if opts[:port] - opts[:request].port = opts[:port] - end - klass.consider_all_requests_local = opts[:all_local] - klass.local = opts[:local] - controller = klass.new - controller.stubs(:rescue_action_in_public_without_hoptoad) - opts[:request].query_parameters = opts[:request].query_parameters.merge(opts[:params] || {}) - opts[:request].session = ActionController::TestSession.new(opts[:session] || {}) - controller.process(opts[:request], opts[:response]) - controller - end - - def process_action_with_manual_notification(args = {}) - process_action(args) do - notify_hoptoad(:error_message => 'fail') - # Rails will raise a template error if we don't render something - render :nothing => true - end - end - - def process_action_with_automatic_notification(args = {}) - process_action(args) { raise "Hello" } - end - - should "deliver notices from exceptions raised in public requests" do - process_action_with_automatic_notification - assert_caught_and_sent - end - - should "not deliver notices from exceptions in local requests" do - process_action_with_automatic_notification(:local => true) - assert_caught_and_not_sent - end - - should "not deliver notices from exceptions when all requests are local" do - process_action_with_automatic_notification(:all_local => true) - assert_caught_and_not_sent - end - - should "not deliver notices from actions that don't raise" do - controller = process_action { render :text => 'Hello' } - assert_caught_and_not_sent - assert_equal 'Hello', controller.response.body - end - - should "not deliver ignored exceptions raised by actions" do - ignore(RuntimeError) - process_action_with_automatic_notification - assert_caught_and_not_sent - end - - should "deliver ignored exception raised manually" do - ignore(RuntimeError) - process_action_with_manual_notification - assert_caught_and_sent - end - - should "deliver manually sent notices in public requests" do - process_action_with_manual_notification - assert_caught_and_sent - end - - should "not deliver manually sent notices in local requests" do - process_action_with_manual_notification(:local => true) - assert_caught_and_not_sent - end - - should "not deliver manually sent notices when all requests are local" do - process_action_with_manual_notification(:all_local => true) - assert_caught_and_not_sent - end - - should "continue with default behavior after delivering an exception" do - controller = process_action_with_automatic_notification(:public => true) - # TODO: can we test this without stubbing? - assert_received(controller, :rescue_action_in_public_without_hoptoad) - end - - should "not create actions from Hoptoad methods" do - controller = build_controller_class.new - assert_equal [], HoptoadNotifier::Catcher.instance_methods - end - - should "ignore exceptions when user agent is being ignored by regular expression" do - HoptoadNotifier.configuration.ignore_user_agent_only = [/Ignored/] - process_action_with_automatic_notification(:user_agent => 'ShouldBeIgnored') - assert_caught_and_not_sent - end - - should "ignore exceptions when user agent is being ignored by string" do - HoptoadNotifier.configuration.ignore_user_agent_only = ['IgnoredUserAgent'] - process_action_with_automatic_notification(:user_agent => 'IgnoredUserAgent') - assert_caught_and_not_sent - end - - should "not ignore exceptions when user agent is not being ignored" do - HoptoadNotifier.configuration.ignore_user_agent_only = ['IgnoredUserAgent'] - process_action_with_automatic_notification(:user_agent => 'NonIgnoredAgent') - assert_caught_and_sent - end - - should "send session data for manual notifications" do - data = { 'one' => 'two' } - process_action_with_manual_notification(:session => data) - assert_sent_hash data, "/notice/request/session" - end - - should "send session data for automatic notification" do - data = { 'one' => 'two' } - process_action_with_automatic_notification(:session => data) - assert_sent_hash data, "/notice/request/session" - end - - should "send request data for manual notification" do - params = { 'controller' => "hoptoad_test", 'action' => "index" } - controller = process_action_with_manual_notification(:params => params) - assert_sent_request_info_for controller.request - end - - should "send request data for manual notification with non-standard port" do - params = { 'controller' => "hoptoad_test", 'action' => "index" } - controller = process_action_with_manual_notification(:params => params, :port => 81) - assert_sent_request_info_for controller.request - end - - should "send request data for automatic notification" do - params = { 'controller' => "hoptoad_test", 'action' => "index" } - controller = process_action_with_automatic_notification(:params => params) - assert_sent_request_info_for controller.request - end - - should "send request data for automatic notification with non-standard port" do - params = { 'controller' => "hoptoad_test", 'action' => "index" } - controller = process_action_with_automatic_notification(:params => params, :port => 81) - assert_sent_request_info_for controller.request - end - - should "use standard rails logging filters on params and env" do - filtered_params = { "abc" => "123", - "def" => "456", - "ghi" => "[FILTERED]" } - ENV['ghi'] = 'abc' - filtered_env = { 'ghi' => '[FILTERED]' } - filtered_cgi = { 'REQUEST_METHOD' => '[FILTERED]' } - - process_action_with_automatic_notification(:filters => [:ghi, :request_method], - :params => { "abc" => "123", - "def" => "456", - "ghi" => "789" }) - assert_sent_hash filtered_params, '/notice/request/params' - assert_sent_hash filtered_cgi, '/notice/request/cgi-data' - end - - context "for a local error with development lookup enabled" do - setup do - HoptoadNotifier.configuration.development_lookup = true - HoptoadNotifier.stubs(:build_lookup_hash_for).returns({ :awesome => 2 }) - - @controller = process_action_with_automatic_notification(:local => true) - @response = @controller.response - end - - should "append custom CSS and JS to response body for a local error" do - assert_match /text\/css/, @response.body - assert_match /text\/javascript/, @response.body - end - - should "contain host, API key and notice JSON" do - assert_match HoptoadNotifier.configuration.host.to_json, @response.body - assert_match HoptoadNotifier.configuration.api_key.to_json, @response.body - assert_match ({ :awesome => 2 }).to_json, @response.body - end - end - - context "for a local error with development lookup disabled" do - setup do - HoptoadNotifier.configuration.development_lookup = false - - @controller = process_action_with_automatic_notification(:local => true) - @response = @controller.response - end - - should "not append custom CSS and JS to response for a local error" do - assert_no_match /text\/css/, @response.body - assert_no_match /text\/javascript/, @response.body - end - end - - should "call session.to_hash if available" do - hash_data = {:key => :value} - - session = ActionController::TestSession.new - ActionController::TestSession.stubs(:new).returns(session) - session.stubs(:to_hash).returns(hash_data) - - process_action_with_automatic_notification - assert_received(session, :to_hash) - assert_received(session, :data) { |expect| expect.never } - assert_caught_and_sent - end - - should "call session.data if session.to_hash is undefined" do - hash_data = {:key => :value} - - session = ActionController::TestSession.new - ActionController::TestSession.stubs(:new).returns(session) - session.stubs(:data).returns(hash_data) - if session.respond_to?(:to_hash) - class << session - undef to_hash - end - end - - process_action_with_automatic_notification - assert_received(session, :to_hash) { |expect| expect.never } - assert_received(session, :data) { |expect| expect.at_least_once } - assert_caught_and_sent - end - -end diff --git a/vendor/plugins/hoptoad_notifier/test/configuration_test.rb b/vendor/plugins/hoptoad_notifier/test/configuration_test.rb deleted file mode 100644 index 27e87d8..0000000 --- a/vendor/plugins/hoptoad_notifier/test/configuration_test.rb +++ /dev/null @@ -1,199 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class ConfigurationTest < Test::Unit::TestCase - - include DefinesConstants - - should "provide default values" do - assert_config_default :proxy_host, nil - assert_config_default :proxy_port, nil - assert_config_default :proxy_user, nil - assert_config_default :proxy_pass, nil - assert_config_default :project_root, nil - assert_config_default :environment_name, nil - assert_config_default :notifier_version, HoptoadNotifier::VERSION - assert_config_default :notifier_name, 'Hoptoad Notifier' - assert_config_default :notifier_url, 'http://hoptoadapp.com' - assert_config_default :secure, false - assert_config_default :host, 'hoptoadapp.com' - assert_config_default :http_open_timeout, 2 - assert_config_default :http_read_timeout, 5 - assert_config_default :ignore_by_filters, [] - assert_config_default :ignore_user_agent, [] - assert_config_default :params_filters, - HoptoadNotifier::Configuration::DEFAULT_PARAMS_FILTERS - assert_config_default :backtrace_filters, - HoptoadNotifier::Configuration::DEFAULT_BACKTRACE_FILTERS - assert_config_default :ignore, - HoptoadNotifier::Configuration::IGNORE_DEFAULT - assert_config_default :development_lookup, true - end - - should "provide default values for secure connections" do - config = HoptoadNotifier::Configuration.new - config.secure = true - assert_equal 443, config.port - assert_equal 'https', config.protocol - end - - should "provide default values for insecure connections" do - config = HoptoadNotifier::Configuration.new - config.secure = false - assert_equal 80, config.port - assert_equal 'http', config.protocol - end - - should "not cache inferred ports" do - config = HoptoadNotifier::Configuration.new - config.secure = false - config.port - config.secure = true - assert_equal 443, config.port - end - - should "allow values to be overwritten" do - assert_config_overridable :proxy_host - assert_config_overridable :proxy_port - assert_config_overridable :proxy_user - assert_config_overridable :proxy_pass - assert_config_overridable :secure - assert_config_overridable :host - assert_config_overridable :port - assert_config_overridable :http_open_timeout - assert_config_overridable :http_read_timeout - assert_config_overridable :project_root - assert_config_overridable :notifier_version - assert_config_overridable :notifier_name - assert_config_overridable :notifier_url - assert_config_overridable :environment_name - assert_config_overridable :development_lookup - end - - should "have an api key" do - assert_config_overridable :api_key - end - - should "act like a hash" do - config = HoptoadNotifier::Configuration.new - hash = config.to_hash - [:api_key, :backtrace_filters, :development_environments, - :environment_name, :host, :http_open_timeout, - :http_read_timeout, :ignore, :ignore_by_filters, :ignore_user_agent, - :notifier_name, :notifier_url, :notifier_version, :params_filters, - :project_root, :port, :protocol, :proxy_host, :proxy_pass, :proxy_port, - :proxy_user, :secure, :development_lookup].each do |option| - assert_equal config[option], hash[option], "Wrong value for #{option}" - end - end - - should "be mergable" do - config = HoptoadNotifier::Configuration.new - hash = config.to_hash - assert_equal hash.merge(:key => 'value'), config.merge(:key => 'value') - end - - should "allow param filters to be appended" do - assert_appends_value :params_filters - end - - should "warn when attempting to read environment filters" do - config = HoptoadNotifier::Configuration.new - config. - expects(:warn). - with(regexp_matches(/deprecated/i)) - assert_equal [], config.environment_filters - end - - should "allow ignored user agents to be appended" do - assert_appends_value :ignore_user_agent - end - - should "allow backtrace filters to be appended" do - assert_appends_value(:backtrace_filters) do |config| - new_filter = lambda {} - config.filter_backtrace(&new_filter) - new_filter - end - end - - should "allow ignore by filters to be appended" do - assert_appends_value(:ignore_by_filters) do |config| - new_filter = lambda {} - config.ignore_by_filter(&new_filter) - new_filter - end - end - - should "allow ignored exceptions to be appended" do - config = HoptoadNotifier::Configuration.new - original_filters = config.ignore.dup - new_filter = 'hello' - config.ignore << new_filter - assert_same_elements original_filters + [new_filter], config.ignore - end - - should "allow ignored exceptions to be replaced" do - assert_replaces(:ignore, :ignore_only=) - end - - should "allow ignored user agents to be replaced" do - assert_replaces(:ignore_user_agent, :ignore_user_agent_only=) - end - - should "use development and test as development environments by default" do - config = HoptoadNotifier::Configuration.new - assert_same_elements %w(development test cucumber), config.development_environments - end - - should "be public in a public environment" do - config = HoptoadNotifier::Configuration.new - config.development_environments = %w(development) - config.environment_name = 'production' - assert config.public? - end - - should "not be public in a development environment" do - config = HoptoadNotifier::Configuration.new - config.development_environments = %w(staging) - config.environment_name = 'staging' - assert !config.public? - end - - should "be public without an environment name" do - config = HoptoadNotifier::Configuration.new - assert config.public? - end - - def assert_config_default(option, default_value, config = nil) - config ||= HoptoadNotifier::Configuration.new - assert_equal default_value, config.send(option) - end - - def assert_config_overridable(option, value = 'a value') - config = HoptoadNotifier::Configuration.new - config.send(:"#{option}=", value) - assert_equal value, config.send(option) - end - - def assert_appends_value(option, &block) - config = HoptoadNotifier::Configuration.new - original_values = config.send(option).dup - block ||= lambda do |config| - new_value = 'hello' - config.send(option) << new_value - new_value - end - new_value = block.call(config) - assert_same_elements original_values + [new_value], config.send(option) - end - - def assert_replaces(option, setter) - config = HoptoadNotifier::Configuration.new - new_value = 'hello' - config.send(setter, [new_value]) - assert_equal [new_value], config.send(option) - config.send(setter, new_value) - assert_equal [new_value], config.send(option) - end - -end diff --git a/vendor/plugins/hoptoad_notifier/test/helper.rb b/vendor/plugins/hoptoad_notifier/test/helper.rb deleted file mode 100644 index 02dd994..0000000 --- a/vendor/plugins/hoptoad_notifier/test/helper.rb +++ /dev/null @@ -1,238 +0,0 @@ -require 'test/unit' -require 'rubygems' - -gem 'jferris-mocha', '0.9.5.0.1241126838' - -require 'shoulda' -require 'mocha' - -$LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. vendor ginger lib]) -require 'ginger' - -require 'action_controller' -require 'action_controller/test_process' -require 'active_record' -require 'active_record/base' -require 'active_support' -require 'nokogiri' - -require File.join(File.dirname(__FILE__), "..", "lib", "hoptoad_notifier") - -begin require 'redgreen'; rescue LoadError; end - -module TestMethods - def rescue_action e - raise e - end - - def do_raise - raise "Hoptoad" - end - - def do_not_raise - render :text => "Success" - end - - def do_raise_ignored - raise ActiveRecord::RecordNotFound.new("404") - end - - def do_raise_not_ignored - raise ActiveRecord::StatementInvalid.new("Statement invalid") - end - - def manual_notify - notify_hoptoad(Exception.new) - render :text => "Success" - end - - def manual_notify_ignored - notify_hoptoad(ActiveRecord::RecordNotFound.new("404")) - render :text => "Success" - end -end - -class HoptoadController < ActionController::Base - include TestMethods -end - -class Test::Unit::TestCase - def request(action = nil, method = :get, user_agent = nil, params = {}) - @request = ActionController::TestRequest.new - @request.action = action ? action.to_s : "" - - if user_agent - if @request.respond_to?(:user_agent=) - @request.user_agent = user_agent - else - @request.env["HTTP_USER_AGENT"] = user_agent - end - end - @request.query_parameters = @request.query_parameters.merge(params) - @response = ActionController::TestResponse.new - @controller.process(@request, @response) - end - - # Borrowed from ActiveSupport 2.3.2 - def assert_difference(expression, difference = 1, message = nil, &block) - b = block.send(:binding) - exps = Array.wrap(expression) - before = exps.map { |e| eval(e, b) } - - yield - - exps.each_with_index do |e, i| - error = "#{e.inspect} didn't change by #{difference}" - error = "#{message}.\n#{error}" if message - assert_equal(before[i] + difference, eval(e, b), error) - end - end - - def assert_no_difference(expression, message = nil, &block) - assert_difference expression, 0, message, &block - end - - def stub_sender - stub('sender', :send_to_hoptoad => nil) - end - - def stub_sender! - HoptoadNotifier.sender = stub_sender - end - - def stub_notice - stub('notice', :to_xml => 'some yaml', :ignore? => false) - end - - def stub_notice! - returning stub_notice do |notice| - HoptoadNotifier::Notice.stubs(:new => notice) - end - end - - def create_dummy - HoptoadNotifier::DummySender.new - end - - def reset_config - HoptoadNotifier.configuration = nil - HoptoadNotifier.configure do |config| - config.api_key = 'abc123' - end - end - - def clear_backtrace_filters - HoptoadNotifier.configuration.backtrace_filters.clear - end - - def build_exception - raise - rescue => caught_exception - caught_exception - end - - def build_notice_data(exception = nil) - exception ||= build_exception - { - :api_key => 'abc123', - :error_class => exception.class.name, - :error_message => "#{exception.class.name}: #{exception.message}", - :backtrace => exception.backtrace, - :environment => { 'PATH' => '/bin', 'REQUEST_URI' => '/users/1' }, - :request => { - :params => { 'controller' => 'users', 'action' => 'show', 'id' => '1' }, - :rails_root => '/path/to/application', - :url => "http://test.host/users/1" - }, - :session => { - :key => '123abc', - :data => { 'user_id' => '5', 'flash' => { 'notice' => 'Logged in successfully' } } - } - } - end - - def assert_caught_and_sent - assert !HoptoadNotifier.sender.collected.empty? - end - - def assert_caught_and_not_sent - assert HoptoadNotifier.sender.collected.empty? - end - - def assert_array_starts_with(expected, actual) - assert_respond_to actual, :to_ary - array = actual.to_ary.reverse - expected.reverse.each_with_index do |value, i| - assert_equal value, array[i] - end - end - - def assert_valid_node(document, xpath, content) - nodes = document.xpath(xpath) - assert nodes.any?{|node| node.content == content }, - "Expected xpath #{xpath} to have content #{content}, " + - "but found #{nodes.map { |n| n.content }} in #{nodes.size} matching nodes." + - "Document:\n#{document.to_s}" - end -end - -module DefinesConstants - def setup - @defined_constants = [] - end - - def teardown - @defined_constants.each do |constant| - Object.__send__(:remove_const, constant) - end - end - - def define_constant(name, value) - Object.const_set(name, value) - @defined_constants << name - end -end - -# Also stolen from AS 2.3.2 -class Array - # Wraps the object in an Array unless it's an Array. Converts the - # object to an Array using #to_ary if it implements that. - def self.wrap(object) - case object - when nil - [] - when self - object - else - if object.respond_to?(:to_ary) - object.to_ary - else - [object] - end - end - end - -end - -class CollectingSender - attr_reader :collected - - def initialize - @collected = [] - end - - def send_to_hoptoad(data) - @collected << data - end -end - -class FakeLogger - def info(*args); end - def debug(*args); end - def warn(*args); end - def error(*args); end - def fatal(*args); end -end - -RAILS_DEFAULT_LOGGER = FakeLogger.new - diff --git a/vendor/plugins/hoptoad_notifier/test/hoptoad_2_0.xsd b/vendor/plugins/hoptoad_notifier/test/hoptoad_2_0.xsd deleted file mode 100644 index ed92103..0000000 --- a/vendor/plugins/hoptoad_notifier/test/hoptoad_2_0.xsd +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb b/vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb deleted file mode 100644 index 7d1290d..0000000 --- a/vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb +++ /dev/null @@ -1,138 +0,0 @@ -require File.dirname(__FILE__) + '/helper' -require 'rubygems' - -require File.dirname(__FILE__) + '/../lib/hoptoad_tasks' -require 'fakeweb' - -FakeWeb.allow_net_connect = false - -class HoptoadTasksTest < Test::Unit::TestCase - def successful_response(body = "") - response = Net::HTTPSuccess.new('1.2', '200', 'OK') - response.stubs(:body).returns(body) - return response - end - - def unsuccessful_response(body = "") - response = Net::HTTPClientError.new('1.2', '200', 'OK') - response.stubs(:body).returns(body) - return response - end - - context "being quiet" do - setup { HoptoadTasks.stubs(:puts) } - - context "in a configured project" do - setup { HoptoadNotifier.configure { |config| config.api_key = "1234123412341234" } } - - context "on deploy({})" do - setup { @output = HoptoadTasks.deploy({}) } - - before_should "complain about missing rails env" do - HoptoadTasks.expects(:puts).with(regexp_matches(/rails environment/i)) - end - - should "return false" do - assert !@output - end - end - - context "given valid options" do - setup { @options = {:rails_env => "staging"} } - - context "on deploy(options)" do - setup { @output = HoptoadTasks.deploy(@options) } - - before_should "post to http://hoptoadapp.com/deploys.txt" do - URI.stubs(:parse).with('http://hoptoadapp.com/deploys.txt').returns(:uri) - Net::HTTP.expects(:post_form).with(:uri, kind_of(Hash)).returns(successful_response) - end - - before_should "use the project api key" do - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries('api_key' => "1234123412341234")). - returns(successful_response) - end - - before_should "use send the rails_env param" do - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries("deploy[rails_env]" => "staging")). - returns(successful_response) - end - - [:local_username, :scm_repository, :scm_revision].each do |key| - before_should "use send the #{key} param if it's passed in." do - @options[key] = "value" - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries("deploy[#{key}]" => "value")). - returns(successful_response) - end - end - - before_should "use the :api_key param if it's passed in." do - @options[:api_key] = "value" - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries("api_key" => "value")). - returns(successful_response) - end - - before_should "puts the response body on success" do - HoptoadTasks.expects(:puts).with("body") - Net::HTTP.expects(:post_form).with(any_parameters).returns(successful_response('body')) - end - - before_should "puts the response body on failure" do - HoptoadTasks.expects(:puts).with("body") - Net::HTTP.expects(:post_form).with(any_parameters).returns(unsuccessful_response('body')) - end - - should "return false on failure", :before => lambda { - Net::HTTP.expects(:post_form).with(any_parameters).returns(unsuccessful_response('body')) - } do - assert !@output - end - - should "return true on success", :before => lambda { - Net::HTTP.expects(:post_form).with(any_parameters).returns(successful_response('body')) - } do - assert @output - end - end - end - end - - context "in a configured project with custom host" do - setup do - HoptoadNotifier.configure do |config| - config.api_key = "1234123412341234" - config.host = "custom.host" - end - end - - context "on deploy(:rails_env => 'staging')" do - setup { @output = HoptoadTasks.deploy(:rails_env => "staging") } - - before_should "post to the custom host" do - URI.stubs(:parse).with('http://custom.host/deploys.txt').returns(:uri) - Net::HTTP.expects(:post_form).with(:uri, kind_of(Hash)).returns(successful_response) - end - end - end - - context "when not configured" do - setup { HoptoadNotifier.configure { |config| config.api_key = "" } } - - context "on deploy(:rails_env => 'staging')" do - setup { @output = HoptoadTasks.deploy(:rails_env => "staging") } - - before_should "complain about missing api key" do - HoptoadTasks.expects(:puts).with(regexp_matches(/api key/i)) - end - - should "return false" do - assert !@output - end - end - end - end -end diff --git a/vendor/plugins/hoptoad_notifier/test/logger_test.rb b/vendor/plugins/hoptoad_notifier/test/logger_test.rb deleted file mode 100644 index ed50fd4..0000000 --- a/vendor/plugins/hoptoad_notifier/test/logger_test.rb +++ /dev/null @@ -1,85 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class LoggerTest < Test::Unit::TestCase - def stub_http(response, body = nil) - response.stubs(:body => body) if body - @http = stub(:post => response, - :read_timeout= => nil, - :open_timeout= => nil, - :use_ssl= => nil) - Net::HTTP.stubs(:new).returns(@http) - end - - def send_notice - HoptoadNotifier.sender.send_to_hoptoad('data') - end - - def stub_verbose_log - HoptoadNotifier.stubs(:write_verbose_log) - end - - def assert_logged(expected) - assert_received(HoptoadNotifier, :write_verbose_log) do |expect| - expect.with {|actual| actual =~ expected } - end - end - - def assert_not_logged(expected) - assert_received(HoptoadNotifier, :write_verbose_log) do |expect| - expect.with {|actual| actual =~ expected }.never - end - end - - def configure - HoptoadNotifier.configure { |config| } - end - - should "report that notifier is ready when configured" do - stub_verbose_log - configure - assert_logged /Notifier (.*) ready/ - end - - should "not report that notifier is ready when internally configured" do - stub_verbose_log - HoptoadNotifier.configure(true) { |config | } - assert_not_logged /.*/ - end - - should "print environment info a successful notification without a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPSuccess) - send_notice - assert_logged /Environment Info:/ - assert_not_logged /Response from Hoptoad:/ - end - - should "print environment info on a failed notification without a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPError) - send_notice - assert_logged /Environment Info:/ - assert_not_logged /Response from Hoptoad:/ - end - - should "print environment info and response on a success with a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPSuccess, 'test') - send_notice - assert_logged /Environment Info:/ - assert_logged /Response from Hoptoad:/ - end - - should "print environment info and response on a failure with a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPError, 'test') - send_notice - assert_logged /Environment Info:/ - assert_logged /Response from Hoptoad:/ - end - -end diff --git a/vendor/plugins/hoptoad_notifier/test/notice_test.rb b/vendor/plugins/hoptoad_notifier/test/notice_test.rb deleted file mode 100644 index 59418fd..0000000 --- a/vendor/plugins/hoptoad_notifier/test/notice_test.rb +++ /dev/null @@ -1,363 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class NoticeTest < Test::Unit::TestCase - - include DefinesConstants - - def configure - returning HoptoadNotifier::Configuration.new do |config| - config.api_key = 'abc123def456' - end - end - - def build_notice(args = {}) - configuration = args.delete(:configuration) || configure - HoptoadNotifier::Notice.new(configuration.merge(args)) - end - - def stub_request(attrs = {}) - stub('request', { :parameters => { 'one' => 'two' }, - :protocol => 'http', - :host => 'some.host', - :request_uri => '/some/uri', - :session => { :to_hash => { 'a' => 'b' } }, - :env => { 'three' => 'four' } }.update(attrs)) - end - - should "set the api key" do - api_key = 'key' - notice = build_notice(:api_key => api_key) - assert_equal api_key, notice.api_key - end - - should "accept a project root" do - project_root = '/path/to/project' - notice = build_notice(:project_root => project_root) - assert_equal project_root, notice.project_root - end - - should "accept a component" do - assert_equal 'users_controller', build_notice(:component => 'users_controller').controller - end - - should "alias the component as controller" do - assert_equal 'users_controller', build_notice(:controller => 'users_controller').component - assert_equal 'users_controller', build_notice(:component => 'users_controller').controller - end - - should "accept a action" do - assert_equal 'index', build_notice(:action => 'index').action - end - - should "accept a url" do - url = 'http://some.host/uri' - notice = build_notice(:url => url) - assert_equal url, notice.url - end - - should "accept a backtrace from an exception or hash" do - array = ["user.rb:34:in `crazy'"] - exception = build_exception - exception.set_backtrace array - backtrace = HoptoadNotifier::Backtrace.parse(array) - notice_from_exception = build_notice(:exception => exception) - - - assert_equal notice_from_exception.backtrace, - backtrace, - "backtrace was not correctly set from an exception" - - notice_from_hash = build_notice(:backtrace => array) - assert_equal notice_from_hash.backtrace, - backtrace, - "backtrace was not correctly set from a hash" - end - - should "set the error class from an exception or hash" do - assert_accepts_exception_attribute :error_class do |exception| - exception.class.name - end - end - - should "set the error message from an exception or hash" do - assert_accepts_exception_attribute :error_message do |exception| - "#{exception.class.name}: #{exception.message}" - end - end - - should "accept parameters from a request or hash" do - parameters = { 'one' => 'two' } - notice_from_hash = build_notice(:parameters => parameters) - assert_equal notice_from_hash.parameters, parameters - end - - should "accept session data from a session[:data] hash" do - data = { 'one' => 'two' } - notice = build_notice(:session => { :data => data }) - assert_equal data, notice.session_data - end - - should "accept session data from a session_data hash" do - data = { 'one' => 'two' } - notice = build_notice(:session_data => data) - assert_equal data, notice.session_data - end - - should "accept an environment name" do - assert_equal 'development', build_notice(:environment_name => 'development').environment_name - end - - should "accept CGI data from a hash" do - data = { 'string' => 'value' } - notice = build_notice(:cgi_data => data) - assert_equal data, notice.cgi_data, "should take CGI data from a hash" - end - - should "accept notifier information" do - params = { :notifier_name => 'a name for a notifier', - :notifier_version => '1.0.5', - :notifier_url => 'http://notifiers.r.us/download' } - notice = build_notice(params) - assert_equal params[:notifier_name], notice.notifier_name - assert_equal params[:notifier_version], notice.notifier_version - assert_equal params[:notifier_url], notice.notifier_url - end - - should "set sensible defaults without an exception" do - backtrace = HoptoadNotifier::Backtrace.parse(caller) - notice = build_notice - - assert_equal 'Notification', notice.error_message - assert_array_starts_with backtrace.lines, notice.backtrace.lines - assert_equal({}, notice.parameters) - assert_equal({}, notice.session_data) - end - - should "use the caller as the backtrace for an exception without a backtrace" do - backtrace = HoptoadNotifier::Backtrace.parse(caller) - notice = build_notice(:exception => StandardError.new('error'), :backtrace => nil) - - assert_array_starts_with backtrace.lines, notice.backtrace.lines - end - - should "convert unserializable objects to strings" do - assert_serializes_hash(:parameters) - assert_serializes_hash(:cgi_data) - assert_serializes_hash(:session_data) - end - - should "filter parameters" do - assert_filters_hash(:parameters) - end - - should "filter cgi data" do - assert_filters_hash(:cgi_data) - end - - context "a Notice turned into XML" do - setup do - HoptoadNotifier.configure do |config| - config.api_key = "1234567890" - end - - @exception = build_exception - - @notice = build_notice({ - :notifier_name => 'a name', - :notifier_version => '1.2.3', - :notifier_url => 'http://some.url/path', - :exception => @exception, - :controller => "controller", - :action => "action", - :url => "http://url.com", - :parameters => { "paramskey" => "paramsvalue", - "nestparentkey" => { "nestkey" => "nestvalue" } }, - :session_data => { "sessionkey" => "sessionvalue" }, - :cgi_data => { "cgikey" => "cgivalue" }, - :project_root => "RAILS_ROOT", - :environment_name => "RAILS_ENV" - }) - - @xml = @notice.to_xml - - @document = Nokogiri::XML::Document.parse(@xml) - end - - should "validate against the XML schema" do - assert_valid_notice_document @document - end - - should "serialize a Notice to XML when sent #to_xml" do - assert_valid_node(@document, "//api-key", @notice.api_key) - - assert_valid_node(@document, "//notifier/name", @notice.notifier_name) - assert_valid_node(@document, "//notifier/version", @notice.notifier_version) - assert_valid_node(@document, "//notifier/url", @notice.notifier_url) - - assert_valid_node(@document, "//error/class", @notice.error_class) - assert_valid_node(@document, "//error/message", @notice.error_message) - - assert_valid_node(@document, "//error/backtrace/line/@number", @notice.backtrace.lines.first.number) - assert_valid_node(@document, "//error/backtrace/line/@file", @notice.backtrace.lines.first.file) - assert_valid_node(@document, "//error/backtrace/line/@method", @notice.backtrace.lines.first.method) - - assert_valid_node(@document, "//request/url", @notice.url) - assert_valid_node(@document, "//request/component", @notice.controller) - assert_valid_node(@document, "//request/action", @notice.action) - - assert_valid_node(@document, "//request/params/var/@key", "paramskey") - assert_valid_node(@document, "//request/params/var", "paramsvalue") - assert_valid_node(@document, "//request/params/var/@key", "nestparentkey") - assert_valid_node(@document, "//request/params/var/var/@key", "nestkey") - assert_valid_node(@document, "//request/params/var/var", "nestvalue") - assert_valid_node(@document, "//request/session/var/@key", "sessionkey") - assert_valid_node(@document, "//request/session/var", "sessionvalue") - assert_valid_node(@document, "//request/cgi-data/var/@key", "cgikey") - assert_valid_node(@document, "//request/cgi-data/var", "cgivalue") - - assert_valid_node(@document, "//server-environment/project-root", "RAILS_ROOT") - assert_valid_node(@document, "//server-environment/environment-name", "RAILS_ENV") - end - end - - should "not send empty request data" do - notice = build_notice - assert_nil notice.url - assert_nil notice.controller - assert_nil notice.action - - xml = notice.to_xml - document = Nokogiri::XML.parse(xml) - assert_nil document.at('//request/url') - assert_nil document.at('//request/component') - assert_nil document.at('//request/action') - - assert_valid_notice_document document - end - - %w(url controller action).each do |var| - should "send a request if #{var} is present" do - notice = build_notice(var.to_sym => 'value') - xml = notice.to_xml - document = Nokogiri::XML.parse(xml) - assert_not_nil document.at('//request') - end - end - - %w(parameters cgi_data session_data).each do |var| - should "send a request if #{var} is present" do - notice = build_notice(var.to_sym => { 'key' => 'value' }) - xml = notice.to_xml - document = Nokogiri::XML.parse(xml) - assert_not_nil document.at('//request') - end - end - - should "not ignore an exception not matching ignore filters" do - notice = build_notice(:error_class => 'ArgumentError', - :ignore => ['Argument'], - :ignore_by_filters => [lambda { |notice| false }]) - assert !notice.ignore? - end - - should "ignore an exception with a matching error class" do - notice = build_notice(:error_class => 'ArgumentError', - :ignore => [ArgumentError]) - assert notice.ignore? - end - - should "ignore an exception with a matching error class name" do - notice = build_notice(:error_class => 'ArgumentError', - :ignore => ['ArgumentError']) - assert notice.ignore? - end - - should "ignore an exception with a matching filter" do - filter = lambda {|notice| notice.error_class == 'ArgumentError' } - notice = build_notice(:error_class => 'ArgumentError', - :ignore_by_filters => [filter]) - assert notice.ignore? - end - - should "not raise without an ignore list" do - notice = build_notice(:ignore => nil, :ignore_by_filters => nil) - assert_nothing_raised do - notice.ignore? - end - end - - should "act like a hash" do - notice = build_notice(:error_message => 'some message') - assert_equal notice.error_message, notice[:error_message] - end - - should "return params on notice[:request][:params]" do - params = { 'one' => 'two' } - notice = build_notice(:parameters => params) - assert_equal params, notice[:request][:params] - end - - should "ensure #to_hash is called on objects that support it" do - assert_nothing_raised do - build_notice(:session => { :object => stub(:to_hash => {}) }) - end - end - - def assert_accepts_exception_attribute(attribute, args = {}, &block) - exception = build_exception - block ||= lambda { exception.send(attribute) } - value = block.call(exception) - - notice_from_exception = build_notice(args.merge(:exception => exception)) - - assert_equal notice_from_exception.send(attribute), - value, - "#{attribute} was not correctly set from an exception" - - notice_from_hash = build_notice(args.merge(attribute => value)) - assert_equal notice_from_hash.send(attribute), - value, - "#{attribute} was not correctly set from a hash" - end - - def assert_serializes_hash(attribute) - [File.open(__FILE__), Proc.new { puts "boo!" }, Module.new].each do |object| - hash = { - :strange_object => object, - :sub_hash => { - :sub_object => object - }, - :array => [object] - } - notice = build_notice(attribute => hash) - hash = notice.send(attribute) - assert_equal object.to_s, hash[:strange_object], "objects should be serialized" - assert_kind_of Hash, hash[:sub_hash], "subhashes should be kept" - assert_equal object.to_s, hash[:sub_hash][:sub_object], "subhash members should be serialized" - assert_kind_of Array, hash[:array], "arrays should be kept" - assert_equal object.to_s, hash[:array].first, "array members should be serialized" - end - end - - def assert_valid_notice_document(document) - xsd_path = File.join(File.dirname(__FILE__), "hoptoad_2_0.xsd") - schema = Nokogiri::XML::Schema.new(IO.read(xsd_path)) - errors = schema.validate(document) - assert errors.empty?, errors.collect{|e| e.message }.join - end - - def assert_filters_hash(attribute) - filters = %w(abc def) - original = { 'abc' => "123", 'def' => "456", 'ghi' => "789", 'nested' => { 'abc' => '100' } } - filtered = { 'abc' => "[FILTERED]", - 'def' => "[FILTERED]", - 'ghi' => "789", - 'nested' => { 'abc' => '[FILTERED]' } } - - notice = build_notice(:params_filters => filters, attribute => original) - - assert_equal(filtered, - notice.send(attribute)) - end - -end diff --git a/vendor/plugins/hoptoad_notifier/test/notifier_test.rb b/vendor/plugins/hoptoad_notifier/test/notifier_test.rb deleted file mode 100644 index 399d3ea..0000000 --- a/vendor/plugins/hoptoad_notifier/test/notifier_test.rb +++ /dev/null @@ -1,222 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class NotifierTest < Test::Unit::TestCase - - class OriginalException < Exception - end - - class ContinuedException < Exception - end - - include DefinesConstants - - def setup - super - reset_config - end - - def assert_sent(notice, notice_args) - assert_received(HoptoadNotifier::Notice, :new) {|expect| expect.with(has_entries(notice_args)) } - assert_received(notice, :to_xml) - assert_received(HoptoadNotifier.sender, :send_to_hoptoad) {|expect| expect.with(notice.to_xml) } - end - - def set_public_env - HoptoadNotifier.configure { |config| config.environment_name = 'production' } - end - - def set_development_env - HoptoadNotifier.configure { |config| config.environment_name = 'development' } - end - - should "yield and save a configuration when configuring" do - yielded_configuration = nil - HoptoadNotifier.configure do |config| - yielded_configuration = config - end - - assert_kind_of HoptoadNotifier::Configuration, yielded_configuration - assert_equal yielded_configuration, HoptoadNotifier.configuration - end - - should "not remove existing config options when configuring twice" do - first_config = nil - HoptoadNotifier.configure do |config| - first_config = config - end - HoptoadNotifier.configure do |config| - assert_equal first_config, config - end - end - - should "configure the sender" do - sender = stub_sender - HoptoadNotifier::Sender.stubs(:new => sender) - configuration = nil - - HoptoadNotifier.configure { |yielded_config| configuration = yielded_config } - - assert_received(HoptoadNotifier::Sender, :new) { |expect| expect.with(configuration) } - assert_equal sender, HoptoadNotifier.sender - end - - should "create and send a notice for an exception" do - set_public_env - exception = build_exception - stub_sender! - notice = stub_notice! - - HoptoadNotifier.notify(exception) - - assert_sent notice, :exception => exception - end - - should "create and send a notice for a hash" do - set_public_env - notice = stub_notice! - notice_args = { :error_message => 'uh oh' } - stub_sender! - - HoptoadNotifier.notify(notice_args) - - assert_sent(notice, notice_args) - end - - should "create and sent a notice for an exception and hash" do - set_public_env - exception = build_exception - notice = stub_notice! - notice_args = { :error_message => 'uh oh' } - stub_sender! - - HoptoadNotifier.notify(exception, notice_args) - - assert_sent(notice, notice_args.merge(:exception => exception)) - end - - should "not create a notice in a development environment" do - set_development_env - sender = stub_sender! - - HoptoadNotifier.notify(build_exception) - HoptoadNotifier.notify_or_ignore(build_exception) - - assert_received(sender, :send_to_hoptoad) {|expect| expect.never } - end - - should "not deliver an ignored exception when notifying implicitly" do - set_public_env - exception = build_exception - sender = stub_sender! - notice = stub_notice! - notice.stubs(:ignore? => true) - - HoptoadNotifier.notify_or_ignore(exception) - - assert_received(sender, :send_to_hoptoad) {|expect| expect.never } - end - - should "deliver an ignored exception when notifying manually" do - set_public_env - exception = build_exception - sender = stub_sender! - notice = stub_notice! - notice.stubs(:ignore? => true) - - HoptoadNotifier.notify(exception) - - assert_sent(notice, :exception => exception) - end - - should "pass config to created notices" do - exception = build_exception - config_opts = { 'one' => 'two', 'three' => 'four' } - notice = stub_notice! - stub_sender! - HoptoadNotifier.configuration = stub('config', :merge => config_opts, :public? => true) - - HoptoadNotifier.notify(exception) - - assert_received(HoptoadNotifier::Notice, :new) do |expect| - expect.with(has_entries(config_opts)) - end - end - - context "building notice JSON for an exception" do - setup do - @params = { :controller => "users", :action => "create" } - @exception = build_exception - @hash = HoptoadNotifier.build_lookup_hash_for(@exception, @params) - end - - should "set action" do - assert_equal @params[:action], @hash[:action] - end - - should "set controller" do - assert_equal @params[:controller], @hash[:component] - end - - should "set line number" do - assert @hash[:line_number] =~ /\d+/ - end - - should "set file" do - assert_match /\/test\/helper\.rb$/, @hash[:file] - end - - should "set rails_env to production" do - assert_equal 'production', @hash[:environment_name] - end - - should "set error class" do - assert_equal 'RuntimeError', @hash[:error_class] - end - - should "not set file or line number with no backtrace" do - @exception.stubs(:backtrace).returns([]) - - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - - assert_nil @hash[:line_number] - assert_nil @hash[:file] - end - - should "not set action or controller when not provided" do - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - - assert_nil @hash[:action] - assert_nil @hash[:controller] - end - - context "when an exception that provides #original_exception is raised" do - setup do - @exception.stubs(:original_exception).returns(begin - raise NotifierTest::OriginalException.new - rescue Exception => e - e - end) - end - - should "unwrap exceptions that provide #original_exception" do - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - assert_equal "NotifierTest::OriginalException", @hash[:error_class] - end - end - - context "when an exception that provides #continued_exception is raised" do - setup do - @exception.stubs(:continued_exception).returns(begin - raise NotifierTest::ContinuedException.new - rescue Exception => e - e - end) - end - - should "unwrap exceptions that provide #continued_exception" do - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - assert_equal "NotifierTest::ContinuedException", @hash[:error_class] - end - end - end -end diff --git a/vendor/plugins/hoptoad_notifier/test/sender_test.rb b/vendor/plugins/hoptoad_notifier/test/sender_test.rb deleted file mode 100644 index e0a1a8d..0000000 --- a/vendor/plugins/hoptoad_notifier/test/sender_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class SenderTest < Test::Unit::TestCase - - def setup - reset_config - end - - def build_sender(opts = {}) - config = HoptoadNotifier::Configuration.new - opts.each {|opt, value| config.send(:"#{opt}=", value) } - HoptoadNotifier::Sender.new(config) - end - - def send_exception(args = {}) - notice = args.delete(:notice) || build_notice_data - sender = args.delete(:sender) || build_sender(args) - sender.send_to_hoptoad(notice) - sender - end - - def stub_http - response = stub(:body => 'body') - http = stub(:post => response, - :read_timeout= => nil, - :open_timeout= => nil, - :use_ssl= => nil) - Net::HTTP.stubs(:new => http) - http - end - - should "post to Hoptoad when using an HTTP proxy" do - response = stub(:body => 'body') - http = stub(:post => response, - :read_timeout= => nil, - :open_timeout= => nil, - :use_ssl= => nil) - proxy = stub(:new => http) - Net::HTTP.stubs(:Proxy => proxy) - - url = "http://hoptoadapp.com:80#{HoptoadNotifier::Sender::NOTICES_URI}" - uri = URI.parse(url) - - proxy_host = 'some.host' - proxy_port = 88 - proxy_user = 'login' - proxy_pass = 'passwd' - - send_exception(:proxy_host => proxy_host, - :proxy_port => proxy_port, - :proxy_user => proxy_user, - :proxy_pass => proxy_pass) - assert_received(http, :post) do |expect| - expect.with(uri.path, anything, HoptoadNotifier::HEADERS) - end - assert_received(Net::HTTP, :Proxy) do |expect| - expect.with(proxy_host, proxy_port, proxy_user, proxy_pass) - end - end - - should "post to the right url for non-ssl" do - http = stub_http - url = "http://hoptoadapp.com:80#{HoptoadNotifier::Sender::NOTICES_URI}" - uri = URI.parse(url) - send_exception(:secure => false) - assert_received(http, :post) {|expect| expect.with(uri.path, anything, HoptoadNotifier::HEADERS) } - end - - should "post to the right path for ssl" do - http = stub_http - send_exception(:secure => true) - assert_received(http, :post) {|expect| expect.with(HoptoadNotifier::Sender::NOTICES_URI, anything, HoptoadNotifier::HEADERS) } - end - - should "default the open timeout to 2 seconds" do - http = stub_http - send_exception - assert_received(http, :open_timeout=) {|expect| expect.with(2) } - end - - should "default the read timeout to 5 seconds" do - http = stub_http - send_exception - assert_received(http, :read_timeout=) {|expect| expect.with(5) } - end - - should "allow override of the open timeout" do - http = stub_http - send_exception(:http_open_timeout => 4) - assert_received(http, :open_timeout=) {|expect| expect.with(4) } - end - - should "allow override of the read timeout" do - http = stub_http - send_exception(:http_read_timeout => 10) - assert_received(http, :read_timeout=) {|expect| expect.with(10) } - end - - should "connect to the right port for ssl" do - stub_http - send_exception(:secure => true) - assert_received(Net::HTTP, :new) {|expect| expect.with("hoptoadapp.com", 443) } - end - - should "connect to the right port for non-ssl" do - stub_http - send_exception(:secure => false) - assert_received(Net::HTTP, :new) {|expect| expect.with("hoptoadapp.com", 80) } - end - - should "use ssl if secure" do - stub_http - send_exception(:secure => true, :host => 'example.org') - assert_received(Net::HTTP, :new) {|expect| expect.with('example.org', 443) } - end - - should "not use ssl if not secure" do - stub_http - send_exception(:secure => false, :host => 'example.org') - assert_received(Net::HTTP, :new) {|expect| expect.with('example.org', 80) } - end - -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore b/vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore deleted file mode 100644 index 841ba95..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ginger*.gem \ No newline at end of file diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE b/vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE deleted file mode 100644 index e031e3c..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 Pat Allan - -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. diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile b/vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile deleted file mode 100644 index ca823a5..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile +++ /dev/null @@ -1,50 +0,0 @@ -Ginger is a small gem that allows you to test your projects using multiple versions of gem libraries. The idea is from "Ian White's garlic":http://github.com/ianwhite/garlic/tree - hence the related name of this - but my approach is a bit different, since I don't test my plugins from within a rails application. Maybe they can be merged at some point - I just hacked this up quickly to fit my needs. - -To get it all working, you need to do four things. The first is, of course, to install this gem. - -
sudo gem install freelancing-god-ginger --source=http://gems.github.com
- -Next, add the following line of code to your @spec_helper.rb@ file (or equivalent): - -
require 'ginger'
- -You'll want to put it as high up as possible - in particular, before any @require@ calls to libraries you want to cover multiple versions of. - -Step number three is creating the sets of scenarios in a file called @ginger_scenarios.rb@, which should go in the root, spec or test directory of your project. Here's an example, showing off the syntax possibilities. - -
require 'ginger'
-
-Ginger.configure do |config|
-  config.aliases["active_record"] = "activerecord"
-  
-  ar_1_2_6 = Ginger::Scenario.new
-  ar_1_2_6[/^active_?record$/] = "1.15.6"
-  
-  ar_2_0_2 = Ginger::Scenario.new
-  ar_2_0_2[/^active_?record$/] = "2.0.2"
-  
-  ar_2_1_1 = Ginger::Scenario.new
-  ar_2_1_1[/^active_?record$/] = "2.1.1"
-  
-  config.scenarios << ar_1_2_6 << ar_2_0_2 << ar_2_1_1
-end
- -Above, I've added three different scenarios, for three different versions of ActiveRecord. I also added an alias, as people sometimes use the underscore, and sometimes don't. The gem's name has no underscore though, so the _value_ of the alias matches the gem name (whereas the key would be alternative usage). - -You can have multiple gems set in each scenario - and you don't have to use regular expressions, you can just use straight strings. - -
sphinx_scenario = Ginger::Scenario.new
-sphinx_scenario["riddle"] = "0.9.8"
-sphinx_scenario["thinking_sphinx"] = "0.9.8"
- -Don't forget to add them to @config@'s scenarios collection, else they're not saved anywhere. - -And finally, you'll want to run the tests or specs for each scenario. This is done using the @ginger@ CLI tool, which parrots whatever parameters you give it onto @rake@. So just do something like: - -
ginger spec
-ginger test
-ginger spec:unit
- -h2. Contributors - -* "Adam Meehan":http://duckpunching.com/ diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile b/vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile deleted file mode 100644 index 0721d01..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile +++ /dev/null @@ -1,57 +0,0 @@ -require 'rubygems' -require 'spec' -require 'rake/rdoctask' -require 'spec/rake/spectask' -require 'rake/gempackagetask' - -$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib' - -require 'ginger' - -spec = Gem::Specification.new do |s| - s.name = "ginger" - s.version = Ginger::Version::String - s.summary = "Run specs/tests multiple times through different gem versions." - s.description = "Run specs/tests multiple times through different gem versions." - s.author = "Pat Allan" - s.email = "pat@freelancing-gods.com" - s.homepage = "http://github.com/freelancing_god/ginger/tree" - s.has_rdoc = true - s.rdoc_options << "--title" << "Ginger" << - "--line-numbers" - s.rubyforge_project = "ginger" - s.test_files = FileList["spec/**/*_spec.rb"] - s.files = FileList[ - "lib/**/*.rb", - "LICENCE", - "README.textile" - ] - s.executables = ["ginger"] -end - -Rake::GemPackageTask.new(spec) do |p| - p.gem_spec = spec - p.need_tar = true - p.need_zip = true -end - -desc "Generate ginger.gemspec file" -task :gemspec do - File.open('ginger.gemspec', 'w') { |f| - f.write spec.to_ruby - } -end - -desc "Run the specs under spec" -Spec::Rake::SpecTask.new do |t| - t.spec_files = FileList['spec/**/*_spec.rb'] - t.spec_opts << "-c" -end - -desc "Generate RCov reports" -Spec::Rake::SpecTask.new(:rcov) do |t| - t.libs << 'lib' - t.spec_files = FileList['spec/**/*_spec.rb'] - t.rcov = true - t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems'] -end \ No newline at end of file diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger b/vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger deleted file mode 100644 index 42d7267..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env ruby - -require 'rubygems' -require 'ginger' -require 'rake' - -if ARGV.length == 0 - puts <<-USAGE -ginger #{Ginger::Version::String} -Use ginger to run specs for each scenario defined. Scenarios must be set out in -a file called ginger_scenarios.rb wherever this tool is run. Once they're -defined, then you can run this tool and provide the rake task that would -normally be called. - -Examples: - ginger spec - ginger test - ginger spec:models -USAGE - exit 0 -end - -file_path = File.join Dir.pwd, ".ginger" - -File.delete(file_path) if File.exists?(file_path) - -scenarios = Ginger::Configuration.instance.scenarios -puts "No Ginger Scenarios defined" if scenarios.empty? - -scenarios.each_with_index do |scenario, index| - puts <<-SCENARIO - -------------------- -Ginger Scenario #{index+1} -------------------- - SCENARIO - - File.open('.ginger', 'w') { |f| f.write index.to_s } - system("rake #{ARGV.join(" ")}") -end - -File.delete(file_path) if File.exists?(file_path) diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec b/vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec deleted file mode 100644 index a08c78b..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec +++ /dev/null @@ -1,33 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{ginger} - s.version = "1.0.0" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Pat Allan"] - s.date = %q{2008-10-11} - s.default_executable = %q{ginger} - s.description = %q{Run specs/tests multiple times through different gem versions.} - s.email = %q{pat@freelancing-gods.com} - s.executables = ["ginger"] - s.files = ["lib/ginger/configuration.rb", "lib/ginger/kernel.rb", "lib/ginger/scenario.rb", "lib/ginger.rb", "LICENCE", "README.textile", "spec/ginger/configuration_spec.rb", "spec/ginger/kernel_spec.rb", "spec/ginger/scenario_spec.rb", "spec/ginger_spec.rb", "bin/ginger"] - s.has_rdoc = true - s.homepage = %q{http://github.com/freelancing_god/ginger/tree} - s.rdoc_options = ["--title", "Ginger", "--line-numbers"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{ginger} - s.rubygems_version = %q{1.3.0} - s.summary = %q{Run specs/tests multiple times through different gem versions.} - s.test_files = ["spec/ginger/configuration_spec.rb", "spec/ginger/kernel_spec.rb", "spec/ginger/scenario_spec.rb", "spec/ginger_spec.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - else - end - else - end -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb deleted file mode 100644 index f6b1aba..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'ginger/configuration' -require 'ginger/scenario' -require 'ginger/kernel' - -module Ginger - module Version - Major = 1 - Minor = 0 - Tiny = 0 - - String = [Major, Minor, Tiny].join('.') - end - - def self.configure(&block) - yield Ginger::Configuration.instance - end -end - -Kernel.send(:include, Ginger::Kernel) - -Ginger::Configuration.detect_scenario_file \ No newline at end of file diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb deleted file mode 100644 index 75c103d..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'singleton' - -module Ginger - class Configuration - include Singleton - - attr_accessor :scenarios, :aliases - - def initialize - @scenarios = [] - @aliases = {} - end - - def self.detect_scenario_file - ['.','spec','test'].each do |path| - require "#{path}/ginger_scenarios" and break if File.exists?("#{path}/ginger_scenarios.rb") - end - end - end -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb deleted file mode 100644 index 0d6b99c..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb +++ /dev/null @@ -1,56 +0,0 @@ -module Ginger - module Kernel - def self.included(base) - base.class_eval do - def require_with_ginger(req) - unless scenario = ginger_scenario - require_without_ginger(req) - return - end - - if scenario.version(req) - gem ginger_gem_name(req) - end - - require_without_ginger(req) - end - - alias_method :require_without_ginger, :require - alias_method :require, :require_with_ginger - - def gem_with_ginger(gem_name, *version_requirements) - unless scenario = ginger_scenario - gem_without_ginger(gem_name, *version_requirements) - return - end - - if version_requirements.length == 0 && - version = scenario.version(gem_name) - version_requirements << "= #{version}" - end - - gem_without_ginger(gem_name, *version_requirements) - end - - alias_method :gem_without_ginger, :gem - alias_method :gem, :gem_with_ginger - - private - - def ginger_scenario - return nil unless File.exists?(".ginger") - - scenario = nil - File.open('.ginger') { |f| scenario = f.read } - return nil unless scenario - - Ginger::Configuration.instance.scenarios[scenario.to_i] - end - - def ginger_gem_name(gem_name) - Ginger::Configuration.instance.aliases[gem_name] || gem_name - end - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb deleted file mode 100644 index fb36d69..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Ginger - class Scenario < Hash - def add(gem, version) - self[gem] = version - end - - def version(gem) - self.keys.each do |key| - case key - when String - return self[key] if gem == key - when Regexp - return self[key] if gem =~ key - end - end - - return nil - end - - def gems - self.keys - end - end -end \ No newline at end of file diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb deleted file mode 100644 index 80d3dde..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' - -describe Ginger::Configuration do - it "should be a singleton class" do - Ginger::Configuration.should respond_to(:instance) - end -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb deleted file mode 100644 index dcc8c30..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' - -describe "Ginger::Kernel" do - it "should description" do - # - end -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb deleted file mode 100644 index 997254d..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' - -describe Ginger::Scenario do - it "should allow for multiple gem/version pairs" do - scenario = Ginger::Scenario.new - scenario.add "thinking_sphinx", "1.0" - scenario.add "riddle", "0.9.8" - - scenario.gems.should include("thinking_sphinx") - scenario.gems.should include("riddle") - end - - it "should be able to be used as a hash" do - scenario = Ginger::Scenario.new - scenario["thinking_sphinx"] = "1.0" - scenario["riddle"] = "0.9.8" - - scenario.gems.should include("thinking_sphinx") - scenario.gems.should include("riddle") - end - - it "should allow gem names to be regular expressions" do - scenario = Ginger::Scenario.new - scenario.add /^active_?record$/, "2.1.0" - - scenario.gems.first.should be_kind_of(Regexp) - end - - it "should return the appropriate version for a given gem" do - scenario = Ginger::Scenario.new - scenario.add "riddle", "0.9.8" - - scenario.version("riddle").should == "0.9.8" - end - - it "should use regular expressions to figure out matching version" do - scenario = Ginger::Scenario.new - scenario[/^active_?record$/] = "2.1.0" - - scenario.version("activerecord").should == "2.1.0" - scenario.version("active_record").should == "2.1.0" - end - - it "should return nil if no matching gem" do - scenario = Ginger::Scenario.new - scenario.add "riddle", "0.9.8" - - scenario.version("thinking_sphinx").should be_nil - end -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb deleted file mode 100644 index abd9f20..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require File.dirname(__FILE__) + '/spec_helper' - -describe "Ginger" do - it "should add scenarios to the Configuration instance" do - Ginger.configure do |config| - scenario = Ginger::Scenario.new - scenario["riddle"] = "0.9.8" - - config.scenarios << scenario - end - - Ginger::Configuration.instance.scenarios.length.should == 1 - end -end diff --git a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb b/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb deleted file mode 100644 index 28b1c5d..0000000 --- a/vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' - -require 'ginger' - -Spec::Runner.configure do |config| - # ... -end \ No newline at end of file -- libgit2 0.21.2