text stringlengths 10 2.61M |
|---|
# == Schema Information
#
# Table name: bids
#
# id :bigint not null, primary key
# bid_amount :decimal(, )
# created_at :datetime not null
# updated_at :datetime not null
# auction_id :bigint
# user_id :bigint
#
# Indexes
#
# index_bids_on_auction_id (auction_id)
# index_b... |
class Player
attr_reader :choice, :name, :score, :computer
def initialize(name)
@name = name
@choice = nil
@score = 0
@computer = false
end
def rock
@choice = :rock
end
def paper
@choice = :paper
end
def scissors
@choice = :scissors
end
def add_score
@score += 1... |
class DcsDocument
class Serializer
def load(text)
return unless text
DcsDocument.from_xml(text)
end
def dump(obj)
return obj.to_xml if obj.respond_to?(:to_xml)
obj
end
end
def self.add_oai_metadata_terminology_proxies t
t.identifier(:proxy => [:metadata, :dc, :iden... |
# example:
class GoodDog
DOG_YEARS = 7
def initialize(n, a)
@name = n
@age = a
end
def human_years
age * DOG_YEARS
end
private
attr_accessor :name, :age
end
sparky = GoodDog.new("Sparky", 4)
puts sparky.human_years # 28
puts sparky.name # Private method error
puts sparky.age # Private met... |
# frozen_string_literal: true
# Advent of Code 2020
#
# Robert Haines
#
# Public Domain
require 'aoc2020'
module AOC2020
class JurassicJigsaw < Day
OPPOSITE = {
top: :bottom,
bottom: :top,
left: :right,
right: :left
}.freeze
ROTATE = {
top: :left,
bottom: :right,
... |
# frozen_string_literal: true
module JSONAPI
module Rails
class StandardErrorsSerializer
attr_reader :error
private :error
def initialize(exposures)
@error = exposures[:object]
freeze
end
def as_jsonapi
key = 'data'
SerializableActiveModelError
... |
class RemoveImageUrlColumnFromCrafts < ActiveRecord::Migration
def change
remove_column :crafts, :image_url
end
end
|
require 'skypekit_pure/errors'
require 'skypekit_pure/api'
require 'skypekit_pure/request'
require 'skypekit_pure/skype'
require 'skypekit_pure/version'
module SkypekitPure
extend self
def connect(ssl_key, host = '127.0.0.1', port = 8963)
Skype.new(ssl_key, host, port)
end
end |
class StateSerializer < ActiveModel::Serializer
attributes :id, :name
def id
object._id.to_s
end
end
|
class OtherexpensesController < ApplicationController
def index
@expenses = Otherexpense.all
end
def new
@expenses= Otherexpense.new
end
def show
end
def create
@expenses = Otherexpense.new(expenses_params)
if @expenses.save
flash[:success] = "Otherexpense has been successfully updated"
... |
# encoding: UTF-8
#
# Author:: Xabier de Zuazo (<xabier@zuazo.org>)
# Copyright:: Copyright (c) 2015 Xabier de Zuazo
# License:: Apache License, Version 2.0
#
# 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 t... |
class Tournament < ApplicationRecord
OWNER_LIMIT = 5
RANKING_TYPES = [:glicko2, :king_of_the_hill]
DEFAULT_RANKING_TYPE = RANKING_TYPES.first
extend FriendlyId
friendly_id :slug_canditates, use: :slugged
belongs_to :owner, :class_name => 'User'
has_many :players, :dependent => :destroy
has_many :inv... |
require "rails_helper"
describe " on Home Page" do
it " the Log In button will render the log in page" do
visit root_url
click_on "Log In"
expect(page).to have_text("Log In")
end
it "does not work" do
visit new_user_session_url
expect(page).not_to have_text("Welcome Back")
end
end
|
class AccountLineItem < ActiveRecord::Base
belongs_to :vendors
belongs_to :customers
belongs_to :journals
belongs_to :account, foreign_key: "account_id"
end
|
# Read files and metadata from MPQ archives.
#
# We'll use `bindata` as a DSL for binary extraction, and since we only care
# about StarCraft 2 replays at the moment, the only decompression we need is
# `bzip2`.
require 'bindata'
require 'bzip2'
# A massive thanks to Justin Olbrantz (Quantam) and Jean-Francois Roy ... |
FactoryBot.define do
factory :contact do
type { "" }
first_name { "MyString" }
last_name { "MyString" }
phone_number { "MyString" }
shop { nil }
end
end
|
class DeviceSpot < ActiveRecord::Base
acts_as_gmappable
def gmaps4rails_address
"#{self.address}"
end
def gmaps4rails_infowindow
"#{self.name}"
end
def gmaps4rails_title
"#{self.name}"
end
end
|
# frozen_string_literal: true
namespace :test_calendar do
desc 'Clear events from the test calendar'
task :clear, [:verbose] => :environment do |_task, args|
GoogleAPI::Calendar.new.clear_test_calendar(verbose: args[:verbose].present?)
end
end
|
module TypeHelpers
module JointState
def self.from_array(arr)
ret = Types::Base::JointState.new
arr.size > 0 ? ret.position = arr[0] : ret.position
arr.size > 1 ? ret.speed = arr[1] : ret.speed
arr.size > 2 ? ret.effort = arr[2] : ret.effort
arr.size > 3 ? ret.raw = arr[3] : ret.raw
... |
require 'fileutils'
module Dotpkgbuilder
class Context
attr_reader :source_dir, :source_dir, :scripts_dir, :working_dir, :templates_dir
attr_accessor :package_name, :package_title, :version
attr_accessor :number_of_files, :install_kbytes
attr_accessor :preinstall, :preinstall_file, :postinstall, :p... |
# An encrypted location peice for a user
#
# user_id::
# encrypted_message::
# message_hash::
class Spot < ActiveRecord::Base
# Transient attributes
attr_accessor :phone_number, :latitude, :longitude, :speed, :course, :timestamp, :time_in_zone
# Associations
belongs_to :user
# Validations
validates :... |
##
# 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
Rank = GreatRanking
... |
# binary_node.rb
# Nodes for a binary tree
class BinaryNode
attr_accessor :data, :left, :right
def initialize(data, left_node = nil, right_node = nil)
@data = data
@left = left_node
@right = right_node
end
def insert(val)
if val <= @data
@left.nil? ? @left = BinaryNode.new(val) : @left.i... |
# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
require "openssl"
# This filter allow you to generate predictable, string encoded hashed keys
# based om event contents and timestamp. This can be used to avoid getting
# duplicate records indexed into Elasticsearch.
#
# Hashed keys to be... |
#!/usr/bin/env ruby
require 'curses'
def hex_to_rgb(hex)
m = hex.match /#(..)(..)(..)/
[m[1].hex*4, m[2].hex*4, m[3].hex*4]
end
colors = [
'#4B8BBE',
'#306998',
'#FFE873',
'#FFD43B',
'#646464',
].map{|c| hex_to_rgb(c)}
begin
Curses.init_screen
Curses.start_color# if Curses.has_colors?
#Curses.us... |
FactoryBot.define do
factory :order do
postcode { '000-0001'}
prefecture_id { 2 }
city { '札幌市'}
bloc { '1' }
building { '1 '}
phone { '09012345678' }
token { 'tok_abcdef... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../song')
class SongTest < MiniTest::Test
def test_get_genre
@ymca = Song.new('ymca', 'cheesy')
assert_equal('cheesy', @ymca.genre)
end
end
|
class XTEA
attr_reader :key, :key_o
MASK = 0xFFFFFFFF
DELTA = 0x9E3779B9
def initialize(key=rand(2**128), n=32)
@key_o = key
@n = n
if key.class == Bignum
@key = [key & MASK, key>>32 & MASK, key>>64 & MASK, key>>96 & MASK]
elsif key.class == String
@key = key.unpack('LLLL')
end
end
def de... |
# 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... |
require 'sphinx_helper'
RSpec.describe SearchController, type: :controller do
let(:service) { double('SphinxSearchService') }
describe 'GET #search' do
it 'return right data' do
expect(SphinxSearchService).to receive(:new).and_return(service)
expect(service).to receive(:call)
get :search, p... |
class Upload < ActiveRecord::Base
has_many :sections, through: :upload_sections
attr_accessible :title, :size, :filetype, :file, :section_id
mount_uploader :file, UploadUploader
def self.is_doc
where("filetype LIKE 'application%'")
end
end
|
class User < ApplicationRecord
has_secure_password
has_many :product
# => Basic password validation
validates_length_of :password, within: 8..20,allow_nil:true, allow_blank:false
validates_confirmation_of :password, allow_nil:true, allow_blank:false
before_validation {
(self.email = self.email... |
require 'board'
describe Board do
let(:test_board) { Board.new }
describe "#initialize" do
let(:empty_board) do
[
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]
]
end
it "... |
class User < ActiveRecord::Base
validates :email, uniqueness: true
def to_json
super(except: :password)
end
end
|
class ProductsController < ApplicationController
def show
@product = Product.find(params[:id])
end
def new
@product = Product.new
@product_items = Product.where("distribute = ?", params[:distribute]).paginate(page: params[:page]).per_page(10)
end
def create
@product = Product.new(products_params)
@p... |
# frozen_string_literal: true
require "rails_helper"
describe CommentsController do
let(:comment) { assigns(:comment) }
describe "#new" do
before { get :new }
it { is_expected.to render_template(:new) }
it "assigns a new comment" do
expect(comment).to be_a_new(Comment)
end
end
descri... |
require 'rails_helper'
RSpec.describe 'supply_teachers/suppliers/all_suppliers.html.erb' do
let(:supplier) { create(:supply_teachers_supplier) }
let(:branch) { create(:supply_teachers_branch, supplier: supplier) }
before do
assign(:branches, SupplyTeachers::Branch.all.page)
assign(:branches_count, 10)
... |
module EARMMS::MembershipAdminUserEditRolesHelpers
def get_available_roles(user)
user_roles = user.get_roles
roles = [
{
:name => "Mass emailing",
:roles => [
{
:role => "email:members",
:desc => "Send emails to entire membership",
:has => u... |
class UsersController < ApplicationController
before_filter :assign_user, :only => :show
before_filter :require_login, :only => [:show, :index]
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
cookies.permanent[:user_id]... |
# by Kami Gerami
#
#
Vagrant.require_version ">= 1.7.2"
# vars
domain = "example.com"
hostname_lb = "lb" # hostname for lb
hostname_backend = "webapp" # hostname for backend servers
# Nodes
# Available parameters :
# :run => "once" || "always" (blank defaults to always)
# :memory => "1024" || "512" is the default... |
# frozen_string_literal: true
class Usergroup
DELIMITER_TIME = ':'
DELIMITER_DATE = ' '
NUMBERS = %w[first second third fourth].freeze
DAYS_INTO_WEEK = {
monday: 0,
tuesday: 1,
wednesday: 2,
thursday: 3,
friday: 4,
saturday: 5,
sunday: 6,
}.freeze
attr_access... |
require 'rails_helper'
RSpec.describe 'ランチ履歴の表示機能', type: :system do
before do
member1 = create(:member, real_name: '鈴木一郎')
member2 = create(:member, real_name: '鈴木二郎')
member3 = create(:member, real_name: '鈴木三郎')
member4 = create(:member, real_name: '鈴木四郎')
member5 = create(:member, real_name: '... |
class ChangeDataTypesInReviews < ActiveRecord::Migration[5.1]
def change
remove_column :reviews, :communication
remove_column :reviews, :driving
remove_column :reviews, :comfort
remove_column :reviews, :punctual
end
end
|
class UsersController < ApplicationController
before_filter :get_account
before_filter :restrict_account_access
before_filter :restrict_client_access
def new
@user = User.new
@client = Client.find_by_id(params[:client_id])
@user.client_id = @client.id if @client
end
def create
@user = User.... |
require 'spec_helper'
describe ConsultManagement::Consult do
describe "バリデーション" do
it { should validate_presence_of :name }
it { should validate_presence_of :link }
it { should validate_presence_of :work_content }
it { should validate_presence_of :contact }
end
end
|
Downloading pictures
Anyway, I could search for all JPEGs with Dir['*.jpg']. Actually, since these are
case-sensitive searches, I should probably include the all-caps version as
well, Dir['*.{JPG,jpg}'], which roughly means “Find me all files starting with
whatever and ending with a dot and either JPG or jpg.” Of cours... |
class CreateUserCompanies < ActiveRecord::Migration
def change
create_table :user_companies do |t|
t.integer :user_id, null: false
t.integer :company_id, null: false
t.boolean :hidden, default: false
t.boolean :applied, default: true
t.text :notes
t.timestamps null: false
e... |
class Entry < ActiveRecord::Base
validates :content, presence: true
validates :title, presence: true
def next
@entry = Entry.where("id > ?", id).order("id ASC").first
end
def previous
@entry = Entry.where("id < ?", id).order("id DESC").first
end
end
|
require File.expand_path(File.dirname(__FILE__) + '/../acceptance_helper')
feature 'Dashboard Bulk Upload Article PDFs' do
background do
log_in_as_administrator
@issue = FactoryGirl.create(:issue, :fully_loaded)
end
scenario 'Upload PDFs for all Articles in an issue' do
visit edit_dashboard_issue_... |
module ApplicationHelper
def avatar_url(user, size = 48)
default_url = "#{root_url}images/guest-#{size}.png"
gravatar_id = Digest::MD5::hexdigest(user.email).downcase
"http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=#{CGI.escape(default_url)}"
end
def will_paginate_entries(collect... |
require_dependency 'webpush'
module DiscoursePushNotifications
class Pusher
def self.push(user, payload)
updated = false
subscriptions(user).each do |_, subscription|
subscription = JSON.parse(subscription)
message = {
title: I18n.t(
"discourse_push_notificatio... |
class Student < ActiveRecord::Base
belongs_to :instructor
validates :name, presence: true
belongs_to :instructor
has_many :enrollments
has_many :courses, :through => :enrollments
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { User.create!(email: "user@blocitoff.com", password: "password") }
describe "attributes" do
it "should respond to email" do
expect(user).to respond_to(:email)
end
end
describe "invalid email" do
let(:user) { User.new(e... |
# encoding: utf-8
module Cql
module Protocol
class ResponseFrame
def initialize(buffer=ByteBuffer.new)
@headers = FrameHeaders.new(buffer)
check_complete!
end
def stream_id
@headers && @headers.stream_id
end
def header_length
8
end
def ... |
name "cookbook-texlive"
maintainer "Takeshi KOMIYA"
maintainer_email "i.tkomiya@gmail.com"
license "Apache 2.0"
description "Installs TeXLive"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.3.2"
%w{ fedora redhat centos ubuntu debian amazon ... |
class StatisticsIndex
attr_reader :base_name, :state, :version, :uid
def self.from_template(template)
index_name = template.index_patterns.split('-')[0..1].join('-')
StatisticsIndex.new index_name, template.state, template.version
end
def self.from_name(name)
base_name = name.split('-')[0..1].joi... |
def echo(value_in)
return value_in
end
def shout(value_in)
return value_in.upcase
end
def repeat(value_in, num = 2)
return ("#{value_in} " * num).strip
end
def start_of_word(str, length)
return str[0...length]
end
def first_word(str)
return str.split(' ')[0]
end
def titleize(str)
str = str.... |
# frozen_string_literal: true
module Vedeu
module Runtime
# Stores all client application controllers with their respective
# actions.
#
# @api public
#
module Router
include Vedeu::Common
extend Vedeu::Repositories::Storage
extend self
# Registers a controller wi... |
require 'byebug'
class Player
attr_reader :name
attr_accessor :just_guessed
def initialize(name)
@name = name
@just_guessed = false
end
def get_guess(board)
puts "#{name}, please enter coordinates for first guess."
guess = gets.chomp.split(",").collect(&:to_i).collect { |x| x -= 1 }
unti... |
class UserEntity
attr_reader :password, :email, :name, :provider, :uid
attr_accessor :id
def initialize(id: nil, password: nil, email: nil, name: nil, provider: nil, uid: nil)
@id = id
@password = password
@email = email
@name = name
@provider = provider
@uid = uid
end
end |
require 'google_maps_service'
class Event < ApplicationRecord
belongs_to :user
has_attached_file :image, styles: { thumb: "260x160>" }, default_url: "/system/events/images/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
validates_presence_of :name, :description, :b... |
Rails.application.routes.draw do
devise_for :users, path: '', path_names: { sign_in: "login", sign_out: "logout", sign_up: "register", edit: "account/edit" }
root to: "pages#main"
resources :posts do
put :sort, on: :collection
member do
get :toggle_status
end
end
resources :images
resource... |
class UserCompSchedule < ApplicationRecord
belongs_to :user
belongs_to :competition_info
end
|
require 'rails_helper'
describe 'Items API' do
describe 'relationships' do
it 'can return merchant associated with an item' do
merchant1 = create(:merchant)
merchant2 = create(:merchant)
merchant3 = create(:merchant)
item1 = create(:item, merchant: merchant1)
item2 = create(:item, m... |
class ProjectSerializer
include FastJsonapi::ObjectSerializer
attributes :title
has_many :todos
end
|
ProblemList::Application.routes.draw do
resources :lists
root to: 'lists#new'
end
|
# encoding: utf-8
module MarkupHelper
def section_title(title, options={})
options[:class] = "#{options[:class]} section"
content_tag(:h2, content_tag(:span, content_tag(:span, title)), options)
end
def purchase_button_for(product)
form_for(:order, :url => populate_orders_url, :html => { :class => 'b... |
# t.string :room_location
class Classroom < ApplicationRecord
has_many :course_sessions, dependent: :nullify
validates :room_location, presence: true
end
|
class AddColumnFollowing < ActiveRecord::Migration
def change
add_column :followings, :following_id, :integer
end
end
|
class Deck
def initialize
@cards = Array.new
suits = [:hearts, :diamonds, :spades, :clubs]
suits.each do |suit|
(2..10).each do |value|
@cards << Card.new(suit, value)
end
@cards << Card.new(suit, "J") #J
@cards << Card.new(suit, "Q") #Q
@cards << Car... |
class ChangeTypeForFeepaid < ActiveRecord::Migration[5.2]
def change
change_column(:appointments, :fee_paid, :float, using: '0')
end
end
|
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Fog::AWS::EC2::Instances' do
describe "#all" do
it "should return a Fog::AWS::EC2::Instances" do
ec2.instances.all.should be_a(Fog::AWS::EC2::Instances)
end
it "should include persisted instances" do
instance = ec2.instance... |
class AddDonationRecurrenceToDonations < ActiveRecord::Migration
def change
add_column :donations, :donation_recurrence, :string
end
end
|
# frozen_string_literal: true
require "test_helper"
class UserTest < ActiveSupport::TestCase
test 'should not save user with missing credentials' do
@new_user = User.create
assert @new_user.errors[:username].present?, 'expect missing username error'
assert @new_user.errors[:email].present?, 'expects mi... |
class CreateReports < ActiveRecord::Migration
def change
create_table :reports do |t|
t.references :store
t.string :name
t.integer :cash_variance
t.integer :eftpos_variance
t.decimal :rostered_hours, precision: 6, scale: 2
t.integer :units
t.timestamps
end
end
end
|
require 'rails_helper'
feature "images appear when logged in" do
scenario "user can click thumbnail to view image show page" do
create_user
image = create_image
login_user
find('.single-image').click
expect(page).to have_content(image.title)
expect(page).to have_content(image.keywords)
end
... |
class FontShipporiMinchoB1 < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/shipporiminchob1"
desc "Shippori Mincho B1"
desc "Based on the Tsukiji Typeface making facility of Tokyo"
homepage "https://fonts.google.com/specimen/Shippori+Min... |
ActiveAdmin.register Service do
permit_params :service_type_id, :type_service, :name, :quantity, :time, :price,
:icon
filter :service_type
filter :type_service
filter :name
filter :quantity
filter :time
filter :price
index do
selectable_column
id_column
column :service_type... |
class ClientGenerator < BaseScaffold
def build
define_source_paths
@template_dir = "#{Configuration::FRONTEND}/#{model_parameter_name}/"
empty_directory @template_dir
create_js("controller", "#{controller_class_name}")
generate_html("list")
generate_html("details")
generate_html("form... |
class ForgotPasswordResetController < UIViewController
attr_accessor :user
def self.new(args = {})
s = self.alloc
s.user = args[:user]
s
end
def viewDidLoad
super
self.edgesForExtendedLayout = UIRectEdgeAll
rmq.stylesheet = ForgotPasswordResetControllerStylesheet
rmq(self.view).ap... |
require_relative "dictionary"
class Game
def initialize(player1, player2)
@fragment = ''
@player1 = player1
@player2 = player2
@p1letters = ''
@p2letters = ''
puts "OK " + player1 + " and " + player2 + ',' + " let's begin."
puts "----------------------------"
... |
require 'rails_helper'
describe WordValidation do
subject { WordValidation.new(raw_json) }
it 'exists with valid attributes' do
expect(subject.word).to eq('foxes')
expect(subject.root).to eq('fox')
end
end
def raw_json
{:metadata=>{:provider=>"Oxford University Press"},
:results=>
[{:id=>"fox... |
class User < ActiveRecord::Base
has_secure_password
validates :name, {presence: true,uniqueness: true}
def posts
return Post.where(user_id: self.id)
end
end
|
class Me::ProfilesController < ApplicationController
# GET /users/1
# GET /users/1.json
def show
end
# GET /users/1/edit
def edit
end
# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
respond_to do |format|
if current_user.update(user_params)
format.html { redirect_to me_... |
# frozen_string_literal: true
## --- BEGIN LICENSE BLOCK ---
# Copyright (c) 2016-present WeWantToKnow AS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including wit... |
class ChangeUserDefaultPic < ActiveRecord::Migration
def change
change_column_default(:users, :photo_url, "https://res.cloudinary.com/dlpclqzwk/image/upload/v1478276712/noPhoto_50_y9zhkk.png")
end
end
|
class Repo < ActiveRecord::Base
belongs_to :people
has_many :commits
def build_commits
begin
commits = Octokit.commits(self.full_name)
rescue Octokit::Error
commits = []
end
commits.each do |commit|
Commit.create(repo_id: self.id,
author: commit[:commit]... |
require 'test_helper'
class PearlsControllerTest < ActionDispatch::IntegrationTest
setup do
@pearl = pearls(:one)
end
test "should get index" do
get pearls_url
assert_response :success
end
test "should get new" do
get new_pearl_url
assert_response :success
end
test "should create p... |
#!/usr/bin/env ruby
require './PTCommon/Arguments'
require './Startup'
require './UIServer'
require './AppScanner'
args = PTCommon::Arguments.new(
{
'port' => "5555",
'bindaddr' => "127.0.0.1",
'v' => false, # Verbose mode
'help' => false,
'version' => false,
'theme' => 'default',
'pauseonfailure' => ... |
require 'spec_helper'
describe Lease::Template do
it 'should created templates' do
template = described_class.new(
state: 'Illinois',
html_file: fixture_file_upload(Rails.root.join('../fixtures/files/lease-illinois.html'), 'text/html')
)
expect(template.valid?).to be_truthy
end
end
|
# Gif class has many favorites, and many gifs through favorites
class Gif < ActiveRecord::Base
has_many :favorites
has_many :users, through: :favorites
# def user_favorite_urls
# # match up gif_id to the favorites method
# favorites.map do |favorite|
# favorite.find_by()
# # and map out urls f... |
class Goal < ActiveRecord::Base
as_enum :goal_type, [:novel, :coding_project, :blog], map: :string
belongs_to :user
end |
# Copyright 2019 The inspec-gcp-cis-benchmark 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
# Copyright (C) 2014-2015 Donovan Glover
# http://dglover.co/ | https://dglvr.github.io/rosarla
require "fileutils"
# @require https://www.npmjs.com/package/typescript
module Typescript
def self.compile(given_files)
(given_files).each do |this_file|
%x(tsc #{this_file})
new_file = this_file.gsub(".t... |
# frozen_string_literal: true
RSpec.describe ExceptionalAbsurdityMill do
it "has a version number" do
expect(ExceptionalAbsurdityMill::VERSION).not_to be nil
end
it "produces a string" do
expect(ExceptionalAbsurdityMill::Base.random).to be_an_instance_of(String)
end
describe "creates an array of ha... |
class AddFieldsToMedications < ActiveRecord::Migration
def change
add_column :medications, :type, :string
add_column :medications, :animal_type_id, :integer
add_column :medications, :series_name, :string
add_column :medications, :series_number, :integer
add_column :medications, :series_interval, :... |
class MessagesController < ApplicationController
def index
@messages = Message.all
@client = Twilio::REST::Client.new ENV['TWILLIO_ACCOUNT_SID'], ENV['TWILLIO_AUTH_TOKEN']
@message = Message.new
end
def show
@messae = Message.find(params[:id])
end
def new
@message = Message.new
end
def create ... |
require 'rails_helper'
RSpec.describe Config, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:owner) }
end
describe 'validations' do
it 'allows valid values' do
valid_keys = ['hello@example.com', 'foo-bar', 'a' * 30]
valid_keys.each do |key|
config = build_s... |
module LinkedResearchMetadata
module Transformer
# Organisation transformer
#
class Organisation < Base
# @param config [Hash]
# @option config [String] :url The URL of the Pure host.
# @option config [String] :username The username of the Pure host account.
# @option config [Str... |
class TrabajoGradosController < ApplicationController
before_action :set_trabajo_grado, only: [:show, :edit, :update, :destroy]
# GET /trabajo_grados
# GET /trabajo_grados.json
def index
@trabajo_grados = TrabajoGrado.all
end
# GET /trabajo_grados/1
# GET /trabajo_grados/1.json
def show
end
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.