text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe 'photos/show', type: :view do
let!(:photo) { create :photo, caption: 'totally caption', description: 'lookit' }
before(:each) do
assign(:photo, photo)
end
it 'renders metadata' do
render
expect(rendered).to match(/totally caption/)
expect(rendered).to matc... |
=begin
Include Battle Events from another Troop
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
No requirements
Allows you to include all the battle events from a troop
in all the other troops.
----------------------
Instructions
----------------------
Choose which troop you wish to have t... |
require 'planet/config'
require 'html5/tokenizer'
class PlanetFormatter
def process( stylesheet, feed )
raise 'Abstract method called'
end
def plain(value)
#TODO add HTML stripper
tokenizer = HTML5::HTMLTokenizer.new(value)
line = ""
tokenizer.each { |t|
# puts "PLAIN: token, type=#{t... |
FactoryBot.define do
factory :recipe, class: 'Recipe' do
sequence(:name) { |n| "Recipe#{n}" }
description { 'Sub Recipe' }
unit_price { 10.0 }
association :company, factory: :company
after(:create) do |recipe|
recipe.ingredients << FactoryBot.create(:ingredient)
end
end
end
|
class ChangeTextTypeToExhibitions < ActiveRecord::Migration
def up
change_column :exhibitions, :description, :text, :limit => 4294967295
end
def down
change_column :exhibitions, :description, :text, :limit => 65535
end
end
|
require 'spec_helper'
describe User do
let :user do
Factory(:user)
end
it "has a reference to twitter accounts" do
user.twitter_accounts.count.should == 0
end
it "returns the correct number of twitter accounts" do
TwitterAccount.create!(
:handle => "test",
:access_token => "asdf"... |
include_recipe 'yum-gd'
package 'ffmpeg' do
version node['ffmpeg']['package']['version']
action :install
not_if node['ffmpeg']['package']['devel_only']
end
package 'ffmpeg-devel' do
version node['ffmpeg']['package']['version']
action :install
not_if node['ffmpeg']['package']['install_devel']
end
|
require 'rails_helper'
RSpec.describe StaticPagesController, type: :request do
describe "homeの機能テスト" do
before do
get root_path
end
it "/に正常にアクセスできる" do
expect(response).to have_http_status(:ok)
end
end
end
|
class Employee < ApplicationRecord
has_one_attached :image
belongs_to :salary_type
belongs_to :department
has_many :departments
has_many :attendances
has_many :day_types
has_many :leaves
has_many :salaries
end
|
class PlacementException < Exception
def initialize(*args)
case args.size
when 1
super "Direction #{args.first} not recognized"
when 2
super "Invalid coordinates cardinality given=#{args.first}, playground=#{args.last}"
when 3
super "Placement coordinates not valid: give... |
namespace :trigrams do
task :extract_most_frequent_trigrams do
limit = 300
SUPPORTED_LANGUAGES.each do |language|
trigrams = Hash.new(0)
Dir.entries("#{File.dirname(__FILE__)}/../../data/wiki_#{language}").each do |dirname|
if dirname[0] != "."
Dir.entries("#{File.dirname(__F... |
class Sport < ApplicationRecord
validates :part, presence: true
validates :weight, presence: true
validates :times, presence: true
validates :exercise, presence: true
validates :time, presence: true
validates :distance, presence: true
validates :body_weight, presence: true
belongs_to :user
has_... |
class AddMultipierColumnToDraws < ActiveRecord::Migration
def change
add_column :draws, :multiplier, :integer
end
end
|
ActiveAdmin.register Patient do
menu :priority => 2, label: proc{ t("active_admin.patients")}
permit_params :first_name, :middle_name, :last_name, :birthday, :gender, :status, :location_id
config.filters = false
config.clear_action_items!
scope proc{ I18n.t("active_admin.patient.published")}, :published, :defaul... |
class Dwelling < ActiveRecord::Base
belongs_to :vendor
has_many :applications
has_many :users, through: :applications
end |
# frozen_string_literal: true
# Configuration for payable models
module Concerns
module Payment
module ModelConfigs
extend ActiveSupport::Concern
def purchase_info
case parent_type
when 'Registration'
registration_info
when 'MemberApplication'
member_appli... |
class User < ActiveRecord::Base
has_paper_trail class_name: "C2Version"
validates :client_slug, inclusion: {
in: ->(_) { Proposal.client_slugs },
message: "'%{value}' is not in Proposal.client_slugs #{Proposal.client_slugs.inspect}",
allow_blank: true
}
validates :email_address, presence: true, uni... |
class AddNomProfilToAuteur < ActiveRecord::Migration[6.0]
def change
add_column :auteurs, :nom, :string
add_column :auteurs, :profil, :string
end
end
|
# frozen_string_literal: true
class MemberApplicant < ApplicationRecord
belongs_to :member_application
validates :member_type, :first_name, :last_name, :email, presence: true
validates :address_1, :city, :state, :zip, presence: { if: :primary }
validates :email, uniqueness: true
validate :at_least_one_phon... |
class Match < ApplicationRecord
belongs_to :home_team, class_name: 'Team'
belongs_to :away_team, class_name: 'Team'
has_many :innings, dependent: :destroy
has_many :bat_innings, through: :innings, dependent: :destroy
has_many :bowl_innings, through: :innings, dependent: :destroy
has_many :extras, through: ... |
require 'find'
require 'omf_base/lobject'
require 'omf_web'
require 'omf-web/content/content_proxy'
require 'omf-web/content/repository'
require 'irods4r'
module OMF::Web
# This class provides an interface to a directory based repository
# It retrieves, archives and versions content.
#
class IRodsContentRepo... |
class Invoice < ActiveRecord::Base
belongs_to :customer
has_many :consultants, through: :invoice_items
has_many :invoice_items
accepts_nested_attributes_for :invoice_items, reject_if: :all_blank, allow_destroy: true
attr_accessible :customer_id, :desc, :discount, :due_date, :invoice_date, :paid_date, :short_... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
require 'rails_helper'
RSpec.describe "index page", type: :feature do
before :each do
@user = create(:user)
Event.create(user_id: 1,
is_reviewed: true,
title: "5k christmas charity run",
datetime: DateTime.iso8601('2100-12-25T04:05:06-05:00'), # require 'date... |
# == Schema Information
#
# Table name: diaper_drives
#
# id :bigint not null, primary key
# end_date :date
# name :string
# start_date :date
# created_at :datetime not null
# updated_at :datetime not null
# organization_id :bigint
#
requir... |
class WritenDocumentPhoto < ActiveRecord::Base
belongs_to :writen_document
belongs_to :photo
attr_accessor :association_should_exist
end
|
require_relative "test_helper"
require "date"
class TestMoves < Minitest::Test
def setup
@client = Moves::Client.new(ENV["ACCESS_TOKEN"])
@today = Time.now.strftime("%Y-%m-%d")
@day = "2014-01-01"
@week = "2014-W1"
@month = "2014-01"
@from_to = {:from => "2014-01-01", :to => "2014-01-07"}
... |
require 'rails_helper'
RSpec.describe SubscribersController, regressor: true do
# === Routes (REST) ===
it { should route(:post, '/subscribers/new').to('subscribers#create', {}) }
it { should route(:get, '/subscribers/activate/1').to('subscribers#activate', {:activation_key=>"1"}) }
it { should route(:get, '/... |
# == Schema Information
#
# Table name: follows
#
# id :bigint not null, primary key
# follower_id :integer
# creator_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Follow < ApplicationRecord
validates :creator_id, uniqueness: { scope:... |
# encoding: utf-8
class User
include DataMapper::Resource
property :id, Serial
property :name, String
property :email, String
property :avatar, String # path to avatar image
property :reward, Text
property :reminder, Date
property :repeat, Enum[:none, :da... |
#! /usr/bin/ruby
# Script that enters Hastings.se and creates a game and changes some options
require 'watir-webdriver'
require 'headless'
module GameTest
def create_game browser
browser.button(id: 'create-game-btn').wait_until_present
browser.button(id: 'create-game-btn').click
browser.text_field(id: ... |
#
# This class contains the data needed to perform a refresh. The data are the collections of nodes, virtual machines and
# templates retrieved using the KubeVirt API.
#
# Note that unlike other typical collectors it doesn't really retrieve that data itself: the refresh worker will create
# with the data that it alread... |
require 'test_helper'
module Account
class UserTest < ActiveSupport::TestCase
def setup
@user = User.create(email: 'sgriessner@fh-salzburg.ac.at', encrypted_password: '12345678', first_name: 'Stephan', last_name: 'Griessner')
end
def teardown
User.destroy_all
end
test "must give ful... |
class Race < ActiveRecord::Base
def done?
due_date > Date.today
end
end
|
ActiveAdmin.register Profile do
permit_params :username,
:first_name,
:last_name,
:age,
:city_from,
:gender,
:detailed_description,
:short_description,
:profile_type,
:phone_number,
:country_from,
:user_id
end
|
class Message < ApplicationRecord
include PublicActivity::Common
belongs_to :conversation
belongs_to :user
# belongs_to :sender, class_name: :User, foreign_key: 'sender_id'
validates_presence_of :body
# after_create_commit { MessageBroadcastJob.perform_later(self) }
end
|
class FontUdevGothicNf < Formula
version "1.1.0"
sha256 "13763a5d7d0cf2a025740b910820933af745a1734baf730c910fad82ffa85178"
url "https://github.com/yuru7/udev-gothic/releases/download/v#{version}/UDEVGothic_NF_v#{version}.zip"
desc "UDEV Gothic NF"
desc "Integrate fonts from BIZ UD Gothic and JetBrains Mono"
... |
module SupplyTeachers
class BranchSearchResult
attr_reader :id
attr_reader :supplier_name
attr_reader :name
attr_reader :contact_name
attr_reader :telephone_number
attr_reader :contact_email
attr_reader :slug
attr_accessor :rate
attr_accessor :distance
attr_accessor :daily_rate... |
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :username, :null => false
t.string :password
t.string :apikey
t.string :fullname
t.string :email
t.string :group
t.boolean :sysadmin
t.timestamps
end
add_index :... |
control "M-5.21" do
title "5.21 Ensure the default seccomp profile is not Disabled (Scored)"
desc "
Seccomp filtering provides a means for a process to specify a filter for
incoming system
calls. The default Docker seccomp profile works on whitelist basis and
allows 311 system
calls blocking all others... |
class Post < ApplicationRecord
validates_presence_of :title, :body, :category_id
belongs_to :category
end
|
# 08.01.2020
# Unit 3 Exercise 2
# Q2
# Write a program that plays duck duck goose.
# Allow the user to enter the player's number
# they want to call goose on, and then say "duck"
# for each player before the "goose", then say
# "goose" for the chosen player.
puts "Which player do you want to be the Goose? Please just... |
# -*- encoding: utf-8 -*-
require 'nokogiri'
require 'open-uri'
module SeoParams
class Yahoo
def initialize(url)
@url = url
@response = Nokogiri::HTML(open("http://search.yahoo.com/search?p=site:#{url}"))
end
def yahoo_pages
index = @response.xpath("//span[@id='resultCount']").first.... |
require 'test_helper'
class EntryItemLinesControllerTest < ActionController::TestCase
setup do
@entry_item_line = entry_item_lines(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:entry_item_lines)
end
test "should get new" do
get :new
... |
require "spec_helper"
describe Comment do
subject(:comment){ FactoryGirl.build(:anonymous_comment) }
let(:user){ FactoryGirl.build(:user) }
context "given an email and name" do
before {
comment.email = "hello@sample.com"
comment.name = "Hello Sample"
}
it{ should be_valid }
it... |
class AddCnameAndEnameToMedicinePrescriptExternals < ActiveRecord::Migration[5.0]
def change
add_column :medicine_prescript_externals, :cname, :string
add_column :medicine_prescript_externals, :ename, :string
end
end
|
class School
attr_reader :start_time,
:hours_in_school_day,
:student_names,
:standard_student_names
def initialize(start_time, hours_in_school_day)
@start_time = start_time
@hours_in_school_day = hours_in_school_day
@student_names = []
@standard_student_nam... |
require 'json'
require 'stringio'
module Hatchet
class AnvilApp < App
def initialize(directory, options = {})
@buildpack = options[:buildpack]
@buildpack ||= File.expand_path('.')
super
end
def push_without_retry!
out, err = wrap_stdout_and_rescue(Anvil::Builder::BuildError) do
... |
module SessionsHelper
# Logs in the given user.
def log_in(user)
session[:user_id] = user.id
end
# Returns true if the given user is the current user
def current_user?(user)
user == current_user
end
# Returns the current Logged-in user (if any).
def current_user
@current_user ||= User.fin... |
class Comment < ApplicationRecord
belongs_to :idea
belongs_to :user, optional: true
end
|
class AddMinMaxTimeToRepetition < ActiveRecord::Migration
def change
add_column :repetition_schemes, :min_time_slot_duration, :integer
add_column :repetition_schemes, :max_time_slot_duration, :integer
end
end
|
class Vote < ApplicationRecord
belongs_to :participant
belongs_to :selected_restaurant
end
|
class TheaterDates
def self.week(weeks_from_now = 0)
first = weeks_from_now.week.from_now.beginning_of_week(:wednesday)
last = weeks_from_now.week.from_now.end_of_week(:wednesday)
first..last
end
end
|
class CreateResourceHistories < ActiveRecord::Migration
def change
create_table :resource_histories do |t|
t.string :historable_type
t.integer :historable_id
t.string :action_type
t.string :new_status
t.string :last_status
t.references :user, index: true
t.hstore :user_da... |
class CreateFileUploads < ActiveRecord::Migration
def change
create_table :file_uploads do |t|
t.belongs_to :user, null: false
t.string :originalname, null: false
t.string :filename, null: false
t.integer :size, null: false
t.string :sha1_hash, null: false
t.string :file, null:... |
require 'spec_helper'
describe "Contact pages" do
subject { page }
describe "send message" do
before { visit contact_path }
it { should have_heading('Contact') }
it { should have_title(full_title('Contact')) }
let(:submit) { "Send" }
describe "with invalid information" do
it "sho... |
require 'test/unit'
require 'xmlmunger'
class NestedHashTest < Test::Unit::TestCase
def nested_hash
::XMLMunger::NestedHash[a: {b: 1}, c: { d: {e: 2} }]
end
def test_transform_nested_hash
nested_hash2 = nested_hash.transform { |value| value + 1 }
assert_equal nested_hash2[:a][:b], 2
assert_equ... |
module Trie
class Node
attr_reader :value
attr_reader :children
attr_accessor :visited
# The node of the tree.
# Each node has one character as its member.
def initialize(value_)
@value = value_
@children = []
@visited = false
... |
class GuestbooksController < ApplicationController
before_action :require_login, :only => [:admin, :create, :update, :destroy, :set_default, :toggle_visibility, :archive, :export]
before_action :set_guestbook, only: [:show, :edit, :update, :destroy]
skip_before_action :verify_authenticity_token
layout 'admin', ... |
require 'byebug'
class PhysicalDefence
attr_accessor :user, :modified_defence
def initialize(user)
@user = user
@modified_defence = 0
end
def perform(attack_power)
@modified_defence = final_defence_power
damage_user(attack_power)
end
def defence_modifier
{
defence_power: [
... |
class Question < ActiveRecord::Base
belongs_to :survey
has_many :responses
validates :text, presence: true
validates :survey_id, presence: true
end
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'stringify/version'
Gem::Specification.new do |spec|
spec.name = "stringer"
spec.version = Stringer::VERSION
spec.authors = ["rommelniebres"]
spec.email = ["rom... |
require 'spec_helper'
describe "Config Variables" do
describe "STRIPE_API_KEY" do
it "should be set" do
Stripe.api_key.should_not eq("Your_Stripe_API_key"),
"Your STRIPE_API_KEY is not set, Please refer to the 'Configure the Stripe Initializer' section of the README"
end
end
describe "S... |
# Encoding: UTF-8
require_relative '../spec_helper'
describe 'duo-openvpn::app' do
describe package('duo-openvpn') do
it 'is installed' do
expect(subject).to be_installed
end
end
%w(
/usr/lib/openvpn/plugins/duo/ca_certs.pem
/usr/lib/openvpn/plugins/duo/https_wrapper.py
/usr/lib/openv... |
class RemovePictureFromMatchMap < ActiveRecord::Migration
def up
remove_column :match_maps, :picture
end
def down
add_column :match_maps, :picture, :string
end
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
namespace :v1 do
get "/contacts" => "contacts_list#index"
post "/contacts" => "contacts_list#create"
get "/contacts/:id" => "contacts_list#show"
patch "/contacts/:id"... |
require 'rails_helper'
describe Hospital, type: :model do
describe "relationships" do
it { should have_many :doctors }
end
describe "instance methods" do
before :each do
@grey_sloan = Hospital.create!(
name: "Grey Sloan Memorial Hospital"
)
@dr_grey = Doctor.create!(
na... |
class Entry < ApplicationRecord
belongs_to :pool
has_many :picks, dependent: :destroy
has_many :contestants, through: :picks
validates :pool, :name, presence: true
def points
contestants.map(&:points).sum
end
end
|
#
# Doctrine database creation.
#
node[:deploy].each do |application, deploy|
script "create_db" do
interpreter "bash"
user "root"
cwd "#{deploy[:deploy_to]}/current"
code <<-EOH
php app/console doctrine:database:create --if-not-exists --env="#{node[:symfony][:environment]}"
EOH
end
end
|
class CreateAppointments < ActiveRecord::Migration
def change
create_table :appointments do |t|
t.string :state
t.time :start_time
t.bool :interconsulta
t.int :patient
t.references :program, index: true, foreign_key: true
t.timestamps null: false
end
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Formatters
module Rbnf
Substitution = Struct.new(:type, :contents, :length) do
def description
@description ||= contents.map(&:value).join
end
def rule... |
# frozen_string_literal: true
require 'pathname'
SPEC_ROOT = Pathname(__dir__).realpath.freeze
if ENV['SIMPLECOV']
require 'simplecov'
SimpleCov.start do
enable_coverage :branch
primary_coverage :branch
add_filter %r{^/spec/}
add_group 'Admin', 'slices/admin'
add_group 'Reporting', 'slices/rep... |
# this is the version of the redis-compactor task that we used to
# shrink the rank database. this repo will have some unique challenges,
# like the fact that peter wants the ability to query the db for averages in
# specific date windows (probably ruling out the partition-by-month strategy).
# but for the most part, i... |
require 'rails_helper'
RSpec.describe PagesController, type: :controller do
it { should route(:get, '/').to(action: :home) }
describe 'GET #show' do
# Set up
let(:user) { create(:user) }
let!(:tweet_listings) { create_list(:tweet, 3, user: user) }
# Preparation
before { get :show }
# Assertion
it ... |
class Province < ApplicationRecord
belongs_to :country
has_many :cities
has_many :distributor_allocations
def self.can_check_distributor(distributor_allocations)
puts "Do you want to search by Province [Y/N]"
option = gets.chomp
case option
when "y"
puts "Enter the Province name : "
... |
class User < ActiveRecord::Base
has_many :sender_cookie_batches, class_name: "CookieBatch", foreign_key: "sender_id"
has_many :recipient_cookie_batches, class_name: "CookieBatch", foreign_key: "recipient_id"
end
|
class Ctpp2NginxModule < Formula
desc "Embeds virtual template engine CT++ in the nginx"
homepage "http://ngx-ctpp.vbart.ru/"
url "http://dl.vbart.ru/ngx-ctpp/ngx_ctpp2-0.5.tar.gz"
sha256 "f8adfecc23e2c23af95df8549ef92fd52598b21506a9d9df2278b2605668d5a6"
head "svn://svn.vbart.ru/ngx_ctpp2/trunk"
bottle :un... |
class ReviseAttributesForWorks < ActiveRecord::Migration[5.2]
def change
remove_column :works, :username
end
end
|
ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation, :avatar, :avatar_url
jcropable
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :cur... |
# my_app1.rb
#
require 'sinatra'
get '/' do
"Hello from Sinatra!!"
end
post '/login' do
usrname = params[:usrname]
passwd = params[:passwd]
if usrname == 'Deepak' and passwd == 'passwd'
"Hey!! you are Authenticated."
else
"Authentication failed."
end
end
|
class AddAnnotatedAtToAnnotations < ActiveRecord::Migration
def change
add_column :annotations, :annotated_at, :datetime, default: nil, after: :end_location
end
end
|
## some source files are meant to be loaded while others are meant to be executed as a program (script)
## we invoke the file by typing ./script.rb if file name is script.rb
## we must add this line that tells the "shell" (bash or zsh) to use the Ruby interpreter to run the code
# !/usr/bin/env ruby
## if it was #!/u... |
class Myserif < ApplicationRecord
belongs_to :user
validates :content, presence: true, length: { maximum: 255 }
validates :title, presence: true, length: { maximum: 50 }
validates :character, length: { maximum: 100 }
validates :genre, presence: true
has_many :genres
has_many :favorites, dependent... |
class Item < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :category
belongs_to_active_hash :delivery
belongs_to_active_hash :status
belongs_to_active_hash :city
belongs_to_active_hash :days
has_one_attached :image
belongs_to :user
has_one :buy
has... |
# frozen_string_literal: true
require_relative 'spec_helper'
RSpec.describe PaypalClient::Client do
let(:sandbox) { true }
let(:stubs) { nil }
let(:cache) { ActiveSupport::Cache::MemoryStore.new }
let(:params) do
{
client_id: 'client_id',
client_secret: 'client_secret',
cache: cache,
... |
class ReceiptMailer < ApplicationMailer
# default from: 'notifications@example.com'
def receipt_email(order)
@order = order
mail(to: @order.email, subject: "Your order receipt for #{@order.id}")
end
end
|
class CreateUniversalApiProfiles < ActiveRecord::Migration
def change
create_table :universal_api_profiles do |t|
t.string :login
t.string :password
t.string :target_branch
t.string :provider
t.string :endpoint
t.boolean :current
t.timestamps
end
end
end
|
#
# @author Kristian Mandrup
#
# Base module for Single role strategies
#
module Trole::Strategy
module BaseOne
#
# a Many role strategy is included by a role subject (fx a UserAccount class)
# a Many role strategy should always include BaseMany
# when BaseMany is included, it ensures that the comple... |
################################################################################
require('minitest/autorun')
################################################################################
class MatchLabTest < MiniTest::Unit::TestCase
##############################################################################
... |
module Roglew
module WGL
ACCELERATION_ARB ||= 0x2003
ACCUM_ALPHA_BITS_ARB ||= 0x2021
ACCUM_BITS_ARB ||= 0x201D
ACCUM_BLUE_BITS_ARB ||= 0x2020
ACCUM_GREEN_BITS_ARB ||= 0x201F
ACCUM_RED_BITS_ARB ||= 0x201E
ALPHA_BITS_ARB ||=... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Resources
module Requirements
class DependencyRequirement
attr_reader :importer_classes
def initialize(importer_classes)
@importer_classes = importer_classes
... |
class Bear
attr_reader :name
attr_accessor :stomach
def initialize(name, stomach)
@name = name
@stomach = stomach
end
def get_fish(fish)
@stomach.push(fish)
end
def bear_roar()
return "RROOOOOAAARRRRRR"
end
# def food_count()
# @fish.count... |
class Api::V1::BaseController < ::ApplicationController
append_view_path File.expand_path("#{Rails.root}/app/views/api/v1")
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
private
def record_not_found
respond_to do |format|
format.json { render json: { message: 'Record not found' ... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class Cask::Artifact::Colorpicker < Cask::Artifact::Base
def self.me?(cask)
cask.artifacts[:colorpicker].any?
end
def install
@cask.artifacts[:colorpicker].each { |colorpicker| link(colorpicker) }
end
def uninstall
@cask.artifacts[:colorpicker].each { |colorpicker| unlink(colorpicker) }
end
... |
################################ UNDERSTANDING 2D ARRAYS ################################
# notes using this post as reference: http://www.dotnetperls.com/2d-array-ruby
#####Ruby program that uses 2D array
# This 2D array contains two sub-arrays
values = Array[[10, 20, 30], [40, 50, 60]]
values.each do |x| # ... |
require 'diary'
describe Diary do
describe '.all' do
it 'shows all diary entry titles' do
expect(Diary.all).to include('Diary entry 1')
end
end
end |
class LargePost < ActiveRecord::Base
belongs_to :club
belongs_to :user
attr_protected :id,
:club_id,
:user_id,
:created_at,
:updated_at
minLimit = 2.freeze
maxLimit = 100.freeze
validates_length_of :title,
... |
# code here!
class School
attr_reader :name, :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(name, grade)
@roster[grade] ||= []
@roster[grade] << name
end
def grade(number)
@roster[number]
end
def sort
@roste... |
require File.dirname(__FILE__) + '/../test_helper'
class OldNodeTest < ActiveSupport::TestCase
api_fixtures
def test_old_node_tag_count
assert_equal 9, OldNodeTag.count, "Unexpected number of fixtures loaded."
end
def test_length_key_valid
key = "k"
(0..255).each do |i|
tag = OldNodeTag.n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.