text stringlengths 10 2.61M |
|---|
class Order < ActiveRecord::Base
module Paypal
extend ActiveSupport::Concern
def paypal_checkout_url(return_url, cancel_url)
response = client.setup(
payment_request,
return_url,
cancel_url,
pay_on_paypal: true,
no_shipping: true,
allow_note: false
... |
require 'delegate'
class ThreadLocal
def self.finalizer_proc
@finalizer_proc ||= lambda do |object_id|
Thread.list.each do |thread|
if thread_locals = Thread.current.thread_variable_get(:thread_locals)
thread_locals.delete object_id
end
end
end
end
def initialize(de... |
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
$:.unshift(File.dirname(__FILE__))
require 'TestSetup'
require 'RandomThings'
class PgBitTest < Test
include SqlPostgres
include RandomThings
def test_ctor_defaults
assertEquals(PgBit.new.bits, [])
end
def test_ctor_and_accessors
bits... |
require 'rails_helper'
RSpec.feature 'Admin discipline_monitors', type: :feature do
let(:admin) {create :admin}
let(:resource_name) { DisciplineMonitor.model_name.human }
before(:each) do
login_as admin, scope: :admin
@academic = create_list(:academic, 2).sample
@monitor_type = create_list(:monitor... |
# frozen_string_literal: true
class SubscriptionsController < ApplicationController
before_action :authenticate_user!
before_action :load_lesson, except: :index
def index
@subscriptions = current_user.subscriptions
end
def create
if Subscription.closed?
redirect_back_or @course, alert: t('cont... |
class Product < ActiveRecord::Base
default_scope :order => 'title'
has_many :line_items
before_destroy :ensure_not_referenced_by_any_line_item
validates :title, :description, :image_url, :presence => true
validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
validates :title, :uniqueness =>... |
class Supplier::CategoriesController<ApplicationController
before_action :authenticate_user!
before_action :authorize_supplier
def index
@categories = Category.all
end
def show
@category = Category.find(params[:id])
@subcategories = @category.subcategories.all
end
private
def category_params
... |
# frozen_string_literal: true
module Mutations
# Create or update category
class SaveCategory < BaseMutation
null false
argument :id, ID, required: false
argument :name, String, required: true
argument :category_group_id, ID, required: true
argument :goal, Integer, required: false
field :... |
require 'dank/version'
require 'dank/mixin'
require 'redis'
module Dank
def self.config config
@app_name = config[:app_name]
@autocomplete_on = config[:autocomplete]
end
def self.app_name
@app_name || 'hate'
end
def self.autocomplete_on
return @autocomplete_on unless @autocomplete_on == nil... |
class Chef < ActiveRecord::Base
has_many :recipes #the Chef model has many recipes, plural because it's the many part of one-to-many (rails convention)
before_save {self.email = email.downcase} #because we made email uppercase before
validates :chefname, presence: true, length: {minimum: 3, maximum: 40}
VALID_E... |
class CreatePropietarios < ActiveRecord::Migration
def change
create_table :propietarios do |t|
t.string "nombre", :limit => 40
t.string "apellido", :limit => 40
t.string "email", :limit => 255
t.string "telefono", :limit => 40
t.string "telefono_secundario", :limit => 40
t.float "co... |
require 'rails_helper'
RSpec.describe Login::BaseLogin, type: :model do
subject(:login) do
Login::BaseLogin.new(email: 'user@example.com', extra: {})
end
describe '#auth_provider' do
it 'raises an exception' do
expect { login.auth_provider }.to raise_error(RuntimeError, 'not implemented')
end
... |
module Fog
module Compute
class Brkt
class Real
def update_csp_image(id, attributes={})
request(
:expects => [202],
:method => "POST",
:path => "v1/api/config/cspimage/#{id}",
:body => Fog::JSON.encode(attributes)
)
e... |
class AddCaseIdToDocument < ActiveRecord::Migration
def change
add_column :documents, :case_id, :integer
add_index :documents, :case_id
end
end
|
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :set_current_user
def set_current_user
@current_user = EndUser.find_by(id: session[:user_id])
end
protected
def after_sign_in_path_for(resource)
case resource
... |
class Post < ActiveRecord::Base
validates_presence_of :title, :publish_date, :body, :user_id
validates_length_of :summary, :maximum => 300, :allow_blank => true
belongs_to :blog
belongs_to :user
has_many :comments, :dependent => :destroy
acts_as_taggable
before_save :format_attributes
named_sco... |
Mage::Application.routes.draw do
get "/" => "Pages#home", :as => "home"
get "/search" => "Pages#search", :as => "search"
get "/sign-in" => 'Sessions#new', :as => "sign_in"
delete "/sign-out" => 'Sessions#destroy', :as => "sign_out"
post "/sign-in" => "Sessions#create", :as => "sessions"
get "/register" =>... |
class Image < ActiveRecord::Base
belongs_to :parent, :polymorphic => true
has_attached_file :image,
:styles => { :ipad_mini_retina => "2048x1496", :ipad_mini => "1024x798", :large => "512x399", :medium => "205x150>", :thumb => "100x100>" },
:url => "/assets/:class/:id/:style/:basename.:extension",
:path => "... |
# frozen_string_literal: true
class Batch < ApplicationRecord
belongs_to :batch_status
has_many :packages
accepts_nested_attributes_for :packages
end
|
#association_javascript :resource1 => 'document',
# :resource2 => 'media_item',
# :association => 'document_media_item',
# :path_controller => '/admin/associations',
# :extra_fields => [],
# ... |
# frozen_string_literal: true
module AutomaticUpdate
class LoginRequest < DataRequest
REQUEST_URL = 'https://www.usps.org/x/validate.cgi?/cgi-bin-nat/tools/infobeg.cgi'
REQUEST_DATA = {
'cert' => ENV.fetch('AUTOMATIC_UPDATE_CERTIFICATE', nil),
'pin' => ENV.fetch('AUTOMATIC_UPDATE_PASSWORD', nil)... |
Rails.application.routes.draw do
# frontend plugins
scope PluginRoutes.system_info['relative_url_root'] do
scope '(:locale)', locale: /#{PluginRoutes.all_locales}/, defaults: {} do
instance_eval(PluginRoutes.load('front'))
end
end
# frontend camaleon cms
scope PluginRoutes.system_info['relative... |
# frozen_string_literal: true
require 'bolt/error'
# Runs the `plan` referenced by its name. A plan is autoloaded from `$MODULEROOT/plans`.
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction) do
# Run a plan
# @param plan_name The plan to ... |
class Questionnaire < ApplicationRecord
MEASURES = [:inclusion1, :inclusion2, :inclusion3, :inclusion4, :inclusion5,
:consent1, :consent2, :consent3, :consent4, :consent5, :consent6, :full_name, :email,
:mobile_number, :home_telephone, :gender, :age, :employment_status,
:filter1, :filter2, :past24, :pa... |
module DatesHelper
def pretty_date(date)
format = date.year == Date.current.year ? :short : :short_year
l(date, format: format)
end
end
|
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
describe Attribute do
context "getter method prefix" do
it "should be 'is' to boolean attributes" do
Attribute.new("active", "boolean").getter_prefix.should == "is"
end
it "should be 'get' otherwise" do
Attribute.new... |
class RenameGroupsIntoUserGroups < ActiveRecord::Migration
def change
rename_table :groups, :user_groups
end
end
|
module Errors
extend ActiveSupport::Concern
class ServiceUnavailableError < StandardError; end
included do
rescue_from ServiceUnavailableError do
respond_to do |format|
format.html { render file: Rails.root.join('public', '503'), layout: false, status: :service_unavailable }
format.any... |
## Copyright (c) 2015 SONATA-NFV, 2017 5GTANGO [, ANY ADDITIONAL AFFILIATION]
## ALL RIGHTS RESERVED.
##
## 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/licen... |
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/restaurants/new.html.erb" do
include RestaurantsHelper
before(:each) do
assigns[:restaurant] = stub_model(Restaurant,
:new_record? => true,
:name => "value for name",
:phone => "value for phone",
:emai... |
class Configure
def initialize(root)
@root = root
end
def set(configs)
configure_keys(@root, configs)
end
private
def configure_keys(object, hash)
hash.each do |key, value|
if value.kind_of? Hash
child = object.send(key)
configure_keys(child, value)
else
... |
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/meals/edit.html.erb" do
include MealsHelper
before(:each) do
assigns[:meal] = @meal = stub_model(Meal,
:new_record? => false,
:capacity => "1"
)
end
it "should render edit form" do
render "/meals/edit... |
require "spec_helper"
describe "qwyz item pages" do
subject { page }
before do
@user = create_test_user("n", "e@q.c", "passpass", "passpass")
@qwyz = create_test_qwyz(@user.id, "name", "question", "desc")
sign_in(@user)
end
describe "create a new qwyz item" do
before do
visit new_qwyz_item_path(qwyz... |
require 'spec_helper'
feature 'User watches the current phase of a challenge when the current phase is the selections ideas phase' do
# scenario 'anyone should see the total number of entries' do
# challenge = create :challenge,
# ideas_phase_due_on: 2.weeks.ago,
# i... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'EarningRule', type: :request do
def login(shop)
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:shopify,
provider: 'shopify',
uid: shop.shopify_domain,
... |
class AddFacebookToAdminUser < ActiveRecord::Migration
def change
add_column :admin_users, :provider, :string
add_column :admin_users, :uid, :string
add_column :admin_users, :name, :string
add_column :admin_users, :oauth_token, :string
add_column :admin_users, :oauth_expires_at, :datetime
end
end
|
require 'data_model/err'
module Moon
module DataModel
# Class for representing Object types
class Type
@@types = {}
# Class representing the Type
# @!attribute [r] model
# @return [Module] the main class of the type
attr_reader :model
# Object representing the model's ... |
# Create new hash
roman_numeral = { }
status = 'invalid'
# Defining the roman numeral hash
roman_numeral['I'] = 1
roman_numeral['V'] = 5
roman_numeral['X'] = 10
roman_numeral['L'] = 50
roman_numeral['C'] = 100
roman_numeral['D'] = 500
roman_numeral['M'] = 1000
while status != 'valid'
# Request a Roman numeral, capit... |
class FixColumnName < ActiveRecord::Migration[5.0]
def change
change_table :articles do |t|
t.rename :categoryid, :category_id
end
end
end
|
require 'ppc/baidu/account'
require 'ppc/baidu/plan'
require 'ppc/baidu/bulk'
require 'ppc/baidu/group'
require 'ppc/baidu/key'
require 'ppc/baidu/report'
require 'awesome_print'
require 'net/http'
require 'net/https'
require 'json'
# require 'savon'
module PPC
class Baidu
include ::PPC
def initialize(params... |
class CreateVehicles < ActiveRecord::Migration
def change
create_table :vehicles do |t|
t.string :name
t.text :description
t.string :patrimony
t.integer :status_vehicle
t.string :vehicle_plate
t.references :vehicle_type, index: true
t.references :vehicle_service,... |
# == Schema Information
#
# Table name: schedules
#
# id :integer not null, primary key
# hometeam :integer
# awayteam :integer
# date :datetime
# homegoals :integer
# awaygoals :integer
# league_id :integer
# hometeam_league_... |
class Card
include DataMapper::Resource
attr_accessor :id, :title, :body, :user
property :id, Serial # auto-increment integer key
property :name, String
property :content, Text
property :date, Date
property :created_at, DateTime
has_tags :tags
has 1, :user, :thr... |
class AddMoreInfoToDelivery < ActiveRecord::Migration
def change
add_column(:deliveries, :first_last_name, :text)
add_column(:deliveries, :phone_number, :text)
add_column(:deliveries, :address_continued, :text)
end
end
|
class CreateHeatsEvents < ActiveRecord::Migration
def change
create_table :heats_scouts, :id => false do |t|
t.integer :scout_id
t.integer :heat_id
end
end
end
|
require 'rubygems'
require 'bundler'
Bundler.require
require 'sinatra'
require 'google_translate'
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
get "/" do
haml :index
end
post "/*" do
if params["page"]
@arabic = params["page"]["arabic"]
# Parses depending on requested format.
... |
#encoding: utf-8
trap('SIGINT') {
Botpop::Plugins::Proxy.database_users_write({})
exit
}
class Proxy < Botpop::Plugin
include Cinch::Plugin
match("!proxy list", use_prefix: false, method: :exec_proxy_list)
match("!proxy ip", use_prefix: false, method: :exec_proxy_ip)
match("!proxy get", use_prefix: false... |
RSpec.describe Hanami::Action do
describe '.expose' do
it 'creates a getter for the given ivar' do
action = ExposeAction.new
response = action.call({})
expect(response[0]).to be(200)
expect(action.exposures.fetch(:film)).to eq('400 ASA')
expect(action.exposures.fetch(:time)).to be(... |
require 'timeout'
module Omnimutant
class Runner
def initialize(dirs_and_matchers:, exclude_dirs_and_matchers: [],
timeout:, test_command:, test_passing_regex:, verbose:0)
@dirs_and_matchers = dirs_and_matchers
@exclude_dirs_and_matchers = exclude_dirs_and_matchers
@timeout... |
class CreateTcTemplateFields < ActiveRecord::Migration
def self.up
create_table :tc_template_fields do |t|
t.string :type
t.integer :school_id
t.text :field_name
t.text :field_info
t.integer :priority
t.integer :parent_field_id
t.timestamps
end
end
def self.down
... |
class Company < ActiveRecord::Base
attr_accessible :name
has_many :offices
has_many :employees, :class_name => 'User'
has_one :subscription, :dependent => :destroy
validates_presence_of :admin_id, :name
after_create :make_admin_employee
def admin
User.find(admin_id)
end
private
def make_admin... |
FactoryGirl.define do
factory :league do
sequence(:name) {|n| "league#{n}" }
sport { FactoryGirl.create(:sport) }
visible true
end
end |
require 'rails_helper'
RSpec.describe CreateCourtRemindersJob, active_job: true, type: :job do
describe '#perform' do
let(:court_dates_path) { Rails.root.join('spec', 'fixtures', 'court_dates.csv') }
let(:court_locs_path) { Rails.root.join('app', 'assets', 'config', 'court_locations.csv') }
let(:user) { ... |
class AddStatusIdToStatuses < ActiveRecord::Migration[5.1]
def change
add_column :statuses, :status_id, :string
end
end
|
When(/^I click on delete button of a paricular admin$/) do
on DeletePage do |mage|
mage.del_button
end
end
Then(/^I should be able to delete an admin$/) do
on DeletePage do |mage|
mage.is_deleted?
end
end
|
require 'test/unit'
require 'lib/adsb/frame'
class TestRawFrames < Test::Unit::TestCase
def test_identification_frame
frame = ADSB::Frame.from_hex('8D3C67492010C231E508200D193B')
assert_equal(ADSB::Frame::IdentificationReport, frame.class)
assert_equal('DLH19P ', frame.identification)
end
end
|
require 'pry'
class Board
DIRECTIONS = [[1,0],[0,1],[1,1],[-1,1],[-1,0],[0,-1],[-1,-1],[1,-1]]
attr_accessor :columns
def initialize(args = {})
@width = args[:width] || 7
@height = args[:height] || 6
board_str = args.fetch(:board,nil)
if board_str
@columns = Array.new(@width){Arr... |
require 'strscan'
module TemplateParser
class Tokenizer
def initialize(source)
@scanner = StringScanner.new(source)
@state = :bol # :bol, :document
@start_doc = false
@line_no = 1
end
def next
return nil if @scanner.eos?
send("next_on_state_#{@state}")
end
... |
class ServiceCache < ActiveRecord::Base
def self.cache_timeframe
1.day # default, override in subclass
end
def self.all_records
self.base_where_clause
end
def self.find(key)
match = self.base_where_clause.where(key:key).limit(1)
return match.present? ? parse_data(match.first.data) : nil
e... |
class CreateDelayedJobs < ActiveRecord::Migration
def change
add_column :delayed_jobs, :queue, :string
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
end
end
|
require 'rails_helper'
RSpec.describe Item do
describe 'relationhips' do
it { should have_many :invoice_items }
it { should have_many(:invoices).through(:invoice_items) }
it { should belong_to :merchant }
end
describe 'validations' do
it { should validate_presence_of :name }
it { should valid... |
class AdminController < ApplicationController
before_filter :authenticate_user!
before_filter :validate_authorization!
add_breadcrumb 'Dashboard',"/"
add_breadcrumb 'Admin',"/admin/index"
add_breadcrumb "Valuesets", '', :only=>"valuesets"
add_breadcrumb "Users", '', :only=>"users"
def index
@jobs = Admi... |
class Chatbot::Speech
include ActiveModel::Model
attr_accessor :text
attr_accessor :locale
validates :text, presence: true, length: { maximum: 500 }
validates :locale, inclusion: { in: ChatSession.locales.keys.collect(&:to_s) }
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "pages#home"# Direct to home page- using PAGES_controller
devise_for :users, controllers: { registrations: 'users/registrations' }
resources :users do
resource :profi... |
class FontJunge < Formula
head "https://github.com/google/fonts/raw/main/ofl/junge/Junge-Regular.ttf", verified: "github.com/google/fonts/"
desc "Junge"
homepage "https://fonts.google.com/specimen/Junge"
def install
(share/"fonts").install "Junge-Regular.ttf"
end
test do
end
end
|
class CurrentConditionsDisplay
include Observer
include DisplayElement
attr_reader :temperature, :humidity, :pressure
def initialize(weather_data)
@weather_data = weather_data
weather_data.register_observer(self)
end
def update(temperature, humidity, pressure)
@temperature = temperature
@... |
class CommentsController < ApplicationController
before_action :set_commentable
def new
@comment = Comment.new
end
def create
logger.info(comment_params)
@comment = @commentable.comments.new(comment_params.merge({user: current_user}))
if @comment.save!
redirect_to @question
else
... |
module Spree
module Api
class SlidesController < Spree::Api::BaseController
skip_before_filter :check_for_user_or_api_key
skip_before_filter :authenticate_user
def index
lang = I18n.locale || 'en'
@slides = Spree::Slide.where(language: lang)
respond_with(@slides)
e... |
module Extensions::AttributeMethods
def attributes
HashWithIndifferentAccess[instance_variables.map do |var_name|
[var_name.to_s.gsub('@', ''), instance_variable_get(var_name)]
end]
end
end |
Vagrant.configure("2") do |config|
config.vm.box = "mh-aws"
config.vm.provider :aws do |aws, override|
override.ssh.username = "admin"
override.ssh.private_key_path = "~/.ssh/vagrant-test.pem"
aws.elastic_ip = "52.28.82.97"
end
config.vm.define "yeoman-vm" do |machine|
machine.vm.hostname = "... |
class EARMMS::SystemGrantController < EARMMS::SystemController
get '/' do
next halt 404 unless logged_in?
next halt 404 unless has_role? 'system:grant'
@title = "Grant roles"
haml :'system/grant/index'
end
get '/list' do
next halt 404 unless logged_in?
next halt 404 unless has_role? 'sys... |
require 'spec_helper'
describe 'Business Service Providers API V1', type: :request do
before(:all) do
BusinessServiceProvider.recreate_index
BusinessServiceProviderData.new(
"#{Rails.root}/spec/fixtures/business_service_providers/articles.json").import
end
describe 'GET /v1/business_service_provid... |
# Removed my_ before as the study drill suggested
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
# The variables above are descriptions of a person which include strings using the format of ' ' quotes and some use integers
puts "Le... |
module Types
class UserType < Types::BaseObject
field :id, ID, null: false
field :name, String, null: false
field :username, String, null: false
field :email, String, null: false
field :password_digest, String, null: false
field :reviews, [Types::ReviewType], null: true
field :review_count... |
class MenuItem < ActiveRecord::Base
has_many :galleries, :as => :imageable
has_many :pictures, :through => :galleries
belongs_to :category
end
|
#
# Authors: Christopher M Wood (<woodc@us.ibm.com>)
# John F Hutchinson (<jfhutchi@us.ibm.com)
# © Copyright IBM Corporation 2015.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
=begin
Assumptions:
-We will adopt the following naming convention to find/use/manage bosinst_data (BID) for a client LPAR:
... |
require "test/unit"
# Instructions:
# ---------------------
# 1. Run this program, and notice that all of the tests will fail.
# 2. Your assignment: add code to the methods so that the tests pass.
#
# Do NOT change any of the code in the TestCalculations class. :-)
# ----------------------
SCORING_RULES = { 1 => 1, 2... |
class LikesIndex < ActiveRecord::Migration
def up
end
def change
add_index :likes, :id
end
def down
end
end
|
class Slide < Airmodel::Model
# default to text if slide has no 'kind' defined
def slide_type
if self["Kind"].blank?
"text"
else
self["Kind"].parameterize
end
end
# list Assets in display order
def media_assets
self['media'].is_a?(Array) ? self['media'].reverse : []
end
# li... |
class Resource < ApplicationRecord
belongs_to :location
validates :category, presence: true
validates_inclusion_of :category, :in => ['Standing timber', 'Rough cut lumber', 'Milled lumber']
validates :status, presence: true
validates_inclusion_of :status, :in => ['Ready for harvest', 'Ready for market', 'Rea... |
Spree::LineItem.class_eval do
validate :quantity_does_not_exceed_limit
private
def quantity_does_not_exceed_limit
errors.add(:quantity, "You can not buy more than #{product.limit_qty} items") if quantity>product.limit_qty
end
end
|
#
#
# RESURRECTION OBJECTS
#
#
# RBPTH = "chingu/rebirth_assets/"
class Rift < Chingu::GameObject
trait :timer
def tremble
self.factor = 1.1
after(400) { self.factor = 0.9 }
after(480) { self.factor = 1.1 }
after(900) { self.factor = 1.2 }
after(950) { self.factor = 1.0 }
after(1050) {... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# -*- encoding : utf-8 -*-
class CreateChiefs < ActiveRecord::Migration
def change
create_table :chiefs do |t|
t.string :fname
t.string :sname
t.string :mname
t.string :title
t.timestamps
end
end
end
|
directory node['bank']['log_dir'] do
owner 'root'
group 'root'
mode 0755
action :create
end
log "message" do
message "Created /var/log/bank."
level :info
end
|
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Storage.delete_bucket' do
describe 'success' do
before(:each) do
AWS[:storage].put_bucket('fogdeletebucket')
end
it 'should return proper attributes' do
actual = AWS[:storage].delete_bucket('fogdeletebucket')
actual.st... |
class PigLatinizer
def piglatinize(input)
words = input.split(" ")
vowels = ["a", "e", "i", "o", "u",]
piglatin_words = []
words.each do |word|
letters = word.split("")
if vowels.include?(letters.first.downcase)
letters << "way"
letters.join("")
else
until v... |
#
# Be sure to run `pod lib lint SnapshotKit.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'Snapsho... |
# encoding: utf-8
require 'spec_helper'
describe Anima::Update, '#update' do
subject { object.update(attributes) }
let(:object) { class_under_test.new(foo: 1, bar: 2) }
let(:class_under_test) do
Class.new do
include Anima.new(:foo, :bar), Anima::Update
end
end
context 'with empty attributes... |
# frozen_string_literal: true
module ReceiptHelper
def receipt_customer(payment)
case payment&.customer
when String
mail_to(payment.customer)
when User
mail_to(payment.customer.email, payment.customer.full_name)
when MemberApplicant
mail_to(
payment.customer.email, "#{paymen... |
Senate::Application.routes.draw do
devise_for :profiles
resources :projects
get "pages/home"
match "feedback", :via => [:get, :post], :to=>"pages#feedback"
resources :blogs
resources :terms do
collection do
get :current
end
end
resources :offices
resources :committees do
resou... |
require 'spec_helper'
describe Technicalstaff do
before(:each) do
@teamstat = FactoryGirl.create(:teamstat)
@person = FactoryGirl.create(:person)
@attr = { :teamstat_id => @teamstat.id, :person_id => @person.id, :created_by_id => 1, :updated_by_id => 1 }
end
it "should create a new instance given v... |
class CreateDogs < ActiveRecord::Migration[6.1]
def change
create_table :dogs do |t|
t.string :name
t.string :color
t.string :breed
t.integer :aggressivebehavior
t.integer :speed
t.float :size
t.integer :sensitive
t.datetime :lastupdated
t.integer :sociability... |
require 'test/unit'
require './robot'
class Test_Robot < Test::Unit::TestCase
def setup
@robot = Robot.new(5,5)
end
def test_place_on_valid_location
assert @robot.place(0, 0)
assert_equal [0, 0], @robot.location
assert @robot.place(4, 4)
assert_equal [4, 4], @robot.location
end
def test... |
class Nvwa < Formula
desc "Small collection of C++ utilities"
homepage "https://github.com/adah1972/nvwa"
url "https://github.com/adah1972/nvwa/archive/Rel_1_0.tar.gz"
sha256 "ee802e1e6df821c771d5b5c6b8a00138e58d50f57a2edaabcdf978eb10a09d35"
def install
Dir.chdir "nvwa" do
system "#{ENV.cxx} #{ENV.... |
require "./lib/Lesson 9 Maximum Slice Problem/MaxDoubleSliceSum/max_double_slice_sum"
describe 'MaxDoubleSliceSum' do
describe 'Example Test' do
it 'Example' do
expect(max_double_slice_sum([3,2,6,-1,4,5,-1,2])).to eq 17
end
end
describe 'Correctness Tests' do
context 'Simple1' do
it 'Fi... |
module Eway
class Connection
attr_reader :body_response, :post_body
attr_reader :response
attr_accessor :verbose
def initialize
@root_url = Eway::Settings.root_url
@verbose = 0
end
def create_access_code
@url = @root_url + Eway::CREATE_ACCESS_CODE
@resource = Curl::Easy.http_post(@url) do |c... |
class Message < ApplicationRecord
belongs_to :user
belongs_to :lobby
validates :body, presence: true, length: { in: 1..2000 }
end
|
class CreateEmployeesTable < ActiveRecord::Migration
def up
add_column :branches_employees, :id, :primary_key
rename_column :branches_employees, :employee_id, :user_id
rename_table :branches_employees, :employees
end
def down
rename_table :employees, :branches_employees
rename_column :employe... |
class Trade < ActiveRecord::Base
DIRECTIONS = [:short, :long]
INTEREST_RATES = [0.2, 0.4]
belongs_to :rate_comparison
validates_presence_of :direction
validates_presence_of :rate_comparison_id
validates_presence_of :enter_rate
validates_presence_of :interest_rate
validates_inclusion_of :direction... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.