text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe Skill, type: :model do
it 'must be valid' do
skill = create(:skill)
expect(skill).to be_valid
end
it 'must be invalid' do
skill = build(:skill, name: nil)
expect(skill).not_to be_valid
expect(-> { create(:skill, name: nil) }).to raise_error
end
it... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
phpver = 70
httpport = 80
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
# config.vm.box_check_update = false
# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: ... |
class FingerService
attr_reader :feed_data
def initialize(target)
@target = target
@feed_data = FeedData.new
end
def finger!
# TODO: ensure caching of finger lookup.
data = FingerData.new(Redfinger.finger(@target))
@feed_data.url = data.url
@feed_data.finger_data = data... |
require 'rails_helper'
RSpec.describe Item, type: :model do
describe "creation" do
context "valid attributes" do
it "should be valid" do
item = FactoryGirl.build(:car)
expect(item).to be_valid
end
end
context "invalid attributes" do
it "should not be valid" do
i... |
# frozen_string_literal: true
class AddColumnToGiver < ActiveRecord::Migration[5.0]
def change
add_column :givers, :title, :string, after: :giver_category
add_column :givers, :type, :string, after: :giver_category
add_column :givers, :class, :string, after: :giver_category
end
end
|
FactoryGirl.define do
factory :photo do
gallery_id 0
image { build(:photo_image) }
link { Faker::Internet.url }
trait :with_gallery do
gallery { build(:gallery) }
end
end
end
|
class Tournament::Result
def initialize( entries )
@entries = entries.to_ary
@entries.each_with_index { |e,i | e.number = i + 1 }
d = @entries.size
@score_table = Array.new(d) { Array.new(d, 0) }
@score_table.each_with_index do |row, i|
(0...d).each do |j|
next if i == j
row[... |
require "test_helper"
describe Merchant do
let(:merchant) { merchants(:fred) }
it "must be valid" do
expect(merchant).must_be :valid?
end
describe "validations" do
it "requires a name" do
merchant = merchants(:fred)
merchant.name = nil
valid = merchant.save
expect(valid).mus... |
class Admin::AvailabilityReportsController < Admin::BaseController
before_action :load_shelter
def new
@report = @shelter.availability_reports.new
end
def create
@shelter.availability_reports.create(:number_of_beds => params[:availability_report][:number_of_beds])
redirect_to admin_shelters_path
... |
class Photo < ApplicationRecord
enum license: [:copyright, :copyleft, :creative_commons]
enum visibility: [:pub, :pri]
validates :name, :url, :user_id, presence: true
validates :license, inclusion: { in: Photo.licenses }
validates :visibility, inclusion: { in: Photo.visibilities }
validates_with PhotoValid... |
# Algorithm: Heap-Sort
# Time-Complexity: O(nlogn)
def heap_sort(array)
array_size = array.size
adjusted_array = [nil] + array
(array_size / 2).downto(1) do |i|
adjusted_down(adjusted_array, i, array_size)
end
while array_size > 1
adjusted_array[1], adjusted_array[array_size] = adjusted_array[array_si... |
# frozen_string_literal: true
RSpec.describe 'Search Request', type: :request do
include_context 'with branch location'
include_context 'with user token'
include_context 'with json response'
subject(:search!) { get "/api/search/#{keyword}", headers: headers }
let(:keyword) { SecureRandom.hex }
context '... |
class Entrytag < ApplicationRecord
belongs_to :tag
belongs_to :entry
accepts_nested_attributes_for :tag
end
|
FactoryBot.define do
sequence(:content_en) {|n| "Some english contenet\n, number #{n}"}
sequence(:content_sv) {|n| "Lite svenskt innehåll\n, nummer #{n}"}
sequence(:link) {|n| "https://tlth.se/url#{n}"}
sequence(:slug) {|n| "slug#{n}"}
sequence(:title_en) {|n| "Title number #{n}"}
sequence(:title_sv) {|n| "... |
#State notetag: <damage_var: variable id>
module Dhoom
module REGEXP
module State
DAMAGE_VAR = /<(?:damage_var|DAMAGE_VAR):[ ]*(\d+)>/i
end
end
end
class RPG::State < RPG::BaseItem
attr_reader :damage_var
def load_notetags_damage_var
self.note.split(/[\r\n]+/).each { |line|
case... |
require 'rails_helper'
RSpec.describe LinksController, type: :controller do
let(:user) { create(:user) }
let!(:question) { create(:question, user: user) }
let!(:link) { create :link, name: 'link_name', url: 'https://thinknetica.teachbase.ru/', linkable: question }
let(:another_user) { create(:user) }
descr... |
class AddThumbnailToPartnerService < ActiveRecord::Migration[5.0]
def change
add_column :partner_services, :thumbnail, :text
end
end
|
=begin
Tests d'intégration de l'action "log" d'administration impossible quand
on n'est pas administrateur.
Cas : Online - Simple User
=end
require 'spec_helper'
describe "Logs sans être administrateur" do
before(:each) do
TI::set_online
TI::as_simple_user
end
let(:page){ TI::goto("admin/log?log=conne... |
class Alien
attr_accessor :position
def move(axis)
alien_index = axis.index(@position)
@position =
if rand(2).even?
alien_index == 15 ? '1.5' : axis[alien_index + 1]
else
alien_index == 0 ? '0.1' : axis[alien_index - 1]
end
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
#facebook helpers
def get_user_city
@current_user ||= User.find(session[:user_id]) if session[:user_id]
graph = Koala:... |
require 'rails_helper'
RSpec.describe "Wants", type: :system do
let(:users) { create_list(:user, 6) }
let(:item_a) { create(:item, name: "プロを目指す人のためのRuby入門 言語仕様からテスト駆動開発・デバッグ技法まで (Software Design plusシリーズ) [ 伊藤淳一(プログラミング) ]") }
let(:item_b) { create(:item, name: "現場で使える Ruby on Rails 5速習実践ガイド [ 大場寧子 ]") }
l... |
class Dojo < ActiveRecord::Base
validates :branch, :street, :city, :state, presence: true # check if all is included
validates :state, length: { is: 2 } # check state is only 2 characters
has_many :students # relations ALWAYS ADD
before_validation :upper_state # before any other validations, check if st... |
MOVEMENTS = INPUT.split(",")
VECTORS = {
"n" => [0, 1, -1],
"ne" => [1, 0, -1],
"se" => [1, -1, 0],
"s" => [0, -1, 1],
"sw" => [-1, 0, 1],
"nw" => [-1, 1, 0]
}.freeze
def distance(x, y, z)
(x.abs + y.abs + z.abs) / 2
end
x = 0
y = 0
z = 0
max = 0
MOVEMENTS.each do |movement|
motion = VECTORS[movement... |
#encoding: utf-8
class Product < ActiveRecord::Base
has_many :sale_prod_relations
has_many :res_prod_relations
has_many :station_service_relations
has_many :order_prod_relations
has_many :pcard_prod_relations
has_many :prod_mat_relations
has_many :svcard_prod_relations, :dependent => :destroy
belongs_to... |
class NotesController < ApplicationController
before_action :authenticate_user!
def index
@project = Project.find(params[:project_id])
@project.notes
end
def new
end
def create
@project = Project.find(params[:project_id])
@project.notes.create(note_params.merge(user: current_user))
r... |
class AddUniqueconstraintsToVisits < ActiveRecord::Migration
def change
add_index :visits, [:dal, :al, :visitor_id], unique: true
end
end
|
class DocumentationsController < ApplicationController
include Searchable
expose :documentations, -> { search(@active_company.documentations.includes_associated, sortable_fields) }
expose :documentation, id: ->{ params[:slug] }, scope: ->{ @active_company.documentations.includes_associated }, find_by: :slug
#... |
class ListsController < ApplicationController
before_action :authenticate_user!, except: [:index]
before_action :correct_user, only: [:show, :update, :destroy]
def index
@lists = current_user.lists if current_user
end
def show
respond_to do |format|
format.html { redirect_to root_path }
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
# Require YAML module
require 'yaml'
common=nil
... |
class PaymentsController < ApplicationController
before_action :set_payment, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@payments = Payment.all
respond_with(@payments)
end
def show
respond_with(@payment)
end
def new
@payment = Payment.new
respond_with(@payme... |
require 'spec_helper'
describe Debit do
subject { build(:debit) }
it { should be_valid }
let(:debit){ build(:debit) }
describe "validations" do
it "should not permit positive debits" do
debit.amount = 11.00
debit.should_not be_valid
end
it "must require an accompanying credit" d... |
class PassWagon < Wagon
def initialize(volume)
super(:pass, volume)
end
def load
raise 'No free places!' if @filled == @volume
super(1)
end
end
|
module Mutations
DeleteEntry = GraphQL::Relay::Mutation.define do
name "DeleteEntry"
input_field :entry_id, !types.ID
return_field :entry_id, !types.ID
return_field :pool, !Queries::PoolType
resolve ->(inputs, _context) do
entry = Queries::NodeIdentification.object_from_id(inputs[:entry_i... |
require 'colorize'
class Game
attr_reader :comp_board, :player_board
attr_accessor :comp_ships, :player_ships
def initialize(comp_board, player_board)
@comp_board = comp_board
@player_board = player_board
@comp_ships = {}
@player_ships = {}
end
def place_all_comp_ships
@comp_ships.keys.... |
require_relative '../spec_helper'
describe StartGame do
let(:str) { "e4\ne5\nNf3" }
let(:start_game) { StartGame.new(str) }
describe "#new" do
it "works" do
expect(start_game).to be_an_instance_of StartGame
end
end
describe "#call" do
it "starts the game" do
expect { start_game.call... |
# encoding: UTF-8
module API
module Helpers
module V1
module GamePollsHelpers
extend Grape::API::Helpers
def serialized_game_poll(game_poll, options = {})
options = { serializer: :game_poll }.merge(options)
serialized_object(game_poll, options)
end
end
... |
class Instructor::LessonsController < ApplicationController
# Make sure the user is logged in first
before_action :authenticate_user!
before_action :require_authorized_for_current_section
def new
# Build a blank lesson to flesh out
@lesson = Lesson.new
end
def create
# Create the lesson i... |
class HomeController < ApplicationController
before_filter :default_currency, only: :index
def index
if params[:query].present?
colors = params[:query][:colors].nil? ? Color.pluck(:name) : params[:query][:colors]
sizes = params[:query][:sizes].nil? ? Size.pluck(:name) : params[:query][:sizes]
... |
class SalesController < ApplicationController
load_and_authorize_resource :except => [:create, :new]
def index
if params[:search].present?
@sales = Sale.near(params[:search], 30, :order => :distance)
@markers = Sale.date_sort.to_gmaps4rails
else
#@sales = Sale.all
@sales = Sale.order('da... |
require 'thread'
require 'snmp2mkr/host'
require 'snmp2mkr/vhost'
module Snmp2mkr
class HostManager
def initialize(persist_file: nil)
@lock = Mutex.new
@host_id_lock = Mutex.new
@hosts = {}
@vhosts = {}
@persist_file = persist_file
if @persist_file && File.exist?(@persist_fi... |
module Mirren
class Error < StandardError
end
class JsonError < Error
def initialize(value)
super("Error handling JSON: #{value}")
end
end
class ClientError < Error
def initialize(value)
super("Client error: #{value}")
end
end
class ApiError < Error
def initialize(messag... |
# frozen_string_literal: true
require 'sinatra/base'
require 'jiji/web/services/abstract_service'
module Jiji::Web
class InitialSettingService < Jiji::Web::AbstractService
options '/initialized' do
allow('GET,OPTIONS')
end
get '/initialized' do
ok(initialized: security_setting.password_set... |
class AddWikipediaToGenerics < ActiveRecord::Migration[5.0]
def change
add_column :generics, :wikipedia_page_url, :string
add_column :generics, :wikipedia_summary, :text
add_column :generics, :wikipedia_image_urls, :string
add_column :generics, :wikipedia_links, :string
add_column :generics, :wiki... |
class CreateSplits < ActiveRecord::Migration
def change
create_table :splits do |t|
t.string :name
t.integer :distance_from_start
t.integer :sub_order
t.timestamps null: false
end
end
end
|
require_relative '../puzzle'
describe Puzzle do
describe ".check_number" do
it "returns 'oi' if number is multiple of 4" do
number = Puzzle.check_number(16)
expect(number).to eq 'oi'
end
it "returns 'ay' if number is multiple of 5" do
number = Puzzle.check_number(25)
expect(numb... |
class BlogsController < ApplicationController
def index
@blogs= Blog.all
end
def new
@blog = Blog.new
end
def edit
@blog =Blog.find(params[:id])
end
def create
@blog = Blog.new(blog_params)
if @blog.save
redirect_to @blog
else
render 'new'
end
end
def update
@blog =Blog.find(params[:id])
if @blo... |
class AdminSetup::QuestionController< ApplicationController
skip_before_action :require_login
def new
end
def index
@questions = Question.all
end
def create
@poll = Poll.new(poll_params)
choices_param = params[:choices]
@choices = []
c... |
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
setup do
@user = users :michael
@article = articles :sample_article
@comment = comments :sample_comment
end
test 'should be valid' do
assert @comment.valid?, "#{@comment.errors.messages}"
end
test 'should not be blank' do
... |
class Ip < ActiveRecord::Base
belongs_to :whitelist
validates_presence_of :address
validate :valid_ip, on: [:create, :update]
private
def valid_ip
errors.add(:address, "invalid ip address") if (IPAddr.new(self.address) rescue nil).nil?
end
end
|
# frozen_string_literal: false
class Game
attr_reader :player1, :player2, :play_column
attr_accessor :game_board, :next_move, :game_over
def initialize
@player1 = 'ß'
@player2 = '₴'
@next_move = [1, 2].sample
@game_board = GameBoard.new
@game_over = 0
end
def update_which_player_has_nex... |
directory "#{Chef::Config[:file_cache_path]}/private"
aws_kms 'default' do
crypt_folder "#{Chef::Config[:file_cache_path]}/cookbooks/custom_resource_test/files/crypt"
decrypt_folder "#{Chef::Config[:file_cache_path]}/private"
action :decrypt
# DO NOT DO THIS! This is for testing. It's pretty much a terrible id... |
class Device < ActiveRecord::Base
attr_accessible :platform, :registration_id, :version
belongs_to :user
validates_presence_of :user_id
end
|
class AddRegisteredOnToEntities < ActiveRecord::Migration
def self.up
add_column :entities, :registered_on, :date, :default => nil
end
def self.down
end
end
|
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.belongs_to :circle
t.belongs_to :user
t.datetime :time
t.float :latitude
t.float :longitude
t.integer :pace
t.text :notes
t.boolean :complete
t.float :min_amt
t.integer :... |
class User < ApplicationRecord
has_secure_password
has_many :recipes, foreign_key: :creator_id
has_many :ratings
validates :username, :email, presence: true, uniqueness: true
end
|
class User < ApplicationRecord
validates :username, :password_digest, :session_token, presence: true
def self.find_by_credentials(username, password)
u = User.find_by(username: username)
p = Bcrypt::Password.new(u.password_digest.to_s)
up = Bcrypt::Password.is_password(p)
if p
return u
... |
# frozen_string_literal: true
module Knuckles
module Stages
# After un-cached models have been hydrated they can be rendered. Rendering
# is synonymous with converting a model to a hash, like calling `as_json`
# on an `ActiveRecord` model. Knuckles provides a minimal (but fast) view
# module that can... |
class Whisper < DebianFormula
homepage 'http://launchpad.net/graphite'
url 'https://github.com/tmm1/graphite.git', :tag => '60287e0'
arch 'all'
name 'whisper'
version '0.9.9-pre2'
section 'python'
description 'database engine for fast, reliable fixed-sized databases'
build_depends 'python'
depends '... |
require "rubygems"
require "redis"
class Fixnum
def second
self
end
alias :seconds :second
def minute
60.seconds*self
end
alias :minutes :minute
def hour
60.minutes*self
end
alias :hours :hour
def day
24.hours*self
end
alias :days :day
def week
7.days*self
end
alias :w... |
module SimpleCov
module Formatter
class ShieldFormatter
VERSION = '0.1.0'.freeze
end
end
end
|
require 'bigdecimal'
module SqlPostgres
# Translation functions. These are internal and should not be used
# by clients unless you want extra work when they change.
module Translate
# Turn a Ruby object into an SQL string.
#
# The conversion depends upon the type of thing:
#
# [[String, .... |
require_dependency "consult_management/application_controller"
module ConsultManagement
module Susanoo
module Admin
class ConsultCategoriesController < ApplicationController
before_action :admin_required
before_action :set_new_consult_category, only: [:index, :cancel]
before_action ... |
module Racc
# DSL for defining a grammar in code, rather than using a grammar file
module DSL
def self.define_grammar(&block)
env = DefinitionEnv.new
env.instance_eval(&block)
env.grammar
end
# Methods are DSL 'keywords' which can be used in a `define_grammar` block
#
# Key me... |
# frozen_string_literal: true
class AddReferenceToUserInLoginCreds < ActiveRecord::Migration[6.1]
def change
add_reference :login_creds, :user, foreign_key: true
end
end
|
# -*- coding: utf-8 -*-
require 'spec_helper'
describe 'issue202' do
before do
@ben7th = User.create(
:name => 'ben7th',
:email => 'ben7th@sina.com',
:password => '123456'
)
@dir_media_resource = MediaResource.create(
:name => '我是目录',
:is_dir => true,
... |
Deface::Override.new(virtual_path: "spree/admin/shared/_product_tabs",
name: "add_sale_prices_tab",
insert_bottom: "[data-hook='admin_product_tabs']",
partial: 'spree/admin/sale_prices/product_tab',
disabled: false)
|
require 'test_helper'
class MinecraftServerLogMonitorTest < ActiveSupport::TestCase
def setup
Preference.path_to_server = "#{Rails.root}/tmp"
end
def test_perform
adapter_type = ActiveRecord::Base.connection.adapter_name.downcase.to_sym
status_select = case adapter_type
when :sqlite
moni... |
class AddColumnSectionsFile < ActiveRecord::Migration
def change
add_column :sections, :file, :string, null: false
end
end
|
require "./spec/spec_helper.rb"
require_relative "web_helpers"
feature 'Enter names' do
scenario 'submitting names' do
sign_in_and_play
expect(page).to have_content 'Bob vs Marley!!'
end
end
feature 'See Hit Points' do
scenario 'seeing points of Player 2'do
sign_in_and_play
e... |
class Relationship < ActiveRecord::Base
belongs_to :follower, class_name: "User"
belongs_to :followed, class_name: "User"
validates :follower_id, presence: true
validates :followed_id, presence: true
validate :must_be_able_to_follow
validates_uniqueness_of :follower, scope: :followed
def must_be_able_to_follow
... |
#Fedena
#Copyright 2011 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the ... |
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module EvolutionSimulation
module Swimmer
Vision = Struct.new(:angle, :distance, :eyes)
class Swimmer < Evolution::Organism
... |
require 'json'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'nexus', 'config.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'nexus', 'exception.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '... |
class Manager < ApplicationRecord
has_many :companies, dependent: :destroy
has_many :employees, through: :companies
has_secure_password
validates :username, :firstName, :lastName, :password, :email, presence: true
validates :username, :email, uniqueness: true
validates :password, length: {in: 6... |
require 'tax_cloud/response/response_base'
require 'tax_cloud/tic'
module TaxCloud
class GetTICsResponse < ResponseBase
def initialize(attrs = {})
@raw_tics = attrs[:ti_cs]
super
end
def tics
@tics ||= parse_tics(@raw_tics)
end
protected
def parse_tics(raw_tics)
if ... |
control "M-2.1" do
title "2.1 Ensure network traffic is restricted between containers on
the\ndefault bridge (Scored)"
desc "
By default, all network traffic is allowed between containers on the same
host on the
default network bridge. If not desired, restrict all the inter-container
communication. Link
... |
class Comment < ApplicationRecord
belongs_to :user
belongs_to :gossip
validates :content,presence: true
validates :user_id,presence: true
validates :gossip_id,presence: true
end
|
module Url
extend self
def follow(url, hop = 0)
return url if hop == 5
r = RestClient.get(url){|r1,r2,r3|r1}
return follow(r.headers[:location], hop + 1) if r.code > 300 && r.code != 304 && r.code < 400
return url if r.code == 200 || r.code == 304
rescue
return url
end
def get_youtube_url(url... |
require_relative './input'
require_relative './operator_lookup'
require_relative './command_lookup'
require_relative './language'
require_relative './message_printer'
# Well, it's a REPL! Handles inputs and printing, repeatedly.
class REPL
attr_reader :calculator
def initialize(calculator)
@calculator = cal... |
class RemoveFlags < ActiveRecord::Migration
def change
drop_table :flags
end
end
|
module Admins
module Campaigns
class SendReminder < Operation
def process
send_mail
result.new('Mails have been sent to all participants')
end
private
def campaign
@campaign ||= Campaign.find(params[:id])
end
def result
Struct.new(:message)
... |
# Modules are collection of methods, constants and variable which can be shared in multiple calsses
# We cannot instanciate module.
# Use module as namespace
module Cold
class Planet
def name
'Pluto, Uranus'
end
end
end
module Hot
class Planet
def name
'Mercury, venus'
end
end
end... |
require 'byebug/command'
require 'irb'
module Byebug
#
# Enter IRB from byebug's prompt
#
class IrbCommand < Command
def regexp
/^\s* irb \s*$/x
end
def execute
unless @state.interface.is_a?(LocalInterface)
return errmsg(pr('base.errors.only_local'))
end
IRB.start(... |
module Roglew
#classes/modules that include BaseContextModule must implement methods #bind and #unbind
module BaseContextModule
module ClassMethods
def immediate_module(mod)
raise ArgumentError, 'not a module' unless mod.is_a?(Module)
@immediate_mod = mod
end
def defe... |
class CreateOrderMeals < ActiveRecord::Migration[6.0]
def change
create_table :order_meals do |t|
#t.integer :meal_id
t.integer :amount
t.belongs_to :order
t.belongs_to :meal
t.timestamps
end
end
end
|
require_relative '02_searchable'
require 'active_support/inflector'
# Phase IIIa
class AssocOptions
attr_accessor(
:foreign_key,
:class_name,
:primary_key
)
def model_class
class_name.constantize
end
def table_name
class_name.downcase + "s"#.pluralize
end
end
class BelongsToOptions <... |
class Answer < ActiveRecord::Base
attr_accessible :rating, :comment, :question_id
belongs_to :solution
belongs_to :question
validates :rating, :numericality => { :greater_than => 0,
:less_than => 6,
:message => "is not an integer ... |
# encoding: utf-8
namespace :rent do
desc 'Veritabanı sıfırla'
task :db_build => ['db:drop', 'db:create', 'db:migrate', 'db:seed']
desc 'günlük 00:01 de çalışacak görev'
task :daily_task => :environment do
# bir önceki güne ait kullanıcı işlemlerini yönetime mail gönder
PostOffice.daily_actions.deliv... |
require 'rails_helper'
RSpec.describe Commit, type: :model do
describe "ingest" do
before do
@commit_data = Hashie::Mash.new({
sha: '1234abc',
author: { username: 'test-user' },
timestamp: DateTime.now.iso8601,
message: '[Fixes #10] test message'
})
end
it "u... |
class CreateHolidays < ActiveRecord::Migration[5.1]
def change
create_table :holidays do |t|
t.belongs_to :company, index: true
t.string :event_name
t.date :holiday_date
t.boolean :special_or_not, default: false
t.timestamps
end
end
end
|
require 'optparse'
class TestLsParser
def parse_args(args)
options = {}
parser = OptionParser.new do |opts|
opts.banner = "Usage: mobcli test ls [options]. It lists all the unit tests in the JUnit XML report."
opts.on("--path [PATH]", "List the JUnit tests the have failed based on JUnit XML rep... |
class RemoveColumnFromUser < ActiveRecord::Migration
def change
remove_column :users, :first_name
remove_column :users, :last_name
remove_column :users, :home_phone
remove_column :users, :cell_phone
remove_column :users, :work_phone
remove_column :users, :address
end
end
|
require 'git'
require 'docker'
module BuildSpecRunner
# Module for building the default AWS CodeBuild images. See {DefaultImages.build_image}
module DefaultImages
# The default directory used to clone the AWS CodeBuild Images repo
REPO_PATH = '/tmp/build_spec_runner/'
# The default CodeBuild Dockerf... |
require 'spec_helper'
describe 'Braintree::ClientToken.generate' do
it 'includes expected encoded fields' do
raw_client_token = Braintree::ClientToken.generate
client_token = decode_client_token(raw_client_token)
regex = /\Ahttp:\/\/localhost:\d+\/merchants\/[^\/]+\/client_api\Z/
expect(client_token... |
FactoryGirl.define do
factory :deploy_log do
deployer "deployer_1"
tag "1"
application "bakery"
environment "production"
end
end |
class AccountsController < ApplicationController
before_filter :authenticate_user!
before_filter :administrator!, :except => [:edit, :update]
def index
if current_user.administrator
@users = User.order('last_name ASC, last_name IS NULL')
else
@users = [current_user]
end
end
def n... |
# encoding: utf-8
class Sanitize
VERSION = '3.1.0'
end
|
require 'rails_helper'
RSpec.describe Comment, type: :model do
let(:post) {
Post.create!(title: 'a title', content: 'and some content')
}
subject { post.comments.new }
it "create" do
subject.update_attributes(content: 'and some content')
expect(subject).to be_valid
end
it "validates" do
... |
module Authentication
def authenticated_as user=nil, &block
context "when user is logged in" do
let(:current_user) do
if user.nil?
FactoryGirl.create :user
else
send(user)
end
end
before do
request.headers["Authorization"] = "Token token=\"#{c... |
class ReservationsController < ApplicationController
def index
@listings = current_user.listings
end
def reserve_spot
@spot = Spot.find(params[:id])
end
def confirm_spot
@spot = Spot.find(params[:spot_id])
@listing = Spot.find(params[:listing_id])
@reservation = Reservation.new
@rese... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.