text stringlengths 10 2.61M |
|---|
class Tweet < ActiveRecord::Base
belongs_to :user
attr_accessible :body
def self.creatable?(creator, parent)
creator == parent
end
def self.readable?(reader, parent)
return true unless parent.protected?
reader == parent
end
def readable?(reader)
return true unless user.protected?
re... |
Rails.application.routes.draw do
mount EngineTest::Engine => "/engine_test"
end
|
# encoding: UTF-8
$parsed = {}
class Wu
def self.to_mongo(value)
value.nil? ? nil : proccess_data(value)
end
def self.from_mongo(value)
to_mongo(value)
end
private
def self.numeric?(object)
true if Float(object) rescue false
end
def self.proccess_data data
if numeric? data
retur... |
class RemovePartnersCodesFromSettings < ActiveRecord::Migration
def change
remove_column :settings, :car_rental
remove_column :settings, :hotels
remove_column :settings, :flights
end
end
|
require "spec_helper"
describe "Edit talk", :type => :request, :js => true do
let!(:user) { create(:user, :paul) }
let!(:billy) { create(:user, :billy, username: "@username_billy", name: "Billy Boy") }
let!(:luis) { create(:user, :luis, username: "@username_luis", name: "Luis XIV") }
let!(:talk) { creat... |
require "rails_helper"
describe DailyMailer do
let(:user) { create(:user) }
let!(:question) { create(:question, user: user) }
describe '#daily_digest' do
let(:email){DailyMailer.daily_digest(user).deliver_now}
it 'should send mail to user' do
expect(email.to.first).to eq user.email
end
... |
FactoryBot.define do
factory :game_master do
association :user
description { Faker::Lorem.paragraph(sentence_count: 2, supplemental: false, random_sentences_to_add: 4) }
end
end
|
class User < ApplicationRecord
has_many :wagers
has_many :golfers, through: :wagers
end
|
class FoodPoro
attr_reader :fcdid, :description, :brand, :ingredients, :gtinupc, :total_items
def initialize(data)
@fcdid = data[:fcdId]
@description = data[:description]
@brand = data[:BrandOwner]
@ingredients = data[:ingredients]
@gtinucp = data[:gtinUpc]
@total_items = data.count
end
e... |
LINES = INPUT.split("\n")
MASK_MATCHER = /^mask = (?<mask>[01X]+)$/
INPUT_MATCHER = /^mem\[(?<address>\d+)\] = (?<value>\d+)$/
class InputMask
def initialize(mask_string)
@mask_string = mask_string
end
def apply(value)
(value & zeroes) | ones
end
private
def ones
@ones ||= @mask_string.tr("... |
#! /usr/bin/env ruby
#
# Reconfigure the server setting in puppet.conf
module Migration
class ConfigServer
attr_accessor :config
def initialize(config_file=nil)
if config_file then
self.config = config_file
else
self.config = File.exists?("/opt/puppet/bin/puppet") ? "/etc/puppetl... |
class ApplicationController < ActionController::Base
def after_sign_in_path_for(resource)
user_jobs_path(resource.id)
end
def after_sign_up_path_for(resource)
new_user_job_path(resource.id)
end
end
|
# frozen_string_literal: true
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'fcrepo_wrapper'
require 'solr_wrapper'
require 'active_fedora/rake_support'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Bundler::G... |
class AddActivedAtToTempBirthdayParties < ActiveRecord::Migration
def change
add_column :temp_birthday_parties, :actived_at, :timestamp
add_index :temp_birthday_parties, :actived_at
end
end
|
Rails.application.routes.draw do
get 'password_resets/new'
get 'password_resets/edit'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'static_pages#home'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact'... |
class Book < ApplicationRecord
has_many :selections, dependent: :destroy
has_many :lists, through: :selections
end
|
class ChatBroadcastWorker
require 'net/https'
require 'digest/md5'
include Sidekiq::Worker
def perform(chat_message_id)
chat_message = ChatMessage.find chat_message_id
channel = '/messages/new'
message = {channel: channel,
data: {
message: chat_message.message,
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Schemas::Administrative do
subject(:work) { model_class.new }
let(:model_class) do
Class.new(ActiveFedora::Base) do
include ::Schemas::Administrative
def save; end # no-op; stubbed save
end
end
it_behaves_like 'a model ... |
#!/usr/bin/env ruby
##
## dynarows.rb
##
## This demos shows the use of the validation mechanism of the table
## and uses the table's cache (no -command or -variable) with a cute
## dynamic row routine.
##
## ( based on 'dynarows.tcl' included source archive of tktable extension )
##
require 'tk'
require 'tkextlib/tkt... |
component 'rubygem-winrm-fs' do |pkg, settings, platform|
pkg.version '1.3.1'
pkg.md5sum '706b7e0e917a1f0b18473785eb534194'
instance_eval File.read('configs/components/_base-rubygem.rb')
end
|
# frozen_string_literal: true
# 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:
#
User.create([{ name: 'Admin', email: 'admin@gmail.com', p... |
# Rake tasks that run the specs.
namespace :spec do
SPEC_DIR = File.dirname(__FILE__) + '/../spec'
RSPEC_DIR = "#{SPEC_DIR}/rubyspec/1.8/"
MSPEC_CMD = "#{SPEC_DIR}/mspec/bin/mspec"
DEBUG = "-B #{MAGLEV_HOME}/debug.mspec -T -d"
desc "Run the continuous integration specs against MRI"
task :mri do
... |
module SpyFu
module Requests
class UrlApi
# SpyFu requires the q and r params
# The q is for query. This is the main input to the API.
# You give a url or domain and we give back a list of keywords.
# The r is for max number of results. Paging is not implemented.
# So if you make a r... |
class Game
def initialize(player_one, player_two)
@player_one = player_one
@player_two = player_two
@active_player = @player_one
end
def start_game
## new rounds will launch as long as both players have lives
while @player_one.lives.positive? && @player_two.lives.positive?
if @active... |
# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User, ".languages" do
it "returns expected values" do
User::languages.should == {"en" => "English", "es" => "Español"}
end
end
describe User, "#name" do
before(:each) do
@user = User.new
end
it "returns F... |
# frozen_string_literal: true
module GraphQL
module PersistedQueries
VERSION = "0.1.1"
end
end
|
class AddDefaultValueAnswerCorrect < ActiveRecord::Migration[5.2]
def change
change_column :answers, :correct, :boolean, :default => false
end
end
|
require "faraday"
require "json"
require "geekpark_api/version"
require "geekpark_api/configuration"
require "geekpark_api/sign"
require "geekpark_api/orders"
require "geekpark_api/user"
require "geekpark_api/activities"
module GeekparkApi
class << self
#config
def config
Configuration.instance
e... |
Minuteman::Application.routes.draw do
root 'welcome#index'
resources :books
resources :locations
resources :library_systems, only: [:show]
resources :users do
collection do
get :login
get :logout
get :oauth_callback
end
end
resources :sync_errors, only: [:index, :show]
requir... |
class Labels::TasksController < ApplicationController
def index
@label = Label.find(params[:label_id])
@label_with_tasks = Label.where(:id => @label.id).with_current_tasks_for_user(@current_user, @start_time, @end_time).first
render :action => :index
end
end |
class Insurance
attr_reader :name, :id
def initialize(attributes)
@name = attributes[:name]
@id = attributes[:id]
end
def self.all
results = DB.exec("SELECT * FROM insurance ORDER BY id;")
insurances = []
results.each do |result|
name = result['name']
id = result['id'].to_i
... |
require 'test_helper'
class SessionsControllerTest < ActionDispatch::IntegrationTest
test "should be able to login" do
get sign_in_path
post session_path, params: {session: {email: "email@test.com", password: "password"}}
assert_response :redirect
follow_redirect!
follow_redirect!
assert_matc... |
class FixIndentifyCard < ActiveRecord::Migration
def change
rename_column :verifies, :indentify_card, :identify_card
rename_column :verifies, :image, :vocation_photo
end
end
|
require_relative 'card'
class Deck
attr_reader :cards, :discard_pile
def initialize
@cards = []
@discard_pile = []
create_cards
end
def view
@cards.each { |card| puts card.to_s }
end
def last(num_of_cards)
@cards.last(num_of_cards)
end
def shuffle!
@cards.shuffle!
end
d... |
class EpisController < ApplicationController
before_filter :authenticate_user!
def index
@epis = Epi.all
respond_to do |format|
format.html # index.html.erb
format.json {render json: @epis}
end
end
def show
@epi = Epi.find(params[:id])
respond_to do |format|
format.html # index.html.erb
forma... |
require "rails_helper"
module Clockface
RSpec.describe EventsPresenter do
let(:event) { create(:event) }
let(:presenter) { Clockface::EventsPresenter.new(event) }
describe "#period" do
it "returns the translated period" do
event.update!(period_value: "1", period_units: "weeks")
exp... |
class BlogEntriesController < ApplicationController
load_and_authorize_resource :blog
load_and_authorize_resource :blog_entry, :through => :blog
before_filter :init
def init
@blog=Blog.find(params[:blog_id])
end
# GET /blog_entries
# GET /blog_entries.json
def index
orig_blog_entries = @blog.bl... |
# Git Pivotal Tracker Integration
# Copyright (c) 2013 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... |
require './lib/ship'
require './lib/grid'
require './lib/placement_validator'
require './lib/message'
class Player
attr_reader :personal_grid, :opponent_grid, :ships,
:ship_types, :grid_size, :shots
def initialize(size = 4, ships = [2, 3])
@grid_size = size
@ship_types = ships
@sh... |
require 'spec_helper'
describe ExpensesController do
before do
@user = create(:user)
end
describe 'index' do
it 'returns all expenses' do
expense = create(:expense, user: @user)
get :index, user_id: @user.id
expect(assigns(:expenses)). to eq [expense]
end
context 'filtering'... |
class FontComforter < Formula
head "https://github.com/google/fonts/raw/main/ofl/comforter/Comforter-Regular.ttf", verified: "github.com/google/fonts/"
desc "Comforter"
desc "Appealing for many usages"
homepage "https://fonts.google.com/specimen/Comforter"
def install
(share/"fonts").install "Comforter-Re... |
class Roster < ActiveRecord::Base
include Auditable
attr_accessible :teamstat_id, :person_id, :position, :jersey_number, :goals, :assists, :shots, :fouls, :yellow_cards, :red_cards, :minutes, :saves
before_validation :init_stats
before_save :init_stats
belongs_to :teamstat
belongs_to :person
#FIXME cre... |
class Game
def initialize
@player1 = Player.new('Player 1')
@player2 = Player.new('Player 2')
@problem = Problem.new
@player_asks, @player_responds = @player2, @player1
end
def play
banner("New game")
new_turn
while @player1.lives > 0 && @player2.lives > 0 do
banner('NE... |
class RenameVideoUrlToVideoIdInPost < ActiveRecord::Migration
def change
rename_column :posts, :video_url, :video_id
end
end
|
# Ghost methods
require_relative('store')
class ReportingSystem
def initialize
@store = Store.new
end
def method_missing(name, *args)
super unless @store.respond_to?(name)
@store.send(name)
end
end |
# 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... |
class Api::V1::CustomerSerializer
include FastJsonapi::ObjectSerializer
set_type :customer # optional
set_id :id # optional
attributes :id, :first_name, :last_name, :email, :access_token, :avatar,
:national_id, :cell_phone, :birthday, :hashed_id, :mobile_push_token
attribute :rewiews_count do |c... |
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
def setup
@user = users(:tomas)
@other_user = users(:archer)
end
test "should get about" do
get about_path
assert_response :success
assert_select "title", full_title("About")
end
test "should be... |
require "fileutils"
abort("$MWA_DIR not defined.") unless ENV["MWA_DIR"]
abort("$SRCLIST_ROOT not defined.") unless ENV["SRCLIST_ROOT"]
$mwa_dir = ENV["MWA_DIR"].chomp('/')
#$project = ENV["PAWSEY_PROJECT"]
$project = "mwaeor"
class Float
def close_to?(n, tol: 0.1)
(self - n).abs < tol
end
end
class ... |
class PurchasesController < ApplicationController
def show
@purchase = Purchase.find_by_uuid(params[:id])
@plan = Plan.find(@purchase.product_id)
end
end
|
class Evaluation < ApplicationRecord
belongs_to :user
belongs_to :saler, class_name: "User"
belongs_to :buyer, class_name: "User"
with_options presence: true do
validates :user_id
validates :saler_id
validates :buyer_id
validates :evaluation
end
end
|
class CreateVehicles < ActiveRecord::Migration[6.0]
def change
create_table :vehicles do |t|
t.string :flavour
t.string :weight
t.integer :half_hull
t.integer :maxgear
t.integer :handling
t.integer :crew
t.timestamps
end
end
end
|
#!/usr/bin/env rake -f
require 'yaml'
require 'json'
def approx_version_string(str)
return str if str.eql? "current"
Gem::Version.new(str).segments.first(3).join('.')
end
desc 'trigger recrawl on swiftype'
task :recrawl do
swift_token = ENV['SWIFTYPE_TOKEN']
swift_domain_id = ENV['SWIFTYPE_DOMAIN_ID']
abo... |
class RenameColumn < ActiveRecord::Migration
def change
rename_column :transactions, :type, :t_type
end
end
|
class HolaSessionController < ApplicationController
def create
@hola_user = HolaUser.create_from_params({ phone_no: params[:mobile],
name: params[:name],
email: params[:email]
})... |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :verify_signed_out_user
respond_to :json
def linkedin
@user = User.find_for_linkedin_oauth(request.env["omniauth.auth"], "linkedin")
if @user.persisted?
sign_in(resource_name, resource)
render js... |
require "test_helper"
describe ProductsHelper do
let(:one) {products(:tree1)}
let(:two) {products(:tree2)}
describe "#product_description" do
it "returns properly if the description exists" do
product_description(one).must_equal "No description."
end
it "returns properly if the description is... |
# TODO figure out how to produce SVG-->PNG for emails
# https://github.com/gregjopa/d3-server-side-demo
require "execjs-async"
class D3Service
def try_async
context = ExecJS.compile_async <<-JAVASCRIPT
var run = function(html, code){
var jsdom = require('/app/node_modules/jsdom');
jsdom.e... |
class AddAttachmentCarPhotoToParticipations < ActiveRecord::Migration
def self.up
change_table :participations do |t|
t.attachment :car_photo
end
end
def self.down
remove_attachment :participations, :car_photo
end
end
|
class AddFormattedAddressToVenues < ActiveRecord::Migration
def change
add_column :venues, :formatted_address, :string
end
end
|
module Api
class ProjectsController < ApplicationController
skip_filter :set_current_user_and_project, :apply_currents, :clean_data
http_basic_authenticate_with name: "admin", password: "secret"
# Method: GET
# Ex: curl /api/projects
# Returns JSON array of all projects
def index
... |
require_relative "lib/slanger/version"
Gem::Specification.new do |spec|
spec.name = "oceanex-slanger"
spec.version = Slanger::VERSION
spec.authors = ["Joblee", "Steve", "Meng", "Sniper", "Jiayu"]
spec.email = ["jobleeyoui@gmail.com"]
spec.summary = "A websocket service compatible with Pusher libraries"
sp... |
module CDI
module V1
module StudentDeliveries
class CreateService < BaseCreateService
include V1::ServiceConcerns::StudentDeliveriesParams
record_type ::StudentDelivery
private
def can_create_record?
return false unless valid_user?
unless valid_... |
class PeopleController < InheritedResources::Base
before_filter :authenticate_user!, :except => [:index, :show, :claim, :feed]
before_filter :get_person_and_verify_ownership, :only => [:edit, :update]
before_filter :verify_administrator, :only => [:create, :destroy, :new]
def index
if params[:tag]
@... |
module HasHumanDate
def human_date_created_at
human_created_at[/[\d]{4}-[\d]{,2}-[\d]{,2}/]
end
def human_created_at
human_date_on(:created_at)
end
def human_date_on(field)
date(send(field))
end
private
def date(date)
date.strftime('%Y-%m-%d, %H:%M')
end
end
|
require "test_helper"
describe Vanity::Experiment::Base do
before do
metric "Happiness"
end
# -- Defining experiment --
it "can access experiment by id" do
exp = new_ab_test(:ice_cream_flavor) do
metrics :happiness
default false
end
assert_equal exp, experiment(:ice_cream_flavor)
... |
require 'rails_helper'
RSpec.describe CCS::FM::Supplier, type: :model do
describe '.selected_suppliers' do
let(:lot) { '1a' }
before do
[
{ lots: [{ lot_number: lot, regions: %w[r0 r1], services: %w[s0 s1] }] },
{ lots: [{ lot_number: lot, regions: %w[r0 r2], services: %w[s0 s2] }] },
... |
OPS = {
'+' => { priority: 0, left_associative: true, action: ->(x, y) { x + y } },
'*' => { priority: 0, left_associative: true, action: ->(x, y) { x * y } },
'-' => { priority: 0, left_associative: false, action: ->(x, y) { x - y } },
'/' => { priority: 0, left_associative: false, action: ->(x, y) { x / y } }... |
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Runic Enchantment - Individual Equipment Patch
# Author: Kread-EX
# Version 1.01
# Release date: 17/03/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#-----------------------------------------... |
class Guest
attr_reader :name
def initialize(name, monies)
@name = name
@monies = monies
end
def get_monies
@monies
end
def pay_entry_fee(entry_fee)
@monies >= entry_fee ? @monies -= entry_fee : 'Insufficient monies'
end
end |
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'home'
map.resources :users, :has_many => [:bookmarks, :posts]
map.resources :sessions
map.resources :bookmarks
map.resources :posts, :has_many => [:bookmarks, :applicants], :has_one => :neighbourhood,
:collection => {:search =>... |
module KsStripe
# Validate the Card Number by Luhn Algorithm
#
class KsLuhn
# Validate the Card Number by Luhn Algorithm
#
# == Parameter: Credit Card Number
# == Retruns: true if card number is valid otherwise false
def self.valid?(code)
return false if (code.to_i==0)
s1 = s2 =... |
class DefaultPostPublishedToFalse < ActiveRecord::Migration
def up
change_column :posts, :published, :boolean, default: false
end
def down
change_column :posts, :published, :boolean, default: true
end
end
|
def is_local_build
ENV['triggered_by'].nil? && ENV['CIRCLECI'].nil?
end
def dynamic_framework_dependencies
value = ENV['DYNAMIC_FRAMEWORKS_DEPENDENCIES'] || ""
value.split(",")
end
def local_dynamic_framework_dependencies
["Protobuf"]
end
def should_add_flipper_on_local_build
# skip flipper setup by defaul... |
require 'maws/instance'
# for EC2 instances aws_id is a random id
# name is a value of 'Name' tag
class Instance::EBS < Instance
def destroy
connection.ec2.delete_volume(aws_id)
info "destroying EBS volume #{name}:#{device} (#{aws_id})"
end
def attached?
aws_attachment_status == 'attached'
end
... |
require 'test_helper'
class CalendarsControllerTest < ActionDispatch::IntegrationTest
def test_カレンダーがまだなければ追加に遷移
sign_in user_without_calendar
assert Calendar.where('user_id = ?', user_without_calendar).empty?
get calendars_path
assert_response :redirect
follow_redirect!
assert_equal '/cale... |
class User < ActiveRecord::Base
def self.fetch_by_token(token)
find_by(id: token.to_i)
end
end
|
class Accommodation < ApplicationRecord
validates_presence_of :number, :capacity, :description, :price
validates_numericality_of :number, :capacity, :price
validates_uniqueness_of :number
validates :occupied, inclusion: { in: [ true, false ] }
has_many :bookings
end
|
class PicturesController < ApplicationController
def upload
service = PictureService.new(upload_params, current_user)
service.upload
render service.result
end
def show
service = PictureService.new(show_params, current_user)
service.show
render service.result
end
def show_picture
... |
class AddIndexToLogEntries < ActiveRecord::Migration
def change
add_index :log_entries, [:activity_log_id, :date], unique: true
end
end
|
class SessionsController < ApplicationController
def register
username = params[:username]
password = params[:password]
if !username || !password
render json: {error: 'Required username and password'}, status: 400
return
end
if User.find_by(username: username) != nil
render js... |
class AddOwnerIdToOrganization < ActiveRecord::Migration
def change
add_column :organizations, :owner_id, :integer, null: false, foreign_key: { references: :users }
end
end
|
class Pullrequest::ApprovalRemoved < Pullrequest::Base
attr_accessor :approval
def verb
"unapproved"
end
def color
"warning"
end
end
|
require 'rails_helper'
require 'user.rb'
require 'users_controller.rb'
RSpec.describe User, type: :model do
describe 'validation' do
it 'should not register a new user if the password and password_confirmation do not match' do
@user = User.new(first_name: 'Jane', last_name: 'Doe', email: 'jane.doe@gmail.co... |
#!/usr/bin/env ruby
module RelayAPI::API
def self.versions
[
{
'name' => 'latest',
'path' => '/api',
'class' => RelayAPI::API::V1
},
{
'name' => 'v1',
'path' => '/api/v1',
'class' => RelayAPI::API::V1
}
]
end
end
require 'relayapi/a... |
RailsAdmin.config do |config|
### Popular gems integration
RailsAdmin.config do |config|
config.authorize_with do
authenticate_or_request_with_http_basic('Site Message') do |username, password|
username == 'admin' && password == 'admin'
end
end
config.model Product do
edit d... |
class Company < ActiveRecord::Base
def self.all_areas ; %w[Energy Technology Liability Cauzione Credit Rischi-civili-Abitazioni] ; end # shortcut: array of strings
validates :compagnia, :presence => true
# Scheda Condizioni
has_attached_file :scheda_condizioni,
:url => "/secure/knowhow_attachments/:attachme... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resource :greenhouse do
resources :plant_sectors
end
resources :plants
root to: "greenhouses#index"
get '/greenhouse/work', to: 'xtreme_farm_bot#work'
get '/greenhouse/envi... |
require 'integration_spec_helper'
describe 'File upload' do
if account?
before(:all) do
@storage = login
end
[12, 6_000, 2_000_000].each do |size|
context "when a file (#{size} bytes) is uploaded" do
let(:path) { "#{temp_folder}/testfile_#{SecureRandom.hex(6)}" }
let(:co... |
# Teskal
class RolesController < ApplicationController
layout 'base'
before_filter :require_admin
verify :method => :post, :only => [ :destroy, :move ],
:redirect_to => { :action => :list }
def index
list
render :action => 'list' unless request.xhr?
end
def list
@rol... |
require 'active_record'
namespace :db do
task :configuration => :environment do
require 'yaml'
require 'erb'
yaml = ERB.new(File.read('config/database.yml')).result
@config = YAML.load(yaml).fetch(ENV['RACK_ENV'])
puts "Configuration - #{@config}"
end
task :configure_connection => :configura... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Event, type: :model do
describe 'associations' do
let(:event) { create :event }
it { expect(event).to have_many(:debit_transfers) }
it { expect(event).to have_many(:credit_transfers) }
end
describe 'validations' do
describe '#... |
class Departamento < ActiveRecord::Base
before_save {self.codigo = codigo.upcase}
validates :nombre, presence: true, uniqueness: { case_sensitive: false }
validates :codigo, presence: true, format: {with: /\A[a-zA-Z]{2}\z/}
end
|
#!/usr/bin/env ruby
#coding: utf-8
require 'uri'
class String
def urlencoded?
return true if self.match(/(%[0-9ABCDEF]{2})+/i)
return false
end
end
def show_usage
STDERR.puts "Использование: #{__FILE__} [decode|encode|test] <string>"
exit 1
end
case ARGV.count
when 1
action = 'test'
subject = ARGV[0].to_... |
class IntellijIdeaUltimate < Cask
url 'http://download-ln.jetbrains.com/idea/ideaIU-13.0.1.dmg'
homepage 'https://www.jetbrains.com/idea/index.html'
version '13.0.1'
sha1 '539b6b3e10e03ed9b54518fa3ccee75c9cefdcf2'
link 'IntelliJ IDEA 13.app'
end
|
require 'rails_helper'
RSpec.describe Submission, type: :model do
it "stops submitting after 6 posts" do
user = User.create(:email => "josh_edney1@hotmail.com")
debate = Debate.create(:user => user, :topic => "This is a topic")
Submission.create!(:user => user, debate: debate, sub_type: "pro", content:... |
class Clerk < ActiveRecord::Base
# declare your association
belongs_to :boss
validates_presence_of :first_name
validates_presence_of :last_name
# virtual_column :name
# def name
# "#{last_name}, #{first_name}"
# end
# visually mark recently updated records
virtual_column :updated
def updated
... |
@a13 = Episode.create(
title: "Ep 13: Matthew Mc-Comet-Hey",
number: 13,
published_at: "2015-01-27 0:00:01",
media: "http://resources.brickcaster.com/abstraction/013_matthew_mc_comet_hey.mp3",
media_length: 3706,
media_size: 89045012,
summary: "Micah and Ryan catch up with Ryan's super-commuter lifestyle, summarize the... |
desc ""
namespace :genesis do
desc "network operations"
namespace :network do
desc "Scaffold a new genesis network for use in docker-compose"
task :scaffold, [:chainnet, :validator_count] do |t, args|
if args[:chainnet].nil?
puts "Please provide chainnet argument. ie testnet, mainnet"
... |
require "nokogiri"
require "htmlentities"
require "pp"
module MathML2AsciiMath
def self.m2a(x)
docxml = Nokogiri::XML(x)
parse(docxml.root).gsub(/ /, " ").
sub(/^\s+/, "").
sub(/\s+$/, "")
end
def self.encodechars(x)
x.gsub(/\u03b1/, "\\alpha").
gsub(/\u03b2/, "\\beta").
gs... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.