text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
module Files
class Plan
attr_reader :options, :attributes
def initialize(attributes = {}, options = {})
@attributes = attributes || {}
@options = options || {}
end
# int64 - Plan ID
def id
@attributes[:id]
end
# boolean - Are advanced beh... |
require "test_helper"
describe RecipiesController do
describe "root" do
it "will return success" do
get root_path
must_respond_with :success
end # success
end # root
describe "index" do
it "will return success when there are recipies to display" do
VCR.use_cassette("recipes") do
... |
require 'fileutils'
module Vagrant
module Butcher
module Helpers
module KeyFiles
include ::Vagrant::Butcher::Helpers::Guest
def cache_dir(env)
@cache_dir ||= File.expand_path(File.join(root_path(env), butcher_config(env).cache_dir))
end
def guest_key_path(env)
... |
# require 'test_helper'
#
# class AdminsRoutesTest < ActionController::TestCase
# test 'should route to list admin' do
# assert_routing({ method: 'get', path: '/admins' }, { controller: 'admins', action: 'index'})
# end
#
# test 'should route to find an admin' do
# assert_routing({ method: 'get', path: '/... |
require "test_helper"
require 'base64'
describe Rugged::Object do
before do
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
@repo = Rugged::Repository.new(@path)
end
it "cannot lookup a non-existant object" do
assert_raises Rugged::OdbError do
@repo.lookup("a496071c1b46c854b31185ea9... |
class Admin::PrefectosController < ApplicationController
layout 'admin'
require_role "administrador"
# GET /prefectos
# GET /prefectos.xml
def index
@prefectos = Prefecto.paginate(:per_page => 20, :page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.xml { re... |
# Sets up the Rhouse gem environment.
# Configures logging, database connection and various paths
module Rhouse
# Gem version
VERSION = '0.0.3'
# Root path of rhouse
PATH = ::File.expand_path(::File.join(::File.dirname(__FILE__), *%w[..]))
# Lib path
LIBPATH = ::File.join( PATH, "lib" )
# Confi... |
class CreateSermons < ActiveRecord::Migration[5.0]
def change
create_table :sermons do |t|
t.belongs_to :series, index: true
t.string :title
t.string :speaker
t.date :sermondate
t.string :audiofile
t.text :desc
t.timestamps
end
end
end
|
class RemoveRankAndAddFaultRateFixOnTimeRateToProvider < ActiveRecord::Migration
def self.up
remove_column :providers, :rank
add_column :providers, :fault_rate, :string
add_column :providers, :fix_on_time_rate, :string
end
def self.down
add_column :providers, :rank, :integer
remove_column :pr... |
require 'test_helper'
class AuthTest < Test::Unit::TestCase
context "vimeo advanced auth" do
setup do
@auth = Vimeo::Advanced::Auth.new("12345", "secret")
end
context "making api calls" do
should "check an auth token" do
stub_post("?format=json&api_key=12345&method... |
class RepayPreview < ActionMailer::Preview
# Accessible from http://localhost:3000/rails/mailers/notifier/welcome
def paid
RepayMailer.with(user: User.first, extract: Extract.first).paid
end
end |
class AddCategoryToReportingRelationship < ActiveRecord::Migration[5.1]
def change
add_column :reporting_relationships, :category, :string, default: 'no_cat'
end
end
|
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = NormalRanki... |
class CommentsController < ApplicationController
def index
@comments = Comment.all
end
def create
@comment = Comment.new(params[:comment])
@comment.user_ip = request.remote_ip
if logged_in?
@comment.user = current_user
end
@comment.save
redirect_to_back_or_default root_path
end
def ... |
class Api::UsersController < ApplicationController
def show
@user = User.includes(:posts_on_wall)
.includes(:posts_on_wall_authors)
.includes(:comments)
.includes(:likes)
.includes(:posts)
.includes(:wall_users)
.inclu... |
require 'spec_helper'
describe 'Tasks' do
let(:user) { create(:user) }
it 'shows a form for new tasks' do
login_as user
visit '/tasks/new'
expect(page).to have_field('Title')
expect(page).to have_field('Deadline')
expect(page).to have_field('Difficulty')
expect(page).to have_field('Import... |
class UsersController < ApplicationController
def search
@users = User.where("name like ?", "%#{search_params[:q]}%").order('name ASC')
respond_to do |format|
format.json { render json: @users }
end
end
private
def search_params
params.permit(:q)
end
end
|
require 'test_helper'
class UsersEditTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
def setup
@user = users( :michael )
end
test "unsuccessful edit" do
log_in_as(@user)
get edit_user_path( @user )
assert_template 'users/edit'
patch user_path( @user ... |
require_relative('../db/sql_runner.rb')
require_relative('./customer.rb')
class Screening
attr_accessor :show_time, :ticket_available
attr_reader :id
def initialize(screening)
@id = screening['id'].to_i if screening['id']
@show_time = screening['show_time']
@ticket_available = screening['ticket_ava... |
class Comment < ApplicationRecord
validates :user_id, presence: true
validates :article_id, presence: true
validates :content, presence: true, length: { maximum: 150 }
belongs_to :user
belongs_to :article
has_many :articles, as: :attachment, dependent: :nullify
def as_json(options = {})
super(... |
class AbstractsController < ApplicationController
def new
@abstract = Abstract.new
@address = Address.new
end
def create
abstract = Abstract.new(abstract_params)
if abstract.save
flash[:success] = t('abstract.successful_creation')
else
flash[:error] = abstract.errors.full_messa... |
require 'rails_helper'
RSpec.describe SessionsController, type: :controller do
describe 'GET #new' do
context 'when logged' do
let(:user) { create(:user) }
before { session[:user_id] = user.id }
it 'redirect to root_Path' do
get :new
expect(response).to redirect_to(root_path)
... |
class ChangedMenusModifiedKlass < ActiveRecord::Migration
def self.up
change_column :menus, :klass, :string
end
def self.down
change_column :menus, :klass, :integer, :limit=>nil, :default=>nil
end
end
|
module Tephue
class Configuration
attr_accessor :secure_hasher
def initialize
@secure_hasher = BcryptHasher
end
# Return the map of entities -> repositories
# @return Hash<Object,Base>
def repositories
@repositories ||= {}
end
# Register a repository to be used by an ... |
module SDC
# Script routines for easier readability, directly referencing other methods
def self.key_pressed?(key, override_text_input: false)
return @window.has_focus? && (override_text_input || !@text_input) && SDC::EventKey.const_defined?(key) && SDC::EventKey.is_pressed?(SDC::EventKey.const_get(key))
end
d... |
require 'spec_helper'
describe PushWoosher::Device::Base do
let(:token) { SecureRandom.hex }
let(:hwid) { SecureRandom.hex }
let(:options) { { token: token, hwid: hwid } }
subject { described_class.new(options) }
it { should respond_to(:token) }
it { should respond_to(:hwid) }
it { should respond_to(:d... |
class CreateAddresses < ActiveRecord::Migration
def change
create_table :addresses, :id => false do |t|
t.uuid :id, :primary_key => true, default: "uuid_generate_v4()"
t.string :location
t.string :phone
t.string :name
t.string :zip_code
t.boolean :default
t.uuid :develop... |
class Question < ActiveRecord::Base
belongs_to :user
belongs_to :category
has_many :answers
validates :title, :detail, :category_id, presence: true
def num_answers
answers.size
end
end
|
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'feeds#week'
# 信息流
resources :feeds do
collection do
get :week
end
end
# 团队信息流
resources :teams do
collection do
get :we... |
# The String#to_i method converts a string of numeric characters (including an optional plus or
# minus sign) to an Integer. String#to_i and the Integer constructor (Integer()) behave
# similarly. In this exercise, you will create a method that does the same thing.
# Write a method that takes a String of digits, and ... |
require 'timeout'
class WebsiteUtils
#Returns a hash where key is link and value is the language of subtitle
def self.get_article_urls(document)
unless document.nil?
links = Hash.new
items_div = document.css('div.gallery').css('article').children
#puts items_div.inspect
items_div.each{|... |
require 'spec_helper'
describe File.expand_path("bin/create_release.rb") do
begin
require File.expand_path("bin/create_release.rb")
rescue NameError => ex
raise("Failed to load: #{ex}")
end
context 'tags and branches git repo' do
let(:branches_n_tags_repo_with_spurious) do
double(
ta... |
class CorePerson < ActiveRecord::Base
self.table_name = :core_person
include EbrsAttribute
has_one :person, foreign_key: "person_id"
has_one :person_birth_detail, foreign_key: "person_id"
has_one :person_address, foreign_key: "person_id"
has_one :person_attribute, foreign_key: "person_id"
... |
class Public::ProfilesController < PublicController
before_action :set_profile, only: [:show]
# GET /profiles
# GET /profiles.json
def index
@profiles = Profile.all
end
# GET /profiles/1
# GET /profiles/1.json
def show
end
private
# Use callbacks to share common setup or constraints betwe... |
require "blacklight"
# MUST eager load engine or Rails won't initialize it properly
require 'blacklight_solrplugins/engine'
require "blacklight_solrplugins/util"
module BlacklightSolrplugins
# It's important to autoload everything that uses Blacklight modules/classes,
# b/c Blacklight also autoloads. This means... |
class ProfileCharacteristic < ApplicationRecord
belongs_to :profile
belongs_to :characteristic
end
|
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/title_ratings/index.html.erb" do
include TitleRatingsHelper
before(:each) do
title_rating_98 = mock_model(TitleRating)
title_rating_98.should_receive(:action).and_return("1")
title_rating_98.should_receive(:comedy).and_return("1")
... |
#
# Specifying rufus-tokyo
#
# Mon Jan 26 15:10:03 JST 2009
#
require File.dirname(__FILE__) + '/spec_base'
require 'rufus/tokyo'
describe 'Rufus::Tokyo::Map' do
before do
@m = Rufus::Tokyo::Map.new
end
after do
@m.free
end
it 'should be empty initially' do
@m.size.should.be.zero
end
i... |
shared_context "request parameters" do
let(:config) do
{
'quickbooks_access_token' => "qyprdhjEBfA2BI8sD7fWVPH4wL9esaKrYeWLosiPBir3pa5j",
'quickbooks_access_secret' => "yU7RtuM1Lot803jkkCfcyV9GePoNZGnZO8nRbBxo",
'quickbooks_income_account' => "Sales of Product Income",
... |
# frozen_string_literal: true
module Sidekiq
module LimitFetch
module Global
class Semaphore
PREFIX = 'limit_fetch'
attr_reader :local_busy
def initialize(name)
@name = name
@lock = Mutex.new
@local_busy = 0
end
def limit
va... |
module FlashesHelper
FLASH_CLASSES = { :alert => "danger", :warning => "warning", :notice => "success" }.freeze
def user_facing_flashes
flash.to_hash.slice "alert", "warning", "notice"
end
def flash_class(key)
FLASH_CLASSES.fetch key.to_sym, key
end
end
|
module Fgdc2Html
# def fgdc2html(fgdc_file, fgdc_xml)
# input args:
# doc - nokogiri::XML::Document representing the FGDC XML
def fgdc2html(doc)
# doc = Nokogiri::XML(fgdc_xml) do |config|
# config.strict.nonet
# end
return xsl_html.transform(doc).to_html
end
##
# Returns a Nok... |
class CreateCourseTaughts < ActiveRecord::Migration
def change
create_table :course_taughts do |t|
t.integer :faculty_id
t.integer :stu_id
t.integer :course_id
t.datetime :begin_time
t.integer :duration
t.integer :price
t.integer :total_price
t.timestamps null: fal... |
class KeywordsController < ApplicationController
def index
@keywords = params[:ids] ? Keyword.find(params[:ids]) : Keyword.all
render json: @keywords, status: 200
end
def show
render json: Keyword.find(params[:id]), status: 200
end
end
|
# frozen_string_literal: true
module Milestoner
module Errors
# Raised for projects not initialized as Git repositories.
class Git < Base
def initialize message = "Invalid Git repository."
super message
end
end
end
end
|
module Webex
module Meeting
# comment
class Attendee
include Webex
include Webex::Meeting
attr_accessor :meeting_key, :back_url, :invitation, :attendees, :cancel_mail, :email
# attendees: [{FullName: FullName1, EmailAddress: nil, PhoneCountry: nil, PhoneArea: nil, PhoneLocal: nil, Pho... |
#
# Cookbook Name:: zabbix
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "apt"
dpkg_package "zabbix-release" do
source "#{Chef::Config[:file_cache_path]}/zabbix-release_2.2-1+wheezy_all.deb"
action :nothing
notifies :run,... |
require_relative 'movie'
module VideoStore
class Customer
attr_reader :name
def initialize(name)
@name = name
@rentals = []
end
def add_rental(arg)
@rentals << arg
end
def statement
total_amount, frequent_renter_points = 0, 0
@rentals.each do |element|
... |
class UsersController < BaseController
before_action :set_user, only: [:show, :edit, :update, :destroy]
def index
@users= User.all.order('id DESC').paginate(page: params[:page], per_page: 50)
end
def new
@users = User.new
end
def create
@users = User.new(user_params)
respond_to do |forma... |
require 'sinatra/base'
require 'nokogiri'
require 'zlib'
require 'base64'
require 'uri'
require 'cgi'
module Sinatra
module SamlInspectHelpers
def parse_request_data(data)
data.gsub!("\n", '')
data.gsub!(' ', '')
uri = URI.parse(data)
if uri.query.nil?
query_string = CGI.parse(... |
# frozen_string_literal: true
class AddDescriptionToCardReaders < ActiveRecord::Migration
def change
add_column :secure_rooms_card_readers, :description, :string
end
end
|
# encoding: utf-8
class ReportGenerators::LinkedinReport < ReportGenerators::Base
def self.can_process? type
type == LinkedinDatum
end
def add_to(document)
if !linkedin_datum.empty?
add_information_to document
end
end
private
def linkedin_datum
social_network.linkedin_data.where('s... |
require 'digest/sha1'
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
acts_as_voter
named_scope :top, lambda { |*args| { :order => ["karma_score desc"], :limit => (args.first || 5), :conditions => ["karma_score > 0"]} }
named... |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'optparse'
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'cache'
DEFAULT_DIR = "./"
opts = {}
ARGV.options do |o|
o.banner = "ruby #{$0} [OPTION]... CACHEDIR FILETYPE..."
o.on("-m", "移動による抽出を行う(指定しなければコピー)") {|x| opts[:mv] = x}
o.on("-d DIRECTO... |
require_relative "spec_helper.rb"
describe "Wave 1" do
before do
@hotel = Hotel::RoomReservation.new
room_id1 = 14
check_in1 = Date.new(2019, 4, 1)
check_out1 = Date.new(2019, 4, 2)
@reservation1 = @hotel.new_reservation(room_id1, check_in1, check_out1)
room_id2 = 15
check_in2 = Date.ne... |
class Headline < ActiveRecord::Base
#Associations
has_many :articles, -> { order 'cached_votes_score DESC' } do
def most_voted
limit(1)
end
end
has_attached_file :image, styles: { regular: "420x290#"}
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
validates_presence_of :title,... |
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :users, only: [] do
post "follow", to: "relationships#create"
delete "unfollow", to: "relationships#destroy"
resources :operations, only: [:index, :create]
resources :fo... |
# encoding: utf-8
module Api
module V2
class ReportsController < ::Api::BaseApiController
#before_filter :authenticate_user!, :except => [:create]
before_filter :get_user
def create
options = {
:subject => "Note Report",
:description => params[:note_id],
... |
100.times do | num |
p num unless !num.odd?
end
# Second time
# (1..99).each { |n| puts "#{n}" if n.odd? }
# LS Solution:
# value = 1
# while value <= 99
# puts value
# value += 2
# end
# ls solution goes through half as many iterations. |
class Web::Admin::SessionsController < Web::Admin::ApplicationController
layout 'web/admin/sign_in_up'
def new
@session = AdminSignInType.new
end
def create
@session = AdminSignInType.new(params[:admin_sign_in_type])
if @session.valid?
admin = @session.admin
admin_sign_in(admin)
... |
class TicTacToe
X = 'X'
O = '0'
attr_accessor :board
def initialize(board)
raise "The board does not look valid: #{board}" unless board.length == 9
@board = board.split(//).each_slice(3).to_a
end
def valid?
(no_of_crosses - no_of_noughts).abs < 2
end
def no_of_crosses
@board.flatten... |
class SpecialEffect < ApplicationRecord
belongs_to :character
scope :active, -> { where(expiration: DateTime.current..100.years.from_now)
.or(SpecialEffect.where(expiration: nil)) }
end |
require 'rails_helper'
RSpec.describe Answer, :type => :model do
it 'has a valid factory' do
expect(build(:answer)).to be_valid
end
it { is_expected.to validate_presence_of :body }
it { is_expected.to belong_to :question }
it { is_expected.to belong_to :user }
it { is_expected.to have_many :attachments... |
class User < ApplicationRecord
validates :name ,presence: true, uniqueness: true, length: {minimum: 1}
validates :email ,presence: true
has_many :pins
has_many :comments, through :pins
end
|
class CreateTransportAttendances < ActiveRecord::Migration
def self.up
create_table :transport_attendances do |t|
t.date :attendance_date
t.integer :receiver_id
t.string :receiver_type
t.integer :route_type
t.references :route
t.datetime :entering
t.datetime :leaving
... |
# Step 1:
#
# The robot factory manufactures robots that have three possible movements:
#
# • turn right
# • turn left
# • advance
#
# Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of
# {x,y} coordinates, e.g., {3,8}.
#
# Step ... |
require 'spec_helper'
describe CardDeck::TrumpCardDeck::Base do
before(:each) do
@deck = CardDeck::TrumpCardDeck::Base.new
end
it "stores a trump suit if the suit is valid" do
@deck.trump_suit = :spades
@deck.trump_suit.should == :spades
end
it "raises an error if the trump suit is not valid"... |
# frozen_string_literal: true
module GraphQL
module StaticValidation
module RequiredArgumentsArePresent
def on_field(node, _parent)
assert_required_args(node, field_definition)
super
end
def on_directive(node, _parent)
directive_defn = context.schema_directives[node.name... |
class Game < ApplicationRecord
require 'csv'
require 'activerecord-import/base'
belongs_to :season
has_and_belongs_to_many :teams
validates :home_team, presence: true, length: { is: 3 }
validates :away_team, presence: true, length: { is: 3 }
validates :game_year, presence: true, length: { is: 4 }
valid... |
class TerminalesController < ApplicationController
before_action :set_terminal, except: [:index, :new, :create, :caja_registradora]
before_action :quitarBandera, :definirControlador
def definirControlador
@controlador = 'terminales'
end
def quitarBandera
@creacion = false
end
def index
@ter... |
require 'rails_helper'
RSpec.describe CalendarColor, type: :model do
it 'has a valid factory' do
expect(create :calendar_color).to be_valid
end
end
|
class Campaign < ApplicationRecord
belongs_to :expert
has_many :todo_lists, dependent: :destroy
has_many :comments, as: :commentable
accepts_nested_attributes_for :todo_lists, allow_destroy: true
validates :title, presence: true
end
|
module OnDestroy
module Model
extend ActiveSupport::Concern
included do
OnDestroy::OPTIONS.each do |key|
class_attribute key, instance_writer: true
self.send("#{key}=".to_sym, OnDestroy.send(key))
end
around_destroy :do_on_destroy
end
module ClassMethods
# a s... |
#
# Unit tests for heat::keystone::auth
#
require 'spec_helper'
describe 'heat::keystone::auth' do
shared_examples_for 'heat::keystone::auth' do
context 'with default class parameters' do
let :params do
{ :password => 'heat_password' }
end
it { is_expected.to contain_keystone__resourc... |
require_relative "board"
class Player
attr_accessor :color, :board
def initialize(color)
@color = color
end
# check if the piece on a square belongs to you. The game class or board (haven't decided yet) won't allow him to move it if the colors don't match.
def your_piece(sq)
piece = @board.get_piec... |
module Anonymized
module ActsAsAnonymized
extend ActiveSupport::Concern
class_methods do
def acts_as_anonymized(anonymization_strategy)
raise "Anonymization strategy required" unless anonymization_strategy.present?
cattr_accessor :anonymization_strategy
self.anonymization_strate... |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'; require 'bundler/setup'; Bundler.require
require 'open-uri'
ROWS = 52
AVAILABLE_ATTRIBUTES=['rowspan', 'colspan', 'style', 'bgcolor', 'class', 'title', 'onclick']
# Формат: https://gist.github.com/dapi/8649553
file = ARGV[0] || raise("Укажите файл для п... |
class CreateBlogPosts < ActiveRecord::Migration[5.1]
def change
create_table :blog_posts do |t|
t.text :title
t.text :content
t.timestamp :posted_at
t.string :slug
t.references :admin
t.timestamps
end
end
end
|
class CreateTransactions < ActiveRecord::Migration[5.1]
def change
create_table :payments do |t|
t.integer :user_id
t.integer :job_id
t.integer :credit_card_id
t.string :amount
t.string :description
t.string :vat
t.integer :status
t.datetime :payment_date
t.st... |
class AddIsLockedToLineItems < ActiveRecord::Migration
def change
add_column :line_items, :is_locked, :boolean
end
end
|
require 'opal'
require 'browser'
require 'browser/socket'
require 'browser/console'
require 'browser/dom'
require 'browser/dom/document'
require 'browser/http'
require 'browser/delay'
require 'native'
require 'tile'
puts 'Loading Magellan...'
class Magellan
attr_accessor :binding
attr_reader :radius
attr_accesso... |
require 'test_helper'
class KhsControllerTest < ActionDispatch::IntegrationTest
setup do
@kh = khs(:one)
end
test "should get index" do
get khs_url
assert_response :success
end
test "should get new" do
get new_kh_url
assert_response :success
end
test "should create kh" do
asser... |
require "repositories/rental_repository"
RSpec.describe RentalRepository do
describe "#load" do
subject(:load_hashes) { repository.load(rental_hashes, dependencies) }
it "adds the dependencies to the rental" do
load_hashes
rental = repository.fetch(1)
expect(rental.car).to eq car
end
... |
# frozen_string_literal: true
class RmoveReferencesFromRoom < ActiveRecord::Migration[6.0]
def change
remove_foreign_key :rooms, :users
remove_reference :rooms, :user
remove_foreign_key :rooms, :messages
remove_reference :rooms, :message
end
end
|
class AddItemsIndex < ActiveRecord::Migration
def self.up
add_index :items, [:feed_id, :stored_on, :created_on, :id], name: :items_search_index
end
def self.down
remove_index :items_search_index
end
end
|
class Book
attr_accessor :title
def initialize
@chapters = []
end
def add_chapter(input)
@chapters << input
end
def chapters
@chap_num = @chapters.length
p "Your book: #{title} has #{@chap_num} chapters:"
(1..@chap_num).each do |x|
p "#{x}. #{@chapters[x-1]}."
end
end
e... |
require 'data_model/type_validators/soft'
require 'data_model/validators/base'
module Moon
module DataModel
module Validators
# Ensures that the provided value is the Type required, usually
# appended first to a validators stack.
# see {Field#validators}
class Type < Base
class <<... |
require 'rails_helper'
RSpec.describe "Jobs", type: :request, js: true do
describe 'Anonymous User' do
before(:each) do
@job = FactoryGirl.create :job
visit jobs_path
expect(page).to have_selector(get_html_id(@job))
expect(page).to_not have_link('New Job')
end
describe 'permissi... |
require "serverspec"
require "docker"
require "timeout"
require "net/smtp"
require "net/imap"
require "pry"
describe "Subliminal Mail Container" do
before :all do
puts "Starting container"
image = Docker::Image.build_from_dir(".")
container_opts = {
Image: image.id,
Entrypoint: ["bash", "-c",... |
ActiveAdmin.register Company do
permit_params :name, :responsible_id, :customers_type, :timezone
index do
id_column
column :name
column :responsible do |c|
c.responsible.full_name if c.responsible_id
end
column :timezone
column :created_at
column :customers_type do |c|
Compa... |
# -*- coding: utf-8 -*-
require 'rubygems'
require 'graphviz'
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'similarity'
=begin
This example shows how to generate diagrams such as those produced by
Stray and Burgess in:
http://jonathanstray.com/a-full-text-visualization-of-the-iraq-war-logs
It ... |
# encoding: utf-8
require 'redis'
require 'rollout'
# Rollout requires a "user object"
class FakeUser < Struct.new(:id); end
class Plugin::Rollout < Plugin
#
# Config variables:
#
# rollout.redis.host - The redis instance we should connect to. Defaults
# to Redis.new i.e. localhost
#
# Add routes
def... |
require 'rspec/expectations'
require 'selenium-webdriver'
require_relative './pages/login_page'
require_relative './pages/patient_search'
require_relative './pages/basic_page'
require_relative './pages/cover_sheet_page'
World(RSpec::Matchers)
World(PageObject::PageFactory)
Given (/^The user confirms to "(.*?)" meds ... |
class Section < ApplicationRecord
validates :name, presence: true, uniqueness: true
validates :shelf_id, presence: true
has_many :food_items
belongs_to :shelf
end |
class LuxeWagon < Wagon
validates :lower_places,
presence: true,
numericality: { only_integer: true }
end
|
class CreateHotels < ActiveRecord::Migration[5.2]
def change
create_table :hotels do |t|
t.string :name, null: false
t.string :address
t.attachment :picture
t.float :single_bedroom_price, null: false, default: 0.0
t.float :double_bedroom_price, null: fal... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
setup do
@user = users :john
end
test 'should be valid' do
assert @user.valid?
end
test 'name should be present' do
@user.name = ''
assert @user.invalid?, 'Name is blank'
end
test 'name should not be longer than 50 charac... |
ActiveAdmin.register Dog do
#:prompt => 'Selecione'
form multipart: true do |f|
f.inputs do
f.input :father, :prompt => 'Selecione', :collection => Dog.where("male = true")
f.input :mother, :prompt => 'Selecione', :collection => Dog.where("male = false")
f.input :birth_date
... |
# encoding: utf-8
module TextUtils
module AddressHelper
def normalize_addr( old_address, country_key=nil )
# for now only checks german (de) 5-digit zip code and
# austrian (at) 4-digit zip code
#
# e.g. Alte Plauener Straße 24 // 95028 Hof becomes
# 95028 Hof //... |
require 'fluent/plugin/in_http'
require_relative 'logplex'
module Fluent
class HerokuSyslogHttpInput < HttpInput
Plugin.register_input('heroku_syslog_http', self)
include Logplex
config_param :format, :string, :default => SYSLOG_HTTP_REGEXP
config_param :drain_ids, :array, :default => nil
priva... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.