text stringlengths 10 2.61M |
|---|
class Chef
module Provisioning
module AzureDriver
# Represents available options when bootstrapping a host on Azure
# These are used to tell Azure some initial pieces of information
# for building a new VM.
class BootstrapOptions < Chef::Provisioning::BootstrapOptions
# @return [St... |
# frozen_string_literal: true
module API
# Global api error handlers. With rollbar notifications
module ErrorHandlers
extend ActiveSupport::Concern
included do
rescue_from ActiveRecord::RecordNotFound do |e|
# Rollbar.warning(e)
return_error!("Record not found", 404)
end
... |
module TicTacToe
class Player
CORNERS = ["1", "3", "7", "9"]
def initialize(board)
@board = board
end
protected
def win
check(@me)
end
def block
check(@opponent)
end
def check(side = @me)
[1,2,3].each do |i|
return true if check_row(i, side)
... |
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
workspace 'App.xcworkspace'
project 'App.xcodeproj'
platform :ios, '10.0'
inhibit_all_warnings!
use_frameworks!
CCPod = Struct.new(:name, :version, :git, :branch)
snapkit = CCPod.new('SnapKit', '~> 4.0.0')
alamofire = CCPod.... |
# By default, <code>chart</code> uses a line width of 3 for line charts.
#
# You can use the <code>:line_width</code> option to customize this value.
#
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
data = {views: {2013 => 182, 2014 => 46, 2015 => 8020000000... |
require 'test_helper'
class EppDomainTransferQueryTest < ApplicationIntegrationTest
def test_returns_domain_transfer_details
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
assert_equal '1000', xml_doc.at_css('resul... |
require 'bundler/setup'
require 'rack/rewrite'
require 'sinatra/base'
# The project root directory
$root = ::File.dirname(__FILE__)
use Rack::Rewrite do
app_host = ENV['APP_HOST'] || 'stevenharman.net'
old_posts = { 'a-first-step-to-better-user-experience-thinking-like-a' => 'a-first-step-to-better-user-experien... |
class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name, :gender, :mugshot, :link, :remote_id
attr_accessor :password
before_save :encrypt_password
validates_presence_of :name
validates_confirmation_of :password
validates_presence_of :password, :o... |
# 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 IngredientsController < ApplicationController
def index
ingredients = Ingredient.all
options = {
include: [:recipe, :inventory_item]
}
render json: IngredientSerializer.new(ingredients, options)
end
def show
ingredient = Ingredient.find_by(id:... |
class CategorySerializer < ActiveModel::Serializer
attributes :id, :title, :todos
has_many :todos
end
|
module FFI
class StructLayout # [
# def initialize ;end # in ffi.rb for fixed instvars
def __get(fieldname, cbytearray)
idx = @members_dict[fieldname]
if idx._equal?(nil)
raise ArgumentError, 'invalid field name'
end
ofs = @offsets[idx]
elem_siz = @elem_sizes[idx]
... |
class Leave < ActiveRecord::Base
belongs_to :member
belongs_to :last_updated_by, class_name: 'Member'
validates :member, presence: true
validates :date, presence: true
default_scope -> { order(date: :desc) }
end
|
class PostsController < ApplicationController
require 'digest/md5'
before_action :set_post, only: [:show, :edit, :update, :destroy]
def index
@posts = Post.where(state: 'published').order('created_at DESC').all
@props = @posts.map do |post|
{
created_at: post.created_at.strftime('%d %B %Y'... |
#==============================================================================
# +++ MOG - Anti Animation Lag (v1.1) +++
#==============================================================================
# By Moghunter
# https://atelierrgss.wordpress.com/
#=======================================================... |
# encoding: utf-8
$: << File.expand_path("../lib", File.dirname(__FILE__))
require "rubygems" unless defined?(Gem)
require "bundler/setup"
require "minitest/autorun"
require "minitest/hell"
require "colors"
class ColorsTest < MiniTest::Unit::TestCase
def test_should_define_colors_mames_as_methods
%w[black red... |
class Api::V1::BooksController < Api::V1::ApiController
wrap_parameters format: [:json, :xml, :url_encoded_form, :multipart_form]
def index
@books = Book.all
render json: @books
end
def create
@book = Book.new(book_params)
if @book.save
render json: @book
... |
require_relative './encounter.rb'
# Factory that creates a random monster encounter based on the level of the dungeon.
class DistressedHumanoidEncounter < Encounter
def initialize(level, variation)
@variation = variation # variation can be ally or trap
@type = "distressed humanoid, #{variation}"
super(l... |
class AddOptionToAnswer < ActiveRecord::Migration
def change
add_reference :answers, :option, index: true, foreign_key: true
add_reference :answers, :result, index: true, foreign_key: true
end
end
|
module Requests
module Balancing
extend ActiveSupport::Concern
included do
has_one :balance, class_name: 'Requests::Balance', foreign_key: :user_id
has_many :refunds, class_name: 'Requests::Refund'#, foreign_key: :issued_by
after_create :init_balance!
end
def init_balance!
return balan... |
require 'spec_helper'
require 'libraries/example'
describe_inspec_resource 'example' do
context 'on windows' do
# This helper method here is the equivalent to the first line within the environment
# that defines an os that returns a true when the names align.
# let(:platform) { 'windows' }
environ... |
class MergeAndReassociateTypos < ActiveRecord::Migration[6.1]
def change
# NB: irreversible!
# Create temporary columns to keep track of associations
add_column :typos, :context_id, :integer
add_column :samples, :typo_id, :integer
# Join typos and contexts (formerly periods and site_phases)
... |
require 'socket'
module ArtNetServer
class Server
include UdpSocket
def initialize
@counter = 0
end
def run
@counter += 1
send_message("hello #{@counter}")
end
def send_quit_message
send_message('quit')
end
end
end
|
class Users::RegistrationsController < Devise::RegistrationsController
def if_user_exist?
respond_to do |format|
@user = User.find_by(username: params[:username])
if @user.nil?
format.json { head :no_content}
else
format.json { head :not_acceptable}
end
end
end
end |
class PostCategory < ActiveRecord::Base
has_and_belongs_to_many :posts
validates_uniqueness_of :title
# open up everything for mass assignment
attr_protected
end
|
# frozen_string_literal: true
class Hand < Cardset
# Can accept cards from the deck
def receive(cards)
@cards += cards
end
# Human readable list of cards
def to_s
@cards.join ', '
end
def points
result = @cards.inject(0) { |sum, c| sum + c.points }
# Ace can be 1 and can be 11 (11 by d... |
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.
require_relative 'format/safe'
module Console
module Format
def self.default
Safe.new(format: ::JSON)
end
def self.default_json
self.default
end
end
end
|
require "test_helper"
class CollectionSearchingTest < MiniTest::Unit::TestCase
def setup
@app, @stubs = make_application({parallel:true})
@items = @app[:items]
@query = "foo"
@limit = 100
@total = 110
@make_listing = lambda{|i| make_kv_listing(:items, key: "item-#{i}", reftime: nil, score: ... |
require 'rails_helper'
RSpec.describe ShortVisitsController, type: :controller do
before(:each) do
@user = FactoryGirl.create(:user)
@short_url = FactoryGirl.create(:short_url, {user: @user})
@short_visit = FactoryGirl.create(:short_visit, {short_url: @short_url})
request.env['HTTP_AUTHORIZATION'] = ... |
class RanameFriendsColumn < ActiveRecord::Migration
def up
rename_column :user_preferences, :friend_on_sidekick, :friends_on_sidekick
end
def down
end
end
|
class EmployeesController < ApplicationController
before_action :logged_in_user
def index
@employees = Employee.all
@employers = Employer.all
end
def show
@employee = Employee.find(params[:id])
@employer = @employee.employer
@timesheets = @employee.timesheets
@budgets = @employee.budgets.distinct.ord... |
class StructureLinkService < BaseServicer
attr_accessor :physical_structure,
:audit_structure
def execute!
audit_structure.physical_structure.update(physical_structure.cloneable_attributes)
end
end
|
describe StatusController do
describe 'should return Status for every env for WEBv1 application' do
it 'should return proper status for UAT' do
get '/status/WEBv1/uat'
expect(last_response).to be_ok
result = JSON.parse(last_response.body, symbolize_names: true)
expect(result[:version]).... |
require File.expand_path('rm_vx_data') if false
#===============================================================================
# Vibrazione in battaglia di Holy87
# Difficoltà utente: ★
# Versione 1.1
# Licenza: CC. Chiunque può scaricare, modificare, distribuire e utilizzare
# lo script nei propri progetti, sia amat... |
Given /^an empty (\w+) document collection$/ do |doc|
klass = doc.constantize
step "an empty #{klass.collection_name} collection"
end
Given /^an? (\w+) document named '(.*)' :$/ do |doc, name, table|
@all = []
klass = doc.constantize
table.hashes.each do |hash|
@last = klass.new
hash.each do |attr, v... |
puts "Hello welcome to Caesar's Cypher"
puts "The old chap used a cryptographic method to encode his messages and letters"
puts "How? Shift each letter in the alphabet by a certain number. "
puts "What sentence do you want to encode?"
def cypher(string, shift=5)
code = string.split(//)
code_table =* ("a".."z")... |
class Task < ApplicationRecord
belongs_to :user
has_many :taggings
has_many :tags, through: :taggings, dependent: :destroy
validates :title, :subject, :start_time, :end_time, :priority, presence: true
validates :title, uniqueness: {scope: :user_id}
validate :end_time_after_start_time
scope :search_task,... |
module Api
class CustomersController < ApplicationController
skip_before_action :verify_authenticity_token
def index; end
def show
customer = find_customer
render_response(customer)
end
def create
customer = CreateCustomerServices.new(customer_params).create
render json:... |
class AddSorteotToJugadalots < ActiveRecord::Migration[5.0]
def change
add_reference :jugadalots, :sorteot, foreign_key: true
end
end
|
class CreateKptBoards < ActiveRecord::Migration
def change
create_table :kpt_boards do |t|
t.integer :project_id, :null => false
t.string :title, :null => false, :limit => 80
t.integer :keeps_count, :null => false, :default => 0
t.integer :problems_count, :null => fals... |
class SendMessageMutation < Types::BaseMutation
description "Sends a message to the specified number"
argument :to, Types::PhoneNumberType, required: true
argument :body, String, required: false
argument :media, [Types::ActiveStorageSignedIdType], required: false, default_value: []
field :conversation, Outp... |
# Copyright 2013 Claude Mamo
#
# 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
#
# Unless required by applicable law or agreed to in writing, ... |
Rails.application.routes.draw do
resources :hospitals, only: [] do
resources :surgeries, controller: "hospital_surgeries", only: [:index]
end
resources :surgeries, only: [:index, :show] do
resources :doctor_surgeries
end
end
|
class CatRentalRequestsController < ApplicationController
def new
@cat_request = CatRentalRequest.new
render :new
end
def create
request = CatRentalRequest.new(cat_rental_params)
if request.save
redirect_to cat_url(request.cat_id)
else
render json: request.errors.full_messages, s... |
class AddColumnShipperidToOrders < ActiveRecord::Migration[5.1]
def change
add_column :orders, :shipper_id, :integer
end
end
|
class ModifyInvoiceItemTotalAmount < ActiveRecord::Migration
def change
rename_column :invoice_items, :total_amount, :total
change_column_default :invoice_items, :total, 0
change_column_default :invoice_items, :price, 0
change_column_default :invoice_items, :quantity, 0
end
end |
require 'rails_helper'
RSpec.describe Admin::PlansController, :type => :controller do
# This should return the minimal set of attributes required to create a valid
# Admin::Plan. As you add validations to Admin::Plan, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a ha... |
module SmsEnum
CONFIRM = 1
DECLINE = 2
BALANCE = 3
OTHER = 4
end |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_password_sent_at :datetime
# r... |
class User
include MongoMapper::Document
safe
key :name, String
key :location, String
key :email, String
key :website, String
key :description, String
key :image, String
key :unit_system, String, :default => "IMPERIAL"
timestamps!
many :authorizations
many :trips
many :days, :through => :tri... |
Fabricator(:review) do
rating { ["1", "2", "3", "4", "5"].sample }
comment { Faker::Lorem.paragraph }
end |
# frozen_string_literal: true
require 'test_helper'
class Employee < ::PlainModel::Model
attribute :id, :integer
attribute :name
attribute :hired_at, :time, default: -> { Time.now }
attr_accessor :_query
define_association :boss
define_association :colleagues
define_association :pets
def self._reco... |
# == Schema Information
# Schema version: 20110504160931
#
# Table name: cars
#
# id :integer not null, primary key
# grade :string(255)
# rate :float
# nic :float
# created_at :datetime
# updated_at :datetime
#
class Car < ActiveRecord::Base
attr_accessible :grade, :rate, :ni... |
class Board < ApplicationRecord
# acts_as_list scope: :board
extend FriendlyId
friendly_id :name, use: :slugged
belongs_to :workspace
has_many :groups, dependent: :destroy
# create instance前給slug值,做unique網址
before_create { self.slug = SecureRandom.uuid }
validates :name, presence: true
default_sco... |
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
# Start page
get '/pages/start_page'
root to: 'pages#start_page'
# Auth/OAuth controller/pages
get '/oauth_authentications/start'
get '/auth/:provider/callback', to: 'oauth_... |
require 'yaml'
namespace :harmonious_dictionary do
desc "generate harmonious dictionary for use"
task(:generate => :environment) do
chinese_dictionary_path = File.join(GGA.root, 'config','harmonious_dictionary','chinese_dictionary.txt')
english_dictionary_path = File.join(GGA.root, 'config','harmonious_dic... |
class GarageCommand
def self.command(direction)
new.command(direction)
end
def command(dir_str)
direction = :toggle if dir_str.match?(/(toggle|garage)/i)
direction = :open if dir_str.match?(/(open)/i)
direction = :close if dir_str.match?(/(clos)/i)
direction ||= :toggle
ActionCable.serve... |
require_relative '../spec_helper.rb'
require 'repository'
require 'redis'
require 'json'
describe Repository do
let(:repository) { Repository.new }
before(:each) do
@redis = Redis.new
keys = @redis.keys('*')
keys.each{ |key| @redis.del(key)}
end
context 'no data' do
it 'gets an empty list of ... |
require 'test_helper'
# TODO: Split this file as it takes too long.
class Admin::Api::BuyerUsersTest < ActionDispatch::IntegrationTest
include FieldsDefinitionsHelpers
def setup
@provider = FactoryBot.create :provider_account, :domain => 'provider.example.com'
@provider.default_account_plan = @provider.ac... |
class Peep
include DataMapper::Resource
property :id, Serial
property :message, Text
belongs_to :user
end
|
# coding: utf-8
class AgreementsController < ApplicationController
before_filter :auth_required
respond_to :html, :xml, :json
def index
end
def search
@items = Agreement.order(:name).includes(:participants)
if !params[:q].blank?
@items = @items.where("(name LIKE :q) OR (details LIKE :q)", {:q... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/Card_Generator.rb'
class TestCard_Generator <Minitest::Test
def setup
@generate = Card_Generator.new("./lib/cards.txt")
@card = []
end
def test_generator_exists
assert_instance_of Card_Generator, @generate
end
def test_create_a... |
# 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 MemberStatus < ActiveRecord::Base
belongs_to :member
has_and_belongs_to_many :member_references, :class_name => 'Member'
has_many :notifications, :as => :notifiable, :dependent => :destroy
acts_as_taggable
validates_presence_of :body, :member_id
validate :empty_message
before_create :set_me... |
class SharedMix < ApplicationRecord
belongs_to :mix
belongs_to :user
belongs_to :dj
end
|
module Codegrade
class Commit
attr_reader :sha, :working_directory
def initialize(working_directory = '.', sha = nil)
@working_directory = File.expand_path(working_directory)
@sha = sha
end
def author
commit.author
end
def message
commit.message
end
def file... |
# frozen_string_literal: true
class DraScore < ApplicationRecord
has_many :dra_score_students, dependent: :destroy
has_many :students, through: :dra_score_students
validates \
:dra_level,
:rank,
presence: true,
uniqueness: true
validates \
:rank,
numericality: true
end
|
Gem::Specification.new do |s|
s.name = 'maths-units'
s.version = '0.1.0'
s.date = '2016-08-31'
s.summary = %(Maths Units)
s.description = <<EOS
== Maths Units
Conveniently convert degrees and gradians to radians, for use in
the trig functions in the `Math` module.
See the documentation at <https:/... |
#!/Users/moomindani/.rbenv/shims/ruby
# -*- coding: utf-8 -*-
# Ruby template for Google Code Jam
require 'benchmark'
class Solution
def solve(dataset)
File.open(dataset, 'r') do |input|
File.open(dataset.sub(/\.in/, '.out'), 'w') do |output|
test_cases = input.readline.to_i
1.upto(test_... |
require 'rspec'
require 'rest_client'
require 'json'
require_relative '../../lib/config/configuration_reader'
require_relative '../../lib/config/configuration'
require_relative '../../lib/authentication/authenticator'
describe 'Authenticates' do
it 'returns the bearer token for the given username/password' do
c... |
# Object to find user linked to email from session variable
class GetTeacherInSessionVar
def initialize(token)
@token = token
end
def call
return nil unless @token
decoded_token = JWT.decode @token, ENV['MSG_KEY'], true
payload = decoded_token.first
Teacher.find_by_email(payload['email'])
e... |
class AddProjectReferenceToDefects < ActiveRecord::Migration
def change
add_reference :defects, :project, index: true, foreign_key: true
change_column :defects, :fixed, :boolean, default: :false
end
end
|
require 'crypto'
require 'spec_helper'
describe Solver do
let(:test_solver) { Solver.new }
# let(:test_feed) { Document.new(test_solver.get_feed('http://threadbender.com/rss.xml')) }
let(:test_feed) { REXML::Document.new(File.open('./data/test.xml')) }
let(:test_root) { test_feed.root }
subject {test_solver}
it {... |
class Question < ActiveRecord::Base
# Relationships
has_many :indicator_questions, :dependent => :destroy
has_many :indicators, through: :indicator_questions
# Validations
validates_presence_of :question
# Scopes
scope :active, -> { where("questions.active = ?", true) }
scope :inactive, -> {... |
require 'spec_helper'
describe_recipe 'consul::default' do
cached(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
context 'with default attributes' do
it { expect(chef_run).to include_recipe('selinux::permissive') }
it { expect(chef_run).to create_poise_service_user('consul').with(group: 'c... |
require 'spec_helper'
describe 'Querying Locations endpoint' do
before do
@client = Locations.new
end
context 'when given integer' do
it 'locations should return data' do
expect(@client.locations 1).not_to eq nil
end
it 'locationAreas should return data' do
expect(@client.locationA... |
require 'paypal-sdk-permissions'
class PermissionsController < ApplicationController
def show
api = PayPal::SDK::Permissions::API.new
# Build request object
permissions_request = api.build_request_permissions
permissions_request.scope = ["EXPRESS_CHECKOUT"]
permissions_request.callback = "htt... |
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { FactoryGirl.build(:user) }
it 'should be valid' do
expect(user).to be_valid
end
it 'should have a name' do
user.name = ' '
expect(user).to_not be_valid
end
it 'should have an email' do
user.email = ' '
expe... |
class PostsController < ApplicationController
before_action :set_post, only: %i[ show edit update destroy]
def index
# posts = "COALESCE(title, '') LIKE '%'"
# unless params[:q].nil?
# posts = "COALESCE(title, '') LIKE '%" + params[:q] +
# "%' OR COALESCE(content, '') LIKE '%" + params[:q] + ... |
class AddNameAndAdminAndHighestLevelAndRoomsExploredAndEnemiesKilledAndEmblemAndTitleToUsers < ActiveRecord::Migration
def change
add_column :users, :name, :string
add_column :users, :admin, :boolean
add_column :users, :highest_level, :integer
add_column :users, :rooms_explored, :float
add_column ... |
class Tweeet < ApplicationRecord
belongs_to :user, :optional => true
validates_length_of :tweeet, :within =>1...140
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'バリデーションテスト' do
context '作成時' do
subject(:user) { create(:user) }
it { is_expected.to be_valid }
it { is_expected.to validate_presence_of(:user_id) }
it { is_expected.to validate_presence_of(:user_name) }
# it { is... |
require 'test_helper'
class Api::V1::RequestControllerTest < ActionDispatch::IntegrationTest
setup do
@request = requests(:one)
end
# index
test "should get index as json" do
get :index
assert_equal "application/json", response.content_type include()
end
test "should return success" do
as... |
# == Schema Information
#
# Table name: visits
#
# id :integer not null, primary key
# submitter_id :integer not null
# url_id :integer not null
#
class Visit < ActiveRecord::Base
def self.record_visit!(user, shortened_url)
Visit.create!(submitter_id: user.id, url_i... |
require 'nokogiri'
require 'open-uri'
namespace :cf_affiliates do
desc "Connect to .com and import the affiliate data"
task :scrape => :environment do
ScrapeLogger = Logger.new("#{Rails.root}/log/scrape.log")
url = "http://www.crossfit.com/cf-info/main_affil.htm"
doc = Nokogiri::HTML(open(url)... |
# frozen_string_literal: true
# user_intros.rb
# Author: William Woodruff
# ------------------------
# A Cinch plugin that provides custom intros for users for yossarian-bot.
# ------------------------
# This code is licensed by William Woodruff under the MIT License.
# http://opensource.org/licenses/MIT
requi... |
# Author: Jim Noble
# jimnoble@xjjz.co.uk
#
# Tournament.rb
#
# A Rock/Paper/Scissors tournament.
#
# Takes an array of ["Player", "Strategy"] arrays. The Array can be
# nested to an arbitrary depth. Array must contain all valid
# strategies, and contain n^2 players or a validation error will be
# thrown.
#
# a1 = [[[[... |
module Leaderboards
class Standout
include Enumerable
# l = Leaderboards::Standout.new(year: 2015, stage: 'regional', fictional: true)
# l.reject {|r| r[:event_num] == 3 && r[:division].in?(%w[men women]) }.first(10)
def initialize(tags)
@tags = tags
end
attr_reader :tags
def e... |
# == Schema Information
#
# Table name: home_slides
#
# id :integer not null, primary key
# image_uid :string(255)
# image_name :string(255)
# order :integer
# url :string(255)
# page_id :integer
# site_setting_id :integer
# created_at :datetime... |
require 'xcpretty'
require 'base64'
class BuildkiteFormatter < XCPretty::Simple
KSDIFF_MATCHER = /^ksdiff \"(.*)\"\s\"(.*)\"/
def pretty_format(text)
if KSDIFF_MATCHER.match(text)
if buildkite?
upload_artifacts($1, $2)
inline_artifacts($1, $2)
else
STDOUT.puts("\e[33mNot on... |
require_relative 'product'
require_relative 'county'
require_relative 'store'
# Instantiate the three counties so that we can later utilize them for their tax rates and their ids
miami_dade_county = County.new(1, "Miami-Dade", 0.06)
palm_beach_county = County.new(2, "Palm Beach", 0.08)
broward_county = County.new(3, "... |
class Contact < ApplicationRecord
belongs_to :user
has_many :connections, dependent: :destroy
accepts_nested_attributes_for :connections
validates :first_name, presence: true
validates :last_name, presence: true
validates :email, presence: true
def created_time
self.created_at.str... |
require 'rails_helper'
RSpec.describe Category, type: :model do
describe 'Validations' do
it { should validate_presence_of(:title) }
it { should validate_uniqueness_of(:title) }
end
describe 'Associations' do
it { should have_and_belong_to_many(:books) }
end
describe '.home_page_category' do
... |
module SchemaToScaffold
RSpec.describe CLI do
let(:empty_schema_file) { File.expand_path(File.dirname(__FILE__)) + '/support/empty_schema.rb' }
let(:schema_file) { File.expand_path(File.dirname(__FILE__)) + '/support/schema.rb' }
describe ".start" do
it "prints help message" do
expect {
... |
# frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::Webhooks::Plans::UpdateOperation, :stripe do
subject(:call) do
described_class.new.call(event)
end
let(:event) { StripeMock.mock_webhook_event('plan.updated') }
let(:plan_data) { event.data.object }
let!(:plan) { create(:stripe_plan, str... |
module GapIntelligence
class Download < Record
attributes :start_at, :end_at, class: Date
attribute :created_at, class: Time
attributes :categories, :countries, :category_versions, class: Array
attributes :report_types, :report_type_names, class: Array
attributes :brands, :printer_brands, :chann... |
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
@contact = Contact.new(article_params)
@contact.request = request
if @contact.save
if @contact.deliver
flash.now[:notice] = 'Thank you for your message. I will contact you soon!'
e... |
# -*- coding: utf-8 -*-
require "gettext"
module S7n
class S7nCli
# コマンドを表現する。
class Command
include GetText
# オプションの配列。
attr_reader :options
# 設定。
attr_reader :config
# World オブジェクト。
attr_reader :world
@@command_classes = {}
class << self
... |
class Store < ActiveRecord::Base
belongs_to :seller
has_many :products
end |
class Tree
attr_reader :root_node, :leaf
def initialize(root_node)
@root_node = root_node
end
def add_node(value)
node = @root_node
new_node = Node.new(value)
loop do
if check_value(node, new_node) && node.right
node = node.right
elsif ! check_value(node, new_node) && n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.