text stringlengths 10 2.61M |
|---|
###########################################
# tc_sound.rb
#
# Test suite for the win32-sound package.
############################################
base = File.basename(Dir.pwd)
if base == "test" || base =~ /win32-sound/
Dir.chdir("..") if base == "test"
$LOAD_PATH.unshift Dir.pwd + '/lib'
Dir.chdir("test"... |
require 'spec_helper'
describe Entry do
it { should have_many(:tasks).through(:entry_tasks) }
it { should have_many(:entry_tasks) }
it { should belong_to(:user) }
[:date_of_service,:duration_of_service,:group_size].each do |m|
it { should validate_presence_of(m) }
end
end
|
require 'csv_row_model/concerns/attributes_base'
require 'csv_row_model/concerns/import/parsed_model'
require 'csv_row_model/internal/import/attribute'
module CsvRowModel
module Import
module Attributes
extend ActiveSupport::Concern
include AttributesBase
include ParsedModel
# Mapping of... |
require 'rails_helper'
RSpec.describe Team, :type => :model do
let(:team) {create(:team)}
let(:team_with_4) {create(:team_with_4_users)}
it 'should have valid factories' do
expect(
create(:team)
).to be_valid
expect(
create(:team_with_4_users)
).to be_valid
end
describe 'class' do
it 'should be... |
#!/usr/bin/env ruby
#
# Prime permutations
# http://projecteuler.net/problem=49
#
# The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases
# by 3330, is unusual in two ways: (i) each of the three terms are prime, and,
# (ii) each of the 4-digit numbers are permutations of one another.
#
# There... |
class DataTypesController < ApplicationController
before_filter :authenticate_user!
before_action :set_data_type, only: [:show, :edit, :update, :destroy]
# GET /data_types
# GET /data_types.json
def index
data_types_scope = DataType.current
@data_types = data_types_scope.search_by_terms(parse_search_... |
require 'rails_helper'
RSpec.describe Reservation, type: :model do
context "validations" do
it { should validate_presence_of(:start_date) }
it { should validate_presence_of(:end_date) }
end
context "can calculate total for nights in stay" do
it "calculates correctly" do
space = create(:space)
... |
class AddLanguagesToTeamReportSettings < ActiveRecord::Migration[4.2]
def change
RequestStore.store[:skip_rules] = true
Team.find_each do |team|
settings = team.settings || {}
settings = settings.with_indifferent_access
if settings.has_key?('disclaimer') || settings.has_key?('introduction')... |
namespace :ab do
desc "A notification email to remind a user about the annual fee"
task annual_fee_reminder_email: :environment do
CardAccount::SendAnnualFeeReminder.()
end
end
|
class SearchController < ApplicationController
def index
if params[:screen_name].blank?
flash[:search_form_message] = 'Please enter a Twitter handle'
redirect_to root_path and return if params[:screen_name].blank?
end
redirect_to user_path(:id => params[:screen_name])
end
end
|
# frozen_string_literal: true
require 'tempfile'
require 'nice_hash'
require 'yaml'
require 'tilt/erubi'
require 'erubi/capture_end'
require 'json'
require 'pathname'
require 'fileutils'
require 'etc'
module TemplateCLI
# Main application
class App # rubocop:disable Metrics/ClassLength
TASKS = {
generat... |
class Cart < ActiveRecord::Base
ECO_TAX = 2
has_many :line_items, dependent: :destroy
def add_product(product_id, quantity)
current_item = line_items.find_by(product_id: product_id)
if current_item
quantity ||= 1
current_item.quantity += quantity.to_i
else
current_item = line_items.... |
require_relative 'db_connection'
require 'active_support/inflector'
require "byebug"
# NB: the attr_accessor we wrote in phase 0 is NOT used in the rest
# of this project. It was only a warm up.
class SQLObject
attr_reader :cols
def self.columns
res = []
var = self.table_name
if @cols.nil?
@cols = ... |
class PasswordsController < Devise::PasswordsController
authorize_resource :class => false
skip_before_filter :verify_authenticity_token, :only => [:create, :update]
def create
self.resource = User.find_by_email(resource_params['email'])
yield resource if block_given?
@token = resource.se... |
class Billiard
def initialize(width, depth, ball_radius)
@width = width .to_f
@depth = depth .to_f
@ball_radius = ball_radius.to_f
end
def shoot(x0, y0, theta0, shot_length)
x0 = x0 .to_f
y0 = y0 .to_f
theta0 = theta0 .to_f... |
Gem::Specification.new do |s|
s.name = 'kashflow_soap'
s.version = '0.0.3'
s.date = '2015-10-07'
s.authors = ["Ed Clements","Stephan Yu","Nicola Ferri"]
s.summary = "A Savon wrapper for the KashFlow accounting software API"
s.email = "ed.clements@gmail.com"
s.files = ["lib/kashflow_soap.rb"]
s.license =... |
class ManageIQ::Providers::Vmware::CloudManager::OrchestrationTemplate < OrchestrationTemplate
def parameter_groups
# Define vApp's general purpose parameters.
groups = [OrchestrationTemplate::OrchestrationParameterGroup.new(
:label => "vApp Parameters",
:parameters => vapp_parameters,
)]... |
class BestHand
def self.process(hand, deck)
hand.sort!
results = []
(0..deck.length).each do |time|
hand.combination(hand.length - time).each do |combination|
new_hand = combination | deck[0...time]
results << HandAnalyzer.analyze(new_hand)
end
end
results.sort_by(&:va... |
class FbInvoicesController < ApplicationController
# GET /fb_invoices
# GET /fb_invoices.xml
def index
@fb_invoices = FbInvoice.find_by_id '(firma = 399)'
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @fb_invoices }
end
end
# GET /fb_invoices/1
# ... |
FactoryBot.define do
factory :fe_navigation, class: DataModules::FeNavigation::FeNavigation do
area { 'dresden' }
factory :fe_navigation_with_items, class: DataModules::FeNavigation::FeNavigation do
transient do
entry_count { 2 }
end
after(:create) do |navigation, evaluator|
... |
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
self.rank = rank
self.suit = suit
end
def output_card
puts "#{self.rank} of #{self.suit}"
end
def self.random_card
Card.new(rand(10), :spades)
end
end
card = Card.new
|
require_relative '../feature_spec_helper'
describe "admin", type: :feature do
it "is redirected to the admin dashboard upon loggin in" do
user = FactoryGirl.create :user, :admin
visit '/login'
fill_in "email address", with: user.email
fill_in "password", with: user.password
click_button "Login"... |
# Table class
class Table
# The width of the table
attr_reader:width
# The height of the table
attr_reader:height
# Initialize the table with width and height (in units).
# ====== Parameters
# - +width+:: the width of the table
# - +height+:: the height of the table
def initialize(width, height)
... |
describe Pantograph::Actions::GitBranchAction do
describe "with no CI set ENV values" do
it "gets the value from Git directly" do
# expect(Pantograph::Actions::GitBranchAction).to receive(:`)
# .with(Pantograph::Helper::Git.current_branch)
# .and_return('branch-name')
result = Pantogr... |
$LOAD_PATH << "#{File.dirname(__FILE__)}/idcbatch"
module Idcbatch
require "idcbatch/ad"
require "idcbatch/hrsys"
require "idcbatch/read_config"
IDCBATCHVERSION = "1.2"
def self.version
IDCBATCHVERSION
end
end
|
class Target < ActiveRecord::Base
belongs_to :discussion
belongs_to :targetable, polymorphic: true
validates :discussion, presence: true
validates :targetable, presence: true
after_destroy :remove_discussion, if: -> { discussion.targets.count == 0 }
private
def remove_discussion
discussion.destroy... |
class AddGridsMattersRelationship < ActiveRecord::Migration
def up
create_table :grids_matters do |t|
t.references :grid, :matter
end
end
def down
drop_table :grids_matters
end
end
|
Wcf3::Application.routes.draw do
resources :test_planes do as_routes end
resources :teams do as_routes end
resources :major_element do as_routes end # as_routes = ActiveScaffold routes
resources :minor_element do as_routes end
resources :reference_author do as_routes end
# get "users/show"
# get "use... |
#! /usr/local/bin/ruby
require 'open3'
require 'docker'
sizelists = Hash.new()
childlists = Hash.new() { |h,k| h[k]=[] }
parents = {}
dot_file = []
dot_file << 'digraph docker {'
Docker::Image.all(all: true).each do |image|
id = image.id[0..11]
tags = image.info['RepoTags'].reject { |t| t == '<none>:<none>' }.j... |
# frozen_string_literal: true
require 'spec_helper'
module Uploadcare
module Client
RSpec.describe FileClient do
subject { FileClient.new }
describe 'info' do
it 'shows insider info about that file' do
VCR.use_cassette('rest_file_info') do
uuid = '2e17f5d1-d423-4de6-8e... |
# frozen_string_literal: true
class DrinkLike < ApplicationRecord
belongs_to :user
belongs_to :drink
validates_uniqueness_of :drink_id, scope: :user_id
end
|
module BillHelper
def bill_period(place=:from)
date_string(bill[:statement][:period][place])
end
def currency(number)
number_to_currency(number, unit: '£')
end
def date_string(string)
Date.parse(string).strftime('%d %b')
end
def rental_charge_total
bill[:sky_store][:rentals].sum { |rent... |
require 'spec_helper'
module Ttycaca
describe Terminal do
let (:terminal) { Terminal.new }
describe "#width" do
it "should return a positive integer" do
expect(terminal.width).to be > 0
end
end
describe "#height" do
it "should return a positive integer" do
expect(t... |
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
setup do
@comment = comments(:one)
end
def sign_in
request.headers['Authorization'] = ActionController::HttpAuthentication::Basic.
encode_credentials('dhh', 'secret')
end
test "should create comment" do
assert... |
#!/usr/bin/env ruby
# ARTML Copyright (c)2004 Thomas Sawyer
require 'getoptlong'
require 'artml'
if $0 == __FILE__
opts = GetoptLong.new(
[ "-h", "--help", GetoptLong::NO_ARGUMENT ],
[ "-v", "--verbose", GetoptLong::NO_ARGUMENT ],
[ "-d", "--debug", GetoptLong::NO_ARGUMENT ],
[ "-p", "--preprint",... |
class AddLearnFieldToDocumentations < ActiveRecord::Migration[5.1]
def change
add_reference :documentations, :learn_field, foreign_key: true
end
end
|
require 'spec_helper'
describe 'unattended_upgrades' do
let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
let(:file_options) { '/etc/apt/apt.conf.d/10options' }
context 'with defaults on Raspbian' do
let(:facts) do
{
... |
class DeploymentsController < ApplicationController
def create
project = current_user.projects.find(params[:project_id])
@deployment = project.deployments.build
if @deployment.save
DeploymentJob.perform_later(@deployment.id)
render action: :show
else
flash[:error] = 'Ooops! Somethin... |
require "httplog/extensions/replacers/base_replacer"
module Extensions
module Replacers
class HalfReplacer < BaseReplacer
def replace(value)
value = value.to_s
fch = filtered_characters(value)
filtered_value * fch + value.to_s.slice(fch...value.length)
end
private
... |
# encoding: utf-8
module Antelope
module Generation
class Constructor
# Contains the methods to determine if an object is nullable.
module Nullable
# Initialize.
def initialize
@nullifying = Set.new
end
# Determine if a given token is nullable. This is ho... |
class ArticlesController < ApplicationController
def create
@article = current_user.articles.new(article_params)
if @article.save
render json: { success: "successfully created" }, status: :ok
else
render json: { error: @article.errors.messages.map { |msg, desc| msg.to_s + " " + desc[0] }.join... |
class SignupLink < ActiveRecord::Base
attr_accessible :key, :user_id
belongs_to :user
validates :key, :user_id, presence: true
before_validation :create_key, :unless => Proc.new { |model| model.persisted? }
def link
if Rails.env.development?
host = "http://127.0.0.1"
else
host = "http:... |
require 'test_helper'
class PaistsControllerTest < ActionDispatch::IntegrationTest
setup do
@paist = paists(:one)
end
test "should get index" do
get paists_url
assert_response :success
end
test "should get new" do
get new_paist_url
assert_response :success
end
test "should create p... |
json.array!(@det_compras) do |det_compra|
json.extract! det_compra, :id, :producto_id, :compra_id, :precio, :catidad, :num_bol_fac
json.url det_compra_url(det_compra, format: :json)
end
|
class NoticeCommentsController < ApplicationController
before_action :find_notice
def index
@comments = @notice.comments
end
def show
@comment = @notice.comments.find( params[:id] )
end
def new
@comment = @notice.comments.build
end
def create
@comment = @notice.comments.build( commen... |
require 'test_helper'
class PousadasControllerTest < ActionController::TestCase
setup do
@pousada = pousadas(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:pousadas)
end
test "should get new" do
get :new
assert_response :success
en... |
class SearchController < ApplicationController
before_action :set_param
before_action :authenticate_user!
def index
if @query.blank?
groups = Group.all.reject { |g| g.home? }
@index = true
else
groups = Group.search(
@query,
page: @page,
order: { created_at: :des... |
require 'spec_helper'
describe GapIntelligence::Header do
include_examples 'Record'
describe 'attributes' do
subject(:header) { described_class.new build(:header) }
it 'has name' do
expect(header).to respond_to(:name)
end
it 'has unit' do
expect(header).to respond_to(:unit)
end
... |
# frozen_string_literal: true
module UploadHelper
def category_options
[[]].concat(Category.all.map { |category| [category.name, category.id] })
end
end
|
describe Ace::Compiler do
let :file do
<<-DOC
%{
test
%}
%require "#{VERSION}"
%language "ruby"
%terminal NUMBER
%terminal SEMICOLON ";"
%terminal ADD "+"
%terminal LPAREN "("
%terminal RPAREN ")"
%%
s: e
e: t ADD e
t: NUMBER | LPAREN e RPAREN
%%
... |
class Schedule < Markdown
MARKDOWN = <<MARKDOWN
### Coming Soon!
For now please just go to the prayer page and pray!
MARKDOWN
render do
DIV(style: { marginTop: 75, marginBottom: 100 }) do
papers
end
end
end
|
class CommentSerializer
include FastJsonapi::ObjectSerializer
attributes :content, :name, :entry_id, :created_at, :updated_at, :user_id
end
|
class EventsController < ApplicationController
def index
@events = Event.atlas(params[:atlas_id]).includes(:tags)
@atlas = Atlas.find_by_id(params[:atlas_id])
end
def show
@event = Event.find_by_id(params[:id])
@reports = Report.where(:event_id => @event.id).includes(:tag)
@tags = @event.tags.includes(:typ... |
require 'rails_helper'
RSpec.describe ResumeTable, type: :model do
it {should belong_to(:profile_resume)}
it {should have_many(:resume_table_cell)}
it {should have_many(:resume_table_medium)}
it {should validate_presence_of(:row)}
it {should validate_presence_of(:column)}
it {should validate_presence_of(:p... |
#encoding: UTF-8
class TopFive
include Mongoid::Document
include Mongoid::Timestamps
store_in collection: "top_five", database: "dishgo"
field :name, localize: true
field :description, localize: true
field :beautiful_url, type: String
field :end_date, type: DateTime
field :active, type: Boolean, default: fal... |
require 'data_mapper'
require 'dm-timestamps'
class Peep
include DataMapper::Resource
property :id, Serial
property :message, String
property :posted_by_name, String
property :posted_by_username, String
property :created_at, DateTime
end |
#!/usr/bin/env ruby
# encoding: utf-8
require 'lg_world'
require 'lg_viewer'
require 'test/unit'
module LifeGame
class LifeGameTest < Test::Unit::TestCase
def test_read_object
world = []
File.open('objects/blinker.txt') do |f|
f.each_line do |line|
line.chop!
tmp = line.... |
class CreateApvndmstrs < ActiveRecord::Migration[5.1]
def change
create_table :apvndmstrs do |t|
t.string :vend_code
t.string :vend_name
t.string :vend_status
t.timestamps
end
end
end
|
require 'rails_helper'
RSpec.describe FindForOauthService do
let!(:user) { create(:user) }
let(:auth) { OmniAuth::AuthHash.new(provider: 'facebook', uid: '123456') }
describe 'user already exist' do
subject { FindForOauthService.new(auth, user.email) }
context 'user exist by email' do
it 'returns... |
module ThemesOnRails
class Configuration
def initialize(hash)
@hash = default_config.merge(hash)
end
def asset_pipeline
hash["asset_pipeline"]
end
private
attr_reader :hash
def default_config
{
"asset_pipeline" => true
}
end
end
end
|
#
# Cookbook Name:: graphviz
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
if #{node[:languages][:ruby][:version]} <> "1.9.3"
include_recipe "ruby::default"
end
execute "prepare repo for graphviz" do
command "wget -O #{node['graphviz']['repo']} #{node['gra... |
# frozen_string_literal: true
# typed: true
module AlphaCard
##
# Implementation of Alpha Card Services Capture transaction.
#
# @example
# capture = AlphaCard::Capture.new(transaction_id: '981562', amount: '10.05')
# capture.process
#
# #=> #<AlphaCard::Response:0x1a0fda ...>
#
class Capture... |
class BrandsController < ApplicationController
before_action :set_brand, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, only: [:new, :create, :edit, :destroy], unless: :valid_api_key?
protect_from_forgery except: :create
def index
@brands = Brand.active.includes(products: [:prod... |
module Vertica
module Messages
class CancelRequest < FrontendMessage
message_id nil
def initialize(backend_pid, backend_key)
@backend_pid = backend_pid
@backend_key = backend_key
end
def to_bytes
message_string([
80877102.to_network_int32,
@bac... |
require 'test_helper'
class LibrarianSignupRequestsControllerTest < ActionDispatch::IntegrationTest
setup do
@librarian_signup_request = librarian_signup_requests(:one)
end
test "should get index" do
get librarian_signup_requests_url
assert_response :success
end
test "should get new" do
get... |
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# aasm_state :string
# authenticity_token :string
# ban_reason :string
# first_name :string
# image :string
# last_name :string
# nickname :string
... |
require_relative "board"
require_relative "boardcase"
require_relative "player"
class Game
attr_accessor :players, :board
def initialize
puts "Please enter first player's name"
player1_name = gets.chomp
player1 = Player.new(player1_name,"X")
puts "Please enter second player's name"
player2_name = gets.ch... |
# frozen_string_literal: true
FactoryBot.define do
factory :vendor do
name { 'Vodafone' }
end
end
|
json.array!(@cursos) do |curso|
json.extract! curso, :curso, :completado, :estudiante_id
json.url curso_url(curso, format: :json)
end
|
require 'ohol-family-trees/tiled_placement_log'
#require 'ohol-family-trees/key_plain'
#require 'ohol-family-trees/key_value_y_x'
require 'ohol-family-trees/key_value_y_x_first'
require 'ohol-family-trees/id_index'
require 'ohol-family-trees/cache_control'
require 'ohol-family-trees/content_type'
require 'fileutils'
re... |
class Like < ApplicationRecord
belongs_to :user
belongs_to :space, counter_cache: true
end
|
class Payment < ApplicationRecord
has_many :orders
validates :name, presence: true, uniqueness: {case_sensitive: false}
end
|
#encoding: utf-8
require_relative 'sliding_piece'
class Queen < SlidingPiece
def initialize(board, pos, color)
super
@icon = (color == :white ? "♕" : "♛")
@value = 9
end
def piece_deltas
SIDE_DELTAS + DIAGONAL_DELTAS
end
end |
Given(/^I have shared the following peeps:$/) do |peeps|
peeps.hashes.each do |peep|
fill_in(:message, :with => peep['message'])
click_button 'Share'
end
end
Then(/^I should see "(.*?)" before "(.*?)"$/) do |message, message2|
first_position = page.body.index(message)
second_position = page.body.index(... |
#def nth_fibonacci(n)
# first = 1
# second = 1
# current = nil
#
# (n - 2).times do
# current = first + second
# first = second
# second = current
# end
#
# current
#end
# Solve Fibonacci with an Enumerator
class Fibonacci
def self.get_nth_fib(n)
fib_enum = Enumerator.new do |yielder|
first ... |
class SuperAdmin::SubCategoriesController < SuperAdmin::SuperAdminController
add_breadcrumb "SUB CATEGORIES", "/super_admin/sub_categories"
layout "super_admin"
def index
@sub_categories = Category.where("parent_id IS NOT NULL").order("name asc")
end
def new
@category = Category.new
#render :lay... |
require 'test_helper'
describe ZipCodeLocation do
describe '.get_geolocation_for(zip_code)' do
it "retrieves the latitude and longitude for a given zip code" do
stub_request(:get, "https://maps.googleapis.com/maps/api/geocode/json?components=postal_code:88034100&key®ion=br").
to_return(status: 2... |
class ShippingErrorsController < ApplicationController
before_filter { @shop = Shop.find(params[:shop_id]) }
def index
@shipping_errors = @shop.shipping_errors.order(:message)
end
end |
require 'rqrcode'
module LabelGen
class QrRender
def self.build_url(number)
I18n.translate('label_gen.qr_url', :number => number)
end
def initialize(code, optns = {})
@qr = code
@dark_rgb = optns[:dark_rgb] || "000000"
@light_rgb = optns[:light_rgb] || "FFFFFF"
@l... |
# frozen_string_literal: true
require_relative('../users_request')
require('ostruct')
describe UsersRequest do
let!(:users_request) { UsersRequest.new }
describe '#customize_object' do
context 'give two objects' do
let!(:object) do
OpenStruct.new(
{
id: 1,
emai... |
module Boxzooka
class OrdersResponseResult < BaseElement
scalar :order_id,
node_name: 'OrderID'
scalar :status
collection :error_messages,
flat: :true,
entry_node_name: 'ErrorMessage',
entry_field_type: :scalar,
entry_type: :string
def success?
status == 'Success... |
require 'spec_helper'
describe Arachni::Reactor::Tasks do
subject { described_class.new }
let(:task) { described_class::Persistent.new{} }
let(:another_task) { described_class::Persistent.new{} }
describe '#<<' do
it 'adds a task to the list' do
subject << task
subject.... |
get '/' do
@questions = Question.order(views_count: :desc).all
erb :index
end
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'pry'
require 'carrierwave'
require 'carrierwave-google-storage'
# require 'carrierwave/google/storage'
FeatureUploader = Class.new(CarrierWave::Uploader::Base) do
# def filename; 'image.png'; end
end
def source_environment_file!
if File.exists... |
require 'spec_helper'
module TwitterCli
describe LoginProcessor do
conn = PG.connect(:dbname => ENV['database'])
describe '#execute' do
context 'when user wants to logout' do
it "should handle the login of valid user" do
conn.exec('begin')
login_processor = LoginProcessor.ne... |
require 'spec_helper'
describe Kindergarten::HeadGoverness do
before(:each) do
@governess = Kindergarten::HeadGoverness.new("child")
end
it "should include CanCan ability" do
@governess.should be_kind_of(CanCan::Ability)
end
describe :governing do
it "should guard the child" do
expect {
... |
class RenameCreditEntries < ActiveRecord::Migration[6.0]
def change
rename_table :credit_entries, :credit_items
end
end
|
# config/initializers/swagger-docs.rb
Swagger::Docs::Config.register_apis({
"1.0" => {
:api_extension_type => :json,
:api_file_path => "public/apidocs",
:base_path => "http://localhost:3000",
:clean_directory => true,
:base_api_controller => ActionController::API,
:attributes => {
:info ... |
# frozen_string_literal: true
require_relative 'lib/animals_classes'
ANIMALS_TREE = [Animals, Chordates, Mammals, Primates, Hominids, People, HomoSapiens].freeze
ANIMALS_TREE.each do |cls|
puts cls.new
end
|
require '../util'
desc 'Creates a RDS'
task :create do
subnet_ids = aws <<-SH
aws ec2 describe-subnets
--filters 'Name=tag-key,Values=Name'
'Name=tag-value,Values=default'
--query 'Subnets[*].SubnetId'
SH
security_gruop_ids = aws <<-SH
aws ec2 describe-security-groups
... |
class RenamePartyColumns < ActiveRecord::Migration[5.2]
def change
rename_column :parties, :movie_api_id, :movie_id
rename_column :parties, :start_time_day, :start_time
end
end
|
class UserMailer < ActionMailer::Base
def signup_notification(user)
setup_email(user)
@subject += I18n.t('restful_authentication.activation_required_email_subject')
@body[:url] = "http://YOURSITE/activate/#{user.activation_code}"
end
def activation(user)
setup_email(user)
@subject ... |
class CreatePublicationMastertheses < ActiveRecord::Migration
def change
create_table :publication_mastertheses do |t|
t.integer :publication_id
t.integer :masterthesis_id
t.timestamps null: false
end
end
end
|
require "spec_helper"
# rubocop:disable Style/SpaceInsideBrackets,Style/MultilineArrayBraceLayout
# rubocop:disable Metrics/BlockLength
describe PuppetDBQuery::Tokenizer do
TOKENIZER_DATA = [
[ 'hostname=\'puppetdb-mike-217922\'',
[:hostname, :_equal, "puppetdb-mike-217922"]
],
[ 'disable_puppet = ... |
5 topics on assessment
algorithms
modeling
schema-design
sql
debugging
sherif abushadi god like review
-----------------------------------
recursion vs iteration
# problem: reverse a string using iteration vs recursion
def rev_iter(string)
new_str = ""
strings.chars.each do |letter|
new_str = letter + new_... |
DeleteCheckUserMutation = GraphQL::Relay::Mutation.define do
name 'DeleteCheckUser'
input_field :id, !types.Int
return_field :success, types.Boolean
resolve -> (_root, inputs, _ctx) {
user = User.where(id: inputs[:id]).last
if user.nil?
raise ActiveRecord::RecordNotFound
else
ability ... |
require 'test_helper'
class SubmissionMailerTest < ActionMailer::TestCase
def setup
@writer = create(:writer)
@profile = create(:profile, screen_writer: @writer)
@submission = create(:submission, writer: @writer)
@reviewer = create(:reviewer)
end
test "new_submission_notification" do
mail = ... |
require 'rails_helper'
feature 'recipe', type: :feature do
let(:user) { create(:user) }
scenario 'post recipe' do
# ログイン前には投稿ボタンがない
visit root_path
expect(page).to have_no_link('レシピを書く')
# ログイン処理
visit new_user_session_path
fill_in 'user_email', with: user.email
fill_in 'user_password'... |
#!/usr/bin/env ruby
require 'mkmf'
$CFLAGS = '-std=c99 -Os'
inc_paths = %w(
/usr/include/postgresql
/usr/local/include/postgresql
/opt/local/include
/opt/local/include/postgresql90
/opt/local/include/postgresql85
/opt/local/include/postgresql84
/sw/include
)
lib_paths = %w(
/usr/lib
/usr/local/l... |
require 'minitest/autorun'
# Board
class BasicBoardTest < Minitest::Test
require_relative '../../lib/connect4/board.rb'
def setup
@board = Board.new([[0], [], [], [], [], [], []])
end
def test_moves_in_incomplete_column
@board.move(1, 1)
assert_equal(1, @board[1][0])
end
def test_notices_game_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.