Skip to content

Instantly share code, notes, and snippets.

View vkurennov's full-sized avatar

Vitaly Kurennov vkurennov

View GitHub Profile
# frozen_string_literal: true
require 'rails_helper'
RSpec.configure do |config|
config.use_transactional_fixtures = false
# DatabaseCleaner settings
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
require 'rails_helper'
RSpec.configure do |config|
config.use_transactional_fixtures = false
# DatabaseCleaner settings
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
# Ensure sphinx directories exist for the test environment
ThinkingSphinx::Test.init
### Nginx ###
check process nginx with pidfile /run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 188.166.44.84 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
puts 'Hello, world!"
shared_examples_for "API Authenticable" do
context "unauthorized" do
it 'returns 401 status if request has not access token' do
do_request(method, api_path)
expect(response.status).to eq 401
end
it 'returns 401 status if access token is invalid' do
do_request(method, api_path, access_token: '1234')
expect(response.status).to eq 401
module ControllerHelpers
def login(user)
@request.env['devise.mapping'] = Devise.mappings[:user]
sign_in user
end
end
FactoryGirl.define do
factory :answer do
question
content "yText"
end
factory :illegal_answer, class: "Answer" do
content nil
question_id 'potato'
#deb cdrom:[Ubuntu 14.04.2 LTS _Trusty Tahr_ - Release amd64 (20150218.1)]/ trusty main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
@vkurennov
vkurennov / production.rb
Last active February 23, 2024 08:12
Пример конфига unicorn
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "#{app_path}/shared/tmp/sockets/unicorn.qna.sock", backlog: 64
# logging
stderr_path "log/unicorn.stderr.log"
@vkurennov
vkurennov / monit.rc
Last active February 23, 2024 08:12
Пример конфига для запуска процессов через monit
### Nginx ###
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout