text stringlengths 10 2.61M |
|---|
require "spec_helper"
RSpec.describe "Day 9: Stream Processing" do
let(:runner) { Runner.new("2017/09") }
describe "Part One" do
it "properly scores groups in the input" do
expect(runner.execute!("{}", part: 1)).to eq(1)
expect(runner.execute!("{{{}}}", part: 1)).to eq(6)
expect(runner.execu... |
require 'rails_helper'
RSpec.describe Job, type: :model do
before do
@job = FactoryBot.build(:job)
end
describe '求人の保存' do
context '求人が投稿できる' do
it '全ての必須項目があれば求人を投稿できる' do
expect(@job).to be_valid
end
end
context '求人が投稿できない' do
it 'naemが空では投稿できない' do
@job.... |
class Notifier < ActionMailer::Base
def hello_world(sent_at = Time.now)
setup_google()
subject 'Notifier # hello_world'
recipients 'alexis.perrier@qameha.com'
from 'Alexis Perrier'
sent_on sent_at
body :greeting => 'Hi, dude'
end
protected
def setup_google(... |
class CreateDiscounts < ActiveRecord::Migration[5.2]
def change
create_table :discounts do |t|
t.references :user
t.string :email
t.string :code
t.decimal :amount
t.string :unit
t.decimal :max_amount
t.boolean :active
t.datetime :deleted_at, index: true
t.... |
class AddAreaToInvestee < ActiveRecord::Migration
def self.up
change_table :investees do |t|
t.references :invest_area
end
end
def self.down
change_table :investees do |t|
t.remove :invest_area
end
end
end
|
class TeamHomeSeasonsController < ApplicationController
before_action :set_team_home_season, only: [:show, :edit, :update, :destroy]
# GET /team_home_seasons
# GET /team_home_seasons.json
def index
@team_home_seasons = TeamHomeSeason.all
end
# GET /team_home_seasons/1
# GET /team_home_seasons/1.json... |
class RenameCommunicationVariables < ActiveRecord::Migration
def change
rename_column :communications, :type, :means_of_interaction
rename_column :communications, :subtype, :interaction_title
end
end
|
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Model object.
#
#
class UserUpdateRequestInternal
# @return [String] The full na... |
require 'rails_helper'
RSpec.describe Timeline::School, versioning: true do
let(:school) { create(:school) }
describe '#changesets' do
subject(:timeline) { described_class.new(school: school) }
context 'when there are no relevant changes' do
it 'add no changes to the result' do
expect { sch... |
class TicketImporter
MAX_ROW = 1000
def initialize(company, ticket_import_record)
@company = company
@record = ticket_import_record
@spreadsheet = @record.uploaded_spreadsheet
@sheet = @spreadsheet.sheet(0)
@head_data = @sheet.row(1).map(&:strip)
... |
class AddTurmaMistaIsnToProvas < ActiveRecord::Migration
def self.up
add_column :provas , :turma_mista_isn , :string
end
def self.down
remove_column :provas , :turma_mista_isn
end
end
|
module Web::Admin::DefaultIndexHelper
def model_class
request[:controller].split('/')[2..-1].join('/').singularize.camelize.constantize
end
def get_collection(model_class)
"#{model_class}Decorator".constantize.collections
end
def to_path(constant)
constant = Team if constant.to_s.include? 'Team'... |
FactoryGirl.define do
factory :game_item_answer do
game_related_item nil
user nil
correct false
reply_word "MyString"
end
end
|
module Antlr4::Runtime
class ProxyErrorListener
def initialize(delegates)
raise StandardError, 'delegates is nil' if delegates.nil?
@delegates = delegates
end
def syntax_error(recognizer, offending_symbol, line, char_position_in_line, msg, e)
@delegates.each do |listener|
liste... |
class Driver
@@all = []
def self.mileage_cap(distance)
self.all.select {|driver| driver.total_distance > distance}
end
def initialize(name)
@name = name
@@all << self
end
def passengers
self.rides.map {|ride| ride.passenger}.uniq
end
def rides
Ride.all.select {|ride| ride.driver... |
# frozen_string_literal: true
require "rails_helper"
describe EtsPdf::Parser do
describe ".call" do
let(:lines) { %w[first_line second_line last_line] }
let(:file_content) { lines.join("\n") + "\n" }
let(:path) { Rails.root.join("tmp", "file.txt") }
let(:actual_lines) { described_class.call(path) }
... |
require 'ostruct'
class Order
def user
@_user ||= OpenStruct.new(name: 'Mike', age: 28, occupation: 'slacker')
end
def method_missing(method_name, *arguments, &block)
if method_name.to_s =~ /user_(.*)/
p "calling method"
user.send($1, *arguments, &block)
else
p "calling method_miss... |
require "test_helper"
describe Rental do
describe "validations" do
it "cannot create rental without parameters" do
required_attributes = [:due_date, :customer, :movie]
rental = Rental.new
rental.valid?.must_equal false
required_attributes.each do |attribute|
rental.errors.messages... |
require 'rails_helper'
RSpec.describe SheetSync::Download::TweetReviewSyncPolicy do
describe 'sync?' do
let(:rating) { double('Rating', value: 5) }
let(:listen_url) { 'spotify.com' }
let(:genre) { 'Metal' }
let(:tweet_review) do
double('TweetReview', rating: rating,
... |
require 'vigil/pipeline'
require 'vigil/task'
class Vigil
class GemPipeline < Pipeline
class InstallGemsTask < Task
private
def name
'Bundler'
end
def commands
[%w(bundle install --without development)]
end
end
class TestTask < Task
... |
require "rails_helper"
feature "Admin adds a trip" do
scenario "successfully" do
school = create(:school)
start_date = 5.days.from_now
end_date = 10.days.from_now
visit new_trip_path
fill_in "trip_total_girls", with: 15
fill_in "trip_total_boys", with: 15
fill_in "trip_total_teachers", ... |
# encoding: utf-8
require "logstash/codecs/base"
require "logstash/codecs/spool"
# This is the base class for logstash codecs.
class LogStash::Codecs::JsonSpooler < LogStash::Codecs::Spool
config_name "json_spooler"
milestone 1
public
def decode(data)
super(JSON.parse(data.force_encoding("UTF-8"))) do |ev... |
# By using the symbol ':post', we get Factory Girl to simulate the User model.
Factory.define :post do |post|
post.title "Example Title"
post.date "29 July 2011"
post.content "Example Post Text"
post.frames "2"
post.img_url "imagee"
e... |
class Game
def initialize(hand1, hand2)
@hand1 = hand1
@hand2 = hand2
end
def play_game()
if (@hand1 == @hand2)
return "Draw"
end
if (@hand1 == "rock")
if (@hand2 == "scissor")
return "Rock wins"
else
return "#{@hand2.capitalize} wins"
end
end
... |
require "json"
require_relative "inventory_item.rb"
require_relative "cartItem.rb"
class Checkout
attr_reader :pricing_rules
attr_reader :cart
protected :cart
def initialize(pricing_rules)
# list of cartItem
@cart = []
file = File.open pricing_rules
@pricing_rules = JSON.load file
... |
require "spec_helper"
describe "Player" do
player = Scrabble::Player.new("Norman")
player_2 = Scrabble::Player.new("Amy")
player_3 = Scrabble::Player.new("Logan")
describe "playing Scrabble" do
#player initilization
player.play("hello")
player.play("eggs")
player.play("coffee")
#player_2 ... |
class Calendar < ApplicationRecord
include GoogleCalendar
has_many :events
def import
service = activate_service
response = service.list_calendar_lists
response.items.each do |entry|
calendar = Calendar.find_or_initialize_by(owner_identifier: entry.id)
calendar.update_attributes(summary:... |
require 'rails_helper'
RSpec.describe UrlsController, type: :controller do
describe "parameter whitelisting" do
let(:params) { {other: "stuff", url: {token: "ABC1234", long_url: "http://example.org"}} }
it { is_expected.to permit(:long_url).for(:create, params: params).on(:url) }
end
describe "GET #new... |
require 'rmagick'
class Thumbnailer
@queue = :thumbnails_queue
Original_Bucket = 'scbto-photos-originals'
Thumbnail_Bucket = 'scbto-photos-thumbs'
def self.perform photo_id
photo = Photo.find(photo_id)
s3 = AWS::S3.new
# make sure thumbs bucket available
s3.buckets.create(Thumbnail_Bucket,... |
module StaticPagesHelper
def nav_link(text, path, other = nil)
options = current_page?(path) ? { class: "active" } : {}
content_tag(:li, options) do
link_to text, path, other
end
end
def panel_helper(title, body, expanded, number)
options = { :class => "panel panel-default" }
block = c... |
class CreateExihibitionSessions < ActiveRecord::Migration
def self.up
create_table :exihibition_sessions do |t|
t.datetime :start_at
t.datetime :end_at
t.integer :exihibition_id
t.string :session_number
t.string :abbreviation
t.string :number
t.text :note
t.string :... |
class EntitiesList < ApplicationRecord
include Colorable
include Positionable
positionable_ancestor :agent
include Movable
extend FriendlyId
friendly_id :listname, use: :history, slug_column: 'listname'
belongs_to :agent, touch: true
has_many :entities, dependent: :delete_all
has_many :formulation_a... |
# frozen_string_literal: true
require "rails_helper"
describe TermsHelper do
let(:term) { instance_double(Term, name: "A name", year: "2015", tags: nil) }
describe "#term_title" do
context "with a term with no tags" do
it "returns a concatenation of name year and tags" do
expect(term_title(term... |
FactoryBot.define do
factory :attendance do
checkin { Time.now }
checkout { Time.now + 8.hours }
time_spent { 8.0 }
end
end
|
class OAuth2::AuthorizeCodeController < ApplicationController
protect_from_forgery with: :null_session
before_action :get_service_provider
before_action :check_content_type, if: -> { request.post? }
def new
consumer = @sp.consumers.find_by(client_id_key: params[:client_id])
if consumer.nil?
json ... |
class Post < ApplicationRecord
belongs_to :user
has_many :likes, dependent: :destroy
has_many :comments, dependent: :destroy
mount_uploader :image_post, AvatarUploader
end
|
# == Informacion de la tabla
#
# Nombre de la tabla: *dbm_paises*
#
# idPais :integer(11) not null, primary key
# pais :string(100)
#
# Representa el registro de los diferentes paises.
#
class Paise < ActiveRecord::Base
set_table_name('dbm_paises')
set_primary_key('idPais')
validates_presence_... |
# -*- coding: utf-8 -*-
require_relative '../language'
require_relative '../spatial'
require_relative '../kmeans'
module PdfExtract
module Sections
Settings.declare :width_ratio, {
:default => 0.9,
:module => self.name,
:description => "Minimum ratio of text region width to containing column w... |
module ChatServices
class PubnubClient
include Singleton
def initialize
@pubnub = Pubnub.new(
subscribe_key: Settings.pubnub.sub_key,
publish_key: Settings.pubnub.pub_key
)
end
def publish(channel, message)
params = {
http_sync: true,
channel: channe... |
module Inventory
class SavePackageFromScan
prepend SimpleCommand
attr_reader :user,
:id,
:product_type,
:package_type,
:cultivation_batch_id,
:tag,
:product, # Deduce from product_type, package type & strain from batch
:name, # Dedu... |
module CarrierWave
module FFMPEG
extend ActiveSupport::Concern
module ClassMethods
def faststart
process :faststart => true
end
def transcode options
process :transcode => options
end
def send_thumbnail_to method_name
process :send_thumbnail... |
class Game < ActiveRecord::Base
belongs_to :scheduleable, :polymorphic => true
has_many :game_roles, :dependent => :destroy
has_many :users, :through => :game_roles
has_many :comments, :dependent => :destroy
#after_save :update_standings
def opponent(user)
raise "more than two players for this game"... |
class PetsUpdateToSiriusJob < ApplicationJob
queue_as :default
def perform(*args)
puts "Helloooo!!!"
end
end
|
class CreateTranslations < ActiveRecord::Migration[5.2]
def change
create_table :translations do |t|
t.string :language
t.string :content
t.string :definition
t.references :phrase, foreign_key: true
t.timestamps
end
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Client::Api::V1::ClientsController, type: :controller do
describe 'GET #current' do
let(:client) { create(:client) }
let(:request_params) { { method: :get, action: :current, format: :json } }
before { sign_in_as(client) }
it 'retu... |
# frozen_string_literal: true
class UniformNotifier
class BugsnagNotifier < Base
class << self
def active?
!!UniformNotifier.bugsnag
end
protected
def _out_of_channel_notify(data)
exception = Exception.new(data[:title])
exception.set_backtrace(data[:backtrace]) i... |
# frozen_string_literal: true
# Copyright (c) 2019 Danil Pismenny <danil@brandymint.ru>
class CarDecorator < Draper::Decorator
include ActionView::Helpers::DateHelper
delegate_all
delegate :model, to: :object
def current_mileage
humanized_mileage object.current_mileage
end
def next_maintenance_mil... |
class ApplicationController < ActionController::Base
# before_action :authenticate_user!
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:acc... |
# represent a job posted by employer member
class ChatEvent
include Mongoid::Document
include Mongoid::Timestamps
include ActionView::Helpers
# Record last notified via email
field :notified_at, type: DateTime
embedded_in :chat
has_many :chat_message_event_attachments
after_create :notify
aft... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vulnerable Telnet Server in'a Can ( well, a VM ).
Vagrant.configure("2") do |config|
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", ip: "192.168.3... |
class ItemsController < ApplicationController
before_action :set_item, only: %i[ show edit update destroy ]
before_action :item_owner?, only: [:edit, :update, :destroy]
# GET /items or /items.json
def index
@items = current_user.items.all.includes(images_attachments: :blob)
end
def search
require ... |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
# This file provides a place to put code that all of our models inherit.
|
class AddDefaultValueScore < ActiveRecord::Migration
def up
change_column :users, :score, :integer, :default => 0
add_column :users, :wins, :integer, default: 0
end
def down
change_column :users, :score, :integer, :default => nil
remove_column :users, :wins
end
end
|
def load_legacy_environment_variables
# Check for Legacy Environment Variables (to be deprecated)
deprecations_detected = false
legacy_options = [ :expire_after_days_default, :expire_after_days_min, :expire_after_days_max, :expire_after_views_default,
:expire_after_views_min, :expire... |
class UserNotifier < ApplicationMailer
default :from => 'pmo@tvsnext.io'
# send a signup email to the user, pass in the user object that contains the user's email address
def send_signup_email(user)
@user = user
mail( :to => @user.email,
:subject => 'Thanks for signing up with Linchpin' )
end
... |
module Intent
class Damage
attr_accessor :hooks
def initialize(entity)
@entity = entity
@soak_base = Hash.new{|_,_| 0}
@soak_bonus = Hash.new{|_,_| 0}
@resist_base = Hash.new{|_,_| 0}
@resist_bonus = Hash.new{|_,_| 0}
@avoidance = Hash.new{|_,_| 0}
@lazy_loaded = false
@hooks = Array.new
... |
require 'rails_helper'
RSpec.feature 'Like Posts', type: :feature do
scenario 'a post defaults with 0 likes' do
signup_and_login
upload_photo
expect(page).to have_content('0 likes')
end
scenario 'a user can click the like link and the like counter increases' do
signup_and_login
upload_pho... |
class OrdersController < ApplicationController
def create
subscription_type = SubscriptionType.find(params[:subscription_type_id])
order = Order.create!(subscription_type_name: subscription_type.name, amount_cents: subscription_type.price * 100, state: 'pending', user: current_user)
authorize order
redirect_t... |
# frozen_string_literal: true
FactoryBot.define do
factory :reset_password_token do
user
token { nil }
expires_at { nil }
end
end
|
describe ManageIQ::Providers::IbmCloud::VPC::CloudManager::Refresher do
let(:ems) do
api_key = Rails.application.secrets.ibmcvs.try(:[], :api_key) || "IBMCVS_API_KEY"
FactoryBot.create(:ems_ibm_cloud_vpc, :provider_region => "us-east").tap do |ems|
ems.authentications << FactoryBot.create(:authenticatio... |
class IterationsController < ApplicationController
before_filter :login_or_oauth_required, :only => [:edit, :destroy, :update, :create]
before_filter :check_user, :only => [:edit, :destroy, :update]
def new
@deed = Deed.find params[:deed_id]
end
def create
@deed = Deed.find params[:deed_id]
... |
require 'sha1'
require 'sinatra/base'
module Sinatra
module Slaushed
class UserExists < StandardError ; end
class NeedsAuth < StandardError ; end
module Helpers
def create_user(login, pass)
hash = uhash(login, pass)
if redis.setnx k(:auth, login), hash
true
e... |
class AddConsumerScoreToBrands < ActiveRecord::Migration[6.0]
def change
add_column :brands, :consumer_score, :float
end
end
|
require 'rails_helper'
RSpec.feature "GuestCanCreateAccounts", type: :feature do
it 'should be able to create an account' do
visit new_user_path
fill_in "Email", with: "beth@turing.io"
fill_in "Password", with: "123"
fill_in "Password confirmation", with: "123"
click_on "Submit"
expect(curr... |
#==============================================================================
# ** Input
#-------------------------------------------------------------------------------
# Created By Cidiomar R. Dias Junior
# Originally posted at
#
# Terms of Use: Credit "Cidiomar R. Dias Junior"
#
# Maintained on Hime Works
#------... |
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :name
t.date :date
t.time :time
t.integer :etype
t.string :description
t.integer :gender
t.integer :number
t.integer :agemin
t.integer :agemax
t.timestamps
end
... |
class UsersController < ApplicationController
before_action :set_user, only: %i[show]
def index
@users = User.all.where.not(id: current_user.id)
end
def edit
@user = current_user
end
def show
end
def add_friend
if params[:user_id]
end
end
def update
if current_user.update(... |
require 'spec_helper'
describe 'Sign up' do
before(:each) do
visit root_path
end
it 'allows to sign up' do
click_link 'Registrieren'
fill_in "email",with: 'bjoern@admin.de'
fill_in "lastname", with: 'Bjoern'
fill_in "lastname", with: 'Simon'
fill_in "zip", with: '48143'
fill_in "password", with: 'Te... |
case node[:platform]
when 'arch'
package 'rust'
package 'cargo'
include_cookbook 'yaourt'
yaourt 'rust-src'
else
local_ruby_block 'install rust' do
rustc_path = "#{ENV['HOME']}/.cargo/bin/rustc"
block do
system("sudo -E -u #{node[:user]} bash -c 'curl https://sh.rustup.rs -sSf | sh'")
u... |
class RenameClientDataOnProposals < ActiveRecord::Migration
def change
rename_column :proposals, :clientdata_id, :client_data_id
rename_column :proposals, :clientdata_type, :client_data_type
end
end
|
require 'rails_helper'
RSpec.describe Api::UsersController, type: :controller do
describe "GET #show" do
before(:each) do
@user = FactoryGirl.create :user
get :show, id: @user.id, format: :json
end
it "returns the information about a reporter on a hash" do
user_response = JSON.parse(re... |
module Protocol
@objects = {}
@fixed_sizes = ["byte", "short", "int", "long", "boolean"]
@packets = []
def Protocol.add (parsedData)
if parsedData.is_packet
@packets.push parsedData
else
@objects[parsedData.name] = parsedData
end
end
def Protocol.describe
"#{@packets.length} pack... |
class RelationshipsController < ApplicationController
before_action :authenticate_user!
before_action :ensure_correct_user , only: [:destroy]
def follow
current_user.follow(params[:id])
redirect_back(fallback_location: root_path) #⇦行動する前に居た画面に戻る。
end
def unfollow
current_user.unfollow(params[:id... |
class PostService
def initialize(opts={})
raise("Params cannot be blank") if opts[:params].blank?
@params = opts[:params]
@post = Post.find(@params[:id]) unless @params[:id].blank?
end
def index
posts = Post.all
posts.as_json
end
def show
@post.as_json
end
def create
@post =... |
# frozen_string_literal: true
module Vedeu
module Logging
# Provides a stack trace of a running client application upon exit
# in a file for further analysis.
#
module Debug
extend self
# @param binding [Binding]
# @param obj [Object]
# @return [void]
def debug(bindi... |
# 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' }])
# C... |
class RemoveGalleryFromMediaMedia < ActiveRecord::Migration
def change
remove_column :media_media, :gallery_id
end
end
|
module FreeImage
LAST_ERROR = 'free_image_error'
#typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg);
#typedef void (DLL_CALLCONV *FreeImage_OutputMessageFunctionStdCall)(FREE_IMAGE_FORMAT fif, const char *msg);
callback(:output_message_callback, [:format, :pointer], :void)... |
require 'kafkat/command/topic_delete'
describe 'Kafkat::Command::TopicDelete' do
describe '.run' do
context 'pass the delete command to RunClass' do
let(:command) { Kafkat::Command::TopicDelete.new }
let(:args) { %w(test) }
it 'creates the appropriate command arguments' do
allow_any_in... |
class TechnologiesController < ApplicationController
def index
@technologies = Technology.all
end
end
|
class AddTimestampsToBranchMenuCategory < ActiveRecord::Migration
def change
add_column :branch_menu_categories, :created_at, :datetime
add_column :branch_menu_categories, :udpated_at, :datetime
end
end
|
class OptionModelsController < ApplicationController
# GET /options
# GET /options.xml
def index
@options = OptionModel.all
@option = OptionModel.new
if( session[:option_model] )
@option = OptionModel.new(session[:option_model])
end
respond_to do |format|
format.html # index.html... |
#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 ... |
# encoding: utf-8
module Ktl
class DecommissionPlan
def initialize(zk_client, broker_id)
@zk_client = zk_client
@broker_id = broker_id
@replicas_count = Hash.new(0)
@leaders_count = Hash.new(0)
end
def generate
plan = Scala::Collection::Map.empty
brokers = @zk_client.... |
class Note < ActiveRecord::Base
has_many :viewers
belongs_to :user
has_many :readers, through: :viewers, source: :user
accepts_nested_attributes_for :readers
def visible_to
readers.collect { |reader| reader.name }.join(", ")
# method that returns a string of user objects that the model
# is visib... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
$global_date ||= Date.new(Date.today.year,Date.today.month)
$global_date_next ||= Date.new(Date.today.year,Date.today.month + 1)
before_filter :authenti... |
require "rails_helper"
describe "Viewing an individual fruit" do
it "shows the fruit details" do
plantation = Plantation.create!(plantation_attributes)
fruit = plantation.fruits.create!(fruit_attributes)
visit plantation_path(plantation)
click_link fruit.name
expect(current_path).to eq(plantati... |
class CreateGastospropiedads < ActiveRecord::Migration[5.1]
def change
create_table :gastospropiedads do |t|
t.integer :anho
t.integer :mes
t.integer :monto
t.timestamps
end
end
end
|
module Rubywarden
module Test
class Factory
USER_EMAIL = "user@example.com"
USER_PASSWORD = "p4ssw0rd"
def self.create_user email: USER_EMAIL, password: USER_PASSWORD
u = User.new
u.email = email
u.kdf_type = Bitwarden::KDF::TYPE_IDS[User::DEFAULT_KDF_TYPE]
u.kdf... |
# Arrays
# Enumerables
# Hashes
# Map and Select
# Option and Hashes
# The "Ruby Way"
# Symbols
# Default arguments
# Splat operators
# Inject aka reduce
# Scope
# Methods and Local Scope
# lexical scope.
# how variable names resolve if we put them in structures
# like methods, conditionals, or blocks
# Less preferr... |
class Contract < ApplicationRecord
belongs_to :activity
enum rate_type: [:undefined, :hourly, :per_head, :gradient, :monthly, :personal]
def calc_payout(arr)
payment_hash = {}
rate = self.rate_type
case self.rate_type
when "undefined"
byebug
arr.each do |slot|
payment_hash[s... |
class ContributionMailer < ActionMailer::Base
layout 'devise_email'
def payment_success(contribution, transaction)
@user = contribution.user
@project = contribution.project
attachments['contribution_invoice.pdf'] = generate_pdf(contribution, transaction)
mail(to: @user.email, subject: 'Thanks for y... |
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# body :string(255) not null
# owner_id :integer not null
# created_at :datetime
# updated_at :datetime
# post_id :integer not null
# parent_id :integer
#
class Comment < Ac... |
# see if the name "Dino" appears in the string below
advice = "Few things in life are as important as house
training your pet dinosaur."
p advice.include?("Dino")
p advice.match?("Dino") |
class Bill
attr_reader :level, :index, :user_id
attr_accessor :data
def initialize(attributes)
@data = attributes
@user_id = data.user ? data.user.id : data.id
@index = data.index
@level = data.level
@price = data.price
end
def generate
data.duration = contract_duration_in_years
... |
# frozen_string_literal: true
describe Zafira::Operations::Run::Start do
let(:client) do
build(:zafira_client, :with_environment,
:with_test_suite, :with_job, :with_run_owner, :rspec)
end
let(:env) { client.environment }
let(:starter) { Zafira::Operations::Run::Start.new(client) }
before do
... |
class Grid
attr_accessor :cells, :rows, :cols
def initialize(rows, cols, cells=nil)
if cells.nil?
@rows = rows
@cols = cols
@cells = Array.new(rows)
0.upto(rows-1).each do |r|
@cells[r] = Array.new(cols)
end
else
... |
class Geosmailer < ActionMailer::Base
default :from => "from@example.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.geosmailer.email_geoscontact.subject
#
def email_geoscontact(receiver_email, sender_name, sender_email, subject, email_body)
... |
class RemoveIdRecintoFromPropiedads < ActiveRecord::Migration[5.1]
def change
remove_column :propiedads, :id_recinto, :string
end
end
|
require 'spec_helper'
describe Admin::CeremoniesController do
describe "GET new" do
it "sets @ceremony" do
get :new
expect(assigns(:ceremony)).to be_instance_of(Ceremony)
end
it "sets @event" do
some_wedding = Fabricate(:event)
get :new, { event_id: some_wedding.slug }
expe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.