Skip to content

Instantly share code, notes, and snippets.

@jbpros
Created May 18, 2012 11:12
Show Gist options
  • Select an option

  • Save jbpros/2724720 to your computer and use it in GitHub Desktop.

Select an option

Save jbpros/2724720 to your computer and use it in GitHub Desktop.
class World
# ...
commandRemote: (commandName, data, callback) ->
postData = querystring.stringify payload
options =
host: @host,
port: @port,
path: "#{@path}/#{commandName}",
method: 'PUT'
headers:
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length
req = http.request options, (res) =>
throw new Error('Failed to execute remote command') if res.statusCode == 500
responseData = ""
res.on 'data', (data) ->
responseData += data
res.on 'end', ->
result = JSON.parse responseData
callback result
req.end postData
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
class BackdoorsController < ApplicationController
skip_before_filter :verify_authenticity_token
def get_user_attributes_from_id
user = User.find params[:user_id]
render :json => user.attributes.to_json
end
def reset_all
DatabaseCleaner.clean
render :json => nil
end
def stub_provider_response
provider = params[:provider]
response = JSON.parse params[:response]
OmniAuth.config.add_mock :twitter, response
render :json => nil
end
end
YourApp::Application.routes.draw do
# ...
if Rails.env == 'cucumber'
match '/__backdoors__/:action', :controller => 'backdoors'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment