Created
January 24, 2011 14:35
-
-
Save thilo/793294 to your computer and use it in GitHub Desktop.
implementation of dev interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## steps | |
Before do | |
Client::Config.backend_uri.values.each do |uri| | |
begin | |
HTTParty.post("#{uri}dev/purge_db", :body => {}) | |
rescue Errno::ECONNREFUSED | |
p "could not reach #{uri}" | |
end | |
end | |
end | |
## controller | |
if Rails.env.test? | |
require 'database_cleaner' | |
class DevController < ActionController::Base | |
def purge_db | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.clean | |
render :nothing => true | |
end | |
end | |
end | |
## routes | |
match '/dev(/:action)', :controller => 'dev', :via => :post if Rails.env.test? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment