text stringlengths 10 2.61M |
|---|
FactoryBot.define do
factory :contact, class: DataPlugins::Contact::Contact do
title { 'Titel des Kontaktes' }
end
end
|
#!/usr/bin/env ruby
require 'json'
require 'net/http'
require 'uri'
require 'logger'
# Environment Varibles which need to be set in the job config
BUILDKITE_ACCESS_TOKEN = ENV['BUILDKITE_ACCESS_TOKEN']
BUILDKITE_PROJECT = ENV['BUILDKITE_PROJECT'] ||= 'vsphere-baker-windows'
# Environment varibles defined by BuildKite... |
require 'test_helper'
class DiceGameTest < Minitest::Test
def test_with_four_players
players = ['Player A', 'Player B', 'Player C', 'Player D']
dice_game = DiceGame::Engine.new(players)
winners = dice_game.start
winners.each do |player|
assert players.include?(player.name)
end
end
de... |
require 'spec_helper'
module TwitterCli
describe "interface" do
let(:conn) { PG.connect(:dbname => ENV['database']) }
let(:res_red) { conn.exec('select id, username, tweet from tweets where username = $1', ['red']) }
let(:res_anugrah) { conn.exec('select id, username, tweet from tweets where username = $... |
module AdminDashboard
class SubscriptionsController < ApplicationController
before_action :load_subscription, only: [:edit, :destroy]
def index
@subscriptions = Subscription.order(:duration, :created_at)
end
def edit
end
def destroy
@subscription.destroy
redirect_to... |
require "rails_helper"
RSpec.describe Api::LtiDeepLinkJwtController, type: :controller do
before do
setup_application_instance
setup_canvas_lti_advantage(application_instance: @application_instance)
end
context "without jwt token" do
it "should not be authorized" do
post :create, params: { typ... |
require "rails_helper"
# Shorthand for adding prescription drugs, since we do it a lot in this spec
def add_drug(patient, name, dosage, time, do_not_delete: false)
# emulate deletion of existing drug like on mobile app
unless do_not_delete
patient.prescription_drugs
.where(name: name, is_deleted: false)
... |
module Aliyun
class RAMConfig < APIConfig
def self.info
"Aliyu RAM Service"
end
def self.endpoint
'https://ram.aliyuncs.com/'
end
def self.default_parameters
{
:Format=>"JSON",
:Version=>"2015-05-01",
:SignatureMethod=>"HMAC-SHA1",
:SignatureVersio... |
class AuditReportsController < ApplicationController
before_action :set_audit_report, only: [:show, :edit, :update, :destroy]
# GET /audit_reports
# GET /audit_reports.json
def index
@audit_reports = AuditReport.all
end
# GET /audit_reports/1
# GET /audit_reports/1.json
def show
end
# GET /au... |
require 'rspec'
include Math
class Calculator
def add(number_one, number_two)
return number_one + number_two
end
def subtract(number_one, number_two)
return number_one - number_two
end
def multiply(number_one, number_two)
return number_one * number_two
end
def divide(number_one, num... |
# frozen_string_literal: true
# Provides a utility class for loading and validating etcd config
module PuppetX
module Etcd
class EtcdConfig
VALID = ['host', 'port', 'use_ssl', 'ca_file', 'user_name', 'password', 'restrict_paths'].freeze
REQUIRED = ['host', 'port'].freeze
attr_reader :config_ha... |
require 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require 'stringio'
require_relative '../lib/mastermind_printer'
class MasterMindPrinterTest < Minitest::Test
def test_it_greets_user_with_game_title
fake_stdout = StringIO.new
MasterMindPrinter.file = $stdout ... |
# Encoding: UTF-8
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
describe TruncateHtml::HtmlCounter do
def count(html)
html_string = TruncateHtml::HtmlString.new(html)
TruncateHtml::HtmlCounter.new(html_string).count
end
it "it counts a string with no html" do
count("test this shit"... |
class Question < ApplicationRecord
validates :text, presence: true
validates :poll_id, presence: true
belongs_to :poll,
primary_key: :id,
foreign_key: :poll_id,
class_name: 'Poll'
has_many :answer_choices,
primary_key: :id,
foreign_key: :question_id,
class_name: 'AnswerChoice'
has_many :r... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe PrimesTable do
it 'has a version number' do
expect(PrimesTable::VERSION).not_to be nil
end
describe '.run' do
it 'prints the multiplication table for n prime numbers' do
table = <<~TABLE
\ 2 3
\ 2 4 6
\ 3... |
require 'erb'
recipe = {
name: "Roasted Brussel Sprouts",
ingredients: [
"1 1/2 pounds Brussels sprouts",
"3 tablespoons good olive oil",
"3/4 teaspoon kosher salt",
"1/2 teaspoon freshly ground black pepper"
],
directions: [
"Preheat oven to 400 degrees F.",
"Cut off the brown e... |
class RenameStudentsClassColumn < ActiveRecord::Migration[5.2]
def change
rename_column :students,:class,:grade
end
end
|
require './lib/card.rb'
require './lib/deck.rb'
require './lib/turn.rb'
class Player
attr_reader :cards, :name, :deck
def initialize(name, deck)
@name = name
@deck = deck
end
def has_lost?
deck.cards == [] || deck.cards.nil?
end
end
|
class MobileMoney < ActiveRecord::Base
def self.generate_uuid
self.uuid = SecureRandom.uuid.to_s+'-'+Time.now.to_i.to_s
end
end
|
require 'rails_helper'
RSpec.describe Post, type: :model do
describe '#create' do
context 'can save' do
# 1. imageとtextが存在すれば投稿できること
it "is valid with a image, text" do
post = build(:post)
expect(post).to be_valid
end
end
context 'can not save' do
# 2. imageが空では登録... |
# frozen_string_literal: true
require 'test_helper'
class EventRegistrationControllerTest < ActionController::TestCase
test 'allow registering with existing user with differently cased email' do
assert_no_difference(-> { User.count }) do
assert_difference(-> { EventInvitee.count }) do
post :create... |
class BooksController < ApplicationController
layout "book"
helper_method :sort_column, :sort_direction
# GET /books
# GET /books.xml
def index
@title = "Home"
@books = Book.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:per_page => 5, :page => params[:page])
@wid... |
class CreateProperties < ActiveRecord::Migration
def change
create_table :properties do |t|
t.column :buyer_id, :integer
t.column :seller_id, :integer
t.column :name, :string
t.column :display_name... |
describe Jets::Resource::Iam::ManagedPolicy do
let(:permissions_boundary) do
Jets::Resource::Iam::PermissionsBoundary.new(definition)
end
context "single string" do
let(:definition) { "AmazonEC2ReadOnlyAccess" }
it "does not prepend anything" do
expect(permissions_boundary.arn).to eq definition... |
class ConversationsController < ApplicationController
def index
@convos = current_user.conversations
end
def show
@convo = Conversation.find(params[:id])
@messages = @convo.private_messages.order(:created_at)
end
def create
builder = ConversationBuilder.new(conversation_params, current_user)... |
require 'spec_helper'
feature "hidden links" do
let(:user) { Factory(:confirmed_user) }
let(:admin) { Factory(:admin) }
context "anonymous users" do
scenario "cannot see the New Project link" do
visit '/'
assert_no_link_for "New Survey"
assert_no_link_for "Admin"
end
end
context "reg... |
require 'spec_helper'
describe SchedulersController do
before { sign_in(FactoryGirl.create :user) }
let(:scheduler) { (FactoryGirl.create :app).scheduler }
describe 'PUT update' do
it 'updates recording state' do
scheduler.stop_recording
params = { recording: true }
put :update, id: sched... |
# 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 ShippingAddress < ApplicationRecord
belongs_to :customer
validates :address,:direction, presence: true
validates :postcode, format: {with: /\A[0-9]{3}[0-9]{4}\z/}
#{with: /\A[0-9]{3}-[0-9]{4}\z/}とかで真ん中にーも付けれる。
def address_all
self.direction + self.postcode + self.address
end
end
|
module Square
# SubscriptionsApi
class SubscriptionsApi < BaseApi
# Enrolls a customer in a subscription.
# If you provide a card on file in the request, Square charges the card for
# the subscription. Otherwise, Square sends an invoice to the customer's
# email
# address. The subscription start... |
require ('pg')
class Bounty
attr_accessor :name, :species, :bounty_value, :danger_level, :last_known_location, :home_world, :favourite_weapon
attr_reader :id
def initialize(params)
@name = params["name"]
@species = params["species"]
@bounty_value = params["bounty_value"].to_i
@danger_level = p... |
class Recipe < ApplicationRecord
belongs_to :wedding
has_many :flowers, :dependent => :destroy
has_many :hard_goods, :dependent => :destroy
validates :recipe_name, presence: true
validates :recipe_quantity, presence: true
end
|
require 'active_support/concern'
module UserInvitation
extend ActiveSupport::Concern
included do
attr_accessor :invitation_role, :invitation_text
devise :invitable
after_invitation_created :create_team_user_invitation
def self.send_user_invitation(members, text=nil)
msg = []
members.e... |
class BudgetsController < ApplicationController
# GET /budget_items
# GET /budget_items.xml
def index
@budget_items = Budget.all
respond_to do |format|
format.html # index.html.erb
format.html { render :html => "test", :content_type => 'text/html'}
#format.html { render :html => "test"... |
class UserDatatable < AjaxDatatablesRails::ActiveRecord
extend Forwardable
def_delegators :@view, :edit_user_path
def initialize(params, opts = {})
@view = opts[:view_context]
super(params, opts)
end
def user
@user ||= options[:user]
end
def view_columns
# Declare strings in this forma... |
require_relative 'spec_helper'
describe 'root page' do
include Rack::Test::Methods
def app
Sinatra::Application
end
before :all do
User.delete_all
Tweet.delete_all
Follow.delete_all
@browser = Rack::Test::Session.new(Rack::MockSession.new(app))
end
describe 'GET on /' do
befor... |
class JsonLogger < Ougai::Logger
include ActiveSupport::LoggerThreadSafeLevel
include ActiveSupport::LoggerSilence
def initialize(*args)
super
@before_log = lambda do |data|
correlation = Datadog::Tracing.correlation
datadog_trace_info = {
dd: {
# To preserve precision durin... |
require 'zlib'
require 'quickmr/processor_base'
class Splitter < ProcessorBase
def initialize(options)
super
@queues = []
(options[:queue_no] || fail('need queue number')).times do
@queues << SizedQueue.new(options[:queue_size] || 1000)
end
log "splitter initailized with #{@queues.length} queues"
end
... |
include DataMagic
DataMagic.load 'disputes.yml'
Given(/^I log in to the COS application with the "([^"]*)", "([^"]*)" and "([^"]*)"$/) do |user_id, password, sso_id|
visit(LoginPage)
on(LoginPage) do |page|
page.login(user_id, password, sso_id)
end
end
And(/^I select row "([^"]*)" posted transaction from ... |
class Message
include Mongoid::Document
include Mongoid::Timestamps
field :sender_id, type: Moped::BSON::ObjectId
field :sender_class, type: String
field :msg, type: String
validates_presence_of :sender_id, :sender_class, :msg
embedded_in :conversation
end
|
require 'studio_game/game'
require 'studio_game/treasure_trove'
require 'studio_game/playable'
# Outside of the class, we refer to the external state of an
# object as its attributes.
module StudioGame
class Player
include Playable
attr_accessor :health
attr_accessor :name
def initialize(n... |
# модуль определяет выборку заказов по-умолчанию:
# все, кроме статуса == Отменен
module OrderConcern
extend ActiveSupport::Concern
included do
# показываем все, кроме статусов "отменен"
default_scope { where.not(order_status_id: OrderStatus::Canceled.first) }
end
#def alert_after_save
# abort 'aft... |
require 'spec_helper'
describe SportsDataApi::Mlb::Game, vcr: {
cassette_name: 'sports_data_api_mlb_game',
record: :new_episodes,
match_requests_on: [:host, :path]
} do
let(:season) do
SportsDataApi.set_key(:mlb, api_key(:mlb))
SportsDataApi.set_access_level(:mlb, 't')
SportsDataApi::Mlb.sche... |
class CreateRecListings < ActiveRecord::Migration
def change
create_table :rec_listings do |t|
t.string :mls_class
t.string :mls_id
t.text :props
t.string :image
t.string :displayed_on
t.integer :model_id
t.timestamps
end
add_index :rec_listings, :mls_id
add_... |
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_client
def connect
puts "this get printed first"
self.current_client = cookies.signed[:uuid]
end
private
def find_unverified_client
puts "hello"
puts cookies.signed[:uuid... |
module Aucklandia
module StopTimes
STOP_TIMES_ENDPOINT = '/gtfs/stopTimes'
def get_stop_times_by_trip_id(trip_id)
url = build_url(BASE_URL, STOP_TIMES_ENDPOINT, '/tripId/', trip_id)
response = get(url)
JSON.parse(response)['response']
end
end
end |
class CommentsController < ApplicationController
def create
@commentable = find_commentable
@comment = @commentable.comments.build(params[:comment])
@comment.user_id = current_user.id
respond_to do |format|
if @comment.save!
format.html { redirect_to(commentable_url... |
LOCALCYCLE::Application.routes.draw do
resources :categories
resources :products do
get 'pic', on: :member
get 'export', on: :collection
end
resources :goods do
get 'toggle_available', on: :member
get 'marketplace', on: :collection
get 'export', on: :collection
end
resources :markets... |
require "trequester/version"
require 'trequester/trequester'
require 'httparty'
module Trequester
class << self
attr_accessor :auth
def setup(key_id, key_secret)
self.auth = { username: key_id, password: key_secret }
end
end
end
|
Rails.application.routes.draw do
devise_for :users
resources :users, only: [:index, :show]
devise_scope :user do
authenticated :user do
root to: 'posts#index'
end
unauthenticated :user do
root 'devise/sessions#new'
end
end
resources :posts do
member do
post "like", t... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "books/index", type: :view do
before(:each) do
@books = FactoryBot.create_list(:book, 2)
assign(:books, @books)
end
it "renders a list of books" do
allow(view).to receive_messages(:will_paginate => nil)
render
expect(rende... |
class QuoteAttachmentsController < ApplicationController
# GET /quote_attachments
# GET /quote_attachments.json
def index
@quote_attachments = QuoteAttachment.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @quote_attachments }
end
end
# GET /quote_... |
require 'spec_helper'
feature 'Data page' do
background do
visit '/accept_terms'
Capybara.current_session.driver.browser.manage.add_cookie name: true, value: true
end
scenario 'Visit Data page' do
visit '/sources'
expect(page).to have_selector("h1", text: "Data sources")
end
scenario 'afte... |
class DpScraper::Vendor
attr_reader :name, :image_url, :tel, :street, :district, :city, :province, :coupons, :shop_type, :shop_area
def initialize(name: nil, image_url: nil, tel: nil, street: nil, district: nil, city: nil, province: nil, coupons: [])
@name = name
@image_url = image_url
@tel = tel
@street = ... |
require 'rails_helper'
RSpec.describe Vote, type: :model do
before(:each) do
@user = FactoryGirl.create(:user)
@question = FactoryGirl.create(:question, user: @user)
@vote1 = Vote.create(user: @user, votable: @question)
@answer = FactoryGirl.create(:answer, user: @user)
end
it "should be true by ... |
require 'acceptance_helper'
feature 'Global Search' do
before(:each) do
set_driver :dynamic
end
scenario 'results should be returned' do
visit '/sydney'
query = 'sdflhjlds'
find('.test-global-search-input').native.send_key(query)
wait_for_ajax_requests
expect(find('.test-global-search-r... |
feature 'homepage test' do
scenario "homepage displays correct text" do
visit '/test'
expect(page).to have_content("Testing infrastructre working!")
end
end |
class MigrateToSingleStatus < ActiveRecord::Migration[4.2]
def change
unless defined?(Status).nil?
ProjectMedia.all.each do |pm|
s = Status.where(annotation_type: 'status', annotated_type: pm.class.to_s , annotated_id: pm.id).order("id asc").to_a
# create new one with same created_at and upd... |
require 'test/unit'
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'dieroll.rb'
class TestRoller < Test::Unit::TestCase
def setup
@one_d6_plus_one = Dieroll::Roller.new('1d6+1')
@one_d6_plus_one_d4_minus_two = Dieroll::Roller.new('1d6+1d4-2')
@one_d6_minus_one_d4 = Dieroll::Roller.ne... |
class Order < ActiveRecord::Base
# include Payday::Invoiceable
has_many :cartitems, :dependent => :destroy
has_many :products, :through => :cartitems
scope :completed, order("updated_at").where(:completed => true)
scope :shipped, order("updated_at").where(:shipped => true)
scope :bank_transfer, where(:sou... |
require "sqlite3"
require "singleton"
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super("./db/questions.db")
self.type_translation = true
self.results_as_hash = true
end
end
class ModelBase
attr_accessor :id
CLASS_LOOKUP = {
User: ... |
define_actor :game_title do
has_behavior animate_once: {
image: "game_title",
frame_update_time: 120,
second_animation_in: 8_000
}
view do
draw do |target, x_off, y_off, z|
target.draw_image actor.image, 0, 0, 0
end
end
end
|
class AddFireToBaseGoodsDescription < ActiveRecord::Migration[5.1]
def change
add_column :base_goods_descriptions, :fire, :boolean, :default => false
end
end
|
class CreatePacotes < ActiveRecord::Migration
def change
create_table :pacotes do |t|
t.string :destino
t.integer :quantidadepessoas
t.float :total
t.references :usuario, index: true
t.references :reservar_passagem, index: true
t.references :reserva_diaria, index: true
t... |
class Hand
attr_accessor :cards, :tiebreaker
def initialize(deck = Deck.new)
@cards = deck.take(5)
@deck = deck
@tiebreaker = nil
end
def trade_in(cards_gone)
raise "Can only draw 3 cards" if cards_gone.count > 3
cards_gone.each do |idx|
self.cards[idx] = nil
end
self.cards... |
class Image < ApplicationRecord
mount_uploader :src, ImageUploader
has_many :items
end
|
require 'test_helper'
class CoinTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
@coin = coins(:testcoin)
end
test "coin name is not empty" do
@coin.name = ""
assert_not @coin.valid?
end
test "coin amount is not empty" do
@coin.amount = ""
assert_... |
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
Dir['lib/tasks/*.rake'].each { |rake| load rake }
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_ta... |
class PostsController < ApplicationController
before_action :authenticate_user!
def index
user_ids = current_user.timeline_user_ids
@post = Post.where(user_id: user_id).order.("Created at DESC")
end
def show
@post = Post.find(params[:id])
end
end
|
module Retryable
def perform_retry(retry_count = 3, backoff_seconds = 0.25, backoff_multiplier = 2, &block)
yield
rescue
retry_count -= 1
raise if retry_count < 0
sleep backoff_seconds
backoff_seconds *= backoff_multiplier
retry
end
end
|
class Batchtest < ActiveRecord::Base
attr_accessible :batch_id, :jktest_id, :start_test_date, :end_test_date, :attempt
#association
belongs_to :batch
belongs_to :jktest
#has_many :solvedtests
has_many :marks
has_many :testattempts
#validation
validates_associated :marks
validates_associated :t... |
# frozen_string_literal: true
class SplitTimeQuery < BaseQuery
def self.typical_segment_time(segment, effort_ids)
# Params should all be integers, but convert them to integers
# to protect against SQL injection
begin_lap = segment.begin_lap.to_i
begin_id = segment.begin_id.to_i
begin_bitkey = s... |
class ProfilesController < ApplicationController
def show
@profile = Profile.find_by_key('Billy')
end
end
|
#!/usr/bin/env ruby
require 'shrink'
require 'trollop'
opts = Trollop::options do
version "shrink #{Shrink::VERSION} (c) 2012 Jacob Gillespie"
banner <<-EOS
Shrink shrinks (minifies) your web assets. Shrink currently supports JavaScript
via the Google Closure Compiler.
Usage:
shrink [options] <input file>
... |
feature 'can add a bookmark' do
scenario 'adds one bookmark' do
visit '/'
click_button 'Bookmarks'
fill_in 'title', with: 'Facebook'
fill_in 'url', with: 'https://www.facebook.com/'
click_button 'Add'
click_button 'View all'
expect(page).to have_link('Facebook', :href => 'https://www.face... |
require 'docubuild/context_match'
module DocUBuild
class InfobuttonResponder
# Given a collection of Context results, initialize what will be our main collection of
# matches - factoring in documents linked to matched sections, and sections linked to
# matched documents.
def initialize_matches conte... |
$LOAD_PATH << '.'
require 'vertex'
require 'edge'
require 'matrix'
class Graph
attr_accessor :vertexs
def initialize
@vertexs = []
end
def add_vertex(vertex)
vertexs << vertex
vertex.graph = self
end
def remove_vertex(vertex)
vertexs.delete(vertex)
end
end... |
class SendMeetingListJob < ApplicationJob
def perform
ActiveRecord::Base.transaction do
User.find_each do |user|
if user.slack_token.present?
SlackClient.new(user.slack_token).post_message(
user.slack_uid, MeetingsPresenter.new(user).today_meetings_list_text
)
... |
class ContentCloners::TicketTypesCloner < ContentCloners::ContentClonerBase
def clone(convention)
@id_maps[:ticket_types] = clone_with_id_map(
source_convention.ticket_types,
convention.ticket_types
)
end
end
|
cask :v1 => 'gyazo' do
version '2.1'
sha256 '88491cc2a9d481fdb99b822ca49560427ed11578b304203c4504d83fc2562061'
url "https://files.gyazo.com/setup/Gyazo_#{version}.dmg"
homepage 'https://gyazo.com/'
license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placehold... |
class SendWelcomeSms
@queue = :normal
def self.perform(user_uuid)
return unless user = User.find_by_uuid(user_uuid)
phone = user.mobile_phone
return if phone.blank?
url = Rails.application.routes.url_helpers.dashboard_url(protocol: PROTOCOL, host: HOST)
short_url = Api::Bitly.shorten(url)
... |
class ExerciseDescriptionSerializer < ActiveModel::Serializer
include Pundit
attributes :id,
:name,
:short_name_for_mobile,
:description,
:distance,
:duration,
:load,
:repetition,
:tempo,
:video_url,... |
# -- Tipos Ruby --
# -- O tipo de uma variavel é definido no momento que ela recebe o valor --
produto = 'MacAir'
preco = 999
quantidade = 10
disponivel = true
puts produto
puts preco
puts quantidade
puts disponivel
puts produto.class
puts preco.class
puts quantidade.class
puts disponivel.class
|
class MatchResult < ApplicationRecord
has_paper_trail
belongs_to :applicant
belongs_to :program
belongs_to :university
end
|
class User < ApplicationRecord
has_secure_password
# has_one :shopping_cart
has_one :current_cart
has_one :shopping_cart, through: :current_cart
has_many :payments
# has_many :shopping_carts, through: :payments
has_many :purchases, through: :payments
# Returns the hash digest of ... |
# frozen_string_literal: true
require 'spec_helper'
describe Sip2::Messages::Login do
subject(:login_message) { described_class.new(connection) }
let(:connection) { instance_double 'Sip2::Connection' }
describe '#action_message' do
subject(:action_message) do
login_message.action_message(username: u... |
class AddPrizeToParlays < ActiveRecord::Migration[5.2]
def change
add_column :parlays, :prize, :integer, default: 0
add_column :parlays, :withdrawn, :bool, default: false
end
end
|
# frozen_string_literal: true
# typed: false
require 'spec_helper'
describe AlphaCard::Sale do
let(:billing) { AlphaCard::Billing.new(email: 'test@example.com', address_1: 'N', address_2: 'Y', state: 'MN') }
let(:shipping) { AlphaCard::Shipping.new(first_name: 'John', last_name: 'Doe', address_1: '22 N str.', sta... |
require 'simplecov'
SimpleCov.start
require 'minitest/autorun'
require "minitest/reporters"
Minitest::Reporters.use!
require_relative 'to_do_list'
class TodoListTest < MiniTest::Test
def setup
@todo1 = Todo.new("Buy milk")
@todo2 = Todo.new("Clean room")
@todo3 = Todo.new("Go to gym")
@todos = [@to... |
Tabulous.setup do
tabs do
home_tab do
text { 'INICIO' }
link_path { inicio_path }
visible_when { true }
enabled_when { true }
active_when { in_action('index').of_controller('home') }
end
servicio_tab do
text { 'SERVICIO' }
link_... |
require 'redis'
require 'openssl'
class Redis
module Connection
class Universal < Ruby
def connect(uri, timeout)
super if uri.scheme == 'redis'
return connect_ssl(uri, timeout) if uri.scheme == 'redis+ssl'
end
def connect_ssl(uri, timeout)
with_timeout(timeout.to_f / 1_... |
class Comment < ActiveRecord::Base
has_many :replies, :class_name => "Comment", dependent: :destroy
belongs_to :article
belongs_to :comment
validates :article, :text, presence:true
validates :text, length: { maximum: 1401,
too_long: "%{count} characters is the maximum allowed" }
after_create :notif... |
Rails.application.routes.draw do
# root route
root "site#index"
# candles routes
get "api/candles", to:"candles#index"
get "api/candles/:id", to:"candles#show"
post "api/candles", to:"candles#create"
delete "api/candles/:id", to:"candles#delete"
put "api/candles/:id", to:"candles#update"
end
|
class FillProjectsActivityRoles < ActiveRecord::Migration
def self.up
Project.all.each do |project|
activities = project.send(:active_activities, true)
unless activities.blank?
activities.each do |activity|
member_roles = project.all_members_roles
unless member_roles.blank?... |
# frozen_string_literal: true
require 'rbnacl'
require 'json'
require 'base64'
require 'io/console'
module Symmetric
def self.timingsafe_compare(secret1, secret2)
check = secret1.bytesize ^ secret2.bytesize
secret1.bytes.zip(secret2.bytes) { |x, y| check |= x ^ y.to_i }
check.zero?
end
def self.kdf... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :posts
validates :nickname, pres... |
=begin
Implementation of a queue in Ruby,
which contains elements in a first-in, first-out order.
Uses:
- Maintaining a queue of processes that are ready to execute or waiting for
a particular event to occur.
- Buffers.
=end
class Queue
attr_accessor :head, :tail, :size
Node = Struct.new(:from, :to, :obj)
... |
FactoryGirl.define do
factory :recipe do
name "MyString"
short "MyString"
description "MyText"
owner_id 1
end
end
# == Schema Information
#
# Table name: recipes
#
# id :integer not null, primary key
# name :string
# short :string
# descriptio... |
# frozen_string_literal: true
GITHUB_REPO = %r{https://github\.com/([.\-_a-zA-Z0-9]+)/([.\-_a-zA-Z0-9]+)}
# KramdownVisitor is a helper class to visit the nodes in a Markdown/Kramdown document in the repository.
# You are able to specify the types of element you would like to restrict to.
class KramdownVisitor
attr... |
class ManageIQ::Providers::Amazon::NetworkManager::LoadBalancer < ::LoadBalancer
def self.display_name(number = 1)
n_('Load Balancer (Amazon)', 'Load Balancers (Amazon)', number)
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.