text stringlengths 10 2.61M |
|---|
require 'time'
require './tree.rb'
#Given a set of meeting times, and a start and end time of new meeting
#return all the meeting rooms available during that time
class BinarySearchTree < Tree
def insert_node_to_bst(meeting)
node = Node.new(meeting)
unless @root
@root = node
return node
end
... |
# frozen_string_literal: true
RSpec.describe TalkSummary, type: :model do
# Validations
it { should validate_presence_of(:body) }
it { should validate_presence_of(:submitted_at) }
# Associations
it { should belong_to(:submitted_by_user) }
it { should belong_to(:talk) }
end
|
require 'rails_helper'
RSpec.describe V1::AuthorAPI, type: :api do
describe 'insert new authors names' do
context 'POST /v1/author/new?name=fabio%20de%20almeida' do
it 'returns 201' do
call_api
expect(response.status).to eq(201)
end
end
end
describe 'trying to create authors... |
require_relative 'topic_representer'
# Represents essential Repo information for API output
module WiKey
class TopicsRepresenter < Roar::Decorator
include Roar::JSON
collection :topics, extend: TopicRepresenter, class: OpenStruct
end
end |
require "rails_helper"
describe Strategies::Say do
let(:time) { Time.parse "2012-02-12 12:41:32" }
let(:message) {
Message.new(
text: "hello",
user: "someone",
timestamp: time
)
}
it "says stuff" do
s = Strategies::Say.new live: false
s.call message
expect(s.his... |
class Product < ActiveRecord::Base
has_many :backlog_items
validates_presence_of :name
validates_uniqueness_of :name
attr_protected :image
def file=(value)
if value.size > 0
t = Time.new
self.image = "#{t.to_i}_#{File.basename(value.original_filename)}"
filepath = "#{R... |
Gem::Specification.new do |s|
s.name = %q{cis_attachment_fu}
s.version = "0.0.1"
s.authors = ["Sapna"]
s.date = %q{2013-02-05}
s.description = %q{for uploading files or images.}
s.email = %q{sapna.j@cisinlabs.com}
s.extra_rdoc_files = ["README"]
s.files = %w(
CHANGELOG
LICENSE
README
Rakefile
init.rb
i... |
require 'vocabularise/config'
require 'vocabularise/crawler'
# load various handlers
require 'vocabularise/internal_handler'
require 'vocabularise/expected_handler'
require 'vocabularise/controversial_handler'
require 'vocabularise/aggregating_handler'
require 'vocabularise/wikipedia_handler'
require 'vocabularise/me... |
class NoAwardGroups < ActiveRecord::Migration
def self.up
change_table :awards do |t|
t.boolean :awardable
t.belongs_to :parent, :foreign_key => :parent_id
t.change :award_group_id, :integer
end
execute "UPDATE awards SET awardable = true"
change_column :awards, :awardable, :boo... |
class Micropost < ApplicationRecord
belongs_to :user
validates:content,length: {maximum:140},
presence: true
end
|
module MotionBuild ; module Rules
class ParseLLVMBitcodeRule < MotionBuild::ObjectFileRule
attr_reader :arch, :llc_arch
def input_extension
'.bc'
end
def output_extension
'.s'
end
def run
project.builder.notify('llc', source, destination)
project.builder.run('llc', ... |
class InteractiveRecord
def self.table_name
self.to_s.downcase + "s"
end
def self.column_names
DB[:conn].results_as_hash = true
sql = "PRAGMA table_info('#{table_name}')"
table_info = DB[:conn].execute(sql)
table_info.map { |column| column["name"] }.compact
end
# sql = <<-SQL
# SELE... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
Vagrant.configure(2) do |config|
# Box (operation system)
config.vm.box = "ubuntu/trusty64"
# Sync ansible folder
config.vm.synced_folder "ansible", "/etc/ansible", mount_options: ["fmode=666"]
# Load config file
# We can use... |
class SearchMovie
include HTTParty
require_relative '../hooks/hooks.rb'
base_uri "https://api.themoviedb.org/3"
def initialize(headers)
@search_movie_params = {:headers => headers}
end
def get_search_movie(param)
self.class.get("/search/movie?query=#{param}", @search_movie_para... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Language::DocumentFromSchemaDefinition do
let(:subject) { GraphQL::Language::DocumentFromSchemaDefinition }
describe "#document" do
let(:schema_idl) { <<-GRAPHQL
type QueryType {
foo: Foo
u: Union
}
type F... |
class Document < ApplicationRecord
belongs_to :folder
mount_uploader :file, FileUploader
validates :file, filename_uniqueness: false
default_scope { order(:file) }
end
|
class UserSettingEntry < ActiveRecord::Base
belongs_to :setting, class_name: 'UserSetting', foreign_key: 'user_setting_id'
serialize :value, Object
end
|
# Create a person class with at least 2 attributes and 2 behaviors.
# Call all person methods below the class and print results
# to the terminal that show the methods in action.
# YOUR CODE HERE
class Person
attr_accessor :height, :birth_country, :hair_length
def initialize(height, birth_country)
@height = ... |
# frozen_string_literal: true
# This migration comes from alchemy (originally 20200511113603)
class AddMenuTypeToAlchemyNodes < ActiveRecord::Migration[5.2]
class LocalNode < ActiveRecord::Base
self.table_name = :alchemy_nodes
acts_as_nested_set scope: :language_id
def self.root_for(node)
return no... |
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... |
class CreateMessages < ActiveRecord::Migration[5.0]
def change
create_table :messages do |t|
t.references :client, foreign_key: true
t.references :user, foreign_key: true
t.string :body, default: ""
t.string :number_from, null: false
t.string :number_to, null: false
t.boolean :... |
class User < ApplicationRecord
before_save { self.email = email.downcase if email }
validates :username, presence: true, length: { in: 5..24 }
validates :subscriber, inclusion: { in: [true, false] }
EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 80 },
... |
class Player < ActiveRecord::Base
belongs_to :game
belongs_to :user
belongs_to :deck, class_name:"CardPile", dependent: :destroy
belongs_to :hand, class_name:"CardPile", dependent: :destroy
belongs_to :revealed, class_name:"CardPile", dependent: :destroy
belongs_to :play_area, class_name:"CardPile", dependent: ... |
class GradebookReportsController < ApplicationController
before_filter :login_required
filter_access_to :all , :except => [:reload_cosolidated_exam_types,:reload_consolidated_exams,:consolidated_exam_report,:subject_wise_generated_report,:reload_exams,:reload_report_type,:reload_subjects,:subject_reports,:student_r... |
# -*- coding: utf-8 -*-
require 'rack/ketai/carrier/softbank'
describe "Rack::Ketai::Carrier::Softbank" do
before(:each) do
end
# http://creation.mb.softbank.jp/web/web_ua_about.html
# SoftBank 3G Series => 3GC型
# C型 P型は省略(もうなくなるし)
describe "3GCケータイで" do
# http://ke-tai.org/blog/2008/09/08/ph... |
# auto-cred-checker.rb
# Author: m-1-k-3 (Web: http://www.s3cur1ty.de / Twitter: @s3cur1ty_de)
# This Metasploit RC-File could be used to automatically check already discovered
# credentials against some other login services.
# It uses allready discovered credential from the database and tries to use them against some... |
class Article < ApplicationRecord
belongs_to :author, class_name: "User", foreign_key: "user_id"
has_many :reviews, dependent: :destroy
has_many :article_tags, dependent: :destroy
has_many :tags, through: :article_tags
has_rich_text :content
validates :title, presence: true
validates :image_url, presen... |
pg_dba = input('pg_dba')
pg_dba_password = input('pg_dba_password')
pg_db = input('pg_db')
pg_host = input('pg_host')
pg_log_dir = input('pg_log_dir')
pg_owner = input('pg_owner')
pg_conf_file = input('pg_conf_file')
control "V-72885" do
title "The audit information produced by PostgreSQL must be protected f... |
class OrderForm
include ActiveModel::Model
attr_accessor :postal_code, :prefectures_id, :municipality, :address, :building_name, :telephone_number, :user_id, :item_id,
:token
validates :postal_code, :prefectures_id, :municipality, :address, :telephone_number, :token, :user_id, :item_id, presence:... |
class SpeakersController < ApplicationController
def hosts
@hosts = Speaker.where(host_or_guest: 'Host').order('name')
render :hosts
end
def guests
@guests = Speaker.where(host_or_guest: 'Guest').order('name')
render :guests
end
def new
check_for_admin
@speaker = Speaker.new
end
... |
# encoding: UTF-8
class FeedbacksController < ApplicationController
def new
@title = "反馈"
build_feedback
end
def create
build_feedback
if @feedback.save
notice_stickie("成功提交,我们会尽快处理您的反馈意见。")
if current_user
redirect_to home_index_path
else
redirect_to root_url
... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: plans
#
# id :integer not null, primary key
# name :string
# amount_cents :integer default(0), not null
# amount_currency :string default("USD"), not null
# stripe_id :strin... |
# frozen_string_literal: true
# rspec ./spec/lib/statistic_calcs/distributions/log_normal_spec.rb
require 'statistic_calcs/distributions/log_normal'
# rubocop:disable BlockLength
RSpec.describe StatisticCalcs::Distributions::LogNormal do
subject { StatisticCalcs::Distributions::LogNormal.new(options) }
before { ... |
class JobsController < ApplicationController
before_action :set_job, except: %i[index new create]
before_action :authenticate_business!, except: %i[index show]
before_action :redirect_business_job, only: %i[edit update destroy close open]
helper_method :business_job?
# This method smells of :reek:TooManySta... |
# frozen_string_literal: true
require "json"
require "csv"
module Rack
class SessionCounter
class Error < StandardError; end
def initialize(app, statsfile)
@app = app
@statsfile = statsfile
@rate_limit_window = 30
@rate_limit = 10
@cooldown_duration = 15
load_stats
en... |
class FontZhudouSans < Formula
version "1.000"
sha256 "dae5ff79f8f1db78661a6ec0ae7c1732965c034a3c04bd95cd43baabd14996ca"
url "https://github.com/Buernia/Zhudou-Sans/releases/download/v#{version}/Zhudou.Sans.zip"
desc "Zhudou Sans"
desc "煮豆黑体"
desc "CJK symbols and punctuation derived from Noto Sans"
homep... |
Then /^I should see "(.*?)"$/ do |text|
page.should have_content(text)
end
Then /^I should not see "(.*?)"$/ do |text|
page.should_not have_content(text)
end
When /^I click "(.*?)"$/ do |link|
click_link(link)
end
When /^I click the "(.*?)" button$/ do |button|
click_button(button)
end
Given /^I am logged i... |
feature "Proposals index" do
include ProposalTableSpecHelper
include ResponsiveHelper
scenario "filters pending proposals according to current_user" do
user = create(:user)
_reviewable_proposals = create_list(:proposal, 2, :with_approver, observer: user)
_pending_proposals = create_list(:proposal, 2,... |
class Store < ActiveRecord::Base
has_many :reports
has_many :credits
has_many :counts
has_many :keys
has_many :surveys
has_many :products, order: :position
has_many :inventories
has_many :thruputs
has_many :line_items, through: :inventories
has_many :employments
has_many :employees, through: :empl... |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "wess_standings/version"
Gem::Specification.new do |spec|
spec.name = "wess_standings"
spec.version = WessStandings::VERSION
spec.authors = ["Alex Wilson"]
spec.email = ["fon... |
class EARMMS::LoginPasswordResetController < EARMMS::ApplicationController
get '/' do
@title = "Password reset"
next redirect('/') if logged_in?
haml :'auth/password_reset/index'
end
post '/' do
@title = "Password reset"
next redirect('/') if logged_in?
unless request.params.key?("emai... |
describe "scp image requests" do
os_id = compute.operating_systems.first.id
let(:csp_image_format) do
{
"id" => String,
"customer" => String,
"provider" => String,
"csp_image_id" => Fog::Nullable::String,
"modified_by" => String,
"modif... |
class StorySlocationJoin < ActiveRecord::Base
validates :story_id, :slocation_id, presence: true
belongs_to :story
belongs_to :slocation
end
|
#
# Copyright 2015, SUSE LINUX Products GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... |
class PushToSakuraioJob < ApplicationJob
queue_as :default
throttle limit: MakeStack.settings[:push_to_sakuraio_limit_per_hour], period: 1.hour
def execute(webhook_token:, module_id:, payload:)
# "\xAA\xBB\xCC\xDD..." => [["AABBCCDD..."], [], ...]
arrays = payload.scan(/./).map {|b| b.ord.to_s(16).rjust(... |
require 'spec_helper'
describe "benchmark_data/new" do
before(:each) do
assign(:benchmark_datum, stub_model(BenchmarkDatum,
:client_id => 1,
:social_network_id => 1,
:start_date => 1,
:end_date => 1,
:title => "MyString",
:competitor => "MyString",
:blogs => 1,
:fo... |
class TournamentsController < ApplicationController
# GET /tournaments
def index
@tournaments = Tournament.order( 'start_date DESC' )
@current_tournament = Tournament.current
@participants = {}
@tournaments.each do |tournament|
@participants[tournament.id] = Set.new
end
Match.all.ea... |
class Videoasset < ActiveRecord::Base
validates :merlinid, presence: true
self.primary_key = 'merlinid'
has_many :points
accepts_nested_attributes_for :points
end
|
require "test_helper"
describe Product do
let(:kilimanjaro) { products(:kilimanjaro) }
let(:fannypack) { products(:fannypack) }
let(:safari) { products(:safari) }
let(:product) { products(:kilimanjaro) }
describe "Custom Methods" do
it "adjust_inventory" do
item = orderitems(:itemsone)
orde... |
#
# Be sure to run `pod lib lint PullToRefreshKit.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'YLP... |
require_relative '../spec_helper'
require 'models/game.rb'
RSpec.describe Game do
let(:game) { Game.new(1, 2) }
let(:started_game) { game.tap(&:start) }
describe '.find' do
it 'will reinitialize game' do
id = started_game.id
expect(Game.find(id)[1].id).to eq(id)
end
it 'will return an ... |
class WeightsController < ApplicationController
load_and_authorize_resource
# POST /weights
# POST /weights.json
def create
@class_section = ClassSection.find(params[:class_section_id])
@role = Role.find(params[:role_id])
@weight = Weight.new(:name => params[:weight_name],:value => params[:weight_va... |
class VerifierService
def initialize(word)
@word = word
end
def call
@responses = []
phrase_array = split_space_phrase_in_array(@word)
MessageVerifier.all.map { |message_verifier| split_verifier_and_compare_to_message(message_verifier, phrase_array)}
if @responses... |
class CommentSerializer
include FastJsonapi::ObjectSerializer
attributes :content, :meditation_id, :id
belongs_to :meditation
end
|
class AddProfileImagesToCandidates < ActiveRecord::Migration
def change
add_column :candidates, :background_image, :string
add_column :candidates, :profile_image, :string
end
end
|
require 'pry'
class Song
attr_accessor :name, :artist_name
@@all= []
def self.all #returns contents of the array
@@all
end
def save
self.class.all << self #???
end
def self.create
song = self.new #initializes a new song instance
@@all << song #pushes new instance into array
song #r... |
class AddActiveFlagToUserRole < ActiveRecord::Migration
def change
add_column :user_roles, :active, :boolean
end
end
|
module CDI
module V1
class SimpleUserGallerySerializer < ActiveModel::Serializer
root false
attributes :id, :user_id, :active,
:description, :tags,
:cover_image_url, :cover_images_url,
:created_at, :updated_at
end
end
end
|
class Fluent::MySQLSlowQueryExInput < Fluent::NewTailInput
Fluent::Plugin.register_output('mysqlslowquery_ex', self)
config_param :suppress_sql_newline, :bool, default: false
# Define `log` method for v0.10.42 or earlier
unless method_defined?(:log)
define_method(:log) { $log }
end
def initialize
... |
class PatientCasesController < ApplicationController
inherit_resources
defaults :resource_class => PatientCase, :collection_name => 'patient_cases', :instance_name => 'patient_case'
custom_actions :resource => :review, :collection => [:waiting, :bulk]
actions :all
before_filter :authenticate_user!
before_... |
require 'net/http'
rails_env = ENV['RAILS_ENV'] || 'test'
SOLR_PORT = 9983 unless rails_env.downcase == 'test'
SOLR_PORT = 9981 if rails_env.downcase == 'test'
SOLR_CORE = "hydra-#{rails_env}"
namespace :scholars_archive do
namespace :solr do
desc "Kill existing process(es) and restart SOLR"
task :restart... |
require 'rubygems'
require 'ohm'
require '../lib/waveserver'
require '../lib/wavelet'
class Wave < Ohm::Model
collection :wavelets, :Wavelet
attribute :waveid
index :waveid
reference :waveserver, :WaveServer
def [](wavelet_id)
return Wavelet.create :wavelet_id=>wavelet_id.to_s, :wave=>self if self.wave... |
# frozen_string_literal: true
module MLBStatsAPI
# Only the Pacific Coast League uses conferences
module Conferences
# View all PCL conferences.
def conferences(**options) = get('/conferences', **options)
# View PCL conferences by conference ID.
def conference(conference_id, **options) = get("/con... |
### config zone, if you do not config necessary config it will raise an error ######
API_USER_ID = ''
API_USER_KEY = ''
ENABLE_SSO = true # 是否启用sso
mode = ''
if API_USER_ID.blank? or API_USER_KEY.blank? or mode.blank?
raise 'please set the API_USER_ID and API_USER_KEY at config/initializes/usersystem_api_config.r... |
class Phrase
def initialize(str)
@phrase = str
end
def word_count
result = {}
@phrase.split.each do |word|
result[word] ? result[word] += 1 : result[word] = 1
end
result
end
end |
require 'rails_helper'
RSpec.describe PortfolioItemsController, type: :controller do
let(:params) { {} }
let(:user) {create(:user,site_admin:true)}
describe "GET #new" do
it "returns http success if signed in" do
# Sign in
sign_in user
# Try
get :new
expect(response).to have_ht... |
class ProductsController < ApplicationController
before_filter :admin_user, only: [:destroy, :edit, :update, :create, :new]
before_filter :check_for_cancel, only: [:create, :update]
def index
@sort_fields = [["Product Code","product_code"], ["Location","locations.name"], ["Name","products.name"], ["Format","forma... |
class RemoveUserIdAndArticleIdFromComments < ActiveRecord::Migration[5.0]
def change
remove_column :comments, :user_id, :string
remove_column :comments, :article_id, :string
end
end
|
class Timer
#write your code here
attr_accessor :seconds
def initialize
@seconds = 0
end
def time_string
hh = ((@seconds / 3600) % 60).to_s.rjust(2, "0")
mm = ((@seconds / 60) % 60).to_s.rjust(2, "0")
ss = (@seconds % 60).to_s.rjust(2, "0")
arr = [hh, mm, ss]
return arr.join(":")
end
end
|
class Address < ActiveRecord::Base
belongs_to :member
belongs_to :location
belongs_to :area
belongs_to :city
Location_type = {:location => 1, :area => 2, :city => 3}
end
|
class CreateDataCenters < ActiveRecord::Migration[5.0]
def change
create_table :data_centers do |t|
t.string :name
t.string :dc_code, limit: 8
t.integer :bears_instance_id
t.timestamps
end
add_index :data_centers, :dc_code, unique: true
end
end
|
Given(/^I am a confirmed user$/) do
@user = create(:user, :confirmed)
end
Then(/^I should see the login error$/) do
step 'I should see "Invalid credentials!"'
end
When(/^I fill in correct email and password$/) do
fill_in 'Email', with: @user.email
fill_in 'Password', with: @user.password
end
Then(/^I should ... |
class Device < ApplicationRecord
before_create :set_connection_is_true
validates :name, presence: true
validates :status, presence: true
private
def set_connection_is_true
self.connection_is_true = true
end
end
|
class CreateDescriptions < ActiveRecord::Migration
def change
create_table :descriptions, id: false do |t|
t.integer :description_code
t.integer :language_code
t.integer :description_group
t.string :description_text
t.string :short_description_text
end
end
end
|
class Community < ApplicationRecord
has_many :buildings, -> { where(depth: 1) }, class_name: "Room"
has_many :units, -> { where(depth: 2) }, class_name: "Room"
has_many :floors, -> { where(depht: 3) }, class_name: "Room"
has_many :rooms, -> { where(depht: 4) }, class_name: "Room"
has_many :property_managers
... |
require "alt_id/version"
require "alt_id/active_record"
require 'openssl'
require 'base64_with_short'
module AltId
class Error < StandardError; end
DEFAULT_CIPHER = 'aes-128-cbc'
class << self
# @param id integer
# @param secret_key string Rails.application.credentials.secret_key_base
# @param t... |
class HomeController < ApplicationController
def index
@title = t('.title')
@description = t('.description')
end
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
end
|
require 'spec_helper'
describe Comment do
let(:user) { FactoryGirl.create(:user) }
let(:article) { FactoryGirl.create(:article) }
before { @comment = article.comments.build(content: 'Comment content', user_id: :user) }
subject { @comment }
it { should respond_to(:content) }
it { should respond_... |
module StrokeDB
module Util
begin
class FastUUID
require 'rubygems'
require 'inline'
C_FLAGS = `uuid-config --cflags`.chomp
LD_FLAGS = `uuid-config --ldflags --libs`.chomp
inline(:C) do |builder|
builder.add_compile_flags C_FLAGS
builder.add_li... |
require 'stringex/unidecoder'
require 'stringex/core_ext'
module Pii
class Attribute
attr_accessor :raw, :norm
def initialize(raw: nil, norm: nil)
@raw = raw
@norm = norm
end
delegate :blank?, :present?, :to_s, :to_date, :==, :eql?, to: :raw
alias to_str to_s
def ascii
ra... |
# frozen_string_literal: true
module Commands
module Urls
class ConcurrentProcess
MAX_NUMBER_OF_THREADS = 16
def self.call(urls)
urls.map do |url|
maybe_new_thread do
Commands::Urls::Process.call(url)
end
end.map(&:value)
end
private
... |
class Api::V1::PlantsController < ApplicationController
def index
return nil if Plant.all.empty?
render json: PlantSerializer.new(Plant.all)
end
def show
return nil if !Plant.exists?(params[:id])
render json: PlantSerializer.new(Plant.find(params[:id]))
end
def create
new_plant = Plant.n... |
module ActiveRecordShards
module ConnectionSwitcher
def self.extended(klass)
klass.singleton_class.alias_method_chain :columns, :default_shard
klass.singleton_class.alias_method_chain :table_exists?, :default_shard
end
def default_shard=(new_default_shard)
ActiveRecordShards::ShardSelec... |
module XCB
class Cookie::GetWindowAttributes < FFI::Struct
layout :sequence, :uint16
end
end
|
begin
require "rufus/tokyo/tyrant"
rescue LoadError
puts "You need the rufus gem to use the Tyrant moneta store"
exit
end
module Moneta
class Tyrant < ::Rufus::Tokyo::Tyrant
module Implementation
def initialize(options = {})
host = options[:host]
port = options[:port]
super(ho... |
describe SubscriberList do
describe "#triples" do
it "include request, observers, approvers, and purchasers" do
proposal = create(:proposal, :with_observers, :with_approval_and_purchase)
triples = SubscriberList.new(proposal).triples
user_ids = triples.map {|result| result[0].id}
roles = ... |
class IngredientCompartment
attr_reader :ingredients
def initialize ingredients
@ingredients = ingredients
# Using Mutex so that we can use thread synchronization whenever required
@mutex = Mutex.new
end
# For Thread safety synchronization on current Ingredient Compartment Object
def synchroniz... |
require File.dirname(__FILE__) + '/test_helper'
class MyModel < ActiveRecord::Base
acts_as_randomizable
end
class RandomizableTest < Test::Unit::TestCase
def setup
Kernel.stubs(:rand).returns(0.5)
end
def test_one_query
my_model = MyModel.new
MyModel.expects(:find).with(:first, :order => "rando... |
=begin
#Scubawhere API Documentation
#This is the documentation for scubawhere's RMS API. This API is only to be used by authorized parties with valid auth tokens. [Learn about scubawhere](http://www.scubawhere.com) to become an authorized consumer of our API
OpenAPI spec version: 1.0.0
Contact: bryan@scubawhere.co... |
class AddMainBlogToUsers < ActiveRecord::Migration
def change
add_column :users, :main_blog_id, :integer
end
end
|
control "M-1.1" do
title "1.1 Ensure a separate partition for containers has been created
(Scored)"
desc "
All Docker containers and their data and metadata is stored under
/var/lib/docker
directory. By default, /var/lib/docker would be mounted under / or /var
partitions based
on availability.
Dock... |
class Comment < ActiveRecord::Base
validates :author_id, :photo_id, :body, presence: true
belongs_to :author, class_name: 'User'
belongs_to :photo
end
|
require 'pry'
# class CircularQueue
# attr_accessor :buffer, :insert_idx, :remove_idx
# def initialize(buffer_size)
# @buffer = Array.new(buffer_size)
# @insert_idx = 0
# @remove_idx = 0
# end
# def enqueue(num)
# self.dequeue if buffer[self.insert_idx]
# buffer[self.insert_idx] = num
# ... |
require_relative '../../../../spec_helper'
describe 'govuk_envvar', :type => :define do
context 'with a value' do
let(:title) { 'GOVUK_POET_FULL_NAME' }
let(:params) { { :value => 'Robert Burns' } }
it 'writes the value to disk' do
is_expected.to contain_file('/etc/govuk/env.d/GOVUK_POET_FULL_NAME... |
module Kaminari
module Logarithmic
module Strategies
class FixedStepsStrategy < BaseStrategy
def initialize(start, finish, base = 10)
@global_start = start
@global_finish = finish
@base = base
end
def build
start = next_point_or_itself(@global... |
#!/usr/bin/env ruby
# :title: PlanR::Content::PropertyNode
=begin rdoc
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'plan-r/content_repo/metadata_node'
module PlanR
module ContentRepo
class PropertyNode < MetadataNode
KEY = :properties
PATHNAME = '.META.properties'
... |
class Definition
define_method(:initialize) do |phrase|
@phrase = phrase
end
define_method(:phrase) do
@phrase
end
end
|
require 'rails_helper'
RSpec.describe 'home page', type: :system, js: true do
it 'renders the react component' do
visit '/'
expect(page).to have_content('Top#home')
expect(page).to have_content('Hello React!')
end
end
|
require "application_system_test_case"
class DropMinSubjectsTest < ApplicationSystemTestCase
setup do
@drop_min_subject = drop_min_subjects(:one)
end
test "visiting the index" do
visit drop_min_subjects_url
assert_selector "h1", text: "Drop Min Subjects"
end
test "creating a Drop min subject" d... |
module Rhouse::Models
class CommandParameter < ActiveRecord::Base
set_table_name "CommandParameter"
set_primary_key "PK_#{CommandParameter.table_name}"
# relationships...
belongs_to :type,
:foreign_key => "FK_ParameterType",
:class_name => "Rhouse::Models::ParameterType"
has_and... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.