source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/consumer/throttled_consumer_strategy.rb | Ruby | mit | 19 | master | 4,689 | module Chore
module Strategy
class ThrottledConsumerStrategy #:nodoc:
def initialize(fetcher)
@fetcher = fetcher
@queue = SizedQueue.new(Chore.config.num_workers)
@return_queue = Queue.new
@max_queue_size = Chore.config.num_workers
@consumers_per_queue = Chore.config.... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/forked_worker_strategy.rb | Ruby | mit | 19 | master | 7,503 | require 'chore/signal'
module Chore
module Strategy
class ForkedWorkerStrategy #:nodoc:
include Util
attr_accessor :workers
def initialize(manager, opts={})
@options = opts
@manager = manager
@stopped = false
@workers = {}
@queue = Queue.new
Chor... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/preforked_worker_strategy.rb | Ruby | mit | 19 | master | 4,955 | require 'chore/signal'
require 'socket'
require 'chore/strategies/worker/helpers/ipc'
require 'chore/strategies/worker/helpers/preforked_worker'
require 'chore/strategies/worker/helpers/worker_manager'
require 'chore/strategies/worker/helpers/work_distributor'
module Chore
module Strategy
class PreForkedWorkerSt... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/single_worker_strategy.rb | Ruby | mit | 19 | master | 1,826 | module Chore
module Strategy
# Worker strategy for performing batches of work in a linear fashion. Ideally used for running
# Chore jobs locally in a development environment where performance or throughput may not matter.
class SingleWorkerStrategy
attr_reader :worker
def initialize(man... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/helpers/worker_info.rb | Ruby | mit | 19 | master | 258 | module Chore
module Strategy
class WorkerInfo
# Holds meta information about the worker: pid, and connection socket
attr_accessor :pid, :socket
def initialize(pid)
@pid = pid
@socket = nil
end
end
end
end |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/helpers/worker_manager.rb | Ruby | mit | 19 | master | 5,813 | require 'chore/strategies/worker/helpers/ipc'
module Chore
module Strategy
class WorkerManager #:nodoc:
include Ipc
def initialize(master_socket)
@master_socket = master_socket
@pid_to_worker = {}
@socket_to_worker = {}
end
# Create num of missing workers and soc... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/helpers/preforked_worker.rb | Ruby | mit | 19 | master | 5,210 | require 'chore/signal'
require 'socket'
require 'timeout'
require 'chore/strategies/worker/helpers/ipc'
module Chore
module Strategy
class PreforkedWorker #:nodoc:
include Util
include Ipc
def initialize(_opts = {})
Chore.logger.info "PFW: #{Process.pid} initializing"
@manager_... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/helpers/worker_killer.rb | Ruby | mit | 19 | master | 1,205 | require 'get_process_mem'
module Chore
module Strategy
class WorkerKiller #:nodoc:
def initialize
@memory_limit = Chore.config.memory_limit_bytes
@request_limit = Chore.config.request_limit
@check_cycle = Chore.config.worker_check_cycle || 16
@check_count = 0
@curre... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/helpers/ipc.rb | Ruby | mit | 19 | master | 2,266 | require 'socket'
module Chore
module Strategy
module Ipc #:nodoc:
BIG_ENDIAN = 'L>'.freeze
MSG_BYTES = 4
READY_MSG = 'R'
def create_master_socket
File.delete socket_file if File.exist? socket_file
UNIXServer.new(socket_file).tap do |socket|
socket_options(socket... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/strategies/worker/helpers/work_distributor.rb | Ruby | mit | 19 | master | 2,201 | require 'chore/strategies/worker/helpers/ipc'
module Chore
module Strategy
class WorkDistributor #:nodoc:
class << self
include Ipc
def fetch_and_assign_jobs(workers, manager)
jobs = manager.fetch_work(workers.size)
raise "DW: jobs needs to be a list got #{jobs.class}" ... |
github | Tapjoy/chore | https://github.com/Tapjoy/chore | lib/chore/encoders/json_encoder.rb | Ruby | mit | 19 | master | 490 | require 'multi_json'
module Chore
module Encoder
# Json encoding for serializing jobs.
module JsonEncoder
class << self
# Encodes the +job+ into JSON using the standard ruby JSON parsing library
def encode(job)
MultiJson.dump(job.to_hash)
end
# Decodes the +j... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | Gemfile | Ruby | mit | 19 | develop | 3,377 | source 'https://rubygems.org'
ruby '3.2.2'
# Flexible authentication solution for Rails with Warden
# https://github.com/heartcombo/devise
gem 'devise', '>= 4.6.0'
# A comprehensive slugging and pretty-URL plugin.
# https://github.com/norman/friendly_id
gem 'friendly_id', '~> 5.4.2'
# Refer to any model with a URI: g... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | perf.rake | Ruby | mit | 19 | develop | 966 | class MyCustomAuth < DerailedBenchmarks::AuthHelper
attr_writer :user
# Include devise test helpers and turn on test mode
# We need to do this on the class level
def setup
# self.class.instance_eval do
require 'devise'
require 'warden'
extend ::Warden::Test::Helpers
extend ::Devise::TestHel... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config.ru | Ruby | mit | 19 | develop | 423 | # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'rack'
require 'rack/cache'
require 'redis-rack-cache'
use Rack::Deflater
# use Rack::Cache,
# metastore: (ENV["REDIS_URL"] || 'redis://127.0.0.1:6379') + '/1/metastore',
#... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/puma.rb | Ruby | mit | 19 | develop | 459 | workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcen... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/application.rb | Ruby | mit | 19 | develop | 2,249 | require File.expand_path('../boot', __FILE__)
require 'uri'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Archivist
class Application < Rails::Application
# Settings in config/environmen... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/routes.rb | Ruby | mit | 19 | develop | 6,366 | require "sidekiq/web"
Rails.application.routes.draw do
mount ActionCable.server => '/cable'
post 'setup', to: 'main#setup'
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_U... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/sidekiq.rb | Ruby | mit | 19 | develop | 395 | Sidekiq.configure_server do |config|
config.redis = {url: ENV.fetch("REDIS_URL", "redis://localhost"), namespace: "archivist:sidekiq", ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }}
end
Sidekiq.configure_client do |config|
config.redis = {url: ENV.fetch("REDIS_URL", "redis://localhost"), namespace: "archi... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/timeout.rb | Ruby | mit | 19 | develop | 221 | if ENV["RACK_TIMEOUT_SERVICE_TIMEOUT"]
rack_timeout_service_timeout = ENV["RACK_TIMEOUT_SERVICE_TIMEOUT"].to_i
else
rack_timeout_service_timeout = 25
end
Rack::Timeout.service_timeout = rack_timeout_service_timeout |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/devise.rb | Ruby | mit | 19 | develop | 13,246 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/assets.rb | Ruby | mit | 19 | develop | 543 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional ... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/mime_types.rb | Ruby | mit | 19 | develop | 210 | # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
Mime::Type.register "text/tab-separated-values", :tsv |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/aws.rb | Ruby | mit | 19 | develop | 218 | # Aws.config.update({
# region: 'eu-west-1',
# credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']),
# })
# $s3_bucket = Aws::S3::Resource.new.bucket(ENV['S3_BUCKET_NAME']) |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/friendly_id.rb | Ruby | mit | 19 | develop | 4,016 | # FriendlyId Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `friendly_id` class method or defining
# methods in your model.
#
# To learn more, check out... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/filter_parameter_logging.rb | Ruby | mit | 19 | develop | 204 | # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password, :confirm] |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/initializers/json_encoding.rb | Ruby | mit | 19 | develop | 266 | module ActiveSupport::JSON::Encoding
class Oj < JSONGemEncoder
def encode value
::Oj.dump(value)
end
end
end
Oj.default_options = {time_format: :unix, mode: :compat}
ActiveSupport.json_encoder = ActiveSupport::JSON::Encoding::Oj
MultiJson.use :oj |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/environments/production.rb | Ruby | mit | 19 | develop | 4,172 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# config.action_dispatch.rack_cache = {
# metastore: (ENV["REDIS_URL"] || 'redis://127.0.0.1:6379') + '/1/metastore',
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/environments/development.rb | Ruby | mit | 19 | develop | 2,394 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | config/environments/test.rb | Ruby | mit | 19 | develop | 1,938 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/test_helper.rb | Ruby | mit | 19 | develop | 1,078 | require 'simplecov'
SimpleCov.start
# require 'coveralls'
# Coveralls.wear!
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/spec'
require 'devise'
require 'factory_bot'
ActiveRecord::Migration.maintain_test_schema!
class ActiveSu... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/exporters/xml/ddi/cc_loop_test.rb | Ruby | mit | 19 | develop | 571 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Exporters::XML::DDI::CcLoopTest < ActiveSupport::TestCase
setup do
@instrument = FactoryBot.create(:instrument)
@cc_loop = FactoryBot.create(:cc_loop, instrument: @instrument)
end
it "should create the selp URN correctly so ... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/exporters/xml/ddi/instrument_test.rb | Ruby | mit | 19 | develop | 2,033 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Exporters::XML::DDI::InstrumentTest < ActiveSupport::TestCase
setup do
@instrument = instruments :Instrument_2
@exporter = Exporters::XML::DDI::Instrument.new
@exporter.add_root_attributes
@exporter.export_instrument(@ins... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/xml/ddi/fragment_instance_test.rb | Ruby | mit | 19 | develop | 8,981 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::XML::DDI::FragmentInstanceTest < ActiveSupport::TestCase
describe ".parse" do
before do
@instrument = FactoryBot.create(:instrument, study: 'uk.alspac', agency: 'uk.cls.bxs70', prefix: 'bcs_86_mo')
@xml = %Q|
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/xml/ddi/instrument_test.rb | Ruby | mit | 19 | develop | 1,719 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::XML::DDI::InstrumentTest < ActiveSupport::TestCase
fixtures [] # remove all fixtures
describe ".import" do
it "should record urns" do
# Define the path to the XML file
file_path = Rails.root.join('test',... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/xml/ddi/dataset_test.rb | Ruby | mit | 19 | develop | 789 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::XML::DDI::DatasetTest < ActiveSupport::TestCase
fixtures [] # remove all fixtures
describe ".import" do
it "should record urns" do
# Define the path to the XML file
file_path = Rails.root.join('test', 's... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/xml/ddi/code_list_test.rb | Ruby | mit | 19 | develop | 1,421 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::XML::DDI::CodeListTest < ActiveSupport::TestCase
describe ".XML_node" do
it "should record codes" do
instrument = FactoryBot.create(:instrument, study: 'uk.alspac')
code_list = FactoryBot.create(:code_list, ins... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/xml/ddi/question_test.rb | Ruby | mit | 19 | develop | 5,878 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::XML::DDI::QuestionTest < ActiveSupport::TestCase
describe ".question_item_node" do
it "should record response cardinality for code list" do
instrument = FactoryBot.create(:instrument, study: 'uk.alspac', agency: 'uk.... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/txt/mapper/topic_v_test.rb | Ruby | mit | 19 | develop | 4,778 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::TXT::Mapper::TopicVTest < ActiveSupport::TestCase
setup do
@dataset = FactoryBot.create(:dataset)
topic = FactoryBot.create(:topic, id: 15, code: "10320")
FactoryBot.create(:variable, dataset: @dataset, name: 'aln'... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/txt/mapper/mapping_test.rb | Ruby | mit | 19 | develop | 8,262 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::TXT::Mapper::MappingTest < ActiveSupport::TestCase
describe "where instrument already has qv mappings" do
describe "qv mappings from tab delimited text file" do
it "should create a new mappings for the question and v... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/txt/mapper/dv_test.rb | Ruby | mit | 19 | develop | 4,592 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::TXT::Mapper::DVTest < ActiveSupport::TestCase
setup do
@dataset = FactoryBot.create(:dataset)
@source_variable = FactoryBot.create(:variable, dataset: @dataset)
@derived_variable = FactoryBot.create(:variable, data... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/lib/importers/txt/mapper/topic_q_test.rb | Ruby | mit | 19 | develop | 3,510 | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Importers::TXT::Mapper::TopicQTest < ActiveSupport::TestCase
setup do
@instrument = FactoryBot.create(:instrument)
@topic = FactoryBot.create(:topic, code: 102)
@other_topic = FactoryBot.create(:topic, code: 10320)
@aln =... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/jobs/delete_job_test.rb | Ruby | mit | 19 | develop | 586 | require 'test_helper'
module DeleteJobTest; end
class DeleteJobTest::Instrument < ControllerTest
setup do
@user = users :User_1
sign_in @user
@instrument = instruments(:Instrument_1)
end
# test "should destroy instrument" do
# assert_difference('Instrument.count', -1) do
# delete :destro... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/jobs/export_job_test.rb | Ruby | mit | 19 | develop | 2,838 | require 'test_helper'
class ExportJobTest < ActiveSupport::TestCase
def setup
# Use FactoryBot to ensure valid objects
@instrument = create(:instrument, prefix: 'test_instrument')
@dataset = create(:dataset, name: 'Test Dataset', filename: 'test_dataset.xml')
@export = create(:export, state: :pending... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/jobs/export_job/instrument_test.rb | Ruby | mit | 19 | develop | 545 | require 'test_helper'
class TestLogger < Logger
def initialize
@strio = StringIO.new
super(@strio)
end
def messages
@strio.string
end
end
class ExportJob::InstrumentTest < ActiveSupport::TestCase
setup do
@logger = TestLogger.new
Rails.logger = @logger
@instrument = FactoryBot.creat... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/cc_conditions_controller_test.rb | Ruby | mit | 19 | develop | 2,296 | require 'test_helper'
class CcConditionsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@cc_condition = cc_conditions(:CcCondition_9)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrume... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/question_grids_controller_test.rb | Ruby | mit | 19 | develop | 2,150 | require 'test_helper'
class QuestionGridsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@question_grid = question_grids(:QuestionGrid_3)
@instrument = instruments(:Instrument_1)
@xaxis = code_lists(:CodeList_11)
@yaxis = code_lists(:CodeList_14)
end... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/cc_questions_controller_test.rb | Ruby | mit | 19 | develop | 3,620 | require 'test_helper'
class CcQuestionsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@cc_question = cc_questions(:CcQuestion_4)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrument_i... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/topics_controller_test.rb | Ruby | mit | 19 | develop | 1,089 | require 'test_helper'
class TopicsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@topic = topics(:Topic_2)
@l2_topic = topics(:Topic_23)
end
test "should get index" do
get :index, format: :json
assert_response :success
assert_not_nil assigns(... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/datasets_controller_test.rb | Ruby | mit | 19 | develop | 1,591 | require 'test_helper'
class DatasetsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@dataset = datasets(:Dataset_1)
end
test "should get index" do
get :index, format: :json
assert_response :success
assert_not_nil assigns(:collection)
end
test... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/response_units_controller_test.rb | Ruby | mit | 19 | develop | 1,334 | require 'test_helper'
class ResponseUnitsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@response_unit = response_units(:ResponseUnit_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { inst... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/categories_controller_test.rb | Ruby | mit | 19 | develop | 1,307 | require 'test_helper'
class CategoriesControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@category = categories(:Category_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrument_id: @inst... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/cc_loops_controller_test.rb | Ruby | mit | 19 | develop | 2,362 | require 'test_helper'
class CcLoopsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@cc_loop = cc_loops(:CcLoop_1)
@instrument = instruments(:Instrument_3)
end
test "should get index" do
get :index, format: :json, params: { instrument_id: @instrument.i... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/cc_sequences_controller_test.rb | Ruby | mit | 19 | develop | 2,620 | require 'test_helper'
class CcSequencesControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@cc_sequence = cc_sequences(:CcSequence_6)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrument_i... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/instruments_controller_test.rb | Ruby | mit | 19 | develop | 3,974 | require 'test_helper'
class InstrumentsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json
assert_response :success
assert_not_nil assigns(:collection)
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/response_domain_datetimes_controller_test.rb | Ruby | mit | 19 | develop | 1,715 | require 'test_helper'
class ResponseDomainDatetimesControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@response_domain_datetime = response_domain_datetimes(:ResponseDomainDatetime_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/response_domain_texts_controller_test.rb | Ruby | mit | 19 | develop | 1,525 | require 'test_helper'
class ResponseDomainTextsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@response_domain_text = response_domain_texts(:ResponseDomainText_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, for... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/response_domain_numerics_controller_test.rb | Ruby | mit | 19 | develop | 2,193 | require 'test_helper'
class ResponseDomainNumericsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@response_domain_numeric = response_domain_numerics(:ResponseDomainNumeric_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/imports_controller_test.rb | Ruby | mit | 19 | develop | 801 | require 'test_helper'
class ImportsControllerTest < ActionController::TestCase
test "index JSON includes filename for import with no document_id" do
doc = Document.create!(filename: 'instrument-data.xml')
instrument = Instrument.first || create(:instrument)
import = Import.create!(
document: doc,
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/code_lists_controller_test.rb | Ruby | mit | 19 | develop | 4,731 | require 'test_helper'
class CodeListsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@code_list = code_lists(:CodeList_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrument_id: @inst... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/question_items_controller_test.rb | Ruby | mit | 19 | develop | 1,575 | require 'test_helper'
class QuestionItemsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@question_item = question_items(:QuestionItem_145)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { in... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/cc_statements_controller_test.rb | Ruby | mit | 19 | develop | 2,635 | require 'test_helper'
class CcStatementsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@cc_statement = cc_statements(:CcStatement_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrume... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/variables_controller_test.rb | Ruby | mit | 19 | develop | 1,849 | require 'test_helper'
class VariablesControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@variable = variables(:Variable_1)
@dataset = datasets(:Dataset_1)
end
test "should get index" do
get :index, format: :json, params: { dataset_id: @dataset.id }
a... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/controllers/instructions_controller_test.rb | Ruby | mit | 19 | develop | 1,306 | require 'test_helper'
class InstructionsControllerTest < ActionController::TestCase
setup do
@user = users :User_1
sign_in @user
@instruction = instructions(:Instruction_1)
@instrument = instruments(:Instrument_1)
end
test "should get index" do
get :index, format: :json, params: { instrument... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/factories/variables.rb | Ruby | mit | 19 | develop | 1,011 | FactoryBot.define do
factory :variable do
sequence(:name) { |n| "var#{n}" }
sequence(:label) { |n| "Variable Label #{n}" }
var_type { 'Normal' }
dataset
# user_with_questions will create post data after the user has been created
factory :variable_with_questions do
# questions_count is d... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/factories/cc_questions.rb | Ruby | mit | 19 | develop | 210 | FactoryBot.define do
factory :cc_question do
association :question, factory: :question_item
response_unit
topic
sequence(:label) { |n| "q_#{n}" }
instrument { Instrument.first }
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/factories/instruments.rb | Ruby | mit | 19 | develop | 248 | FactoryBot.define do
factory :instrument do
sequence(:label) { |n| "Label #{n}" }
sequence(:agency) { |n| "Agency#{n}" }
sequence(:prefix) { |n| "prefix_#{n}" }
sequence(:study) { |n| "Study#{n}" }
version { '1.0' }
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/factories/question_grids.rb | Ruby | mit | 19 | develop | 287 | FactoryBot.define do
factory :question_grid do
sequence(:label) { |n| "Label ##{n}" }
sequence(:literal) { |n| "Literal #{n}" }
question_type { 'QuestionGrid'}
instrument
horizontal_code_list factory: :code_list
vertical_code_list factory: :code_list
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/factories/cc_loops.rb | Ruby | mit | 19 | develop | 214 | FactoryBot.define do
factory :cc_loop do
sequence(:label) { |n| "l_#{n}" }
instrument { Instrument.first }
loop_var { 'loop1' }
start_val { 1 }
sequence(:ddi_slug) { |n| "#{n}001" }
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/factories/export.rb | Ruby | mit | 19 | develop | 913 | FactoryBot.define do
factory :export do
export_type { 'default' } # Adjust this to a default export type relevant to your app
state { 'pending' } # Default state; adjust based on job progress
log { '[]' } # Default to an empty JSON array; ensure it matches the type expected
# Associations
documen... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/performance/instrument_test.rb | Ruby | mit | 19 | develop | 403 | require 'test_helper'
#require 'rails/performance_test_help'
#class InstrumentPerformanceTest < ActionDispatch::PerformanceTest
# Refer to the documentation for all available options
# self.profile_options = { runs: 5, metrics: [:wall_time, :memory],
# output: 'tmp/performance', formats: [... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/cc_condition_test.rb | Ruby | mit | 19 | develop | 751 | require 'test_helper'
class CcConditionTest < ActiveSupport::TestCase
setup do
@cc_condition = cc_conditions :CcCondition_9
end
test "can read parent construct" do
assert_kind_of ::ParentalConstruct, @cc_condition.parent
end
test "set a new parent" do
seq = @cc_condition.instrument.cc_sequences... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/response_domain_code_test.rb | Ruby | mit | 19 | develop | 616 | require 'test_helper'
class ResponseDomainCodeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@response_domain_code = response_domain_codes :ResponseDomainCode_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @response_domain_code.instrument
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/cc_loop_test.rb | Ruby | mit | 19 | develop | 929 | require 'test_helper'
class CcLoopTest < ActiveSupport::TestCase
setup do
@cc_loop = cc_loops :CcLoop_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @cc_loop.instrument
end
test "can read parent construct" do
unless @cc_loop.parent.nil?
assert_kind_of ParentalConstruc... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/code_list_test.rb | Ruby | mit | 19 | develop | 1,282 | require 'test_helper'
class CodeListTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@code_list = code_lists :CodeList_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @code_list.instrument
end
test "has many codes" do
assert_not_nil @... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/cc_question_test.rb | Ruby | mit | 19 | develop | 5,910 | require 'test_helper'
class CcQuestionTest < ActiveSupport::TestCase
setup do
@cc_question = cc_questions :CcQuestion_4
topic = topics :Topic_2
@cc_question.topic = topic
@cc_question.save!
end
test "belongs to an instrument" do
assert_kind_of Instrument, @cc_question.instrument
end
tes... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/cc_sequence_test.rb | Ruby | mit | 19 | develop | 669 | require 'test_helper'
class CcSequenceTest < ActiveSupport::TestCase
setup do
@cc_sequence = cc_sequences :CcSequence_3
end
test "belongs to an instrument" do
assert_kind_of Instrument, @cc_sequence.instrument
end
test "can read parent construct" do
assert_kind_of ParentalConstruct, @cc_sequenc... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/instruction_test.rb | Ruby | mit | 19 | develop | 548 | require 'test_helper'
class InstructionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@instruction = instructions :Instruction_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @instruction.instrument
end
test "has many questions" do
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/response_domain_text_test.rb | Ruby | mit | 19 | develop | 616 | require 'test_helper'
class ResponseDomainTextTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@response_domain_text = response_domain_texts :ResponseDomainText_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @response_domain_text.instrument
... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/category_test.rb | Ruby | mit | 19 | develop | 224 | require 'test_helper'
class CategoryTest < ActiveSupport::TestCase
setup do
@category = categories :Category_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @category.instrument
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/question_item_test.rb | Ruby | mit | 19 | develop | 1,127 | require 'test_helper'
class QuestionItemTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@question_item = question_items :QuestionItem_5
end
test "belongs to an instrument" do
assert_kind_of Instrument, @question_item.instrument
end
test "has one instruction... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/variable_test.rb | Ruby | mit | 19 | develop | 4,693 | require 'test_helper'
class VariableTest < ActiveSupport::TestCase
setup do
topic = create(:topic)
@variable = create(:variable, topic: topic)
end
test "belongs to dataset" do
assert_kind_of Dataset, @variable.dataset
end
test "has many questions" do
assert_kind_of ActiveRecord::Association... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/response_domain_numeric_test.rb | Ruby | mit | 19 | develop | 640 | require 'test_helper'
class ResponseDomainNumericTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@response_domain_numeric = response_domain_numerics :ResponseDomainNumeric_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @response_domain_numer... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/import_test.rb | Ruby | mit | 19 | develop | 1,139 | require 'test_helper'
class ImportTest < ActiveSupport::TestCase
setup do
@import = create(:import)
end
test "belongs to an dataset" do
assert_kind_of Dataset, @import.dataset
end
test "stores filename from document at create time" do
doc = Document.create!(filename: 'test-file.xml')
instru... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/cc_statement_test.rb | Ruby | mit | 19 | develop | 834 | require 'test_helper'
class CcStatementTest < ActiveSupport::TestCase
setup do
@cc_statement = cc_statements :CcStatement_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @cc_statement.instrument
end
test "can read parent construct" do
unless @cc_statement.parent.nil?
a... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/instrument_test.rb | Ruby | mit | 19 | develop | 1,960 | require 'test_helper'
class InstrumentTest < ActiveSupport::TestCase
setup do
@instrument = instruments :Instrument_1
end
test "has many categories" do
assert_kind_of ActiveRecord::Associations::CollectionProxy, @instrument.categories
end
test "has many code lists" do
assert_kind_of ActiveRecor... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/question_grid_test.rb | Ruby | mit | 19 | develop | 2,584 | require 'test_helper'
class QuestionGridTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@question_grid = question_grids :QuestionGrid_3
end
test "belongs to an instrument" do
assert_kind_of Instrument, @question_grid.instrument
end
test "has one instruction... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/response_unit_test.rb | Ruby | mit | 19 | develop | 373 | require 'test_helper'
class ResponseUnitTest < ActiveSupport::TestCase
setup do
@response_unit = response_units :ResponseUnit_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @response_unit.instrument
end
test "has many questions" do
assert_kind_of ActiveRecord::Associations:... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/dataset_test.rb | Ruby | mit | 19 | develop | 244 | require 'test_helper'
class DatasetTest < ActiveSupport::TestCase
setup do
@dataset = datasets :Dataset_1
end
test "has many variables" do
assert_kind_of ActiveRecord::Associations::CollectionProxy, @dataset.variables
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/response_domain_datetime_test.rb | Ruby | mit | 19 | develop | 648 | require 'test_helper'
class ResponseDomainDatetimeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@response_domain_datetime = response_domain_datetimes :ResponseDomainDatetime_1
end
test "belongs to an instrument" do
assert_kind_of Instrument, @response_domain_d... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/topic_test.rb | Ruby | mit | 19 | develop | 960 | require 'test_helper'
class TopicTest < ActiveSupport::TestCase
setup do
@topic = topics :Topic_32
@topic_2 = topics :Topic_2
end
test 'flattened_nest topics count' do
assert Topic.flattened_nest.count == Topic.count
end
test 'flattened_nest where parent_id is Nil' do
topics = Topic.where(p... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/models/document_test.rb | Ruby | mit | 19 | develop | 246 | require 'test_helper'
class DocumentTest < ActiveSupport::TestCase
test 'document created from string' do
test_string = 'test contents of file'
d = Document.new file: test_string
assert_equal test_string, d.file_contents
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/services/instruments/mappings_tsv_data_service_test.rb | Ruby | mit | 19 | develop | 4,824 | require 'test_helper'
class Instruments::MappingsTsvDataServiceTest < ActiveSupport::TestCase
def setup
# Create topics
@topic1 = FactoryBot.create(:topic, code: 'T1')
@topic2 = FactoryBot.create(:topic, code: 'T2')
# Create datasets
@dataset1 = FactoryBot.create(:dataset, filename: 'DS1.ddi32.r... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | test/services/instruments/control_construct_updater_test.rb | Ruby | mit | 19 | develop | 1,250 | require 'test_helper'
class Instruments::ControlConstructUpdaterTest < ActiveSupport::TestCase
setup do
@instrument = FactoryBot.create(:instrument, study: 'uk.alspac')
@top_sequence = FactoryBot.create(:cc_sequence, instrument: @instrument)
@secondary_sequence = FactoryBot.create(:cc_sequence, instrumen... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/seeds.rb | Ruby | mit | 19 | develop | 2,010 | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/migrate/20151201094926_create_cc_conditions.rb | Ruby | mit | 19 | develop | 204 | class CreateCcConditions < ActiveRecord::Migration[4.2]
def change
create_table :cc_conditions do |t|
t.string :literal
t.string :logic
t.timestamps null: false
end
end
end |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/migrate/20151206165726_create_topics.rb | Ruby | mit | 19 | develop | 398 | class CreateTopics < ActiveRecord::Migration[4.2]
def change
create_table :topics do |t|
t.string :name, null: false, unique: true
#t.references :parent, index: true, foreign_key: true
t.integer :parent_id, index: true
t.string :code, null: false, unique: true
t.timestamps null: fal... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/migrate/20190812092819_create_friendly_id_slugs.rb | Ruby | mit | 19 | develop | 815 | MIGRATION_CLASS =
if ActiveRecord::VERSION::MAJOR >= 5
ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
else
ActiveRecord::Migration
end
class CreateFriendlyIdSlugs < MIGRATION_CLASS
def change
create_table :friendly_id_slugs do |t|
t.string :slug, ... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/migrate/20160716164426_make_unique_rds_qs_order_deferrable.rb | Ruby | mit | 19 | develop | 767 | class MakeUniqueRdsQsOrderDeferrable < ActiveRecord::Migration[4.2]
def change
reversible do |dir|
dir.up do
execute <<-SQL
ALTER TABLE rds_qs
DROP CONSTRAINT unique_for_rd_order_within_question;
ALTER TABLE rds_qs
ADD CONSTRAINT unique_for_rd_order_within_que... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/migrate/20181106140729_dropping_ancestral_topic_materialized_view.rb | Ruby | mit | 19 | develop | 1,602 | class DroppingAncestralTopicMaterializedView < ActiveRecord::Migration[5.0]
def change
reversible do |dir|
dir.up do
execute <<~SQL
DROP TRIGGER update_links ON links;
DROP FUNCTION refresh_ancestral_topics();
DROP MATERIALIZED VIEW ancestral_topic;
SQL
en... |
github | CLOSER-Cohorts/archivist | https://github.com/CLOSER-Cohorts/archivist | db/migrate/20170505135010_create_identifiers.rb | Ruby | mit | 19 | develop | 311 | class CreateIdentifiers < ActiveRecord::Migration[5.0]
def change
create_table :identifiers do |t|
t.string :id_type
t.string :value
t.references :item, polymorphic: true, null: false
t.timestamps
end
add_index 'identifiers', %w(id_type value), :unique => true
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.