text stringlengths 10 2.61M |
|---|
# $Id$
class Circle < ActiveRecord::Base
belongs_to :owner, :class_name => 'Member', :foreign_key => 'user_id'
has_many :relationships
has_many :members, :through => :relationships, :source => :guest
validates_presence_of :name, :message => "Please Select a Relationship"
named_scope :globals, :condition... |
class RenameColumnToParticipantsTable < ActiveRecord::Migration
def change
rename_column :participants, :stated_pants_length, :stated_pants_inseam
rename_column :participants, :waist, :natural_waist
add_column :participants, :pant_waist, :string
end
end
|
module TSV
class Row
extend Forwardable
def_delegators :data, *Enumerable.instance_methods(false)
attr_reader :header, :data
def []=(key, value)
raise TSV::ReadOnly.new('TSV data is read only. Export data to modify it.')
end
def [](key)
if key.is_a? ::String
raise Unkno... |
require 'socket'
require 'eventmachine'
require 'xplane/configuration'
require 'xplane/data_mapper'
require 'xplane/message_data_formatter'
require 'xplane/message'
require 'xplane/connection'
require "xplane/version"
module Xplane
def self.on_data_received(&block)
listen_address = Xplane.config.listen_address
... |
class Post < ActiveRecord::Base
belongs_to :user
named_scope :approved, :conditions => "posts.approved=1"
named_scope :within_range, lambda{|address|
{:association=>{:source=>{:user=>:addresses}, :scope=>[:in_range, address.lat, address.lng, address.zip]}}
}
named_scope :published_in_month, lambda{|mon... |
Given /^I have an existing supplier named "([^"]*)"$/ do |name|
Factory.create(:supplier, :name => name, :address => Factory.create(:address))
end
|
require 'test_helper'
describe 'League' do
describe 'relations' do
it 'should have_many team through organizations' do
create :organization
league = League.first
team = Team.first
Organization.count.must_equal 1
League.count.must_equal 1
Team.count.must_equal 1
league.t... |
class PhoneNumberFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
unless value =~ /\A(\+?1( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4})\z/
object.errors[attribute] << (options[:message] || "enter a valid 10-digit number (e.g. 587-555-5555)")
end
... |
class Tutor::ParameterSanitizer < Devise::ParameterSanitizer
def initialize(*)
super
permit(:sign_up, keys: [:name, :phone_number, :specializations])
end
end |
def our_select(array)
counter = 0
result = []
while counter < array.size
result << array[counter] if yield(array[counter])
counter += 1
end
result
end
p our_select([1, 2, 3, 4, 5]) { |ele| ele > 3 }
p our_select([1, 2, 3, 4, 5]) { |ele| ele.odd? }
|
module Tix
class Seed
require_relative './jammin_java_importer'
@account = Account.find_or_create_by_subdomain('jamminjava')
def self.clear_data
Account.delete_all
Artist.delete_all
Event.delete_all
User.delete_all
end
def self.seed_data
seed_artists
seed_cu... |
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# no... |
Rails.application.routes.draw do
root to:'bmarks#index'
devise_for :users
resources :bmarks, only: [:index, :create, :destroy]
get '/find', to: 'bmarks#find'
end
|
class RemoveMessageUrl < ActiveRecord::Migration
def change
remove_column :guests, :message_url
end
end
|
require 'time'
require_relative "logging"
# monkey patch mongodb to get rid of
# ".. is an illegal key in MongoDB.
# Keys may not start with '$' or contain a '.'. (BSON::String::IllegalKey)"
module Mongo
module Protocol
# fool the monkey
class Message
def validating_keys?
false
end
e... |
class UpdateUser
attr_accessor :user, :organisation, :reset_mfa
def initialize(user:, organisation:, reset_mfa: false)
self.user = user
self.organisation = organisation
self.reset_mfa = reset_mfa
end
def call
result = Result.new(true)
User.transaction do
user.organisation = organisa... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
config.vm.define "cassandra", primary: true do |cassandra|
cassandra.vm.box ="debian-8.1-lxc... |
Gem::Specification.new do |spec|
spec.name = "maybe_client"
spec.version = "1.2.1"
spec.files = ["lib/maybe_client.rb"]
spec.authors = ["Jan Renra Gloser"]
spec.email = ["jan.renra.gloser@gmail.com"]
spec.summary = 'Wrapper for connection clients that handles outages without raising errors (and thus taking ... |
module BestInPlace
module Utils
extend self
def build_best_in_place_id(object, field)
if object.is_a?(Symbol) || object.is_a?(String)
return "best_in_place_#{object}_#{field}"
end
id = "best_in_place_#{object_to_key(object)}"
id << "_#{object.id}" if object.class.ancestors.in... |
class AddCounterCacheToHouses < ActiveRecord::Migration
def change
add_column :houses, :views_count, :integer, :default => 1
end
end
|
FactoryGirl.define do
factory :creator do
name 'Jaylen'
role 'artist'
factory :invalid_creator do
name nil
end
end
end
|
require "rails_helper"
require "sidekiq/testing"
RSpec.describe SendPatientOtpSmsJob, type: :job do
it "sends the OTP via SMS" do
passport_authentication = create(:passport_authentication)
app_signature = ENV["SIMPLE_APP_SIGNATURE"]
otp_message = "<#> #{passport_authentication.otp} is your BP Passport ve... |
#! /usr/bin/env ruby
# Credits:
# - Initial linux version: Gilles Filippini
# - Initial windows port : Marco Frailis
# - Currently maintained and developed by
# Martin DeMello <martindemello@gmail.com>
# fxri already includes Fox
#require "fox12"
require "irb"
require "singleton"
require "English"
require 'thre... |
class Api::V1::TasksController < ApplicationController
def index
@tasks = Task.all
render json: @tasks
end
def show
@task = Task.find_by(id: params[:id])
render json: @task
end
def create
@task = Task.new(task_params)
if @task.save
render json: @tas... |
class AddRedeemValueToPrize < ActiveRecord::Migration
def change
add_column :user_prizes, :status_prize_id, :integer
end
end
|
FactoryBot.define do
factory :member do
customer_code 1
first_name "MyString"
last_name "MyString"
email "MyString"
phone_number 1
next_of_kin_name "MyString"
next_of_kin_phone 1
next_of_kin_email "MyString"
address "MyString"
date_of_birth "2018-06-13"
referal_name "MyStri... |
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from "chat"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
def sendMsg(data)
if !data['id'].nil?
ActionCable.server.broadcast 'chat', msg: data['msg'], id: data['id'], type: data['type']
end
e... |
# frozen_string_literal: true
class AdvertisementService
def initialize(params = {})
@params = params
end
def show_all
retrieve_advertisements(user_id: @params[:user_id])
end
def show
retrieve_advertisements(
status: @params[:status],
id: @params[:advertisement_id]
)
end
pr... |
require 'bcrypt'
class User
include DataMapper::Resource
attr_reader :password
attr_accessor :password_confirmation
validates_confirmation_of :password
validates_format_of :email, :as => :email_address
property :id, Serial
property :name, String, required: true
property :us... |
require('rspec')
require('triangle')
describe(Triangle) do
describe('#equilateral?') do
it('determines if all three sides are the same length') do
test_triangle = Triangle.new(5, 5, 5)
expect(test_triangle.equilateral?()).to(eq(true))
end
end
describe('#isosceles?') do
it('determines if t... |
module Notifier
def Notifier.included(mod)
mod.class_eval do
has_many :notification_scopes, :as => :notifier
has_many :notification_listeners, :as => :notifier, :through => :notification_scopes do
def by_type(type)
find(:all).select {|nl| nl.notification_type_id == type.id}
... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(email: "user@example.com")
end
test "should be valid" do
assert @user.valid?
end
test "email should be present" do
@user.email = " "
assert_not @user.valid?
end
end
|
class Admins::CategoriesController < ApplicationController
before_action :authenticate_admin!, only: [:index, :create, :edit, :destroy]
def index
@category = Category.new
@categories = Category.all.page(params[:page]).reverse_order
end
def create
@category = Category.new(category_params)
if @category.save... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
respond_to :json
def home
render 'layouts/application'
end
def authenticate_user!
token, options = ActionController::HttpAuthentication::Token.token_and_options(request)
email = options.blank? ? ... |
# frozen_string_literal: true
require 'application_system_test_case'
class NewsFeatureTest < ApplicationSystemTestCase
def test_index_public
visit '/news'
assert_current_path '/news'
screenshot('index')
first('.card img').click
modal_selector = '#imageModal .modal-header > button.btn-close'
... |
module Microprocess
module HTTP
class Request
# Parses the "Range:" header, if present, into an array of Range objects.
# Returns nil if the header is missing or syntactically invalid.
# Returns an empty array if none of the ranges are satisfiable.
def byte_ranges(size)
# See <htt... |
module ListMore
class RepoHelper
attr_reader :db
def initialize dbname
db_data = if ENV['RACK_ENV'] == 'production'
parse_rds_string
else
{host: 'localhost', dbname: dbname}
end
@db = PG.connect(db_data)
end
def parse_rds_string
rds_string = ENV['DATABA... |
class CreateNotifiers < ActiveRecord::Migration[5.0]
def change
create_table :notifiers do |t|
t.integer "activity_id"
t.string "name"
t.boolean "enabled", default: true
t.boolean "on_new_comment", default: false
t.boolean "on_new_paper", default: false
t.boolean "on_paper_sta... |
class Gopass < FPM::Cookery::Recipe
description 'slightly more awesome standard unix password manager for teams'
name 'gopass'
version '1.4.1'
revision '1'
homepage 'https://github.com/justwatchcom/gopass/releases'
source "https://github.com/justwatchcom/gopass/releases/download/v#{version}/gopass-... |
class Api::V1::Movies::ModelPolicy
def initialize(user, movie)
@user = user
@movie = movie
end
def show?
user.present?
end
def create?
user.admin?
end
def destroy?
create?
end
def update?
create?
end
attr_reader :user, :movie
end |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
Dir.glob(["./source/ja/*.md", "./source/ja/*.yaml"]) do |filename|
text = File.read(filename)
puts "\tReplace: #{filename} ..."
# Global replacement
unless %w(release_notes upgrading_ruby_on_rails).any? { |s| filename.include? s }
text.gsub! "bin/rake", "bin/rai... |
class AddCashOnDeliveryToProducts < ActiveRecord::Migration
def change
add_column :products, :cash_on_delivery, :string, null: false, default: '支持货到付款'
end
end
|
class DatasetDownloadsController < GpdbController
def show
dataset = Dataset.find(params[:dataset_id])
@streamer = DatasetStreamer.new(dataset, current_user, params[:row_limit])
response.headers["Content-Disposition"] = "attachment; filename=#{dataset.name}.csv"
response.headers["Cache-Control"] = 'no... |
class Admin::AccountsController < Admin::AdminController
before_filter :authenticate_organization_admin!
def index
@accounts = current_organization_admin.organization.accounts
end
def new
@account = Account.new
end
def edit
@account = Account.find params[:id]
end
def destroy
@accoun... |
require 'spec_helper'
describe ClientAuth::Authenticator do
subject { authenticate }
let(:authenticate) { described_class.new(request, rsa_key).authenticate! }
let(:request_method) { 'GET' }
let(:client_name) { 'client_name' }
let(:fullpath) { '/anonymous' }
let(:body) { double(:request_body, read: '') }
... |
require_relative "board"
class Knight < Piece
#include SlidingPiece
attr_reader :position
def initialize(position, value = "K")
@position = position
@value = value
end
def moves
end
end
|
module ArchivesHelper
def delete_warning_message(archive)
text = "Are you sure you want to delete this archive?"
unless archive.can_delete_for_free?
text << " There will be an AWS charge associated since this archive is less than 90 days old."
end
text.html_safe
end
def archive_status_conte... |
class AsteroidSerializer < ActiveModel::Serializer
alias :read_attribute_for_serialization :send
attributes :name, :is_potentially_hazardous_asteroid
def name
object.name
end
def is_potentially_hazardous_asteroid
object.hazardous
end
end
|
module ElasticsearchHelper
MAX_SEARCH_RESULTS = 50
def prefix_match(model, field, prefix, condition)
prefix = sanitize(prefix)
search_params = { query: { query_string: { query: "#{prefix}*", analyze_wildcard: true, fields: [field] } } }
results = if Rails.env == "test"
# Return all reco... |
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
When /^I upload photo "([^\"]*)"$/ do |file|
When "I go to photos"
When "I follow \"Add new photo\""
When "I attach the file \"#{file}\" to \"photo\""
When "I press \"Upload\""
end
Given /^I have uploaded (\d+) photos?$/ do ... |
#!/usr/bin/env ruby
#
# Copyright (C) 2016 Google Inc.
#
# 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 l... |
class VotesController < ApplicationController
def upvote
@vote = Vote.new(user_id: session[:user_id], work_id: params[:work_id])
if @vote.save
flash[:message] = "Successfully upvoted!"
redirect_back(fallback_location: works_path)
else
if @vote.errors.messages.include?(:user_id)
... |
# This resource represents an individual Forum Topic within the system. It
# contains all of the properties and associations for a Topic.
#
# [UUID] The typical use case for retrieving Topic resources is through an
# owner resource (e.g. User, Forum, etc.), so the need for client
# applications to... |
class Playlist < ApplicationRecord
belongs_to :account
has_many :movies
end
|
require 'test_helper'
class UniversityChoicesControllerTest < ActionDispatch::IntegrationTest
setup do
@university_choice = university_choices(:one)
end
test "should get index" do
get university_choices_url
assert_response :success
end
test "should get new" do
get new_university_choice_url
... |
require 'rails_helper'
RSpec.describe Event, type: :model do
let(:user) { User.create(name: 'Elijah') }
let(:user2) { User.create(name: 'Lucas') }
describe 'validation' do
let(:event_valid) { user.created_events.create(title: 'This is a valid title') }
let(:event_invalid) { user.created_events.create(ti... |
module SqlMigrations
class Fixture < SqlScript
def self.find(db_name)
super(db_name, :fixture)
end
def to_s
"Fixture #{@name}, datetime: #{@date + @time}"
end
end
end
|
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... |
require 'test_helper'
describe Subcheat::Svn do
before do
@info = <<-EOS
Path: .
URL: https://some-kind-of-svn.com/svn/project_name/branches/languages
Repository Root: https://some-kind-of-svn.com/svn
Repository UUID: 11af7ba9-5ee7-4c51-9542-47637e3bfceb
Revision: 8049
Node Kind: directory
Schedule: normal
Last ... |
require 'test_helper'
class RecipeTest < ActiveSupport::TestCase
def setup
@chef=Chef.create(chefname: "vaibhav",email: "vsinghal85@gmail.com")
@recipe=@chef.recipes.build(name: "Chicken parm" ,summary:"This is the best chicken parm recipe ever " ,
description: "heat oil,add onions,add tomato sauce,add chicken,cook ... |
module VagrantPlugins
module Beaker
module Provider
module VSphereActions
class PowerOffVM
def initialize( app, env )
@app = app
@logger = Log4r::Logger.new( 'vagrant_plugins::beaker::provider::vsphere_actions::power_off_vm' )
end
def call( env ... |
class PricesController < ApplicationController
def edit
user = current_user.email
@prices = Price.where(user: user).order("original_price ASC NULLS LAST")
@login_user = current_user
if request.post? then
data = params[:price_edit]
if data != nil then
ext = File.extname(data.path)... |
# frozen_string_literal: true
# This abstract class specifies the interface a backend implementation should conform to.
# @abstract
class StatsD::Instrument::Backend
# Collects a metric.
#
# @param metric [StatsD::Instrument::Metric] The metric to collect
# @return [void]
def collect_metric(_metric)
rais... |
class CreateHaircoefficients < ActiveRecord::Migration
def change
create_table :haircoefficients do |t|
t.string "userid"
t.datetime "timedate"
t.float "capmain"
t.float "capalt1"
t.float "capalt2"
t.float "regmain"
t.float "regalt1"
t.float "regalt2"
t.timestamps
end
end
end
|
require 'intercom/traits/api_resource'
module Intercom
module ExtendedApiOperations
module BulkCreate
MAX_BATCH_SIZE = 50
def bulk_create(resources)
unless resources.is_a? Array
raise ArgumentError, '.bulk_create requires Array parameter'
end
collection_name = Util... |
# == Schema Information
#
# Table name: portals
#
# id :integer not null, primary key
# founder :integer default(1)
# datefounded :datetime
# title :string(255)
# header :string(255)
# users_count :integer default(0)
# created_at :datetime not null
# u... |
class AdminsController < ApplicationController
before_filter :authenticate_user!
authorize_resource :class => false
layout :get_layout
def search_admin #allows admin to search and unblock/block users
end
def search_results_admin
search_key = params[:search_key]
search_type = pa... |
class Account < ActiveRecord::Base
belongs_to :authority
has_many :readings
has_and_belongs_to_many :users
end
|
Rails.application.routes.draw do
get 'reports/index'
post '/users', to: 'users#create', as: :users_create_path
patch '/users', to: 'users#update', as: :users_update_path
devise_for :users, controllers: {
sessions: 'users/sessions',
passwords: 'users/passwords',
registrations: 'users/registrat... |
class Categorring < ApplicationRecord
belongs_to :tutorial
belongs_to :category
end
|
class CreateEasyTranslations < ActiveRecord::Migration
def up
create_table :easy_translations do |t|
t.references :entity, :polymorphic => true
t.string :entity_column, :null => false
t.string :lang, :null => false, :default => 'en'
t.string :value
t.timestamps
end
add_inde... |
class UsersController < ApplicationController
def index
if params[:filter] == 'recent_posts'
@filter_link_text = 'MOST POSTS'
@filter_link = 'post_count'
@users = User.order_by_most_recent_post.page(params[:page]).per(21)
else
@filter_link_text = 'RECENT POSTINGS'
@filter_link = ... |
require 'haml'
require 'sinatra'
require 'sinatra/partial'
require 'active_model'
require 'mail'
class Portfolio < Sinatra::Base
register Sinatra::Partial
configure :development do
enable :logging
end
# configure Mail defaults
# Mail.defaults do
# delivery_method :smtp, {
# :address ... |
require "rails_helper"
RSpec.describe Admin::RoomsController, type: :controller do
let! (:user_admin){FactoryBot.create :user, role: :admin}
before {log_in user_admin}
describe "GET #new" do
before{get :new}
it "assigns a blank room to the view" do
expect(assigns(:room)).to be_a_new Room
end
... |
class EmployeesController < ApplicationController
def index
@employees_active = Employee.active.sort_by_type.sort_name
@employees_inactive = Employee.inactive.sort_by_type.sort_name
@employees = Employee.all
end
def new
@employee = Employee.new
end
def create
@employee = Employee.new(employee_params)
... |
class DeleteAmountFromPledges < ActiveRecord::Migration
def change
remove_column :pledges, :amount
end
end
|
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# env :GEM_PATH, ENV['GEM_PATH']
set :environment, ENV['ENVIRONMENT']
require File.expand_path(File.dirname(__FILE__) + "/environment")
set :outp... |
# Problem: take a string and return a new string with all letters alternating
# being capitalized
# Input: String
# Output: String
# Steps:
# 1: Define a method and output the original string
# 2: intialize a new string and counter
# 3: itterte over the string
# - if counter == odd downcase, else counter = ... |
require_relative 'card'
class Deck
@names = %w( 2 3 4 5 6 7 8 9 10 Jack Queen King Joker Ace )
@suits = %w( spades clubs hearts diamonds )
class << self
attr_reader :names, :suits
end
attr_reader :cards
def initialize
@cards = []
self.class.names.each do |name|
self.class.suits.each do |suit|
@c... |
class CreatePayrollEntries < ActiveRecord::Migration
def change
create_table :payroll_entries do |t|
t.integer :employee_id
t.integer :payroll_id
t.decimal :wage, :precision => 8, :scale => 2, :default => 0
t.decimal :bonus, :precision => 8, :scale => 2, :default => 0
t.decimal :dedu... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'tact/version'
Gem::Specification.new do |spec|
spec.name = "tact"
spec.version = Tact::VERSION
spec.authors = ["ollieshmollie"]
spec.email = ["oliverduncan@ic... |
# _____ ______
# | __ \ | ____|
# | |__) | _ _ __ ___ ______| |__ _ __ ___ _ _
# | _ / | | | '_ \ / _ \______| __| | '_ ` _ \| | | |
# | | \ \ |_| | | | | __/ | |____| | | | | | |_| |
# |_| \_\__,_|_| |_|\___| ... |
class FileInput < Formtastic::Inputs::FileInput
def to_html
val = object.send(method)
html = ""
if val.class.to_s == "Paperclip::Attachment"
html = template.image_tag(val, :class => "paperclip_image")
end
html += super
html.html_safe
end
end
|
=begin
#BombBomb
#We make it easy to build relationships using simple videos.
OpenAPI spec version: 2.0.24005
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obta... |
# frozen_string_literal: true
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'alpha_card/version'
Gem::Specification.new do |gem|
gem.name = 'alpha_card'
gem.version = AlphaCard.gem_version
gem.summary = 'Alpha Card Services API for Ruby'
gem.description = 'Gem for creating sales with A... |
cask "tomtom-mydrive-connect" do
version "4.2.13.4586"
sha256 :no_check
url "https://cdn.sa.services.tomtom.com/static/sa/Mac/TomTomMyDriveConnect.dmg"
name "TomTom MyDrive Connect"
desc "Update your TomTom navigation device"
homepage "https://www.tomtom.com/mydrive-connect/"
livecheck do
skip "No r... |
class PagesController < ApplicationController
include ThylogaleUtils
before_action :set_page, only: [:show, :preview, :preview_asset, :raw, :publish, :update, :destroy]
protect_from_forgery except: :preview_asset
def show
end
def preview
render body: @page.preview_view_normalized_data, content_type: ... |
json.array!(@lessons) do |lesson|
json.extract! lesson, :id
json.url course_lesson_url(@course, lesson, format: :json)
end
|
require 'rails_helper'
RSpec.describe Shampoo, type: :model do
subject { shampoo }
describe 'create shampoo' do
let(:shampoo) { build(:shampoo, params) }
context 'when not presence shampoo' do
let(:params) { { name: '' } }
it { is_expected.to be_invalid }
end
context 'when not prese... |
Gem::Specification.new do |s|
s.name = 'malone'
s.version = "0.0.2"
s.summary = %{Dead-simple Ruby mailing solution which always delivers.}
s.date = "2011-01-10"
s.author = "Cyril David"
s.email = "cyx@pipetodevnull.com"
s.homepage = "http://github.com/cyx/malone"
s.specification_version = 2 if s.respo... |
require 'rspec'
require './longest_substring'
describe LongestSubstring do
before do
@t1 = Time.now
end
after do
@t2 = Time.now
elapsed_time = @t2 - @t1
puts "Time elapsed: #{ '%.04f' % (elapsed_time * 1000)} ms"
end
context 'returns entire string if >= 2 distinct characters' do
specify... |
class Lead < ActiveRecord::Base
validates :email, :name, :phone_number, presence: true
end
|
require 'spec_helper'
describe Rounders::Receivers::Receiver do
let(:described_class) { Rounders::Receivers::Receiver }
let(:described_instance) { described_class.new(*arguments) }
let(:arguments) { [] }
let(:config) { Rounders::Receivers::Receiver::Config.new }
let(:messages) do
day = Date.today
(1.... |
class DelLineprsCols < ActiveRecord::Migration[5.0]
def change
remove_column :lineprs, :l2
remove_column :lineprs, :p2
end
end
|
require 'test_helper'
class ProductrequestsControllerTest < ActionController::TestCase
setup do
@productrequest = productrequests(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:productrequests)
end
test "should get new" do
get :new
a... |
require 'omniauth-google-oauth2'
require 'openid/store/filesystem'
require 'securerandom'
module Sinatra
module GoogleAuth
class Middleware
def initialize(app)
@app = app
end
def call(env)
if env['rack.session']["user"] || env['REQUEST_PATH'] =~ /\/auth\/google_oauth2/
... |
# Copyright (c) 2006, 2007 Ruffdogs Software, Inc.
# Authors: Adam Lebsack <adam@holonyx.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program ... |
class CreateItems < ActiveRecord::Migration[5.2]
def change
create_table :items do |t|
t.string :item_name
t.integer :item_price
t.integer :item_quantity
end
end
end
|
# encoding: UTF-8
# Copyright 2011-2013 innoQ Deutschland 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 appli... |
class ProcessEventJob < ActiveJob::Base
queue_as :default
def perform(event: , raw_input:)
EventProcessor
.new(event: event, raw_input: raw_input)
.process
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.