text stringlengths 10 2.61M |
|---|
require 'test_helper'
class RecipesControllerTest < ActionDispatch::IntegrationTest
setup do
@recipe = recipes(:one)
end
test "should get index" do
user = User.find(1)
get recipes_url(as: user)
assert_response :success
assert_match "Sign Out", response.body
end
test "should get new" do
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos64_ja"
config.vm.box_url = "https://dl.dropboxusercontent.com/u/3657281/centos64_ja.... |
# encoding: UTF-8
module CDI
module V1
module ChatMessages
class BatchCreateService < BaseActionService
action_name :batch_chat_message_create
attr_reader :chat_messages
def initialize(user, options={})
@user = user
super(options)
end
def exec... |
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def update_password
@user = User.find_by(authentication_token: params["user_token"])
password = params["password"]
password_confirmation = params["password_confirmation"]
if @user.provider == "faceboo... |
# encoding: utf-8
module Libgeo
class Coordinate
module Presenters
##
# Represent coordinate as float
#
# Returns: {Float} decimal coordinate
#
def to_f
(negative_hemisphere? ? -1 : 1) * (degrees + minutes_only.to_d / 60).to_f
end
##
# Represent coo... |
class LineEdit
def initialize
@text_left = ''
@text_right = ''
end
attr_reader :text_left, :text_right
def text
@text_left + @text_right
end
def insert(text)
raise TypeError unless text.kind_of?(String)
text.unpack('U*') # ensure its valid UTF-8
@text_left += text
end
def erase_left
m = @text_lef... |
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
def test_new
get :new
assert_template 'new'
end
def test_create_invalid
Restaurant.stubs(:authenticate).returns(nil)
post :create
assert_template 'new'
assert_nil session['restaurant_id']
end
def tes... |
class Dungeon
attr_accessor :player
def initialize(player_name)
@player = Player.new(player_name)
@rooms = []
end
def add_room(reference, name, description, connections)
@rooms << Room.new(reference, name, description, connections)
end
def start(location)
@player. location = location
show_current_description
end
def s... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= Employee.new
case user.department_id
when 1 # Management
can :manage, :all
when 2
can :manage, [Client, Proposal, Invoice] ... |
class Author < ActiveRecord::Base
validates :name, :phone_number, presence: true
validates :name, :phone_number, uniqueness: true
validates :phone_number,length: { is: 10 }
end
|
#require 'sinatra'
#set :run, true
#set :static, true
#set :public_folder, ARGV[1] || Dir.pwd
#get '/' do
# redirect 'index.html'
#end
require 'fileutils'
require 'tmpdir'
require 'optparse'
require 'rack'
require 'rack/server'
require 'rack/handler'
require 'rack/builder'
require 'rack/directory'
require 'rack/fi... |
class User < ApplicationRecord
include BCrypt
validates :email, presence: true, uniqueness: true
validate :password_validator
def password_validator
self.errors.add :base, "Password should be reverse of email" unless password == email.reverse
end
def password
@password ||= Password.new(password_di... |
class IdeasController < ApplicationController
before_filter :authenticate_user!
def index
@ideas = current_user.ideas
@publicIdeas = Idea.where("user_id != ?", current_user.id)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @ideas }
end
end
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<-SCRIPT
cat <<EOF > /etc/apt/apt.conf.d/01acng
Acquire::http {
Proxy-Auto-Detect "/vagrant/detect-proxy.sh";
};
EOF
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
config.vm.provision "shell", path: "provis... |
require 'hand'
describe Hand do
let(:deck) { Deck.new}
before(:each) {deck.fill_deck}
let(:hand) do
Hand.new(deck)
end
describe "Hand#initialize" do
it "should initialize to an empty hand" do
expect(hand.cards.size).to eq(0)
end
end
describe "Hand#take_cards" do
it "Should take... |
class Admin < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
validates :name, presence: true
validates :password,... |
class Student
attr_reader :name
@@students = []
def initialize(name)
@name = name
@@students << self
end
def add_boating_test(boating_test, boating_status, instructor)
BoatingTest.new(self, boating_test, boating_status, instructor)
end
def self.find_student(first... |
=begin
#===============================================================================
Title: Execution States
Author: Hime
Date: Jul 10, 2015
--------------------------------------------------------------------------------
** Change log
May 30, 2015
- fixed bug with note-tag
Jul 10, 2014
- Execution state... |
require 'flowster/registerable'
module Flowster
class Precondition < RegisterableObject
end
class Preconditions
include Registerable
def pass?(workflowable, *args, &block)
preconditions.all? do |precondition|
precondition.passes?(workflowable, *args)
end
end
end
end
|
module ShopifyImport
module Creators
class TaxonCreator < BaseCreator
def save!
Spree::Taxon.transaction do
@spree_taxon = create_spree_taxon
add_products
assign_spree_taxon_to_data_feed
end
end
private
def create_spree_taxon
Spree::T... |
require "#{Rails.root}/db/chores/populator"
describe Populator do
before(:all) { DatabaseCleaner.strategy = :truncation }
after(:all) { DatabaseCleaner.strategy = :transaction }
describe '#random_ncr_data' do
it "creates the specified number of work orders" do
num_proposals = 5
expect do
... |
require 'rails_helper'
describe FuelStationService do
it "gets 10 stations from a zipcode" do
service = FuelStationService.new(80203)
stations = service.stations
expect(stations.count).to eq(10)
expect(stations.first["station_name"]).to eq("UDR")
end
end
|
require 'erb'
require 'mongo'
require 'sinatra/base'
require 'yajl'
require 'active_support/core_ext/time/zones'
require 'active_support/core_ext/time/calculations'
require 'active_support/core_ext/date/calculations'
require 'active_support/core_ext/numeric/time'
require 'chronic'
require 'tzinfo'
module Chrono
clas... |
FactoryGirl.define do
factory :level do
name "Pro"
after(:create) do |level|
level.challenges << FactoryGirl.create(:challenge)
end
end
end
|
class RestClient < Cask
url 'https://rest-client.googlecode.com/files/restclient-ui-3.2.1-app.zip'
homepage 'https://code.google.com/p/rest-client'
version '3.2.1'
sha1 'af3ba630c417524ae6a8a972680d26e6ad470dd1'
link 'WizTools.org RESTClient.app'
end
|
describe ::PPC::Baidu::Report do
subject{
::PPC::Baidu::Report.new(
debug:true,
username:'',
password:'',
token:'')
}
it "could get report_id" do
file_id = subject.file_id_of_query
expect(file_id.size).to eq 32
times = 0
state = 0
loop do
state = subject.state... |
class App
include DataMapper::Resource
include File.join(File.dirname(__FILE__), '..', 'settings' )
property :id, String, :required => true, :key=>true
property :filename, String, :required => true
property :identifier, String
property :installs, Integer
property :icon, Boolean
... |
class AddMicrochipBrandIdToAnimals < ActiveRecord::Migration
def change
add_column :animals, :microchip_brand_id, :integer
remove_column :animals, :microchip_brand
end
end
|
RailsAdmin.config do |config|
config.authorize_with do |controller|
redirect_to main_app.root_path unless current_user && current_user.admin
end
# [...]
end
|
class Layer < ActiveRecord::Base
include ActiveModel::Validations
belongs_to :work
belongs_to :selected_polygon_class, :class_name => 'PolygonClass'
has_many :polygons
has_many :polygon_class_colours
has_many :polygon_classes, :through => :polygon_class_colours
has_attached_file :user_layer_file
valida... |
Rails.application.routes.draw do
root 'tops#index'
devise_for :users, controllers: {
registrations: 'users/registrations',
sessions: 'users/sessions'
}
devise_scope :user do
get 'addresses', to: 'users/registrations#new_address'
post 'addresses', to: 'users/registrations#create_address'
end
... |
# The library has a single method for converting PDF files into HTML. The
# method current takes in the source path, and either/both the user and owner
# passwords set on the source PDF document. The convert method returns the
# HTML as a string for further manipulation of loading into a Document.
#
# Requires that pd... |
class AddColumnToPresenters < ActiveRecord::Migration[5.1]
def change
add_column :presenters, :user_id, :bigint
add_column :presenters, :filepath, :string
end
end
|
require 'data_generator/field/base'
module DataGenerator
module Field
# Generates incremental numerical values
class Id < Base
attr_reader :count
def initialize(*attrs)
super(*attrs)
@count = 0
end
private
def _value(entity)
@count += 1
end
e... |
class AddExtraToStudents < ActiveRecord::Migration
def change
# 学院
add_column :students, :faculty, :string
# 专业
add_column :students, :major, :string
# 性别
add_column :students, :gender, :string
# 年级
add_column :students, :grade, :string
# 学生类别
add_column :students, :kind, :... |
class Api::ClassDatesController < ApplicationController
def show
@classes = Course.find(params[:id]).class_dates.order(:date)
render :json => {:classes => @classes}.to_json
end
end
|
class Stopwatch
require 'audible'; include Audible;
def time(&block)
reset
@start = Time.now
begin
block.call
ensure
@stop = Time.now
notify :done, :duration => (@stop-@start)
end
end
def elapsed
@stop-@start
end
private
def reset
@start = @stop = n... |
class RegistrationsController < Devise::RegistrationsController
# POST /resource
# def create
# build_resource
# if resource.save
# if resource.active_for_authentication?
# set_flash_message :notice, :signed_up if is_navigational_format?
# sign_in(resource_name, resource)
# r... |
require "test_helper"
class TicketTest < ActiveSupport::TestCase
test "a ticket can be reserved" do
ticket = create(:ticket)
assert_nil ticket.reserved_at
ticket.reserve!
refute_nil ticket.reload.reserved_at
end
test "a ticket can be released" do
ticket = create(:ticket, :reserved)
ref... |
class AddTodotodoToExchange < ActiveRecord::Migration
def change
add_column :exchanges, :todo, :integer
end
end
|
@genres.each do |genre|
json.set! (genre.id) do
json.partial! 'api/genres/genre', genre: genre
end
end |
# First attempt
class Card
CARD_VALUES = { 2 => 2, 3=> 3, 4=> 4, 5=> 5, 6=> 6, 7=> 7,
8=> 8, 9=> 9, 10=> 10, 'Jack' => 11,
'Queen' => 12, 'King' => 13, 'Ace' => 14
}
include Comparable
attr_reader :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit ... |
require "csv"
module ActiveRecordBrowser::CsvHandler
def arb_import_from_csv(stream, options={})
max_at_once = options[:max_at_once] || 100
header_spec = options[:header_spec] || []
unless header_spec.empty?
columns_to_insert = arb_collect_columns(header_spec)
columns_spec = arb_make_columns_... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root "static_pages#home"
get "login", to: "sessions#new"
get "/api/v1/users/blocked", to: "api/v1/users#blocked"
namespace :api do
namespace :v1 do
resources :users,... |
class EventsController < ApplicationController
before_filter :admin_required
def index
@title = 'Events'
@events = Event.find :all, :order => 'occurs_on DESC'
end
def permalink
if params[:permalink] =~ /(\d+)-.+/
@event = Event.find $1
else
@event = Event.find_by_permalink param... |
# Command line tool that repeatedly contacts a tracker to get as many peers
# for a .torrent file as possible.
# NOTE: Use with caution, since this ignores the interval specified by the
# tracker server. Maybe they won't like this?
require 'net/http'
require 'metainfo'
require 'get_request'
require 'get_response'
requ... |
require File.dirname(__FILE__) + "/../../spec_helper"
describe Admins::AccessController do
let(:membership) { mock_model(Membership) }
let(:scenario) { mock_model(Scenario, :name => 'bla') }
let(:current_user) { Factory.stub(:admin) }
before(:each) do
controller.stub!(:current_user).and_return(current_u... |
# encoding: UTF-8
module API
module V1
module PageStructure
class Base < API::V1::Base
helpers Helpers::V1::PagesStructuresHelpers
PAGE_STRUCTURES_ENDPOINTS = [
:learning_track,
:learning_cycle,
:cycle_planning
]
with_cacheable_endpoints :pag... |
# frozen_string_literal: true
require 'rails_helper'
describe SessionsController do
describe '#create' do
subject(:json_response) { JSON.parse response.body }
let(:user) { create(:user) }
context 'when password is correct' do
before { post :create, username: user.username, password: user.instanc... |
require 'digest/md5'
module Libretsy
class Authenticator
attr_accessor :authorization_response_hash, :client, :nonce, :opaque, :qop, :realm, :response
def initialize(client, response)
@client = client
@response = response
parse_response_headers(@response)
end
def self.authenticat... |
execute "create SSH key pair for Github" do
command "ssh-keygen -N '' -f #{WS_HOME}/.ssh/id_github_#{node["github_project"]}"
user WS_USER
not_if "test -e #{WS_HOME}/.ssh/id_github_#{node["github_project"]}"
end
execute "symlink Github key for git-project" do
command "ln -nfs #{WS_HOME}/.ssh/id_github_{#{node[... |
commands do
allow :git, "git"
end
routines do
tag do
local do |option, argv|
msg, suffix = option.message, argv.shift
msg ||= 'Another release by Rudy'
suffix ||= git 'rev-parse', '--short', 'HEAD'
@tagname = Time.now.strftime("%Y-%m-%d-#{user}-#{suffix}")
git 'tag', :a, @tagn... |
require 'spec_helper'
describe Artist do
it 'should have a name' do
artist = Artist.create()
artist.should respond_to(:name)
end
it 'can have many albums' do
should have_many(:album)
end
it 'can have many songs through albums' do
should have_many(:song).through(:album)
end
end
|
Reform::Form.class_eval do
module MultiParameterAttributes
def self.included(base)
base.send(:register_feature, self)
end
class DateParamsFilter
def call(params)
date_attributes = {}
params.each do |attribute, value|
if value.is_a?(Hash)
call(value) # TO... |
class TowerOfHanoi
#initialize initial stack height
def initialize(num_disks)
@disk = num_disks
end
def play
#Prints intro
puts
puts "Welcome to Tower of Hanoi!"
puts
puts "Instructions:"
puts "Enter where you'd like to move from and to"
puts "in the format [1,3]. Enter 'quit' ... |
class NudgeMailer < MandrillMailer::TemplateMailer
default from: 'contact@usecurrently.com'
default from_name: 'Currently'
def nudge(sender, recipient)
mandrill_mail template: 'Nudge User',
subject: sender.name + ' wants you to update your status',
to: correct_recipient(re... |
class AddApprovalFieldToAccounts < ActiveRecord::Migration[5.0]
def change
change_table :accounts do |t|
t.boolean :Approved
t.rename :BankName, :AccountName
end
end
end
|
##
# = ReadOperations
#
# Defines functionality required for the successful reading, parsing and
# interpreting of a line of text contained in a flat file.
#
module ReadOperations
module ClassMethods #:nodoc:
end # => module ClassMethods
##
# = Instance Methods
#
# Defines behavior for instances of a subcl... |
# frozen_string_literal: true
module Kafka
module Protocol
class AddPartitionsToTxnRequest
def initialize(transactional_id: nil, producer_id:, producer_epoch:, topics:)
@transactional_id = transactional_id
@producer_id = producer_id
@producer_epoch = producer_epoch
@topics =... |
class AddSelfJoinOnCoverage < ActiveRecord::Migration
def change
add_reference :coverages, :coverage, index: true
end
end
|
class BettingPrediction < ActiveRecord::Base
belongs_to :football_match
belongs_to :bookmaker
end
|
require "rspec"
require "hand.rb"
describe Hand do
let(:hand) { Hand.new }
let(:straight_flush) { Hand.new [
Card.new('ace', 'spades'),
Card.new('two', 'spades'),
Card.new('three', 'spades'),
Card.new('four', 'spades'),
Card.new('five', 'spades')
] }
let(:four_of_a_kind) { Hand.new [
... |
#!/usr/bin/ruby
class String
def +(var)
if var.is_a? Integer
res = self.to_i + var
self.replace(res.to_s)
else
self << var
end
end
def -(var)
if var.is_a? Integer
res = self.to_i - var
self.replace(res.to_s)
else
self.slice! var
self
end
end
... |
module Sdp
module Cacher
class Dispatcher
attr_accessor :peers,:storage_path
def initialize(storage_path)
@storage_path = storage_path
@peers = {}
end
def self.get_tlvs(options)
inverted_types = Sdp::ICMPv6::TLV_TYPES.invert
options.reduce({}) {|memo,o... |
RSpec.describe Hanami::Controller::UnknownFormatError do
it 'inheriths from Hanami::Controller::Error' do
expect(Hanami::Controller::UnknownFormatError.superclass).to eq(Hanami::Controller::Error)
end
end
|
require 'helper_classes'
begin
require 'hilink_modem'
module Network
module Device
class Hilink < Stub
include HelperClasses::DPuts
@ids = [{bus: 'usb', id: '12d1:14db'}]
def connection_start
dputs(3) { 'Starting connection' }
HilinkModem::Dialup.connect
... |
require './spec/helper'
RSpec.describe Project do
after { FileUtils.rm '.coco.yml', force: true }
context "with config exit_if_low_coverage = true" do
it "exits with error code if coverage is less than expected" do
create_config({exit_if_coverage_below: 87})
output = StringIO.new
project = P... |
require 'spec_helper'
describe DJ::Worker do
describe 'worker_class_name' do
it 'should return the name of the worker' do
w = WorkerClassNameTestWorker.new
w.worker_class_name.should == 'worker_class_name_test_worker'
w = WorkerClassNameTestWorker.new(:id => 1)
w.worker_class_name... |
class Idea < ActiveRecord::Base
validates :title, :body, presence: true
enum quality: %w(swill plausible genius)
def upvote
increment!(:quality) if Idea.qualities[self.quality] < 2
end
def downvote
decrement!(:quality) if Idea.qualities[self.quality] > 0
end
end
|
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'factory_girl'
require 'pry-rails'
require 'database_cleaner'
FactoryGirl.find_definitions
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| re... |
require_relative 'lib/deadpool/version'
Gem::Specification.new do |spec|
spec.name = 'deadpool'
spec.version = Deadpool::VERSION
spec.author = 'Kirt Fitzpatrick'
spec.summary = '/etc/hosts based failover system w/monitoring'
spec.description = <<~DESCRIPTION
/etc/hosts based failover system w/monitoring.... |
module LibrarySchedulesHelper
def get_open_today(resource, resource_id, json = false, today = nil)
if today == nil
today = Date::today
end
@day_number = today.cwday
# Fetch only the schedules covering today
db_today = today.strftime('%F')
conditions = Array.new
conditions.push("sc... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
class Artist < ApplicationRecord
#掛載 carrierwave
mount_uploader :photo, PhotoUploader
has_many :musics
#artist_event relationship
has_many :shows, dependent: :destroy
has_many :events, through: :shows
#user followed
has_many :artist_followships, dependent: :destroy
has_many :artist_followed, through... |
#!/usr/bin/ruby1.8 -Ku
# -*- coding: utf-8 -*-
=begin
= reset password of dolphin role in postgres
== usage
$ sudo ruby1.8 open-dolphin-reset-password.rb
== License (MIT License)
Copyright (c) 2009 Kazuhiro NISHIYAMA
Copyright (c) 2009 Good-Day, Inc.
Permission is hereby granted, free of charge, to any person obtai... |
# An affiliate campaign
#
# Carries an affiliate fee (and sales fee)
#
class AffiliateCampaign < SalesCampaign
money_columns :affiliate_fee
belongs_to :affiliate, :class_name => 'Contact'
validates :affiliate, :presence => true
##
# The sum cost of this campaign
#
def cost
super + affiliate_fee
en... |
require 'spec_helper'
describe Restaurant do
it "has a valid factory" do
FactoryGirl.create(:restaurant).should be_valid
#validates that the restaurant table has been successfully populated based on ... confirm w/ Steve
end
it "when validation for invalid restaurant name occurs" do
restaurant = Factory... |
# BANANABAD CODE.
# You have been warned.
require 'rubygems'
require 'mechanize'
require 'json'
require 'stringex'
module Tictail
class Fetcher
attr_reader :store_id, :agent, :api, :store_data, :home_page
# @param [String] email
# @param [String] password
def initialize(email, password)
@api ... |
class UserMailer < ActionMailer::Base
default from: "klinikmedifast@gmail.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.user_mailer.signup_confirmation.subject
#
def record_admin_confirmation(record)
@user = record
mail to: "klinikmedi... |
require 'spec_helper'
feature 'Creating a new Idea' do
scenario 'A user has signed up, and submits an idea' do
sign_up
click_link('Submit Your Idea');
expect{create_idea}.to change(ProjectIdea, :count).by 1
expect(User.get(ProjectIdea.first.user_id).projectIdeas.first.title).to eq 'A Twitter Clone'
... |
class CreateWatches < ActiveRecord::Migration[5.1]
def change
create_table :watches do |t|
t.text :regexp_text, null: false
t.references :character, index: true, null: false
t.references :user, null: false
t.boolean :waiting
t.boolean :private
t.text :url
t.timestamps
... |
module Taggable
extend ActiveSupport::Concern
included do
has_many :taggings, as: :taggable, dependent: :destroy, autosave: true
end
def tag_names
tags.pluck(:name)
end
end |
require_relative './person'
require_relative './secret_number'
class Game
# this class will be complex
# we need to write logic to initialize a new game, and run the game loop
# we'll want to write a few separate methods for unique tasks so that our
# code is structured properly
attr_accessor :secret_number, :user, ... |
class CreateInviteRequests < ActiveRecord::Migration
def change
create_table :invite_requests do |t|
t.belongs_to :tournament, :null => false
t.belongs_to :user, :null => false
t.belongs_to :invite
t.timestamps
end
add_index :invite_requests, [:tournament_id, :user_id], :unique =>... |
require "benchmark"
# Util Module
module Util
# calculate measure
# @param [String] name
# @param [Proc] function
def time(name, &function)
if function
# @param [Benchmark::Report]
Benchmark.bm do |to_bench|
to_bench.report(name) do
return function.call
end
end
... |
module DailyTask
class StartTimeLog
prepend SimpleCommand
def initialize(user_id, task_id, args = {})
@task = Cultivation::Task.find(task_id)
@user = User.find(user_id)
@args = args
end
def call
if validate?
@task.update(work_status: 'started')
time_log = @tas... |
require 'httparty'
require_relative 'app/models/customer.rb'
require_relative 'app/models/item.rb'
class OrderClient
include HTTParty
base_uri "http://localhost:8080"
format :json
def self.register(cust)
Customer.register(cust)
end
def self.createItem(item)
Item.c... |
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.7', '>= 5.0.7.1'
# Use sqlite3 as the database for... |
# == Schema Information
#
# Table name: tracks
#
# id :integer not null, primary key
# title :string not null
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# image_file... |
class CreateUserBrags < ActiveRecord::Migration
def change
create_table :user_brags do |t|
t.references :user
t.references :brag
t.integer :type
t.timestamps
end
add_index :user_brags, :user_id
add_index :user_brags, :brag_id
end
end
|
module IssueTypeRepresenter
include Roar::JSON
property :id
property :name
property :component_type_id
property :component_name, :getter => lambda {|args| component_type.name}
end
|
=begin
When looking at count_sheep we can see that the #times block is the only code in the method.
This means it's also the last line in the method. Since #times returns the initial integer, we now know that the return method of count_sheep is 5.
end |
# SteelyCms.
#
# Rails based Content Management System.
#
# Author:: Rafal Wicha (mailto:rafwic@gmail.com)
# Copyright:: Rafal Wicha
# Abstract class for each controller used in CMA.
class Admin::BaseController < ApplicationController
include AuthenticatedSystem
include AdminContext
before_filter :login_... |
module LCD
module Validation
def validate(val, accepted)
raise ArgumentError, "wrong argument #{val}, accepts #{accepted}" unless accepted === val
end
end
end
|
class CreateScrambledWordTests < ActiveRecord::Migration
def change
create_table :scrambled_word_tests do |t|
t.integer :content_id
t.integer :user_id
t.integer :wpm
t.integer :comprehension_rate
t.timestamps
end
add_index :scrambled_word_tests, :content_id
add_index :s... |
require 'spec_helper'
RSpec.describe OwskiLog do
it 'has a version number' do
expect(OwskiLog::VERSION).not_to be nil
end
context 'event succeed' do
it 'starts and finish with status ok' do
holder = OwskiLog::Holder.new
expect {
holder.wrap 'EV1', 'Event one description' do
... |
class InitializeAllTables < ActiveRecord::Migration
def up
create_table "albums", :force => true do |t|
t.integer "type", :limit => 1, :default => 1, :null => false
t.string "name", :limit => 45, :null => false
t.integer 'user_id'
t.text "in... |
class CategorySerializer < ApplicationSerializer
object_as :category
attributes(
:id,
:categorizable_type,
:name,
:slug,
:description,
:created_at,
:updated_at,
# qty: { type: :number },
)
type :string
def plural
category.categorizable_type.pluralize
end
end
|
class AddCourseTeacherToCourseSurveys < ActiveRecord::Migration
def change
add_column :course_surveys, :course_teacher_id, :integer
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.