text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
class Balance
include ActiveModel::Model
Wrapper = Struct.new(:user, :balance, :pending_balance, :created_at) do
include ActiveModel::Serialization
end
def initialize(user)
@user = user
end
def pending_debt
Money.new(
BalanceQuery.new(user).pending_balances... |
class CreateTransactions < ActiveRecord::Migration[5.1]
def change
create_table :transactions do |t|
t.references :event
t.references :attendee
t.integer :status_after
t.integer :status_before
t.timestamps
end
end
end
|
class ApplicationController < ActionController::Base
# around_action :switch_locale
def switch_locale(&action)
locale = user_signed_in? ? current_user.configuration.locale : 'en'
I18n.with_locale(locale, &action)
end
rescue_from CanCan::AccessDenied do |exception|
flash[:notice] = 'You are unauth... |
module JsonSpec
module Exclusion
extend self
def exclude_keys(ruby)
case ruby
when Hash
ruby.sort.inject({}) do |hash, (key, value)|
hash[key] = exclude_key?(key) ? 1 : exclude_keys(value)
hash
end
when Array
ruby.map{|v| exclude_keys(v) }
e... |
class RequirementSeverity < ActiveRecord::Base
has_many :requirements
validates_presence_of :code, :name
validates_uniqueness_of :code, :name
end
|
require "json"
require "selenium-webdriver"
require "test/unit"
class LogIn < Test::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :chrome
@base_url = "https://staging.shore.com/merchant/bookings"
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = 30
@verification_erro... |
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
class AdvancedTaxonExtension < Spree::Extension
version "0.1"
description "Adds an opportunity to attach a picture and description for the taxon."
url "http://yourwebsite.com/extended_taxon"
# Please use e... |
class PartePagamentosController < ApplicationController
before_action :set_parte_pagamento, only: [:show, :edit, :update, :destroy]
# GET /parte_pagamentos
# GET /parte_pagamentos.json
def index
@parte_pagamentos = PartePagamento.all
end
# GET /parte_pagamentos/1
# GET /parte_pagamentos/1.json
def... |
class Item < ApplicationRecord
with_options presence: true do
validates :title
validates :price
validates :content
validates :images
end
has_many_attached :images
belongs_to :user
has_many :comments, dependent: :destroy
has_one :order
end
|
class AddVariablesToScrambles < ActiveRecord::Migration
def change
add_column :scrambles, :currentDiscountStatus, :string
add_column :scrambles, :totalBids, :integer
add_column :scrambles, :nextMilestone, :string
add_column :scrambles, :bidsUntilNextMilestone, :integer
add_column :scrambles, :avai... |
class ProblemsController < ApplicationController
include ApplicationHelper
before_action :check_is_admin, except: [:index, :show]
before_action :set_problem, only: [:show, :edit, :update, :destroy]
def index
@problems = Problem.all
if params.has_key?(:origin_id)
@problems = Origin.find(params[:ori... |
Rails.application.routes.draw do
devise_for :users
root to: 'pages#home'
resources :matches, only: [:index, :show] do
resources :bookings, only: [:create]
end
resources :bookings, only: [:destroy]
resources :seats, only: [:new, :create, :show] do
end
get 'dashboard', to: 'pages#dashboard'
# get... |
# 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
module Awesome
module Definitions
module Stopwords
QUOTED_REGEX = /("[^"]*")/
UNQUOTED_REGEX = /"([^"]*)"/
RM_QUOTED_REGEX = /"[^"]*"/
BEG_OPERATORS = /^[+-]/
END_OPERATORS = /[,+-]$/
EXCLUSION_OPERATORS = /^[-]/
INCLUSION_OPERATORS = /^[+]/
def self... |
class AddSpreeProductAdditionalInstructionsPosition < ActiveRecord::Migration
def change
add_column :spree_product_additional_instructions, :position, :integer
end
end
|
class FeedPostSubject < ActiveRecord::Base
has_one :notification, as: :subject
belongs_to :poster, class_name: "User"
delegate :name, to: :poster, prefix: true
validates :user_id, :poster_id, presence: true
end
|
class PomodorosController < ApplicationController
before_action :set_pomodoro, only: [:show, :update, :destroy]
# GET /pomodoros
# GET /pomodoros.json
def index
@pomodoros = Pomodoro.all
render json: @pomodoros
end
# GET /pomodoros/1
# GET /pomodoros/1.json
def show
render json: @pomodoro... |
require 'spec_helper'
require_relative '../../../lib/sucker_punch/testing/inline'
class PatchedWorker
include SuckerPunch::Worker
def perform
"do stuff"
end
end
SuckerPunch::Queue.new(:patched_queue).register(PatchedWorker, 2)
describe "SuckerPunch Inline Testing" do
let(:queue) { SuckerPunch::Queue.new(... |
class UsersController < ApplicationController
before_filter :require_login, :only => ['show', 'settings']
def show
@user_id = current_user.id
puts current_user.inspect
@user = current_user.get_full_info
@friends = current_user.get_friends
@groups = current_user.groups
@transactions = curre... |
class Administrator < ActiveRecord::Base
has_many :messages, dependent: :destroy
before_create :create_remember_token
validates :login, presence: true
validates :password, presence: true, length: { minimum: 6 }
has_secure_password
def self.new_remember_token
SecureRandom.urlsafe_base64
end
... |
FactoryGirl.define do
factory :question, class: Question do
sequence(:text){ |n| "Pregunta-#{n}" }
question_type "MULTIPLE"
required true
end
end
|
require 'test_helper'
class SketchesControllerTest < ActionDispatch::IntegrationTest
setup do
@sketch = sketches(:one)
end
test "should get index" do
get sketches_url
assert_response :success
end
test "should get new" do
get new_sketch_url
assert_response :success
end
test "should ... |
require 'bundler'
Bundler.require
# https://stackoverflow.com/a/71994319
require 'uri'
def URI.escape(url)
url
end
set :markdown_engine, :redcarpet
set :markdown, layout_engine: :erb,
fenced_code_blocks: true,
lax_html_blocks: true,
with_toc_data: true
activate :syntax... |
feature "viewing bookmarks" do
let(:bookmarks) { ['Google', 'Makers Academy'] }
scenario "see bookmarks at the /bookmarks route" do
visit("/")
click_button("View Bookmarks")
expect(page).not_to have_content "Hello World! Here are your bookmarks"
expect(page).to have_content "Here is your list of b... |
#!/usr/bin/env ruby
# A simple tool to generate Sub Resource Integrity hashes
# and store them in a JSON file which can also be versioned
# or consumed programatically.
require 'digest/sha2'
require 'json'
files = {}
Dir.glob('*.{js,css}').each do |file_name|
next if File.directory? file_name
files[file_name] =... |
# frozen_string_literal: true
require 'divvyup/utils'
require 'json'
# Service is responsible for abstracting all of the redis interactions.
class DivvyUp::Service
include DivvyUp::Utils
def initialize(redis: nil, namespace: nil)
@redis = redis || DivvyUp.redis || Redis.new
@namespace = namespace || Divvy... |
require_relative 'helpers'
class TestBot < Minitest::Spec
include Rack::Test::Methods
include Helpers
def setup
ENV['SLACK_TOKEN_OUT'] = '0000000000000000'
ENV['SLACK_TOKEN_IN'] = '1111111111111111'
ENV['DECAUX_TOKEN'] = '2222222222222222'
ENV['SLACK_TEAM'] = 'bikebotser'
end
def test_help
... |
Rails.application.routes.draw do
# Websites With Authorization
authenticate :user do
resources :websites
end
devise_for :users
#Profile Routing
get '/profile', to: 'profiles#new'
post '/profiles', to: 'profiles#create'
#Skill Routing
get '/skill', to: 'skills#new'
post '/skills', to: 'skills#cr... |
class Admin::HeightsController < ApplicationController
before_action :authenticate_admin!
def index
@height = Height.new
@heights = Height.all
end
def edit
@height = Height.find(params[:id])
end
def create
@heights = Height.all
@height = Height.new(permit_height)
if @height.save
... |
class ApplicationController < ActionController::Base
protect_from_forgery
layout :layout
before_filter :set_current_account
before_filter :set_current_order_if_front
before_filter :clear_completed_order_if_front
before_filter :authenticate_admin!
private
def set_current_account
# Cases
... |
require 'rails_helper'
RSpec.describe TrackPoint, type: :model do
let(:track_point) { FactoryGirl.create :track_point }
describe '#to_coordinates'
it 'returns an array of coordinates' do
expect(track_point.to_coordinates).to eq [52.13, 13.14]
end
end
|
# a method that determines and returns ASCII string value
# should be the sum of every character's value
def ascii_value(input)
input.split('').reduce(0) do |sum , i|
sum + i.ord
end
end
p ascii_value('Four score') == 984
p ascii_value('Launch School') == 1251
p ascii_value('a') == 97
p ascii_value('') == 0 |
require "rails_helper"
RSpec.describe Api::JwtsController, type: :controller do
before do
setup_application_instance
@user = FactoryBot.create(:user)
@user.confirm
@user_token = AuthToken.issue_token(
{
application_instance_id: @application_instance.id,
user_id: @user.id,
... |
module Frontend
class UsersController < FrontendController
attr_reader :user
def next_step
if current_user
case current_user.state
when "invited"
redirect_to register_path
when "registered"
redirect_to booking_calendar_url
when "booked"
... |
class Order < ApplicationRecord
#responsibilty: persistance of orders
#reason to change: order schema changes
has_many :product_requests, inverse_of: :order
has_many :order_items, inverse_of: :order
has_many :products, through: :product_requests, inverse_of: :orders
has_many :product_packages, through: :or... |
class ChangePositionWorkerFromworkercontract < ActiveRecord::Migration
def change
change_column :worker_contracts, :charge_id, :integer
end
end
|
class Admin::AdminsController < Admin::UsersController
protected
def users_scope
User.admin
end
def redirect_path
admin_admins_path
end
end
|
# As Player 1,
# So I can win a game of Battle,
# I want to attack Player 2, and I want to get a confirmation
feature 'Attacking...' do
before :each do
allow(Kernel).to receive(:rand).and_return 10
end
scenario 'Player 2 is attacked' do
sign_in_and_play
click_button('Attack')
expect(page).to have_... |
require 'spec_helper'
describe Admin::OrdersController do
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:user]
FactoryGirl.create(:configuration_setting)
@user = FactoryGirl.create(:user, payment_method: true, role: 3, confirmed_at: "2013-05-28 06:38:19.499604")
@order = Fa... |
class Admin::DisciplinesController < Admin::BaseController
before_action :_set_discipline, except: %i[index new create]
def index
@disciplines = Discipline.all
end
def show; end
def new
@discipline = Discipline.new
render partial: 'form', layout: false
end
def edit
render partial: 'for... |
class QuestionController < BasicInstrumentController
def show
respond_to do |f|
f.json { render json: @object}
f.xml { render body: @object.to_xml_fragment, content_type: 'application/xml' }
end
end
def create
update_question @object = collection.new(safe_params) do |obj|
obj.save
... |
class Artist < ActiveRecord::Base
has_many :songs
has_many :genres, through: :songs
end
|
# frozen_string_literal: true
module Brcobranca
module Boleto
# Banco do Nordeste
class BancoNordeste < Base
# <b>REQUERIDO</b>: digito verificador da conta corrente
attr_accessor :digito_conta_corrente
validates_length_of :agencia, maximum: 4, message: 'deve ser menor ou igual a 4 dígitos... |
#
# Cookbook Name:: kidsruby_os
# Recipe:: chroot_bootstrap
#
# make sure the customization-scripts directory exists
directory "#{node[:kidsruby_os][:remaster_root]}/customization-scripts" do
owner "root"
group "root"
action :create
end
# setup bootstrap files inside the chroot
%w[chroot-bootstrap.sh chef-boo... |
module Steppable
def moves
array = []
origin = self.pos
x, y = origin.first, origin.last
self.move_diffs.each do |diff|
dx, dy = diff.first, diff.last
new_pos = [x + dx, y + dy]
#in bounds check
if new_pos.all? { |coord| coord.between?(0,7) }
if self.board[new_pos].... |
# frozen_string_literal: true
FactoryBot.define do
factory :customer do
name { Faker::Company.bs }
ssn { Faker::CPF.numeric }
end
end
|
require 'rails_helper'
feature 'Searching', js: true do
scenario 'When I visit the main page I see basic layout' do
visit root_path
expect(page).to have_content 'Welcome to database search'
expect(page).to have_css '#search-form'
end
scenario 'When I fill in input, the button text changes' do
... |
class MigracionCompleta < ActiveRecord::Migration[5.1]
def change
add_column :question_comments, :fecha, :date
add_column :question_comments, :texto, :string
add_reference :question_comments, :user
add_reference :question_comments, :question
end
end
|
class CreateProfileEmailAccesses < ActiveRecord::Migration
def change
create_table :profile_email_accesses do |t|
t.integer :email_access_id
t.integer :profile_id
end
end
end
|
module Apple
module DeviceEnrollmentProgram
class Device
attr_reader :serial_number, :model, :profile_status
def initialize(serial_number:, attributes: {})
@serial_number = serial_number
update attributes
end
def update(attributes = {})
@model = attributes['mode... |
require_relative 'board'
require_relative 'human_player'
class Game
def initialize(size, *marks)
# @player_1 = HumanPlayer.new(mark_1)
# @player_2 = HumanPlayer.new(mark_2)
@players = marks.map { |mark| HumanPlayer.new(mark) }
@game_board = Board.new(size)
@curr_player = @pl... |
require 'rails_helper'
RSpec.describe Api::V1::AnswersController, :type => :controller do
describe 'POST /games/:game_id/answers' do
it_behaves_like 'an authenticated only action' do
subject { post(:create, :game_id => 1) }
end
describe 'successful call' do
let(:player) { build(:player) }
... |
class Ability
include CanCan::Ability
def initialize(user)
if user.admin?
can :manage,:all
else
can :update,Product do |product|
product.seller == user
end
can :destroy,Product do |product|
product.seller == user
end
can :create,Product
can ... |
class AddAttachmentEpsProductToProduct < ActiveRecord::Migration
def self.up
add_column :products, :eps_product_file_name, :string
add_column :products, :eps_product_content_type, :string
add_column :products, :eps_product_file_size, :integer
add_column :products, :eps_product_updated_at, :datetime
... |
require "rails_helper"
describe SessionsController do
describe "GET new" do
it "renders new template" do
get :new
expect(response).to render_template :new
end
end
describe "POST create" do
context "with valid credentials" do
let(:paquito) { Fabricate :user }
before do
... |
# deck.rb
VALUES_LIST = (1..13).to_a
SUITS_LIST = [:hearts, :clubs, :spades, :diamonds]
require_relative 'card'
class Deck
def initialize(values, suits)
@cards = []
values.each do |value|
suits.each do |suit|
@cards << Card.new(suit, value)
end
end
end
def draw
drawn_car... |
# frozen_string_literal: true
require 'smarter_csv'
class CSVDataSeeder
DEFAULT_SKILL_NAMES = {
memorization: 'Memorization',
grit: 'Grit',
teamwork: 'Teamwork',
discipline: 'Discipline',
self_esteem: 'Self-Esteem',
creativity: 'Creativity & Self-Expression',
language: 'Language'
}.fre... |
Rails.application.routes.draw do
devise_for :users, controllers: { registrations: "registrations" }
root "static_pages#home"
get "about" => "static_pages#about"
get "contact" => "static_pages#contact"
resources :activities
resources :subjects
resources :users, only: [:index, :show, :updat... |
require "minitest/autorun"
require "change"
class ChangeTest < MiniTest::Unit::TestCase
def setup
@change = Change.new(0.51)
end
def test_that_change_can_be_created
refute_nil @change, 'Change is nil!'
end
def test_change_stores_argument
assert_equal 0.51, @change.money
end
def test_we_can_... |
require 'rake/testtask'
begin
require 'rake/extensiontask'
rescue LoadError
abort <<-error
rake-compile is missing; Rugged depends on rake-compiler to build the C wrapping code.
Install it by running `gem i rake-compiler`
error
end
Rake::ExtensionTask.new('rugged') do |r|
r.lib_dir = 'lib/rugged'
end
task... |
require 'test_helper'
class HourTest < ActiveSupport::TestCase
test "Saving with variable parameters" do
assert save_with, "Valid input"
[:project_id, :user_id, :hourtype_id].each { |p|
assert_not save_with( { "#{p}" => 'asdc' } ), "Non numieric #{p}"
assert_not save_with( { "#{p}" => nil } ), "Omit... |
require 'test_helper'
class EmployeesShowTest < ActionDispatch::IntegrationTest
include ApplicationHelper
def setup
@user = users(:jane)
@employee = employees(:one)
end
test "redirect show as logged-out user" do
get employee_path(@employee)
assert_redirected_to login_path
follow_redirect!... |
require 'rails_helper'
RSpec.describe Product, type: :model do
it { should validate_presence_of :name; :description; :price }
it { should have_many :reviews }
it { should have_many(:users).through(:reviews) }
end
|
# == Schema Information
#
# Table name: comments
#
# id :bigint not null, primary key
# content :text not null
# created_at :datetime not null
# updated_at :datetime not null
# tweet_id :bigint not null
# user_id :bigint not null
#
# Indexe... |
class SpendingInfo < SpendingInfo.superclass
module Cell
class Show < Abroaders::Cell::Base
def initialize(account, options = {})
super
unless eligible_people.any?
raise 'account must have >= 1 eligible person'
end
end
property :eligible_people
property :... |
#
# Cookbook Name:: jolokia-jvm-agent
# Spec:: default
#
require 'spec_helper'
describe 'jolokia-jvm-agent::default' do
platforms = {
'centos' => ['6.6', '7.0'],
'ubuntu' => ['14.04']
}
platforms.each do |platform, versions|
versions.each do |version|
context "on #{platform.capitalize} #{versi... |
class CreateProducts < ActiveRecord::Migration[5.1]
def change
create_table :products do |t|
t.string :sku, null: false
t.string :name, null: false
t.text :description, null: false
t.belongs_to :product_kind, foreign_key: true, null: false
t.bigint :stock, null: false
t.bigint ... |
require "net/ftp"
class FTPConnectionError < Net::FTPError; end
class DownloadError < Net::FTPError; end
class SchemaDumpError < RuntimeError; end
class DatabaseDumpError < RuntimeError; end
class DatabaseUploadError < RuntimeError; end |
# Bugfix: Team.offset(1).limit(1) throws an error
ActiveRecord::Base.instance_eval do
def offset(*args, &block)
scoped.__send__(:offset, *args, &block)
rescue NoMethodError
if scoped.nil?
'depends on :allow_nil'
else
raise
end
end
end
|
require 'rails_helper'
RSpec.describe 'registration page' do
it 'displays correct fields to create new user' do
visit '/users'
click_link 'New User'
expect(current_path).to eq('/users/new')
expect(page).to have_field('user[first_name]')
expect(page).to have_field('user[last_name]')
expect(page).to have_fie... |
class MakeEmailEventIdDefaultToNull < ActiveRecord::Migration
def change
change_column :emails, :event_id, :integer, :null => true, :default => nil
end
end
|
require_relative 'questions_module'
require_relative 'save_module'
require_relative 'models'
class User
extend QuestionsModule
include SaveModule
def self.table_name
"users"
end
def self.find_by_name(fname, lname)
user = QuestionsDatabase.instance.execute(<<-SQL, fname, lname)
SELECT
... |
require 'action_view/helpers/date_helper'
include ActionView::Helpers::DateHelper
class Meta < ActiveRecord::Base
def self.last_commit
begin
commits = GitHub::API.commits('beilabs','www.beilabs.com')
message = "This site was last updated on #{ commits.first.committed_date.to_time + 7.hours }"
F... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable,
:confirmable, :lockable, :timeoutable, :trackab... |
module SPV
# Keeps options which are used to identify path to fixtures
# and options for a waiter which holds execution until expectation
# has been met.
class Options
attr_accessor :waiter, :waiter_options, :shortcut_paths
def initialize(options = {})
@shortcut_paths = {}
options.each do ... |
module EmailRegexpValidator
#http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
def valid_email?(email)
!/^.+@.+\..+$/.match(email).nil?
end
module_function :valid_email?
end |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :confirmable, :rememberable, :trackable, :validatable
apply_simple_captcha
... |
class Table < ApplicationRecord
belongs_to :club
has_one :reservation
# Validates Table Name
validates :table_name, presence: true, length: { maximum: 30 }
#
# # Validates Minimum as String
validates :minimum, presence: true, length: { maximum: 15 }
# Validates Minimum as Int
# validates :minimum, p... |
class UpdateOneGemJob < ApplicationJob
def perform
nekst = LaserGem.unscoped.order( updated_at: :asc).limit(1).first
weeks = (Time.now - nekst.updated_at) / 1.week
return if weeks < 1
UpdateLaserGemJob.perform_later( nekst.name )
end
end
|
class Api::V1::InvoiceItems::InvoiceItemsInvoicesController < ApplicationController
def show
invoice_item = InvoiceItem.find(params["invoice_item_id"])
@invoice = invoice_item.invoice
end
end
|
class Admin < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
attr_accessor :password
validates :password,
:presence => true,
:confirmation => true,
:length => { :minimum => 5, :... |
# encoding: utf-8
control "V-52353" do
title "The DBMS must provide a mechanism to automatically terminate accounts designated as temporary or emergency accounts after an organization-defined time period."
desc "Temporary application accounts could ostensibly be used in the event of a vendor support visit where a su... |
class LogStash::Inputs::KinesisCloudWatchLogSubscription::Worker
include com.amazonaws.services.kinesis.clientlibrary.interfaces::IRecordProcessor
attr_reader(
:checkpoint_interval,
:codec,
:decorator,
:logger,
:output_queue,
)
def initialize(*args)
# nasty hack, because this is the na... |
# encoding: utf-8
# core/plugin/gtk 互換プラグイン
module Plugin::Gtk
class GtkError < StandardError; end
end
Plugin.create(:gtk) do
# 互換クラスのインスタンスを保持する
@pseudo_instances = {
postbox: Plugin::GUI::Postbox.instance,
timeline: Plugin::GUI::Timeline.instance
}
def widgetof(slug_or_instance)
if slug_o... |
require 'spec_helper'
describe "groups you are a part of" do
let(:post1) {create(:post, :recipients => "testonid@onid.oregonstate.edu", :allow_onid => true)}
before do
RubyCAS::Filter.fake("testonid")
visit signin_path
visit root_path
end
context "when logged in as the recipient of a post" do
b... |
class CLI
attr_accessor :user, :animal, :last_selected_species
def initialize
@user = nil
@animal = nil
@last_selected_species = nil
end
def art_
puts " ______ _ ___ ______ _
| ___| | | / _ \\ | ___ \ | |
... |
class TermsController < ApplicationController
before_action :logged_in_user, only: [:index, :new, :edit, :destroy]
before_action :check_guest_user
def new
@term = Term.new
end
def create
@term = Term.new(term_params)
if @term.save
flash[:success] = "新しい用語が登録されました"
redirect_to term... |
require 'test_helper'
module Adminpanel
class SortableGalleryUnitTest < ActiveSupport::TestCase
setup :instance_objects
def test_has_and_ordered_scope
gallery = adminpanel_galleries(:one)
ordered_galleries = gallery.galleryfiles.ordered.pluck(:position)
assert_equal [1,2,3,4,5], ordered_gal... |
class DistillerSerializer < ActiveModel::Serializer
attributes :id, :name, :region, :region_name
belongs_to :region
has_many :whiskeys
def region_name
object.region.country
end
end
|
require "rails_helper"
RSpec.describe RingGroupCall, type: :model do
context "validations" do
it "is valid with valid attributes" do
expect(build_stubbed(:ring_group_call)).to be_valid
end
it { should validate_presence_of(:from_phone_number) }
it { should validate_presence_of(:from_sid) }
en... |
module BCrypt
# A password management class which allows you to safely store users' passwords and compare them.
#
# Example usage:
#
# include BCrypt
#
# # hash a user's password
# @password = Password.create("my grand secret")
# @password #=> "$2a$12$C5.FIvVDS9W4AYZ/Ib37YuWd/7ozp1UaMhU28UKrfS... |
class Answer < ApplicationRecord
belongs_to :Question
belongs_to :Quiz
end
|
# == Schema Information
#
# Table name: participants
#
# id :integer not null, primary key
# nombre :string
# ocupacion :string
# interes :string
# correo :string
# telefono :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Participan... |
# Christie Finnie
# Due: 2019-12-16
# Specs for testing the bowling score keeper
require "rspec"
require "./bowlingScoreKeeper.rb"
RSpec.describe "Bowler" do
context "When strike in frame 1" do
it "Score is nil" do
player = Bowler.new
player.rolls("X")
expect(player... |
# $LICENSE
# Copyright 2013-2014 Spotify AB. All rights reserved.
#
# The contents of this file are 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-... |
require 'spec_helper'
describe Submission do
context "validations" do
it "should validate the presence of a title" do
FactoryGirl.build(:submission, title: "").should_not be_valid
end
it "should validate the presence of a submitter" do
FactoryGirl.build(:submission, submitter: "").should_no... |
class RenameTargetTypeColumn < ActiveRecord::Migration[5.2]
def change
rename_column :targets, :type, :target_type
end
end
|
unless ARGV.size == 1
raise "no valid path to outlook-exported file was provided.\n
Call script with 'ruby #{__FILE__} /path/to/contacts.csv'"
end
raise "File #{ARGV[0]} does not exist!" unless File.exist?(ARGV[0])
FNAME = ARGV[0]
MAX_FIELDS = 61
FORMAT = 'bom|utf-8'.freeze
def i(name)
name = name.lower.... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_IMAGE = "centos/7"
NODE_COUNT = 2
Vagrant.configure("2") do |config|
config.vm.define "master" do |subconfig|
subconfig.vm.box = BOX_IMAGE
subconfig.vm.hostname = "master"
subconfig.dns.tld = "master"
subconfig.vm.network :private_network, ip: "10.0.0... |
require File.join(Dir.pwd, 'spec', 'spec_helper')
describe 'UserProcessList' do
before do
simulate_connection_to_server
end
after do
end
it 'should pass if user process list attribute is not specifed' do
user_id = 123
request_data = FactoryGirl.attributes_for(:user_process_list, {
:tota... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.