2016-08-04 22:18:42 +02:00
|
|
|
$agent = Mechanize.new
|
2016-05-05 04:25:01 +02:00
|
|
|
|
2016-07-27 05:44:07 +02:00
|
|
|
def request(path, data = {})
|
2016-08-04 06:37:23 +02:00
|
|
|
uri = 'http://localhost:8080' + path
|
2016-08-04 22:18:42 +02:00
|
|
|
response = $agent.post(uri, data)
|
2016-05-05 04:25:01 +02:00
|
|
|
|
|
|
|
return JSON.parse(response.body)
|
|
|
|
end
|
|
|
|
|
2016-05-11 03:35:36 +02:00
|
|
|
class Database
|
|
|
|
def initialize()
|
2016-07-27 05:44:07 +02:00
|
|
|
mysqlUser = ENV['MYSQL_USER'] || 'root'
|
|
|
|
mysqlPass = ENV['MYSQL_PASSWORD'] || ''
|
2016-05-11 03:35:36 +02:00
|
|
|
@connection = Mysql.new('localhost', mysqlUser , mysqlPass, 'development')
|
|
|
|
end
|
2016-05-05 04:25:01 +02:00
|
|
|
|
2016-05-11 03:35:36 +02:00
|
|
|
def close()
|
|
|
|
@connection.close
|
|
|
|
end
|
2016-05-05 04:25:01 +02:00
|
|
|
|
2016-05-11 03:35:36 +02:00
|
|
|
def getRow(table, value, field = 'id')
|
|
|
|
queryResponse = @connection.query("select * from #{table} where #{field}='#{value.to_s}'")
|
|
|
|
|
|
|
|
return queryResponse.fetch_hash
|
|
|
|
end
|
2016-05-05 04:25:01 +02:00
|
|
|
end
|
2016-05-11 03:35:36 +02:00
|
|
|
|
|
|
|
$database = Database.new
|
2016-09-25 06:16:10 +02:00
|
|
|
|
|
|
|
$staff = {
|
|
|
|
:email => 'staff@opensupports.com',
|
|
|
|
:password => 'staff'
|
|
|
|
}
|