text stringlengths 10 2.61M |
|---|
class RemoveAgencyFields < ActiveRecord::Migration[5.0]
def change
remove_column :agencies, :description, :text
remove_column :agencies, :lead_officer, :string
end
end
|
# frozen_string_literal: true
describe Zafira::Models::TestCase do
describe 'CONSTANTS' do
describe 'Status' do
let(:constant) { Zafira::Models::TestCase::Status }
describe 'UNKNOWN' do
it { expect(constant::UNKNOWN).to eq(0) }
end
describe 'IN_PROGRESS' do
it { expect(c... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable
enum role: {ADMIN: 'ADMIN', VISITOR: 'VISITOR', CUSTOMER: 'CUST... |
class OneMenusController < ApplicationController
before_action :set_one_menu, only: [:show, :edit, :update, :destroy]
# GET /one_menus
# GET /one_menus.json
def index
@one_menus = OneMenu.all
@order = Order.new
end
# GET /one_menus/1
# GET /one_menus/1.json
def show
end
# GET /one_menus/n... |
require 'rails_helper'
RSpec.describe 'Links Create endpoint', type: :request do
context "as an authenticated user" do
it 'should update a link' do
user = create(:user)
allow_any_instance_of(ApplicationController)
.to receive(:current_user)
.and_return(user)
links = create_list... |
require 'test_helper'
module KanbanBoard
class MemberTest < ActiveSupport::TestCase
def setup
@user = KanbanBoard.user_class.create(first_name: "Stephan", last_name: "Griessner")
@project = Project.create(name: "First project", description: "Project for testing", finishing_date: Date.today)
... |
class ApplicationController < ActionController::Base
include ControllerAuthentication
protect_from_forgery
before_filter :mark_user_request, :if => :logged_in?
before_filter :set_user_time_zone, :if => :logged_in?
private
def mark_user_request
current_user.update_attribute(:last_request_at, Time.now)
... |
require 'spec_helper'
describe Organization do
describe 'methods' do
let!(:organization) { FactoryBot.create(:organization, name: 'org_1') }
describe '#accredit!' do
it 'it should make accredit true.' do
organization.accredit!
expect(organization.accredited).to be true
end
end... |
require 'rails_helper'
feature 'show review of motorcycle' do
scenario 'user sees a motorcycle and its reviews' do
moto = FactoryGirl.create(:motorcycle)
review = FactoryGirl.create(:review, user_id: moto.user.id, motorcycle_id: moto.id)
visit motorcycle_path(moto)
expect(page).to have_content("Mot... |
require File.dirname(__FILE__) + '/../test_helper'
class FastaFileTest < ActiveSupport::TestCase
should_have_attached_file :fasta
should_belong_to :user
should_have_one :biodatabase
should_validate_presence_of :project_id
context "Format DB should fail if no fasta file exists" do
setup do
@fasta_... |
class ChaptersController < ApplicationController
before_action :find_comic
before_action :find_chapter
before_action :admin_user, except: [:index, :new, :show]
def index
@chapters = Chapter.all
end
def show
@chapter_attachments = @chapter.chapter_attachments.all
@comments = @chapter.comments.... |
module Mech::Configurator
def init(path = nil)
require path || File.join(File.dirname(__FILE__), '..', 'conf')
@config ||= Mech::Config.instance
self
end
def config
unless @config
if init
@config ||= Mech::Config.instance
else
raise 'Not load config file'
end
... |
class Bike
attr_reader :name, :working
def initialize(name)
@name = name
@working = true
end
def self.create(name)
@bike = Bike.new(name)
end
def self.instance
@bike
end
def working?
@working
end
def report_broken
@working = false
end
def report_fixed
@working ... |
class FayeJob < ActiveJob::Base
queue_as :faye
def perform(object)
FayeClient.new(data, channels(object)).publish
end
private
def data
'data'
end
def channels(object)
object_class = object.class.to_s.downcase
[
['/', [object_class, object.id].join('_')].join,
['/', object... |
require 'redcarpet'
class MarkdownGenerator
class Render < Redcarpet::Render::HTML
include Redcarpet::Render::SmartyPants
def postprocess(doc)
super.tap do |html|
bad_links = html.scan /\[[^\[\]]+\]\[([^\[\]]+)/
if bad_links.any?
links = bad_links.compact.join ','
m... |
if ARGV.length < 5
puts "usage: raxrun <dataset> <model> <seq_start> <seq_end> <len>"
throw "missing arguments"
end
$dataset = ARGV[0]
$model = ARGV[1]
$seq_start = ARGV[2].to_i
$seq_end = ARGV[3].to_i
$subseq_len = ARGV[4].to_i
$raxml_bin = "~/src/raxml720/raxmlHPC"
$misc_param = "-x 1234"
$subseq_dir = "... |
require 'test_helper'
class UserCommentsTest < ActionDispatch::IntegrationTest
def setup
@user = users(:first)
@list = lists(:one)
@task = tasks(:one)
@comment = comments(:one)
Capybara.current_driver = Capybara.javascript_driver
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.... |
class Experience < ApplicationRecord
belongs_to :user
has_many :meetings, dependent: :destroy
has_many :languages , dependent: :destroy
has_many :skills, dependent: :destroy
# has_many :users, through :meetings
validates :first_name, :last_name, :gender, :age, :location, presence: true
has_one_attached :... |
# frozen_string_literal: true
class CreateCustomerJob < ApplicationJob
queue_as :subscriptions
def perform(user_id:)
user = User.with_pk!(user_id)
CreateCustomerService.new.call(user)
end
end
|
class Todo < ApplicationRecord
validates :item, presence: true
belongs_to :user
end
|
require 'rails_helper'
describe DashboardFacade do # rubocop:disable Metrics/BlockLength
it 'exists' do
token = 'token'
df = DashboardFacade.new(token)
expect(df).to be_a(DashboardFacade)
end
describe 'instance methods' do # rubocop:disable Metrics/BlockLength
describe '#repos' do
it 'retur... |
class AdminNotifier < ActionMailer::Base
layout 'mail'
default :from => 'admin@swipesense.com'
default :to => 'info@swipesense.com'
def hub_report(up_hubs, down_hubs)
@up_hubs = up_hubs
@down_hubs = down_hubs
mail :subject => 'Hub Report'
end
def contact_report(contact)
@contact = contac... |
require 'optparse'
class Options
def self.parse
options = {
max_alternatives: 2,
do_not_perform_vad: false,
silence_duration_threshold: 0.6,
disable_automatic_punctuation: false,
}
OptionParser.new do |opts|
opts.banner = "Usage: #{$1} [options]"
opts.on('-f', '--inp... |
class CreateOffers < ActiveRecord::Migration
def change
create_table :offers do |t|
t.integer :company_id
t.boolean :publish
t.string :header
t.text :advert
t.date :date_start
t.date :date_end
t.text :conditions
t.timestamps
end
end
end
|
class BacklogItem < ActiveRecord::Base
belongs_to :product
belongs_to :user
has_many :tasks
validates_presence_of :description
validates_presence_of :product_id
validates_presence_of :points
validates_numericality_of :points
validates_presence_of :user_id
end
|
class AddAssociatedResourceToPresentationSlide < ActiveRecord::Migration
def change
add_reference :presentation_slides, :associated_resource, polymorphic: true
end
end
|
require "./lib/Lesson 5 Prefix Sums/GenomicRangeQuery/genomic_range_query"
describe 'GenomicRangeQuery' do
describe 'Example Tests' do
it 'example: S = CAGCCTA, P = [2,5,0], Q = [4,5,6] gives [2,4,1]' do
expect(genomic_range_query('CAGCCTA', [2,5,0], [4,5,6])).to eq [2,4,1]
end
end
describe 'Corre... |
class AuthenticationsController < ApplicationController
skip_before_filter :authenticate_user!, only: [:index, :create]
respond_to :json, :html
def index
@authentications = current_user.authentications if user_signed_in?
end
def create
omniauth = request.env["omniauth.auth"]
user = User.where('a... |
class ChangeCostDatatypeForCartitems < ActiveRecord::Migration[6.0]
def change
change_column :cartitems, :cost, :float
end
end
|
class FollowingRelationship < ActiveRecord::Base
belongs_to :user
belongs_to :followed_user, :class_name => "User" #(ie, belongs to a user and the person that user is following. We specify class_name because there is not a separate “followed_user” model. So we tell rails we want to use user as the model for the asso... |
class LogEntry < ActiveRecord::Base
attr_accessible :date, :hours, :activities_attributes
belongs_to :activity_log
has_many :activities
delegate :user, to: :activity_log
accepts_nested_attributes_for :activities
validates :activity_log_id, presence: true
validates :date, presence: true
validates_num... |
class Patient
attr_reader :name, :disease
attr_accessor :room, :id
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@disease = attributes[:disease]
@cured = attributes[:cured] || false
@room = attributes[:room]
end
def cured?
@cured
end
... |
module VagrantPlugins
module WinAzure
module Command
class PowerShell < Vagrant.plugin('2', :command)
def self.synopsis
'execute PowerShell command or script on remote machine'
end
def execute
options = {}
opts = OptionParser.new do |o|
o.b... |
class FixUpSponsorshipTier < ActiveRecord::Migration
def up
# Number of columns to use for this tier's display
add_column :sponsorship_tiers, :columns, :int, default: 4, null: false
# Add # in front
change_column :sponsorship_tiers, :color, :string, length: 7
# Null price = hidden
change_colum... |
class User < ApplicationRecord
include Rails.application.routes.url_helpers
has_many :books
has_many :from_chat_messages, class_name: "ChatMessage", foreign_key: "from_id", dependent: :destroy
has_many :to_chat_messages, class_name: "ChatMessage", foreign_key: "to_id", dependent: :destroy
has_one_attached :p... |
class SongsController < ApplicationController
validates :title, presence: true #Cannot be repeated by the same artist in the same year
validates :released, inclusion: {in: %w(true false)}
#validates :release_year,
# Optional if released is false
# Must not be blank if released is true
# Must be less t... |
class Api::V1::ResourcesController < ApplicationController
before_action :set_location
def index
@resources = @location.resources
render json: @resources
end
def show
@resource = @location.resources.find_by(id: params[:id])
render json: @resource
end
def create
@resource = @location.... |
require 'rails_helper'
describe 'Home', type: :feature do
before do
@mob_cat = create :category, name: 'Mobile Development'
@web_cat = create :category, name: 'Web development'
20.times do |items|
create :order_with_book,
book_id: items,
qty: (items < 4) ? 2 : 1,
... |
class CreateArticles < ActiveRecord::Migration[5.0]
def change
create_table :articles do |t|
# title and body are the two basic fields we need for articles
t.string :title
t.text :body
# this is to reference the table that's created
# timestamps will create 2 col: "created_at" and "u... |
class InterventionTypesController < ApplicationController
def index
@interventiontypes = InterventionType.order('name asc').all
end
def new
@interventiontype = InterventionType.new
end
def create
@interventiontype = InterventionType.new(interventiontype_params)
if @interventiontype.save
redirect_to i... |
require_relative "recommended_link"
require "logger"
require "plek"
require "rummageable"
DUMMY_LOGGER = Logger.new("/dev/null")
module RecommendedLinks
class Indexer
def initialize(logger=DUMMY_LOGGER)
@logger = logger
end
def index(recommended_links)
@logger.info "Indexing #{recommended_l... |
class AddMessageToAuditObject < ActiveRecord::Migration
def change
change_table :component_status_transitions do |t|
t.text :message
end
end
end
|
require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe "商品の出品" do
context "出品成功時" do
it "nameとtextとcategory,delivery,status,city,days,priceがあればOK" do
expect(@item).to be_valid
end
it "category_idが1以外ならOK" do
@i... |
module Users
class RegistrationsController < Devise::RegistrationsController
before_action :configure_account_update_params, only: [:update]
def new
redirect_to new_user_session_path
end
def create
flash[:notice] = 'Contact an administrator for an account'
redirect_to new_user_sess... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
belongs_to :plan #Associates each user with a SINGLE pl... |
class ProfilesController < ApplicationController
expose(:user)
expose(:reviews) { user.reviews.order(created_at: :desc).limit(5) }
def show
user = User.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to root_url, flash: {error: 'User not found.'}
end
end |
module Runs::Triggers
extend ActiveSupport::Concern
def execute_triggers
dispatchers.each do |dispatcher|
if dispatcher.rule.enabled
dispatcher.rule.triggers.each { |trigger| trigger.run_on self }
end
end
end
end
|
describe 'Add text and replace non existing word' do
before(:all) {
@text = "Replace%20it%20by%20asterics"
@replaced = "-"
}
let(:replace_text){ get "?text=#{@text}&add=&fill_text=#{@replaced}" }
it 'Returned string keeps as it is' do
replace_text
expect_json(result: "Replace it by asterics")
... |
class CreateTables < ActiveRecord::Migration[5.0]
def change
create_table :clients do |t|
t.belongs_to :user, foreign_key: true, null: false
t.string :name, null: false
t.string :first_name
t.string :last_name
t.string :department
t.string :address
t.string :postalcode
... |
module XCB
class Reply::GetProperty < FFI::Struct
layout :response_type, :uint8,
:format, :uint8,
:sequence, :uint16,
:length, :uint32,
:type, :atom,
:bytes_after, :uint32,
:value_len, :uint32,
:pad0, [:uint8, 12]
end
end
|
=begin This program will work as an agenda storing name, phone number,
make some note, it might have a calender, store address, e-mail
Ask the user what want to do
if the user want to visualize the list of contacts
or calender or events
if the user wants to add a new contact or new event
if the user ... |
require 'sinatra/base'
require_relative 'player'
require_relative 'game'
require_relative 'rock'
require_relative 'scissors'
require_relative 'paper'
require_relative 'spock'
require_relative 'lizard'
class RPS < Sinatra::Base
set :views, Proc.new { File.join(root, '..', "views") }
set :public_dir, Proc.new { File.j... |
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in webrat_steps.rb
#
def path_to(page_name)
my_domain = "qameha.dev"
my_protocol = "http"
case page_name
# specific epr module
when /the epr home page/
... |
#
# Cookbook Name:: service_factory_test
# Recipe:: default
#
unix_binaries do
install %w{ nc wc egrep }
end
fts_username = "fts_user"
fts_basepath = "/opt/factory_test_service"
fts_script = "#{fts_basepath}/fts.sh"
fts_script2 = "#{fts_basepath}/fts-autostart.sh"
directory fts_basepath do
action :create
ow... |
before "deploy:updated", "puppet:install"
namespace :puppet do
desc "Install and run puppet manifests"
task :install do
puppet_location = fetch(:puppet_install_dir, "/etc/puppet")
# create puppet/fileserver.conf from given puppet file location
puppet_d = fetch(:project_puppet_dir, "#{release_path}/co... |
# encoding: utf-8
require_relative 'spec_helper'
describe "route group" do
it "should redirect to root path without params" do
get "/tgp"
last_response.status.must_equal 302
end
it "should see tgp response body with params" do
get "/tgp", { first: 'first', second: 'second' }
last_response.status... |
class AddColumnsToCacheUser < ActiveRecord::Migration[5.0]
def change
add_column :cache_users, :email, :string
add_column :cache_users, :name, :string
add_column :cache_users, :surname, :string
add_column :cache_users, :phone_number, :string
add_column :cache_users, :address, :text
add_column ... |
class CreateTracts < ActiveRecord::Migration[5.1]
def change
create_table :tracts do |t|
t.integer :project_id
t.integer :user_id
t.string :owner_name
t.string :parcel_address
t.string :owner_phone
t.string :owner_email
t.float :payment_amount
t.... |
class CreateLegacyCharts < ActiveRecord::Migration
def self.up
music_diffs = CxbRank::MUSIC_DIFFS[CxbRank::MODE_REV]
create_table :legacy_charts do |t|
t.references :music, :null => false
t.date :span_s, :null => false
t.date :span_e, :null => false
music_diffs.keys.sort.each do |key|
... |
class Link
attr_reader :uri, :resolved, :content, :tags, :article
def self.perform(link)
link = Link.new(link)
link.run
end
def initialize(uri)
@uri = normalise_uri(uri)
end
def run
begin
resolve_link
update_article and return if article_fetched?
fetch_content
pars... |
class AddColorAndSizeToCartItems < ActiveRecord::Migration[5.0]
def change
add_reference :cart_items, :color, foreign_key: true
add_reference :cart_items, :size, foreign_key: true
end
end
|
# frozen_string_literal: true
describe Kafka::MessageBuffer do
let(:buffer) { Kafka::MessageBuffer.new }
describe "#concat" do
it "adds the messages to the buffer" do
buffer.concat(["foo"], topic: "foo", partition: 0)
expect(buffer.size).to eq 1
expect(buffer.bytesize).to eq 3
end
... |
class ListSerializer < ActiveModel::Serializer
attributes :id, :user_id, :permissions, :name
end
|
class CreateAvailabilities < ActiveRecord::Migration[5.0]
def change
create_table :availabilities do |t|
t.boolean :is_available
t.string :from_ip
t.timestamps
end
end
end
|
class FoodType < ActiveRecord::Base
belongs_to :recipies
has_many :ingredients
end
|
class Achievement < ActiveRecord::Base
has_many :achievement_user
has_many :users, through: :achievement_user
end
|
require "spec_helper"
RSpec.describe "Day 12: Subterranean Sustainability" do
let(:runner) { Runner.new("2018/12") }
let(:input) do
<<~TXT
initial state: #..#.#..##......###...###
...## => #
..#.. => #
.#... => #
.#.#. => #
.#.## => #
.##.. => #
.#### => #
... |
# 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 AddCompanyToUser < ActiveRecord::Migration[5.1]
def change
add_column :users, :company, :string, default: 'ITS'
end
end
|
require 'test_helper'
require 'sword/composers/hyacinth_composer'
require 'sword/deposit_content'
require 'sword/person'
class HyacinthComposerTest < ActiveSupport::TestCase
setup do
@deposit_content = Sword::DepositContent.new
@deposit_content.title = 'Title for Testing the Hyacinth Composer'
@deposit_c... |
=begin
#V4 Online API
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v4
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.15
=end
require 'date'
module RentCentric
class LocationDTO
attr... |
Rails.application.routes.draw do
# get 'user_moods/index'
# get 'user_moods/show'
get '/', to: 'static#welcome', as: 'root'
##### users ######
get '/users/login', to: 'users#login', as: 'login_user'
post '/please_login', to: 'users#please_login'
get '/users/new', to: 'users#new', as: 'new_user'
post ... |
class AddIconToInfrastructures < ActiveRecord::Migration
def change
add_column :infrastructures, :icon, :string
end
end
|
module Fn
module Salesforce
class Rollback < SimpleDelegator
def initialize(plan)
super(
plan.map { |operation|
operation.dup
}.map { |operation| UndoFactory.coerce(operation) }
)
end
end
class UndoFactory
def self.coerce(operation)
... |
# frozen_string_literal: true
require './lib/lolruby/api'
require 'rspec'
RSpec.describe LeagueOfLegends do
context 'with the base client class' do
it 'assert LeagueofLegends.base_uri value' do
expect(LeagueOfLegends.base_uri).to eq('https://na1.api.riotgames.com')
end
end
end
RSpec.describe Leagu... |
json.array!(@room_issues) do |room_issue|
json.extract! room_issue, :activityDate
json.url room_issue_url(room_issue, format: :json)
end
|
require 'pry'
class Song
attr_accessor :name, :artist
def initialize(name)
@name = name
end
def artist_name=(name)
self.artist = Artist.find_or_create_by_name(name)
artist.add_song(self)
end
def self.new_by_filename(filename)
filename_array = filename.split(/\s-\s/)
song = Song... |
class Quantifiable
module InstanceMethods
#Takes sum of items in list
def total_amount
self.items.collect {|item| item.amount}.sum
end
#Sort items in list by date
def items_sort_by_date
self.items.sort_by {|item| item[:date]}.reverse
end
end
end |
class Gathering < ActiveRecord::Base
validates :artist, :place_name, :location, :start_date, :end_date, :description, :tix_price, :funds, :goal, :category_id, presence: true
validates :status, inclusion: ["ongoing", "completed", "incomplete"]
validate :validate_end_date_before_start_date
validate :tix_price_can... |
require_relative '../../tictactoeruby.core/languages/message_generator.rb'
require_relative '../../tictactoeruby.core/exceptions/nil_reference_error.rb'
require_relative '../../tictactoeruby.core/exceptions/invalid_value_error.rb'
module TicTacToeRZ
module Validators
module PlayerSymbolValidator
SYMBOL_PA... |
module Spree
class Post < ActiveRecord::Base
belongs_to :category, inverse_of: :posts
belongs_to :author, inverse_of: :posts
belongs_to :variant
has_many :taggings, inverse_of: :post
has_many :tags, through: :taggings
has_many :post_relations, inverse_of: :post
has_many :related_posts, ... |
module Response
def json_response(relation:, status: :ok, is_collection: false)
render json: JSONAPI::Serializer.serialize(relation, is_collection: is_collection), status: status
end
end
|
require 'rails_helper'
RSpec.describe Address, :type => :model do
describe '#new' do
context 'Given a valid address' do
it 'can create a new address' do
expect(Address.new(
house_number: 1600,
street_name: 'Pennsylavnia',
... |
module PUBG
class Seasons
require "pubg/seasons/data"
require "pubg/seasons/links"
def initialize(args)
@args = args
end
def original
@args
end
def data
d = []
@args["data"].each do |data|
d << Data.new(data)
end
d
end
def links
... |
#!/usr/bin/env ruby
require 'fileutils'
require 'optparse'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'bluesky/version'
class String
def unindent
gsub /^#{self[/\A[ \t]*/]}/, ''
end
end
options = {}
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: \n bluesky new AP... |
require 'rails_helper'
RSpec.feature 'Sending notification by admin' do
before do
@admin = create(:admin)
@hr1 = create(:hr)
@hr2 = create(:hr)
@employee1 = create(:employee)
@employee2 = create(:employee)
login_as(@admin, scope: :admin)
end
scenario 'to all users' do
visit admin_pat... |
class Photo < ActiveRecord::Base
belongs_to :user
has_many :tags, autosave: true, dependent: :destroy
has_many :users, through: :tags
has_attached_file :the_photo, :styles => { :small => "100x100>", :original => "400x400>>" }
validates_attachment_presence :the_photo
validates_attachment_size :the_photo, :le... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# root 'pages#main'
# root 'landing_page#index', page: "home"
# root "pages#show", page: "home"
# root "static_pages#home"
# constraints Clearance::Constraints::SignedI... |
require 'rails_helper'
describe 'home page' do
it 'displays messages' do
visit '/'
expect(page).to have_css('.message', count: 1)
end
end |
class Route < ActiveRecord::Base
has_and_belongs_to_many :operators
has_and_belongs_to_many :ports
def name
Port.find(port_1_id).name + ' - ' + Port.find(port_2_id).name
end
end
|
class Choice < ActiveRecord::Base
belongs_to :question
has_many :response
end
|
# encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)
describe "Option" do
before :each do
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
end
describe "#exists?" do
bug "WTR-367", :watir do
it "returns true if the element exists (page context)" do
bug "... |
class CreateRentItems < ActiveRecord::Migration
def change
create_table :rent_items do |t|
t.references :rent_roll, index: true, foreign_key: true, null: false
t.string :unit_type
t.string :unit_name, null: false
t.integer :amount, null: false
t.timestamps null: false
end
e... |
class Computer
attr_accessor :memory, :inputs, :output, :ip, :relative_base
def initialize memory, inputs
@memory = Hash.new 0
# p memory.size
memory.each_with_index do |x, i|
@memory[i] = x
end
# p @memory
@inputs = inputs # List of input values
@phase = inputs.first
@ip = 0
... |
class Composite
def initialize(text)
@text = text
@left = nil
@right = nil
end
attr_reader :text
attr_accessor :left, :right
def accept(visitor)
visitor.visit_composite(self)
end
end
class DumpVisitor
def initialize
@stack = []
end
def visit_composite(node)
p node.text
@stack << node.right if no... |
require "test_helper"
describe UsersController do
before do
@work = Work.first
@user = User.first
end
describe "login" do
it "Lets user log in" do
perform_login
expect(session[:user_id]).must_equal @user.id
must_respond_with :redirect
must_redirect_to root_path
end
en... |
module TeachersPet
class Cli
option :organization, required: true
option :repository, required: true
students_option
common_options
desc 'delete_repos', "Delete students' assignment repositories."
def delete_repos
TeachersPet::Actions::DeleteRepos.new(options).run
end
end
end
|
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/validus/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Bob Nadler, Jr."]
gem.email = ["bnadlerjr@gmail.com"]
gem.description = %q{Valdations for Plain Old Ruby Objects.}
gem.summary = %q{Valdations for Plain O... |
# This file is used by Rack-based servers to start the application.
# Redirect all requests for wwww.*mallowapp.com to *mallowapp.com.
require 'rack-rewrite'
use Rack::Rewrite do
r301 /.*/, Proc.new { |path, rack_env| "http://#{rack_env['SERVER_NAME'].gsub(/www\./i, '') }#{path}" }, :if => Proc.new { |rack_env| rack... |
require "rails_helper"
RSpec.describe User, type: :model do
context "validation test" do
it "ensures first name presence" do
user = User.new(email: "rspec").save
expect(user).to eq(false)
end
it "ensures first name presence" do
user = User.new(email: "rspec", encrypted_password: "rspec... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.