Skip to content

Instantly share code, notes, and snippets.

module KnapsackRSpecConfigurationPatch
def before(scope = nil, *, &block)
return super unless scope == :suite
puts("Registering #before(:suite): #{caller.first}")
KnapsackRSpecConfigurationPatch.knapsack_before_suite_hooks << block
end
def prepend_before(scope = nil, *, &block)
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '~> 5.1.2' #github: 'rails/rails'
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.0.2'
require 'docker'
Docker.url = ENV['DOCKER_HOST'] if ENV['DOCKER_HOST']
# Manages a Kafka + Zookeeper cluster for tests via Docker.
# This will expose the Kafka server on port 9093 to avoid conflicts
# with port 9092.
class KafkaTestCluster
# We should switch this to confluent/kafka when they release a 0.9.0.1 image
KAFKA_IMAGE = 'ches/kafka:0.9.0.1'.freeze
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '4.2.4'
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '4.2.4'
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '4.2.4'
-- Orgs with no logins in 90 days
select organizations.id,
organizations.name,
to_char(max(security_users.last_sign_in_at), 'MM/DD/YYYY') last_sign_at,
to_char(organizations.created_at, 'MM/DD/YYYY') created_at,
count(*) num_users
from organizations left outer join security_users on (organizations.id = security_users.organization_id)
where organizations.created_at < now() - interval '90 days' and organizations.disabled = false
group by organizations.id, organizations.name
having max(security_users.last_sign_in_at) is null or age(now(), max(security_users.last_sign_in_at)) > interval '90 days'
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.1.14.2' # '4.0.13' # '4.2.5.2' '4.1.14.2'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end