text stringlengths 10 2.61M |
|---|
# 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... |
class Question < ActiveRecord::Base
validates :user, presence: true
has_many :answers
belongs_to :user
end
|
Rails.application.routes.draw do
root "pages#index"
# Users
get "signup" => "users#new"
post "signup" => "users#create"
# Sessions
get "signin" => "sessions#new"
post "signin" => "sessions#create"
delete "signout" => "sessions#destroy"
get "about" => "pages#about"
end
|
class Offer < ApplicationRecord
belongs_to :business
belongs_to :offer_status
def self.parameters(param_hash,key)
param_hash.require(key).permit(
:business_id, :title, :description, :offer_status_id,
:start_from, :want_until, :work_at
)
end
def brothers
Offer.where(business_id: self.business_id).wh... |
module Chess
class Knight < Piece
register_as "N"
def end_squares(from, board)
offsets = [[1,2], [1,-2], [-1, 2], [-1, -2], [-2, -1], [-2, 1], [2, 1], [2, -1]]
gather_single_offsets(from, board, offsets)
end
end
end
|
module Builders
class CompletedReviewTurnaround < BaseService
def initialize(review)
@review = review
end
def call
::CompletedReviewTurnaround.create!(
review_request_id: @review.review_request_id,
value: caculate_completed_turnaround
)
end
def caculate_complete... |
require 'rails_helper'
RSpec.describe CompaniesHelper, type: :helper do
let!(:company) { create(:company) }
describe 'companies' do
let(:employee1) { create(:user) }
let(:employee2) { create(:user) }
let(:employee3) { create(:user) }
let!(:ma1) do
ma = create(:membership_application, :accep... |
class TripLog < ActiveRecord::Base
belongs_to :car
belongs_to :driver
validates_presence_of :tripDate, :locationFrom, :locationTo, :departureTime, :arrivalTime, :mileageFrom, :mileageTo
validates_numericality_of :mileageFrom, :only_integer => true
validates_numericality_of :mileageTo, :only_integer => true
... |
# == DESCRIPTION
# An expression database.
# = OVERVIEW
# When in doubt, you can always use ´.inspect´ on any object to get a full ist of
# available attributes
# = USAGE
# require 'expression-database'
# ExpressionDB::DBConnection.connect("mammal_expression") // Connects to the database (here: mammal_expression)
# ... |
class CreateUserStories < ActiveRecord::Migration
def change
create_table :user_stories do |t|
t.string :title
t.text :description
t.text :criteria
t.integer :story_points
t.integer :priority
t.integer :estimated_hours
t.timestamps
end
end
end
|
Rails.application.routes.draw do
devise_for :users
resources :users
resources :posts#, only: [:index, :show]
get 'home(/:hello)', to: 'home#index' # скобки обозначают необязательность
root 'home#index'
get 'about', to:'home#about'
# For details on the DSL available within this file, see http://guides.ruby... |
class ChangePasswordMutation < Mutations::BaseMutation
graphql_name 'ChangePassword'
argument :password, GraphQL::Types::String, required: true
argument :password_confirmation, GraphQL::Types::String, required: true, camelize: false
argument :reset_password_token, GraphQL::Types::String, required: false, camel... |
Gem::Specification.new do |s|
s.name = 'graphql_includable'
s.version = '1.0.0'
s.licenses = ['MIT']
s.summary = 'An ActiveSupport::Concern for GraphQL Ruby to eager-load query data'
s.authors = ['Dan Rouse', 'Josh Vickery', 'Jordan Hamill']
s.email = ['dan.rouse@squarefoot.com', 'jvickery@squarefoot.com', ... |
class WhySumbarsController < ApplicationController
# GET /why_sumbars
# GET /why_sumbars.json
def index
@why_sumbars = WhySumbar.all
@getting_theres = GettingThere.all
@where_to_stays = WhereToStay.all
@things_to_dos = ThingsToDo.all
@things_to_sees = ThingsToSee.all
@foods ... |
class Coder < ApplicationRecord
has_many :skillsets
has_many :languages, through: :skillsets
validates_presence_of :first_name, :last_name, :about, :looking_for, :img_url
end
|
require'pry'
class Artist
attr_accessor :name, :new_song, :songs
def initialize(name)
@songs = []
@name = name
end
def add_song(new_song)
self.songs << new_song
new_song.artist = self
end
def add_song_by_name(song_name)
@new_song = Song.new(song_name)
add_song(new_song)
end
... |
class Project < ActiveRecord::Base
has_many :tasks
belongs_to :user
end
|
require 'wsdl_mapper/svc_generation/operation_generator_base'
module WsdlMapper
module SvcGeneration
class OperationGenerator < OperationGeneratorBase
def generate_operation(service, port, op, result)
modules = get_module_names service.name
generate_op_input_body service, port, op, result
... |
class Bid < ApplicationRecord
belongs_to :item
belongs_to :user
validates :price, presence: true, numericality: {greater_than: 1}
end
|
require 'spec_helper'
require 'raven/cli'
RSpec.describe Raven::CLI do
# avoid unexpectedly mutating the shared configuration object
let(:config) { Raven.configuration.dup }
context "when there's no error" do
it "sends an event" do
event = described_class.test(config.server, true, config)
expec... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hadouken_game/version'
Gem::Specification.new do |spec|
spec.name = "hadouken_game"
spec.version = HadoukenGame::VERSION
spec.authors = ["Mario Idival", "Savia Freitas"... |
module Api
module V1
class RestaurantsController < ApplicationController
def index
restaurants = Restaurant.order(:name)
render json: {status: 'SUCCESS', message: 'Loaded Restaurants', data: restaurants}, status: :ok
end
def show
restaurant = Restaurant.find(params[:id])
render json: {sta... |
require 'helper'
describe 'getting all of my batches' do
let(:username) { String.generate }
let(:password) { String.generate }
subject { Esendex.new(username, password) }
let(:count) { 40 }
let(:batches) { Batches.generate(count) }
let(:response_body) { batches.to_xml }
before {
stub_request(:get, ... |
require "rake"
namespace :snapshotar do
desc "list available snapshots"
task list: :environment do
file = ARGV.last
task file.to_sym do ; end
p "# Snapshotar: Listing available snapshots"
p Snapshotar.list
end
desc "create a snapshots"
task create: :environment do
file = ARGV.last
... |
require 'rails_helper'
RSpec.describe User, type: :model do
context 'two users with the same email' do
before (:each) do
@user1 = User.create({ name: 'test',
email: 'test@test.com',
password: '12345678',
password_confirm... |
class SurveysController < ApplicationController
before_action :set_survey_template, only: [:new, :show, :create, :edit, :update, :destroy]
before_action :set_survey, only: [:show, :edit, :update, :destroy]
def index
@surveys = Survey.all
end
def show
end
def new
@survey = @survey_template.surv... |
class Assignment < ActiveRecord::Base
has_many :assignment_family_members
has_many :family_members, through: :assignment_family_members
has_many :assignment_needs
has_many :needs, through: :assignment_needs
has_many :assignment_rewards
has_many :rewards, through: :assignment_rewards
belongs_to :owner, ... |
# This file is part of PacketGen
# See https://github.com/sdaubert/packetgen for more informations
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
# This program is published under MIT license.
# frozen_string_literal: true
module PacketGen
module Header
class DHCP
# define DHCP Options... |
class AddScoreToEvents < ActiveRecord::Migration[5.2]
def change
add_column :events, :scraped_score, :string
add_column :events, :team_a_score, :integer
add_column :events, :team_b_score, :integer
end
end
|
require 'rails_helper'
describe DefaultHealthAttribute, type: :model do
it { should belong_to(:target_type) }
end
|
require 'yt/models/base'
require 'yt/models/policy_rule'
module Yt
module Models
# Provides methods to interact with YouTube ContentID policies.
# A policy resource specifies rules that define a particular usage or
# match policy that a partner can associate with an asset or claim.
# @see https://dev... |
# == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# session_new GET /session/new(.:format) session#new
# lo... |
module Farandula
class Seat
attr_accessor :cabin, :place
def initialize(
cabin = nil,
place = nil
)
@cabin = cabin
@place = place
end
def to_s
"cabin #{cabin}, place code #{place}."
end
end
end
|
#
# Cookbook Name:: neobundle
# Recipe:: default
#
BUNDLE_HOME = "/home/" + node["neobundle"]["user"] + "/.vim/bundle"
USER = node["neobundle"]["user"]
GROUP = node["neobundle"]["group"]
directory BUNDLE_HOME do
owner USER
group GROUP
mode 744
action :create
recursive true
end
git BUNDLE_HOME +... |
require 'rails_helper'
RSpec.describe Student, type: :model do
it "should have a number" do
expect(subject).to have_attribute(:number)
end
it "should have a first name" do
expect(subject).to have_attribute(:first_name)
end
it "should have a last name" do
expect(subject).to have_attribute(:last_... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box_check_update = false
config.vm.network "public_network"
config.vm.synced_folder ".", "/var/www/rank"
config.vm.provision "shell", inline: <<-SHELL
set -ex
sudo su
ln -f -s /... |
module BankingCodeChallenge
class Account
attr_reader :number, :bank, :balance, :holder
def initialize number, bank, balance, holder="anonymous"
@number = number
@bank = bank
@balance = balance
@holder = holder
end
def depositMoney amount
@balance += amount
end
... |
module Ricer::Plugins::Core
class Tee < Ricer::Plugin
trigger_is :tee
permission_is :responsible
has_usage '<target[online=1]> <..text..>'
def execute(targets, text)
targets.each do |target|
target.send_message(text)
end
end
end
end
|
# input: string
# output: array of substrings
# rules:
# Explicit requirements:
# - every palindrom possibility in a string is output to an array
# (reminder: a palindrom is a word taht reads the same forward
# and backkward)
# - palindroms are case sensitive
# Algorithm:
... |
require "rails_helper"
describe ApplicationController, type: :controller do
before do
setup_application_instance
end
describe "valid application instance api token" do
before do
admin_api_permissions = {
default: [
"administrator", # Internal (non-LTI) role
"urn:lti:sys... |
FactoryBot.define do
factory :story do
name { "the name" }
description { "the description" }
column
due_date { Time.zone.now + 10.days }
status { "open" }
end
end
|
# frozen_string_literal: true
# rubocop:todo all
require 'lite_spec_helper'
require 'support/shared/server_selector'
describe Mongo::ServerSelector::SecondaryPreferred do
let(:name) { :secondary_preferred }
include_context 'server selector'
let(:default_address) { 'test.host' }
it_behaves_like 'a server s... |
# == Schema Information
#
# Table name: vacancies
#
# id :integer not null, primary key
# title :string(255)
# salary_cents :integer default(0), not null
# contacts :string(255)
# valid_through :date
# created_at :datetime
# updated_at :datetime
#
FactoryGirl.def... |
module RSence
require 'erb'
require 'yaml'
# @private ARGVParser is the "user interface" as a command-line argument parser.
# It parses the command-line arguments and sets up things accordingly.
class ARGVParser
# Returns true if one of the 'start' -type commands were supplied
# and the... |
class Workgroup < ActiveRecord::Base
belongs_to :manager, :class_name => 'User', :foreign_key => 'manager_id'
has_many :workgroup_user_selections
has_many :users, :through => :workgroup_user_selections
has_many :workgroup_region_selections
has_many :regions, :through => :workgroup_region_selections
has_m... |
class RemoveSenderFromMessages < ActiveRecord::Migration
def change
remove_reference :messages, :sender, index: true
end
end
|
require 'byebug'
require_relative('questions_database')
class Users
attr_reader :id
attr_accessor :fname, :lname
# Class Methods
def self.all
all_users = QuestionsDatabase.instance.execute(<<-SQL)
SELECT
*
FROM
users
SQL
all_users.map {|user| Users.new(user) }
end
... |
#!/usr/bin/env ruby
require 'pry'
# https://adventofcode.com/2021/day/5
# --- Day 5: Hydrothermal Venture ---
# You come across a field of hydrothermal vents on the ocean floor! These vents constantly produce large, opaque clouds, so it would be best to avoid them if possible.
# They tend to form in lines; the subm... |
class Yogies < ActiveRecord::Base
#has_one :image, dependent: :destroy
belongs_to :image
has_many :users
def self.by_count
result = []
Rails.cache.fetch( 'index', :expires_in => 1.minutes ) do
yogies = group( :title ).count.sort_by {|key, value| value}.reverse.take(5)
yogies.each do |yo... |
class ApplicationController < ActionController::Base
protect_from_forgery
HUMAN_VERIFY = []
helper_method :current_user
helper_method :current_or_guest_user
helper_method :logging_in
rescue_from CanCan::AccessDenied do |e|
redirect_to root_path, alert: 'Sorry, you can\'t access that page'
end
... |
class Owner < ApplicationRecord
has_many :restaurants
has_many :reviews, through: restaurants
has_secure_password
validates :first_name, presence:true
validates :last_name, presence:true
validates :email, uniqueness: true, presence:true
end
|
FactoryGirl.define do
factory :member do
first_name
last_name
email
active true
birthdate "1979-02-10"
cell_phone "555-555-1212"
password 'password'
factory :avatar do
avatar_file_name { 'profile.png' }
avatar_content_type { 'image/png' }
avatar_file_size { 8 }
... |
#aksdfjskasdasdaasdasda
class ListNode
attr_accessor :val, :next
def initialize(val)
@val = val
@next = nil
end
end
def getIntersectionNode(headA, headB)
a_nodes = {}
current_a = headA
while current_a
a_nodes[current_a] = current_a
current_a = current_a.next
... |
# A triangle is classified as follows:
# equilateral All 3 sides are of equal length
# isosceles 2 sides are of equal length, while the 3rd is different
# scalene All 3 sides are of different length
# To be a valid triangle, the sum of the lengths of the two shortest sides must
# be greater than the length of the long... |
When /^(.+?) receives acknowledge from (.+?)$/ do |destination, source|
wait_or_fail 'Acknowledge not received within time' do
$routers[destination.to_sym][:acks].include? source.to_sym
end
end
When /^(.+?) receives from (.+?) message "(.+?)"$/ do |destination, source, message|
wait_for_message(destination, ... |
class ContactMailer < ActionMailer::Base
default from: "ben@bytenel.com"
def new_message(message)
@message = message
mail(to: 'nelson.ben.c@gmail.com', subject: @message.subject)
end
end
|
require 'lights/hobject'
class Scene < HObject
attr_reader :id, :name, :active, :lights
def initialize(id,data = {})
super(data)
@id = id
@name = data["name"]
@active = data["active"]
@lights = data["lights"]
end
def data
data = {}
data["name"] = @name if @name
data["active"] =... |
class AddScenarioStatusesToBuildStats < ActiveRecord::Migration
def change
add_column :build_stats, :num_failed_bugs_scenarios, :integer
add_column :build_stats, :num_pending_bugs_scenarios, :integer
end
end
|
class Api::V1::CommentsController < ApplicationController
before_action :authenticate_api_v1_user!
before_action :set_comment, only: [:update]
authorize_resource
skip_forgery_protection
def create
@post = Post.find_by id: params[:post_id]
unless @post.present?
return render_error "post not foun... |
class ChangeRoomTypeIdToRoomId < ActiveRecord::Migration
def change
change_table :bookings do |t|
t.rename :room_type_id, :room_id
end
end
end
|
module Bootsy
class ImageGallery < ActiveRecord::Base
belongs_to :bootsy_resource, polymorphic: true
has_many :images, dependent: :destroy
scope :destroy_orphans, ->(time_limit) { where('created_at < ? AND bootsy_resource_id IS NULL', time_limit).destroy_all }
end
end
|
class Atlas < ActiveRecord::Base
attr_accessible :user_id, :name, :types, :types_attributes, :type_count, :realm, :realm_attributes, :tag
belongs_to :user
has_many :sizes, :dependent => :destroy
has_many :types, :dependent => :destroy
has_many :reports, :dependent => :destroy
has_many :events, :dependent => :d... |
# Add your annotations, line by line, to the code below using code comments.
# Try to focus on using correct technical vocabulary.
# Use the # to create a new comment
# Build a Bear
# defines the method build_a_bear with five arguements
def build_a_bear(name, age, fur, clothes, special_power)
# defines method variab... |
And(/^the bag '(.*)' is staged in the accrual root named '(.*)' at path '(.*)'$/) do |bag_name, root_name, path|
StorageManager.instance.accrual_roots.at(root_name).copy_tree_to(path, FixtureFileHelper.storage_root, FixtureFileHelper.complete_bag_key(bag_name))
end
And(/^I should see the accrual form and dialog$/) d... |
module IControl::Management
##
# The CRLDPConfiguration interface enables you to manage CRLDP PAM configuration.
class CRLDPConfiguration < IControl::Base
set_id_name "config_names"
##
# Adds/associates servers to this CRLDP configurations.
# @rspec_example
# @raise [IControl::IControl::Comm... |
require 'test_helper'
require 'minitest/mock'
class OrderTest < ActiveSupport::TestCase
test "opening_hours blank" do
@order = orders(:one)
assert @order.send(:check_open_status)
end
test "put of opening_hours" do
@order = orders(:one)
Time.stub :now, Time.parse('2014-05-24 10:00:00') do
... |
require 'rails_helper'
RSpec.describe ApplicationHelper, type: :helper do
describe '#markdown' do
it "calls Redcarpet's #render method" do
expect_any_instance_of(Redcarpet::Markdown).to receive(:render) { '' }
helper.markdown('simple text')
end
it 'initializes Markdown only once' do
exp... |
FactoryGirl.define do
factory :boat, class: Boat do
user
association :category, factory: :boat_category
boat_type
currency
engine_model
engine_manufacturer
drive_type
country
fuel_type
vat_rate
manufacturer
model
extra
sequence(:name) { |n| "boat-name-#{n}" }
... |
class AttributesFormatService < ApplicationService
def initialize(table, attributes, attributes_type, key = '')
# attributes_type ['key', 'array']
# if type = 'key' need to define key parameter
@table = table
@table_structure = table_structure
@attributes = attributes
@attributes_type = attrib... |
class SessionsController < ApplicationController
def new
if current_user
status_redirect
end
end
def create
user = User.find_by(email: params[:email])
if user.nil? || !user.authenticate(params[:password])
flash[:error] = "Log in information incorrect, please try again."
redirect... |
require 'test/unit'
# def solution(s)
# (('a'..'z').to_a & s.downcase.split(' ')).length == 26 ? 'pangram' : 'not pangram'
# end
def solution(s)
s = s.downcase.split('')
r = s & ('a'..'z').to_a
r.length == 26 ? 'pangram' : 'not pangram'
end
class Tests < Test::Unit::TestCase
def test_simple
assert_eq... |
class CreateRestaurants < ActiveRecord::Migration
def change
create_table :restaurants do |t|
t.integer :owner_id, null: false
t.text :description, null: false
t.string :name, null: false
t.string :address, null: false
t.integer :price_range, null: false
t.float :lat
t.fl... |
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
def setup
@user = users(:test_user)
end
test "layout links" do
get root_path
assert_template 'static_pages/home'
assert_select "a[href=?]", root_path
assert_select "a[href=?]", posts_path
assert_select "a[href=?]", login_path
... |
require 'prawn'
require './card'
require './page'
require 'prawn/measurement_extensions'
class PdfPrinter < Prawn::Document
def initialize
super(
:page_size => [450.mm, 320.mm],
:margin => 0,
:page_layout => :portrait
)
define_grid(:columns => 4, :rows => 6)
end
def save_as(file)... |
class Course < ActiveRecord::Base
has_many :enrollments, primary_key: :id, foreign_key: :course_id,
class_name: "Enrollment"
belongs_to :prereq, primary_key: :id, foreign_key: :prereq_id, class_name: "Course" #if course has a prereq
belongs_to :teacher, primary_key: :id, foreign_key: :instructor_id, class_nam... |
require 'csv'
require_relative 'movie'
class MovieColletion
def initialize(text_file)
@collection = parse_txt_file(text_file)
end
def parse_txt_file(filename)
name = filename.nil? ? 'movies.txt' : filename
if name == 'movies.txt'
CSV.read(name, col_sep: '|')
.map { |m| Movie.new(m) }
... |
module OperationMacros
# Runs a trailblazer op and raises an exception if it fails. Use when you
# know that your test data is good and that a failed op means that you wrote
# the test wrong (or the op is broken.)
def run!(op, *args)
result = op.(*args)
if result.failure?
message = "op #{op} was ... |
module KoiVMRuby
NIL_ = 0
BOOL_ = 1
INTEGER_ = 2
FLOAT_ = 3
STRING_ = 4
HASH_ = 5
FUNCTION_ = 16
end |
describe "Integer" do
context "when calling next" do
it "should return the next integer" do
1.next.should eq 2
2.next.should eq 3
end
it "should return the previous integer" do
1.pred.should eq 0
0.pred.should eq -1
end
it "sho... |
require 'spec_helper'
require 'baby_squeel/nodes/node'
describe BabySqueel::Nodes::Function do
subject(:node) {
described_class.new(
Arel::Nodes::NamedFunction.new('coalesce', [
Post.arel_table[:id],
42
])
)
}
it 'has math operators' do
expect((node + 5) * 5).to produce_s... |
require 'bouncer/strategies/shared/profile'
module Bouncer
module Strategies
class Token < ::Warden::Strategies::Base
def valid?
auth.provided? && auth.valid?
end
def store?
false
end
def authenticate!
user = Bouncer::User.new({
profile: profile,
... |
require 'spec_helper'
describe Intown::Configuration do
it "should set an app_id" do
Intown.configure do |config|
config.app_id = "my_app"
end
Intown.configuration.app_id.should == "my_app"
end
end
|
class Comment < ActiveRecord::Base
belongs_to :post
belongs_to :user
validates_presence_of :content, :length => { :minimum => 5, :maximum => 2000}
end |
require File.dirname(__FILE__) + '/../../../../spec_helper'
require File.dirname(__FILE__) + '/../../shared/constants'
require 'openssl'
describe "OpenSSL::X509::Certificate#serial" do
it 'is 0 by default' do
x509_cert = OpenSSL::X509::Certificate.new
x509_cert.serial.should == 0
end
it 'returns the s... |
class Station < DynamicModel
attr_accessor :name, :line, :division, :latitude, :longitude
attr_reader :id
def self.all
rows = DB[:conn].execute("SELECT * FROM stations")
# we need to create instances
rows.map do |row|
self.send(:new_from_row, row)
end
end
def self.table_name
self.t... |
class Location < ApplicationRecord
has_and_belongs_to_many :eventdates
around_update :set_eventdate_delta_flags
validates_presence_of :building, :room
scope :active, -> { where(defunct: false) }
scope :buildings, -> { active.order(building: :asc).select(:building).distinct.pluck(:building) }
scope :b... |
# encoding: utf-8
require 'spec_helper'
describe TTY::Table::Columns, 'column widths' do
let(:header) { ['h1', 'h2', 'h3', 'h4'] }
let(:rows) { [['a1', 'a2', 'a3', 'a4'], ['b1', 'b2', 'b3', 'b4']] }
let(:table) { TTY::Table.new(header, rows) }
subject { described_class.new(renderer) }
context 'with bas... |
#
# Cookbook Name:: goapp
# Recipe:: default
#
#
# Get the current version of GO if it is installed
#
ruby_block "test_go_version" do
only_if { ::File.exists?("/usr/local/go/bin/go") }
block do
lines = %x(/usr/local/go/bin/go version)
lines.chop
node.set[:govn][:govnv] = lines.chop
end
end
#... |
class ChangeTypeAccesoVehicular < ActiveRecord::Migration[5.0]
def up
change_table :locations do |t|
t.change :acceso_vehicular, :boolean
end
end
def down
change_table :locations do |t|
t.change :acceso_vehicular, :string
end
end
end
|
FactoryBot.define do
factory :coupon, class: Coupon do
name {Faker::Alphanumeric.alphanumeric}
code {Faker::Alphanumeric.alphanumeric}
percent_off {rand(5..15)}
association :merchant
end
end
|
# frozen_string_literal: true
module Interactor
class Base
SUCCESS_RESPONSE = ::OpenStruct.new(success?: true)
class Result
attr_reader :value, :error
def initialize(value = nil, error = nil)
@value = value
@error = error
end
def success?
@error.nil?
e... |
class AddDescriptionToLists < ActiveRecord::Migration
def change
add_column :lists, :description, :text
end
end
|
class AddIndexToStatementMovements < ActiveRecord::Migration[5.2]
def change
add_index :statement_movements, [:statement_id, :movement_id], unique: true
end
end
|
require 'spec_helper'
describe MessageCenter::Message, :type => :model do
before do
@entity1 = FactoryGirl.create(:user)
@entity2 = FactoryGirl.create(:user)
@receipt1 = MessageCenter::Service.send_message(@entity2, @entity1, "Body","Subject")
@receipt2 = MessageCenter::Service.reply_to_all(@recei... |
class Contest < ActiveRecord::Base
has_many :challenges
def self.current
find_by_is_active!(true)
end
def duration_in_seconds
duration_in_minutes * 60
rescue
0
end
def seconds_left
end_time - Time.now.to_i
rescue
0
end
def end_time
start_time + duration_in_seconds
end
... |
class TestBuilder
attr_reader :html, :passed_tests, :failed_tests
def initialize(output)
@html = []
@passed_tests = 0
@failed_tests = 0
to_html(output)
end
private
def to_html(output)
raise 'No test results to show' if output.nil?
output.split("<:LF:>").each do |value|
tag =... |
FactoryBot.define do
factory :company do
name {|n| "company_#{n}"}
system_name {|n| "company_#{n}"}
deployments {[FactoryBot.create(:deployment)]}
cluster { FactoryBot.create(:cluster) }
csm_info { FactoryBot.create(:csm_info)}
end
factory :deployment do
name {|n| "deployment_#{n}"}
end
factory :clus... |
# When events are imported from an .xls or .xlsx file, time_from_start for some split_times
# may be off by :01 in either direction as a result of rounding problems in Excel.
# The following rake tasks are designed to correct for these rounding errors.
namespace :round do
desc 'For a given event_id, rounds intermedi... |
$: << File.dirname(__FILE__) + '/../lib/'
require 'test/spec'
$WARNING = ""
class Object
def warn(msg)
$WARNING << msg.to_s
super msg
end
end
class Test::Spec::Should
def _warn
_wrap_assertion {
begin
old, $-w = $-w, nil
$WARNING = ""
self.not.raise
$WARNING.sho... |
require 'gosu'
module Pomodoro
module Gui
class Window < Gosu::Window
IMAGE_ASSETS = {
background: "assets/images/background.png",
pomodoro: "assets/images/pomodoro.png",
occupied: "assets/images/occupied.png",
rest: "assets/images/rest.png"
}
AUDIO_ASSETS = {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.