text stringlengths 10 2.61M |
|---|
class CompanySettingsController < ApplicationController
skip_before_action :set_company
before_action :set_company_settings_object, only: [:update, :destroy]
before_filter :authenticate_user!
layout "user_dashboard"
load_and_authorize_resource
# def create
# @company_setting = CompanySetting.create(... |
class CreateBuildings < ActiveRecord::Migration
def change
create_table :buildings do |t|
t.string :address
t.string :borough
t.string :owner
t.integer :stories
t.integer :units
t.timestamps
end
end
end
|
class SubscriptionsMailer < ApplicationMailer
include Roadie::Rails::Automatic
def activate(user)
@user = user
mail to: @user.email, subject: "¡#{genderize("Bienvenido", "Bienvenida", @user)} a Make it Real! Activa tu cuenta"
end
def welcome_slack(user)
@user = user
mail to: @user.email, su... |
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../fixtures/classes'
describe "Implementing IEnumerable from IronRuby" do
it "uses the enumerator method defined" do
list = TestList.new
list << "a"
Tester.new.test(list).should include "a"
end
it "uses the enum... |
FactoryBot.define do
factory(:park) do
area {Faker::Number.number(digits: 10)}
description {Faker::Movie.quote}
name {Faker::Mountain.name}
state {Faker::Address.state}
end
factory(:bird) do
family_name {Faker::Creature::Bird.common_family_name}
common_name {Faker::Creature::Bird.common_na... |
class MessagesController < ApplicationController
before_action :authenticate_user!, only: :create
def index
@group = Group.find(params[:group_id])
@groups = current_user.groups
@message = Message.new
@users = @group.users
end
def create
@message = current_user.messages.new(create_params)
... |
class CreateAccounts < ActiveRecord::Migration[6.0]
def change
create_table :accounts do |t|
t.string :nome
t.string :telefone
t.string :cpf
t.decimal :saldo, precision: 8, scale: 2
t.string :status
t.timestamps
end
end
end
|
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :user_group_membership do |f|
f.association :user_group
f.association :user
# Make sure that the User is a member of the Tenant.
f.after_build do |instance|
FactoryGirl.create(:tenant_membersh... |
# Jenkins Pullover Daemon
# Author:: Sam de Freyssinet (sam@def.reyssi.net)
# Copyright:: Copyright (c) 2012 Sittercity, Inc. All Rights Reserved.
# License:: MIT License
#
# Copyright (c) 2012 Sittercity, Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software a... |
class ApplicationController < ActionController::Base
protect_from_forgery
# include ActionController::MimeResponds
# include SessionsHelper
# ログイン済ユーザーのみにアクセスを許可する
# before_action :authenticate_user!
# deviseコントローラーにストロングパラメータを追加する
before_action :configure_permitted_parameters, if: :devise_controller?
... |
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
describe GChart::Map do
before(:each) { @chart = GChart::Map.new }
it "initializes to a default area of 'world'" do
@chart.area.should == 'world'
end
it "defaults to maximum size of 440x220" do
@chart.size.should == '440x220'
end
... |
class Disk < Product
def update(options)
@album = options[:album_name]
@artist_name = options[:artist_name]
@genre = options[:genre]
end
def info
return "Диск \"#{@album_name}\", исполнитель #{@artist_name} (#{@genre})"
end
end |
class PigLatinizer
attr_reader :text
def initialize
# @text = text
end
def piglatinize(text)
@text = text
#split text into an array of words
words = @text.split(" ")
#collect pig latin versions of words
pig_words = words.map do |word|
#find first vowel as an index of the array ([... |
class ApplicationController < ActionController::API
include ::ActionController::Serialization
before_action :set_current_user
before_action :ensure_authentication
private
def set_current_user
@current_user = User.where(api_key: request.headers['HTTP_API_KEY']).first
end
def ensure_authentication
... |
require 'rails_helper'
require "mathdojo"
describe MathDojo do
it "adds" do
expect(MathDojo.new.add(3,8).result).to eq(11)
end
it "adds arrays" do
expect(MathDojo.new.add([1,3,5,9]).result).to eq(18)
end
it "subtracts" do
expect(MathDojo.new.subtract(3,4).result).to eq(-7)
end
it "subtracts ar... |
require 'spec_helper'
describe CrossSellProduct do
it "is invalid without a option" do
FactoryGirl.build(:cross_sell_product, option: nil).should_not be_valid
end
it "is invalid with a option 'a' and if product will be not present " do
FactoryGirl.build(:cross_sell_product, option: "a", product: ni... |
class BackupJobsController < ApplicationController
load_and_authorize_resource :backup_job
before_filter :spread_breadcrumbs
def index
end
def show
end
def new
# Do the same as create.
#
@backup_job = BackupJob.new(:started_at => Time.now)
if @backup_job.save
redirect_to backup_... |
class DatasetImplementationIssuesController < ApplicationController
# GET /dataset_implementation_issues
# GET /dataset_implementation_issues.xml
def index
@page_title = "Issues with VDW Dataset Implementations"
@dataset_implementation_issues = DatasetImplementationIssue.all
respond_to do |format|
... |
##
# Copyright 2017-2018 Bryan T. Meyers
#
# 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 to in w... |
module MaxemailApiSubscriptions
extend self
include MaxemailApiShared
def subscribe(email_address:, list_id:)
return MaxemailApiShared.send_request(params: { method: 'insertRecipient', data: { email_address: email_address, subscribed: 1 }.to_json, listID: list_id }, method: 'list') unless inserted?(email_add... |
class ApplicationController < ActionController::Base
before_action :set_locale
def set_locale
if verify_locale(params[:locale])
cookies[:locale] = params[:locale]
end
if cookies[:locale] && I18n.locale != cookies[:locale]
I18n.locale = cookies[:locale]
end
end
def verify_locale(lo... |
class SitemapsController < ApplicationController
def show
@stores = Store.active
@products = Product.published
@brands = Brand.active
@posts = Post.published
@tags = ActsAsTaggableOn::Tag
end
end |
# = placemark.rb - Yahoo! Geo Placemaker Placemark object
#
# Copyright © 2010 Joseph Bauser
#
require 'rubygems'
require 'hpricot'
module YahooGeo
module Placemaker
# == Overview
#
# A placemark is a parsed Placemaker response including the
# place's WOEID, type, name, and place bounding rect... |
class SampleNameChangeColumnType2 < ActiveRecord::Migration[5.0]
def change
rename_column :community_areas, :Description, :description
end
end
|
#Transformar la clase Herviboro en un módulo.
#Implementar el módulo en la clase Conejo mediante Mixin para poder acceder al método dieta desde la instancia.
#Finalmente imprimir la definición de Hervíboro.
class Herviboro
Definir = 'Sólo me alimento de vegetales!'
def definir
Definir
end
def ... |
class Thinginstance < ActiveRecord::Base
attr_accessible :number, :thing_id, :user_id
belongs_to :user
belongs_to :thing
def pronounce
if self.number > 1 or self.number == 0 then name = self.thing.pluralname
else name = self.thing.singularname
end
self.number.to_s + ' ' + name
end
def value
... |
class SignupNotify < ActionMailer::Base
default from: "zibs.shirsh@gmail.com"
def successful_signup(user)
@user=user
@url='http://localhost/'
mail to: @user.email, subject: 'Welcome Aboard'
end
end
|
require 'test_helper'
class SearchEngiensControllerTest < ActionController::TestCase
setup do
@search_engien = search_engiens(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:search_engiens)
end
test "should get new" do
get :new
assert... |
require_relative "board"
require "byebug"
class Game
attr_accessor :board, :previous_guess
def initialize
@board = Board.new
@previous_guess = []
self.play
end
def play
print "Welcome to Memory Puzzle!"
until board.won?
board.render
prin... |
class ChangeSalutationToSalutationTemplateForContacts < ActiveRecord::Migration
def self.up
rename_column :contacts, :salutation, :salutation_template
end
def self.down
rename_column :contacts, :salutation_template, :salutation
end
end
|
class AddEmailFullNameToComments < ActiveRecord::Migration
def change
add_column :comments, :email, :string
add_column :comments, :full_name, :string
end
end
|
json.array!(@coordinator_semesters) do |coordinator_semester|
json.extract! coordinator_semester, :id, :coordinator_id, :semester_id, :notes
json.url coordinator_semester_url(coordinator_semester, format: :json)
end
|
Gem::Specification.new do |s|
s.name = %q{cast}
s.version = "0.1.0"
s.date = %q{2006-04-25}
s.summary = %q{C parser and AST constructor.}
s.email = %q{george.ogata@gmail.com}
s.homepage = %q{http://cast.rubyforge.org}
s.rubyforge_project = %q{cast}
s.autorequire = %q{cast}
s.authors = ["Georg... |
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2023, by Samuel Williams.
require_relative 'output/default'
require_relative 'output/json'
require_relative 'output/text'
require_relative 'output/xterm'
require_relative 'output/null'
module Console
module Output
def self.new(outpu... |
# Encoding: utf-8
#
# Cookbook Name:: vim-go
# Recipe:: default
#
# Copyright 2015, Mist Systems, 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/L... |
#tag: skill action
module TSBS
Staff_Icons = {
# Raise the staff
"Staff-RAISE" => [4, 0, 0, true, -30,-30,1,-1],
"Xbow-RAISE" => [0,-4,-12, true, -30,45,1,-1],
# Small rotation
"Staff-Rotate1" => [4, 0, 0, true, -30,0,10,-1],
# Heavy Rotation... I mean, Big rota... |
WhoRunIt::Application.routes.draw do
# Sessions
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
# Root
root to: 'events#new'
# Events
resources :events
# Routes
resources :routes
get "/routes/:id/remove", to: "routes#remove"... |
# @param {Integer} left
# @param {Integer} right
# @return {Array<Integer>}
def self_dividing_numbers(left, right)
self_divisors = []
for i in left..right do
if is_self_dividing(i)
self_divisors.push(i)
end
end
self_divisors
end
# @param {Integer} num
# @return Boole... |
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and t... |
class Friend < ActiveRecord::Base
belongs_to :user
attr_accessible :facebook_id, :memo, :user_id, :name, :link
def self.create_new_by_facebook_api(token)
user = User.find_by_token(token)
graph = Koala::Facebook::API.new(token)
friends = graph.get_connections("me", "friends")
friends.each do |frie... |
#############
# Iteration #
#############
def countdown(n)
while n >= 1 do
puts "iterative countdown " + n.to_s
n -= 1
end
end
#############
# Recursion #
#############
def countdown(n)
if n <= 1 # base case
puts "recursive countdown " + n.to_s
else
puts "recursive countdown " + n.to_s
countdo... |
# SyntaxError: (irb):2: syntax error, unexpected ')', expecting '}'
# from /usr/local/rvm/rubies/ruby-2.0.0-rc2/bin/irb:16:in `<main>'
#
# The error above tells me that a hash was opened with '{' but never closed.
# It was likely accidentally closed with a ')' instead of the expected '}'.
|
class Room
attr_accessor :number, :guests
def initialize(number, guests)
@number = number
@guests = guests
end
def add_guests(input_guests)
@guests = []
for guest in input_guests
@guests.push(guest)
end
end
def checkout_guests(leaving_guests)
@guests.delete_if{|guest| leavi... |
require "integration/factories/collection_factory"
class InstanceGroupsFactory < CollectionFactory
def initialize(example)
super(Fog::Compute[:google].instance_groups, example)
end
def get(identity)
@subject.get(identity, TEST_ZONE)
end
def all
@subject.all(zone: TEST_ZONE)
end
def params
... |
class Public::MusicsController < ApplicationController
def index
@musics = Music.page(params[:page]).reverse_order
end
def search
@musics = Music.search(params[:search])
end
def show
@music = Music.find(params[:id])
@band = Band.find(@music.band_id)
end
def new
@music = Music.new
... |
Gem::Specification.new do |s|
s.name = "xen"
s.version = "0.0.3"
s.date = "2010-04-17"
s.authors = ["nico"]
s.email = "nico@rottenbytes.info"
s.rubyforge_project = "xen"
s.has_rdoc = false
s.summary = "Library for accessing Xen informations"
s.homepage = "http://www.github.com/rottenbytes/ruby-xen"
... |
class AddBasePriceToUsers < ActiveRecord::Migration
def change
add_column :users, :base_price, :decimal, :precision => 8, :scale => 2, :default => 70.00
end
end
|
# encoding: binary
# frozen_string_literal: true
RSpec.describe RbNaCl::OneTimeAuth do
let(:key) { vector "auth_key_#{described_class.key_bytes}".to_sym }
let(:message) { vector :auth_message }
let(:tag) { vector :auth_onetime }
context ".new" do
it "raises ArgumentError on a key which is too long... |
require 'rails_helper'
RSpec.describe Item, type: :model do
describe '#create' do
context 'can save' do
it 'is valid with title,explanation,image,video' do
expect(create(:item)).to be_valid
end
it "it Even if you don't have an image, a video will work" do
expect(create(:item, i... |
require 'rails_helper'
describe Meta::MapsController do
before(:all) do
@game = create(:game)
@admin = create(:user)
@admin.grant(:edit, :games)
@user = create(:user)
end
describe 'GET #index' do
it 'succeeds for authorized user' do
sign_in @admin
get :index
expect(resp... |
require 'pry'
class MembersController < ApplicationController
def index
@group = Group.find(member_params.group_id)
@member.where(group_id: @group.id)
end
def new
@group = Group.find(params[:group_id])
@member = Member.new(group: @group)
end
def create
@member = Member.new(member_p... |
class AddItemToDocuments < ActiveRecord::Migration[5.0]
def change
add_reference :documents, :item, foreign_key: true
end
end
|
require 'bundler/setup'
require 'sinatra'
require 'json'
require 'tempfile'
require 'sinatra/cross_origin'
require_relative 'form_filler.rb'
require 'pry'
configure do
enable :cross_origin
end
options '/sf2809' do
halt 200
end
post '/sf2809' do
begin
json_params = JSON.parse(request.body.read)
form = S... |
class CreateNotes < ActiveRecord::Migration
def change
create_table :notes do |t|
t.integer :user_id, null: false
t.string :header, null: false
t.string :text, null: false
t.datetime :date, null: false
t.timestamps
end
add_index(:notes, [:header, :date], :unique => true)
end
en... |
require "rails_helper"
require "rack/mock"
describe OauthStateMiddleware do
context "using site id from site" do
before do
@site = FactoryBot.create(:site)
@user = FactoryBot.create(:user)
@site = FactoryBot.create(:site)
@app_callback_url = "http://atomic.example.com"
@payload = {
... |
# RSence 'Welcome' plugin.
# An instance of a class extended from GUIPlugin includes basic functionality
# to initialize their user interface from YAML files without extra code.
class WelcomePlugin < GUIPlugin
def gui_params( msg )
params = super
params[:text] = {
:welcome => file_read('text/welcome... |
class Jarvis::ScheduleParser < Jarvis::Action
def attempt
return unless valid_words?
::Jarvis::Schedule.schedule(
scheduled_time: @scheduled_time,
user_id: @user.id,
words: @remaining_words,
type: :command,
)
@response = "I'll #{Jarvis::Text.rephrase(@remaining_words)} #{natur... |
class LazyLockStrategy
def self.display_code(lock_code)
# decide whether to go up or down
direction = [1, -1].sample
digits = (0..9).to_a
# rotate each dial by <= 4 spots in direction
lazy_code = lock_code.map do |n|
digits.rotate(direction * (1 + rand(4)))[n]
end
lazy_code
end
en... |
require 'spec_helper'
require 'spaces/interactors/updates_spaces'
require 'spaces/entities/space'
module Spaces
describe UpdatesSpaces do
let(:repo) { Repository.for(:space) }
after :each do
repo.clear
end
it "receives no params and does nothing" do
saved_space = repo.save Space.new(nam... |
class Admin::SettingController < Admin::BaseController
load_and_authorize_resource
def current_issue
@setting = Setting.find_or_create_by_meta_key("current_issue")
end
def block_placements
@settings = Setting.where(meta_key: "block_placement")
end
def create
@setting = Setting.new(params[:s... |
require 'test_helper'
class CurrencyTest < ActiveSupport::TestCase
test '#converted_value returns a valid conversion with exchange rate 1' do
assert_includes 97..98, Currency.converted_value(100, 'CAD')
end
end
|
require 'test_helper'
class Admin::LogsControllerTest < ActionController::TestCase
include Devise::TestHelpers
def setup
john_smith = User.find_by_email("john.smith@mmu.ac.uk")
sign_in john_smith
end
test "should get index" do
get :index
assert_response :success, "Could not render show all ... |
module Mirror
module Helpers
include Mirror::Inflections
# Gera uma sentença com uma array
def sentence(array)
array.to_sentence :last_word_connector => " and "
end
# Flexiona a palara para plurar ou singular
def inflect(word,count)
if count>1
word.pluralize
... |
class SessionsController < ApplicationController
def create
@user = User.find_by_github_uid(omniauth["uid"]) || User.create_from_omniauth(omniauth)
self.current_user = @user
redirect_to user_omniauth_callback_path(:github)
end
protected
def omniauth
request.env['omniauth.auth']
end
end
|
FactoryGirl.define do
factory :career, :class => Refinery::Careers::Career do
sequence(:career_title) { |n| "refinery#{n}" }
end
end
|
class AddStatusToReview < ActiveRecord::Migration
def change
add_column :reviews, :status, :integer
add_column :reviews, :moderation_status, :integer
end
end
|
class Oystercard
MAXIMUM_BALANCE = 90
attr_reader :balance, :MAXIMUM_BALANCE, :in_journey
def initialize
@balance = 0
@in_journey = false
end
def top_up(amount)
fail 'Maximum balance exceeded' if amount + balance > MAXIMUM_BALANCE
@balance += amount
end
def deduct(amount)
@bal... |
module Istisnalar
class Tip < TypeError
end
class Yukleme < LoadError
end
class Dizilim < SyntaxError
def message
"Yazım Hatası"
end
end
end
raise Istisnalar::Dizilim
|
module Refinery
module Bookings
class Setting < Refinery::Core::BaseModel
class << self
def confirmation_body
Refinery::Setting.find_or_set(:booking_confirmation_body,
"Thank you for your booking %name%,\n\nThis email is a receipt to confirm we have received your booking and w... |
class User < ApplicationRecord
include Memery
include Flipperable
include PgSearch::Model
AUTHENTICATION_TYPES = {
email_authentication: "EmailAuthentication",
phone_number_authentication: "PhoneNumberAuthentication"
}
APP_USER_CAPABILITIES = [:can_teleconsult].freeze
CAPABILITY_VALUES = {
t... |
# input: Integer (total number of switches)
# output: array (which lights are on after n repetitions)
# Switches numbered from 1 to n
# Each switch connected to 1 light that is initially off
# Go through row of switches and toggle all of them
# Go back to beginning for second iteration, toggle switches 2,4,6 ...
# For ... |
class ContentPagesController < ApplicationController
before_action :set_main_page, only: [:show, :edit, :update, :destroy]
# GET /
def index
@pictures = Picture.front_page_set
@cache_buster = "?cb=#{Time.now.to_i}"
render :layout => 'main_page'
end
def faq
@title = 'FAQ'
end
def his... |
Rails.application.routes.draw do
namespace :api, defaults: {format: 'json'} do
namespace :v1 do
resources :profiles, only: [:index, :show]
end
end
root 'ember#bootstrap'
get '/*path' => 'ember#bootstrap'
end
|
# frozen_string_literal: true
class CustomStylesController < ApplicationController
before_action :set_custom_style, only: %i[show edit update destroy]
# GET /custom_styles
def index
@custom_styles = CustomStyle.all
end
# GET /custom_styles/1
def show; end
# GET /custom_styles/new
def new
@cu... |
class Member < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :trackable
# Setup accessible (or protected) attributes for your model
# attr_accessible :remember_me
# attr_accessible :ti... |
# == Schema Information
#
# Table name: categories
#
# id :bigint not null, primary key
# depth :integer
# lft :integer
# name :string
# rgt :integer
# slug :string
# created_at :datetime not null
# updated_at :datetime not null
# parent_id :int... |
get "/send/:survey_id/tweet" do
if authorized?(params[:survey_id])
@survey = current_survey(params[:survey_id])
erb :"/send/send_tweet"
else
get_failure
erb :index
end
end
post "/send/:survey_id/tweet" do
@survey = current_survey(params[:survey_id])
if authorized?(params[:survey_id])
ha... |
# encoding: utf-8
control "V-53997" do
title "Connections by mid-tier web and application systems to the Oracle DBMS from a DMZ or external network must be encrypted."
desc "Multi-tier systems may be configured with the database and connecting middle-tier system located on an internal network, with the database loca... |
module HiveMindHive
class Plugin < ActiveRecord::Base
has_one :device, as: :plugin
has_many :runner_version_history
def self.create(*args)
if args[0].keys.include? 'version'
version = args[0]['version']
args[0].delete('version')
end
hive = super(*args)
hive.update... |
class CreateElectionsParticipatedUsers < ActiveRecord::Migration
def change
create_table :elections_participated_users do |t|
t.integer :user_id
t.integer :election_id
t.timestamps null: false
end
end
end
|
class AddMesaToList < ActiveRecord::Migration
def change
add_column :lists, :mesa_n, :string
end
end
|
# More on Iteration and arrays
## Basic While Loop
array_one = ["Fish", "Cat", "Dog", "Bird"]
x = 0
while x < array_one.length
puts array_one[x]
x += 1
end
## Basic Until Loop
array_two = ["Baboon", "Cheetah", "Elephant", "Zebra"]
y = 0
until y >= array_two.length
puts y
puts array_two[y]
y += 1
end
... |
module APICoder
module Commands
class Mock < Thor::Group
argument :config_file
class_option :port, type: :numeric, default: 8080
class_option :host, type: :string, default: '0.0.0.0'
def mock
require 'rack'
require 'rack/api_coder'
load config_file
Rack:... |
module Types::Inclusions
module AnnotationBehaviors
extend ActiveSupport::Concern
included do
implements GraphQL::Types::Relay::Node
global_id_field :id
field :id, GraphQL::Types::ID, null: false
field :annotation_type, GraphQL::Types::String, null: true, camelize: false
field... |
Capistrano::Configuration.instance.load do
namespace :db do
desc "Load seed data into Mongoid database"
task :seed_fu do
run %{cd #{release_path} && bundle exec rake RAILS_ENV=#{rails_env} db:seed_fu}
end
end
after 'deploy:update_code', 'db:seed_fu'
end
|
class Product < ApplicationRecord
has_one_attached :primary_image
has_many_attached :supporting_images
has_many :orders
belongs_to :category
validate :no_negative_stock
def no_negative_stock
if stock.negative?
errors.add(:title, 'stock must be positive integer')
end... |
class NovoCadastroMailer < ApplicationMailer
default from: "LabAberto <contato@beeprinted.com.br>"
def novo_cadastro_email(user, admin)
@site = "http://52.67.230.136/solicitacoes"
@user = user
@admin = admin
mail(to: @admin.email, subject: "Novo Cadastro | Laboratório Aberto de Brasília")
end
end
|
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :surname
t.string :email
t.string :password_digest
t.string :facebook_username
t.string :twitter_username
t.string :linkedin_username
t.string :website_url
... |
require 'minitest'
require 'minitest/autorun'
require 'mocha/setup'
require 'delve/scheduler/simple_scheduler'
class SimpleSchedulerTest < Minitest::Test
def setup
@queue = mock('object')
@scheduler = SimpleScheduler.new @queue
@item = 'item'
end
def test_add
@queue.expects(:add).with(@item, 0)... |
require 'securerandom'
class RemoteTask::Tasks::Adduser < RemoteTask::Tasks::Base
def initialize(execution, password_tier_id:)
super(execution)
@password_tier = PasswordTier.includes(:contest, passwords: :person).find(password_tier_id)
end
def script
[
@password_tier.passwords.map do |password|... |
class RemoveCreatedatFromAccounts < ActiveRecord::Migration[6.0]
def change
remove_column :Accounts, :created_at
end
end
|
#!/usr/bin/env ruby
require 'rubygems'
require 'commander/import'
require 'ruby-progressbar'
require_relative '../lib/experiment'
require 'rugged'
require 'thwait'
require "colorize"
require 'tmpdir'
require 'bigdecimal'
require 'csv'
def to_numeric(anything)
num = BigDecimal.new(anything.to_s)
if num.frac == 0
... |
class TipoTesserasController < ApplicationController
before_filter :signed_in_user
def show
@tipo_tessera = TipoTessera.find_by_id(params[:id])
end
def edit
@tipo_tessera = TipoTessera.find_by_id(params[:id])
end
def update
tipo_tessera = TipoTessera.find(params[:i... |
class RemoveContactsReferencesFromMonths < ActiveRecord::Migration[5.0]
def change
remove_reference(:months, :contacts, index: true)
end
end
|
class AddAmazonBackupToWorkflowAccrualJob < ActiveRecord::Migration
def change
add_reference :workflow_accrual_jobs, :amazon_backup, index: true
add_foreign_key :workflow_accrual_jobs, :amazon_backups
end
end
|
FactoryGirl.define do
factory :account, class: IGMarkets::Account do
account_alias 'alias'
account_id 'A1234'
account_name 'CFD'
account_type 'CFD'
balance { build :account_balance }
can_transfer_from true
can_transfer_to true
currency 'USD'
preferred true
status 'ENABLED'
en... |
require_relative 'spec_helper'
describe 'static loading' do
def app
Sinatra::Application
end
before do
@browser = Rack::Test::Session.new(Rack::MockSession.new(app))
end
it 'loads the boostrap css file' do
@browser.get '/css/bootstrap.min.css'
assert @browser.last_response.ok?, 'Last response is not ok... |
# frozen_string_literal: true
# Create a function that takes three values (hours, minutes, seconds)
# and returns the longest duration
def longest_time(h, m, s)
normalized_time = [h * 60 * 60, m * 60, s]
[h, m, s][normalized_time.index(normalized_time.max)]
end
|
class ChangingNames < ActiveRecord::Migration[5.0]
def change
rename_column :users, :f_name, :first_name
rename_column :users, :l_name, :last_name
end
end
|
#!/usr/bin/env ruby
# encoding: UTF-8
#
# Copyright © 2012-2015 Cask Data, 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 r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.