text stringlengths 10 2.61M |
|---|
class Author
attr_accessor :name
def self.create
author = self.new
end
end |
Rails.application.routes.draw do
devise_for :users
devise_scope :user do
get '/users/sign_out', to: 'devise/sessions#destroy', as: :signout
get '/users/registration', to: 'admin/registrations#new'
get '/users', to: 'admin/registrations#index'
post '/users/registration', to: 'admin/registrations#cr... |
require "spec_helper"
describe Amorail::Task do
before { mock_api }
describe "validations" do
it { should validate_presence_of(:element_id) }
it { should validate_presence_of(:element_type) }
it { should validate_inclusion_of(:element_type).in_range(1..2) }
it { should validate_presence_of(:text) ... |
require 'faker'
FactoryGirl.define do
factory :good do
md5_record_key {Faker::Number.unique.number(10)}
name {Faker::Food.unique.ingredient}
good_type_id 1
nutrition_id {Faker::Number.between(1, 100)}
inner_level {Faker::Number.positive}
min_level 10
max_level 12
measurement_unit 1
... |
# frozen_string_literal: true
require "kafka/compression"
module Kafka
# Compresses message sets using a specified codec.
#
# A message set is only compressed if its size meets the defined threshold.
#
# ## Instrumentation
#
# Whenever a message set is compressed, the notification
# `compress.compres... |
class FamilyMembersController < ApplicationController
before_action :load_application
def new
@family_member = @application.family_members.build
end
def create
@family_member = @application.family_members.create(family_member_params)
respond_to do |format|
if @family_member.save
fo... |
class AddAreaCorporateNameToProducers < ActiveRecord::Migration[5.2]
def change
add_column :producers, :area, :string, null: false, default: ""
add_column :producers, :corporate_name, :string, null: false, default: ""
end
end
|
module MItamae
class CLI
class Local
DEFAULT_OPTIONS = {
node_jsons: [],
node_yamls: [],
dry_run: false,
shell: '/bin/sh',
log_level: 'info',
}
def initialize(args)
@options = DEFAULT_OPTIONS.dup
@recipe_paths = parse_options(args)
... |
class RolenameFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
# Check to see if it has one character
unless value =~ /[a-z]/
object.errors[attribute] << (options[:message] || "must contain at least one letter.")
end
# Check to see if it only uses valid c... |
feature 'Viewing links' do
scenario 'I can filter links by tag' do
create_new_tagged_links
visit '/tags/bubbles'
expect(page.status_code).to eq(200)
within 'ul#links' do
expect(page).not_to have_content('Makers Academy')
expect(page).not_to have_content('Code.org')
... |
# frozen_string_literal: true
module Files
class Announcement
attr_reader :options, :attributes
def initialize(attributes = {}, options = {})
@attributes = attributes || {}
@options = options || {}
end
# string - Announcement body
def body
@attributes[:body]
end
# str... |
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
get 'project_report', :to => 'project_report#index' |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
#config.vm.define "base" do |machine|
# machine.vm.box = "ubuntu/xenial64"
# machine.vm.provision "ansible" do |ansible|
# ansible.playbook = "base-install.yml"
# end
#end
config.vm.define "web" do |machine|
machine.vm... |
class User < ActiveRecord::Base
attr_accessible :banner_image, :bio, :email, :name, :user_image, :password, :password_confirmation, :role
has_secure_password
before_validation :set_default_role
validates :name, presence: true
validates :email, presence: true, uniqueness: true
validates :bio, :length... |
namespace :url_shortener do
desc "Goes through the database and delete old records"
task :prune_urls, [:mins] => [:environment] do |t, args|
puts "Deleteing old record..."
ShortenedURL.prune(args[:mins].to_i)
end
end
# 0 0 1 3 * cd /home/f1nesse13/Documents/AppAcademy/projects/Rai... |
# encoding: UTF-8
require_relative 'settings'
module Creq
# All commands retrive nothing/info or exception
class ReqCommand
def self.call(id, title = '', template = nil)
title = id if title.empty?
body = ''
file_name = "#{Settings.src}/#{id}.md"
raise CreqCmdError, FIL... |
class EpisodeRenaming < ActiveRecord::Migration
def self.up
rename_column :episodes, :episode, :number
add_column :episodes, :unique_number, :string
end
def self.down
rename_column :episodes, :number, :episodes
remove_column :episodes, :unique_number, :string
end
end
|
require 'test_helper'
class AddOrderToShippingAddressesControllerTest < ActionDispatch::IntegrationTest
setup do
@add_order_to_shipping_address = add_order_to_shipping_addresses(:one)
end
test "should get index" do
get add_order_to_shipping_addresses_url
assert_response :success
end
test "shoul... |
# Create your haunted_houses migration here
class CreateHauntedHouses < ActiveRecord::Migration[4.2]
def change
create_table :haunted_houses do |cs|
cs.string :name
cs.string :location
cs.string :theme
cs.integer :price
cs.boolean :family_friendly
cs.datetime :opening_date
... |
require 'rspec'
require 'questions_database'
$FILEPATH = "./db/questions_test.db"
#Database initialized by import_db.sql - look there for appropriate values
describe "Reply" do
system("rm ./db/questions_test.db")
system("cat ./lib/import_db.sql | sqlite3 db/questions_test.db")
context "finding/creating replies... |
require 'sumac'
# make sure it exists
describe Sumac::Messages::Component::Boolean do
# should be a subclass of Base
example do
expect(Sumac::Messages::Component::Boolean < Sumac::Messages::Base).to be(true)
end
# ::from_object, #properties
example do
object = true
component = Sumac::Messages:... |
# Validates uris
# based on: https://github.com/nulib/next-generation-repository/wiki/URI-Construction-for-Controlled-Vocabularies
module Donut
class VocabularyValidationService
VOCABULARIES = [
%r{^http://vocab.getty.edu/ulan/[0-9]+/?$},
%r{^http://vocab.getty.edu/aat/[0-9]+/?$},
%r{^http://id.... |
# -*- coding: UTF-8 -*-
# ucore.rb
# 作者:王政
# 描述:utest 系统 核心单元
# 深圳市金溢科技股份有限公司版权所有, 保留一切权利
require "fiddle"
require "fiddle/import"
def utest_version
"1.4.3.0"
end
#################################### 可以使用的API #######################################################################
def get_bcc(bytes)
bcc = 0
... |
# frozen_string_literal: true
class AuthService::Context
attr_reader :identity, :metadata, :authorization
attr_reader :request, :service
def initialize(request, service)
@request = request
@service = service
@identity = {}
@metadata = {}
@authorization = {}
end
def evaluate!
proc = ... |
require 'spec_helper'
describe Client do
context "validation" do
subject { Client.new() }
it "requires a name" do
subject.save
subject.errors[:name].should_not be_nil
end
it "requires an email" do
subject.save
subject.errors[:email].should_not be_nil
end
it "requi... |
require 'rails_helper'
RSpec.describe FindAgent do
include ModelHelper
it 'Find Agent interactor exists' do
expect(class_exists?(FindAgent)).to eq(true)
end
it 'successful find' do
new_agent = create(:admin_creates_agent).as_json.symbolize_keys
result = FindAgent.call(response: {authenticated: tru... |
require 'test_helper'
class TodosControllerTest < ActionDispatch::IntegrationTest
def setup
@todo = todos(:orange)
end
test "should redirect create when not logged in" do
assert_no_difference 'Todo.count' do
post todos_path, params: { todo: { content: "Lorem ipsum" } }
end
assert_redirect... |
require 'fakerbot/commands/list'
RSpec.describe FakerBot::Commands::List do
let(:output) { StringIO.new }
let(:options) { {} }
let(:command) { FakerBot::Commands::List.new(options) }
before do
command.execute(output: output)
end
context 'when single `list` command' do
it 'executes successfully' d... |
require "rails_helper"
RSpec.shared_examples_for "paginable" do
let(:model) { described_class }
let!(:bucketlists) { create_list(:bucketlist, 10) }
context "when page 1" do
it "returns paginated records" do
results = model.paginate(page: 1, limit: 5)
expect(results.size).to eq(5)
expect(re... |
class CreateJoinTableCategoryProperty < ActiveRecord::Migration
def change
create_join_table :categories, :properties do |t|
t.integer :state, default: 0
# 0 == normal
# 1 == deleted
t.index :state
t.index [:category_id, :property_id]
t.index [:property_id, :category_id]
e... |
class ChangeColumnTypesForApplicants < ActiveRecord::Migration
def up
rename_column :applicants, :FirstStatus, :FirstStatus_string
rename_column :applicants, :PairingStatus, :PairingStatus_string
rename_column :applicants, :Result, :Result_string
add_column :applicants, :FirstStatus, :boolean
add_... |
#
# Spec helpers
#
# @author [nityamvakil]
#
module Helpers
def time_of_next(day)
time = Time.zone.parse(day)
delta = time > Time.zone.today ? 0 : 7
time + delta
end
end
|
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_photographer
def connect
self.current_photographer = find_current_user
end
def disconnect
end
protected
def find_current_user
if current_photographer =Photographer.fin... |
module Runs::Status
extend ActiveSupport::Concern
def ok?
status == 'ok'
end
def canceled?
status == 'canceled'
end
end
|
class AddMicrochipIndexToAnimals < ActiveRecord::Migration
def change
add_index :animals, :microchip_id
end
end
|
##
# ContentBase
#
# A set of definitions, collections, and utilities for
# content in the application.
#
module ContentBase
extend self
#--------------------
# Status definitions
STATUS_KILLED = -1
STATUS_DRAFT = 0
STATUS_REWORK = 1
STATUS_EDIT = 2
STATUS_PENDING = 3
STATUS_LIVE = 5
... |
pg_owner = input('pg_owner')
pg_group = input('pg_owner')
pg_ver = input('pg_version')
pg_data_dir = input('pg_data_dir')
pg_dba = input('pg_dba')
pg_dba_password = input('pg_dba_password')
pg_db = input('pg_db')
pg_host = input('pg_host')
pg_hba_conf_file = input('pg_hba_conf_file')
pg_ident_conf_file = inp... |
class CreateBoletos < ActiveRecord::Migration
def self.up
create_table :boletos do |t|
t.integer :empresa_id, :null => false
t.integer :organizacao_id, :null => false
t.string :banco, :null => false, :limit => 3
t.string :agencia
t.string :conta_corrente
t.string :con... |
class Vote < ActiveRecord::Base
# Always needs to belong to user
belongs_to :user
# Can only belong to ONE of the following
belongs_to :question
belongs_to :comment
belongs_to :post
belongs_to :research_topic
def self.popular_research_questions
res = Vote.select("questions.id as question_id, sum(... |
require 'test/unit'
require 'wsdl/soap/wsdl2ruby'
require 'soap/rpc/standaloneServer'
require 'soap/wsdlDriver'
if defined?(HTTPAccess2) and defined?(OpenSSL)
module WSDL; module RPC
class TestRPCLIT < Test::Unit::TestCase
class Server < ::SOAP::RPC::StandaloneServer
Namespace = "http://soapbuilders.org/rpc-l... |
require "./lib/Lesson 15 Caterpillar Method/CountDistinctSlices/count_distinct_slices"
describe 'CountDistinctSlices' do
describe 'Example Test' do
it 'Example' do
expect(count_distinct_slices(6,[3,4,5,5,2])).to eq 9
end
end
describe 'Correctness Tests' do
context 'Single' do
it 'Simple... |
require 'redis'
require 'json'
require 'sys/filesystem'
require 'fileutils'
module VCAP
module Services
module Serialization
end
end
end
class VCAP::Services::Serialization::Store
REQ_OPTS = %w(serialization_base_dir redis upload_token).map {|o| o.to_sym}
VALID_CREDENTIAL_CHARACTERS = ("A".."Z").to_a... |
class Todo < ActiveRecord::Base
validates_presence_of :text
end
|
require 'spec_helper'
require 'direct_execution_helper'
require 'httpclient'
require 'fileutils'
DEPLOYMENT_LIST_ITEM = /([0-2]?[0-9]:[0-5][0-9] (AM|PM), deployment [a-f0-9]{8})/
describe "rhc deployment scenarios" do
context "with an existing app" do
before(:all) do
standard_config
@app = has_an_ap... |
class Journey
DEFAULT_PENALTY_FARE = 6
attr_reader :fare, :entry_station, :exit_station
def initialize(entry_station = nil)
@complete = false
@fare = DEFAULT_PENALTY_FARE
@entry_station = entry_station
end
def finish(exit_station)
@complete = true
@fare = 1 if @entry_station
@exit_s... |
# frozen_string_literal: true
def random_string(length)
chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
str = ''
1.upto(length) { |_i| str += chars[rand(chars.size - 1)] }
str
end
def is_x64?
host_inventory['facter']['os']['architecture'] == 'x64'
end
|
require 'rails_helper'
RSpec.describe SystemsController, type: :controller do
let (:category) { create(:category) }
let (:systems) { create_list(:system, 3, category: category) }
let(:valid_attributes) do
{
category: category,
name: "new system!"
}
end
describe "GET index" do
it "a... |
module Accountable
module Users
module AccessibleHelpers
def accessible_ids(current_ability)
self.accessible_by(current_ability).map { |object| object.id}
end
end
end
end |
class RemoveExtraFieldsFromUser < ActiveRecord::Migration
def change
remove_column :users, :organization_title
remove_column :users, :description
remove_column :users, :phone_number
remove_column :users, :website_url
remove_column :users, :slug
remove_column :users, :city
end
end
|
# Copyright (c) 2016 Scott O'Hara, oharagroup.net
# frozen_string_literal: true
# Favourites controller
class FavouritesController < ApplicationController
before_action :context
def update
update_favourite true
end
def destroy
update_favourite false
end
def update_favourite(favourite)
@context.update_at... |
module StrokeDB
module StrokeObjects
module SlotHooks
include Declarations
# Sets inheritable get/set hooks on a slot.
#
# Example:
#
# class Person < Hash
# extend SlotHooks
#
# slot_hook :name do
# def get(doc, slotname)
# puts "Acc... |
class PostsByTagController < ApplicationController
def posts
tag = if params[:tag].match(/.json/)
params[:tag].split('.json').first
else
params[:tag]
end
respond_to do |format|
format.json {
@posts = Topic.find_by(tag: tag).posts.public_posts.uniq res... |
module Admin
class Mailer < ApplicationMailer
def new_member(membership_id:)
@membership = Membership.find_by(id: membership_id)
@member = @membership.user
@creator = @membership.creator
@team = @membership.team
@team_leader = @team.leader
subject = "You invited... |
class ChangeAdressToBeStringInProfiles < ActiveRecord::Migration[5.1]
def change
change_column :profiles, :adress, :string
end
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'static_pages#index'
post '/target', to: 'static_pages#target'
post '/return_error', to: 'static_pages#return_error'
get '/advance_ordering', to: 'static_pages#advan... |
require 'test_helper'
class TrafficsControllerTest < ActionController::TestCase
setup do
@traffic = traffics(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:traffics)
end
test "should get new" do
get :new
assert_response :success
en... |
module UspsZipZones
class ExceptionZone < ActiveRecord::Base
def self.by_zips!(origin_zip, destination_zip)
where('zip_from @> ? AND zip_to @> ?', origin_zip.to_i, destination_zip.to_i).last!
end
end
end
|
=begin
Write a Ruby method called: is_prime.
The function must take a number n and it
should return true or false whether the argument
passed (n) is a prime number or not.
A prime number is a number
that is divisible only by 1 and itself.
=end
def is_prime(n)
for x in 2..(n-1)
if (n % x == 0)
prime... |
class Cohort < ApplicationRecord
belongs_to :course
has_many :students
has_one :instructor
end |
class CreateReviews < ActiveRecord::Migration[6.0]
def change
create_table :reviews do |t|
t.integer :buyer_id
t.integer :product_id
t.integer :rating_id
t.string :description
end
end
end
|
require 'java'
java_import java.util.Arrays
java_import org.slf4j.LoggerFactory
java_import org.apache.kafka.clients.consumer.KafkaConsumer
java_import org.apache.kafka.clients.consumer.ConsumerConfig
java_import org.apache.kafka.clients.consumer.ConsumerRecord
java_import org.apache.kafka.clients.consumer.ConsumerRec... |
Rails.application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
root 'welcome#index', as: '/home'
get '/books/:id/admin', to: 'books#admin'
get '/books/all', to: 'books#all'
post 'favorites/new', to: 'favorites#new'
get '/favorites', to: 'favorit... |
require "spec_helper"
describe StudentDetailsController do
describe "routing" do
it "routes to #index" do
get("/student_details").should route_to("student_details#index")
end
it "routes to #new" do
get("/student_details/new").should route_to("student_details#new")
end
... |
class SubjectsController < ApplicationController
def show
@subject = Subject.find(params[:id])
@courses = @subject.courses.where(:session_id=>current_or_guest_user.session)
@instructors = @subject.instructors_by_count
end
def index
currentUser = current_or_guest_user
if(params[:currentSessio... |
# -*- encoding: utf-8 -*-
# stub: mime-types 2.99 ruby lib
Gem::Specification.new do |s|
s.name = "mime-types"
s.version = "2.99"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Austin Ziegler"]
s.date = "2015-... |
class ContactsController < ApplicationController
def index
@categories = Category.all.where(is_active: true).order('created_at ASC')
@contact = Contact.new
end
def create
contact = Contact.new(contact_params)
# if verify_recaptacha
if contact.save
admin = AdminUser.first
UserMailer.new_contact_mail(... |
class VideoResolutions
attr_reader :width, :height
def initialize(width, height)
@width = width
@height = height
end
def low
[width / 3, height / 3]
end
def medium
[width / 2, height / 2]
end
def high
[width, height]
end
def json
{
low: low,
medium: medium,
... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../guests.rb')
require_relative('../songs.rb')
require_relative('../rooms.rb')
class GuestsTest < MiniTest::Test
def setup
@song1 = Songs.new("Wuthering Heights")
@guest_a = Guests.new("Kathleen", 6, @song1)
@guest_b = Guests.new("Dor... |
class AddColumnToEstimate < ActiveRecord::Migration[5.0]
def change
add_column :estimates, :status, :string
end
end
|
require 'set'
# ElasticSearch
# require 'elasticsearch'
# Stretchie Core
require 'stretchie/version'
# Lets put our Stretchie::Pants on
require 'stretchie/pants'
# Defaults
module Stretchie
# Set containing all registered models
@@models = Set.new
# Add a model to the set
def self.add_model model
@@... |
require 'ipaddr'
module Puppet
newtype(:cloudstack_port_forwarding) do
@doc = "Manages a port forwarding rule in CloudStack:
cloudstack_port_forwarding{'rule_name':
ensure => 'present',
front_ip,
protocol,
privateport,
publicport,
virtual_machine,
vi... |
# frozen_string_literal: true
require_relative 'initializable'
class Wegift::Response
include Initializable
STATUS = { success: 'SUCCESS', error: 'ERROR' }.freeze
# Field Name Contents
#
# status - The status of the transaction. Usually “SUCCESS” or “ERROR”
# error_code - The error code, i.e. ... |
begin
require "right_aws"
rescue LoadError
puts "You need the RightScale AWS gem to use the S3 moneta store"
exit
end
module Moneta
# An S3 implementation of Moneta
#
# Example usage:
#
# require 'rubygems'
# require 'moneta'
# require 'moneta/s3'
#
# store = Moneta::S3.new(
# :... |
class DamageToken < ActiveRecord::Base
attr_accessible :fake, :game_id, :player_id, :value
belongs_to :game
belongs_to :player
validates :game, :value, presence: true
validates :value, inclusion: {in: [1, 2, 3]}
def self.setup_stack(game_id)
stack = []
[1,2,3].each do |value|
10.times do
... |
require_relative '../test_helper'
class ImageMagicianTest < Ojo::OjoTestCase
def setup
@image_magician = ::Ojo::ImageMagician.new
end
def test_get_color_values
raw = raw_string('1', '22', '303', '4044')
color_values = @image_magician.send(:get_color_values, raw)
assert_equal '1', color_valu... |
class Dog < ApplicationRecord
belongs_to :city
has_many :strolls
has_many :dogsisters, through: :stroll
end
|
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/cloudfiles_cli/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jacob Atzen", "Martin Neiiendam"]
gem.email = ["jacob@incremental.dk", "mn@lokalebasen.dk"]
gem.description = %q{Simple utility for uploading and downloadi... |
class Category < ActiveRecord::Base
has_and_belongs_to_many :retailers
belongs_to :gender
has_many :subcategories
end
|
class AddShippingChargeToCourseClasses < ActiveRecord::Migration
def change
add_column :course_classes, :shipping_charge, :decimal
end
end
|
require "spec_helper"
RSpec.describe Token do
before do
@user = User.create(
email: 'foo@bar.com',
first_name: 'Foo',
last_name: 'Bar',
password: 'foobar',
)
end
describe "#token=" do
it "should set encrypted token" do
token = Token.new
token.token = '12345678'
... |
module SearchHelper
def check_if_filled?(item)
item.present? && item.empty? == false
end
end
|
json.array!(@mascota) do |mascotum|
json.extract! mascotum, :id, :id_cliente, :nombre, :especie, :raza, :fecha_nacimiento
json.url mascotum_url(mascotum, format: :json)
end
|
require "rails_helper"
RSpec.describe "Accounts" do
let(:id) { create(:lender_cash_account).id }
it_behaves_like "a viewable resource", :accounts
# probably shouldn't allow creates, deletes or updates?
it { expect{post_json "/accounts"}.to raise_error ActionController::RoutingError }
it { expect{pu... |
class CreateEducatorStudentRelationships < ActiveRecord::Migration[5.2]
def change
create_table :educator_student_relationships do |t|
t.integer :student_id
t.integer :educator_id
t.timestamps
end
add_index :educator_student_relationships, [:student_id, :educator_id], name: "educator_s... |
FactoryGirl.define do
factory :user do
sequence(:name) { |n| "Sorcier #{n}" }
sequence(:email) { |n| "sorcier_#{n}@example.com"}
password "poudlard"
password_confirmation "poudlard"
birthday 1980-03-24
user_weight 90
ideal_weight 78.2
do_sport true
want_do_sport false
#user_cv "t... |
class UpdateColumnsInCeremonySongs < ActiveRecord::Migration
def change
remove_column :ceremony_songs, :song_id
add_column :ceremony_songs, :song_name, :string
add_column :ceremony_songs, :song_artist, :string
add_column :ceremony_songs, :additional_info, :text
end
end
|
require 'singleton'
module Roadblock
class Barricade
include Singleton
attr_accessor :barriers
def initialize(my_barriers=[])
self.barriers = my_barriers
end
def add_barrier(klass, &block)
barrier = Roadblock::Barrier.new(klass, &block)
barrier.instance_eval(&block)
sel... |
class Party < ApplicationRecord
has_many :invitations
has_many :users, through: :invitations
def hosted_parties(_host_id)
Party.where('host_id = ?', current_user.id) # TODO: Refactor to model
end
end
|
pg_ver = input('pg_version')
pg_dba = input('pg_dba')
pg_dba_password = input('pg_dba_password')
pg_db = input('pg_db')
pg_host = input('pg_host')
control "V-73047" do
title "PostgreSQL must maintain the authenticity of communications sessions
by guarding against man-in-the-middle attacks that guess at Session... |
#
# lolcat (c)2011 moe@busyloop.net
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is a... |
class Assets::OptionsSerializer < ApplicationSerializer
object_as :asset
attributes(
:name,
)
end
|
require 'Station'
describe Station do
it 'will allow you to make a name on initialization' do
station = Station.new(:bank, 2)
expect(station.name).to eq :bank
end
it 'will allow you to make a zone on initialization' do
station = Station.new(:bank, 2)
expect(station.zone).to eq 2
end
end
|
class Users::RegistrationsController < Devise::RegistrationsController
#allows us to run our code before anything in controller runs
before_filter :select_plan, only: :new
def create
super do |resource| #importing create action code from Devise
if params[:plan] # sees if there ... |
module Apress
module Videos
class OembedValidator < ActiveModel::EachValidator
FIELDS = %w(html thumbnail_url provider_name).freeze
def validate_each(record, attribute, value)
absend_fields = FIELDS.select { |f| value[f].blank? }
if absend_fields.present?
message = options.... |
require 'spec_helper'
describe Susanoo::Exports::PageCreator do
before do
Page.any_instance.stub(:begin_event_date)
end
describe "メソッド" do
before do
allow_any_instance_of(Susanoo::Exports::Creator::Base).to receive(:rsync)
end
describe "#initialize" do
context "ディレクトリのルートが引数で渡された場合"... |
require 'rubygems'
require 'json'
require 'fileutils'
require_relative 'observer'
require_relative 'ai'
# Match handles the main game logic.
module Pingpong
class Match
attr_reader :game_running
def initialize(player_name, listener)
@player_name = player_name
@listener = listener
@wins =... |
class GamesController < ApplicationController
before_filter :load_game, :only => [:show, :edit, :update, :destroy, :split]
before_filter :require_admin, :only => [:edit, :update, :destroy]
def index
@games = Game.paginate :page => params[:page], :order => 'title'
end
def show
@ports = @game.port... |
require 'spec_helper'
describe CasePermission do
describe "#can_read?" do
before(:each) do
@law_case = build(:law_case)
end
it "should return true if the permission is full_access and the target is the given case" do
case_permission = build(:case_permission, target: @law_case, access: :full... |
# coding: utf-8
module SeoAttachment
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def seo_attachment(options = {})
before_create :interpolates_file_names
before_update :interpolates_file_names
Paperclip.interpolates :normally_file_name do |data, style|
... |
class CatagoriesController < ApplicationController
before_action :access_controll, except: [:show]
def show
@catagory = Catagory.find(params[:id])
@plans = @catagory.plans
end
def index
@catagories = Catagory.all
@settings = [
Setting.where(name: 'Site introduction', identifier: 'site_int... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.