text stringlengths 10 2.61M |
|---|
# -*- coding: utf-8 -*-
# module Retriever::Entity
# Segment = Struct.new(:slug, :range, :face, :url, :open, :options) do
# def merge(args)
# new = self.dup
# args.each do |k, v|
# new[k] = v
# end
# new
# end
# end
# end
|
class Admin::AlertsController < Admin::BaseController
layout 'admin/base'
helper_method :recurring_options
before_filter :load_alert, :only => [:show, :edit, :update, :destroy]
permit "reporter"
def show
# @results = MiddleMan.worker(:report_worker).generate_alert(:arg => @report.id, :job_key ... |
class AddPreviousAnswersToMemoryCards < ActiveRecord::Migration
def change
add_column :memory_cards, :previous_answers, :string
end
end
|
class CreateOpportunities < ActiveRecord::Migration
def change
create_table :opportunities do |t|
t.integer :listing_id, null: false
t.integer :user_id, null: false
t.string :status, null: false, default: "favorited"
t.timestamps null: false
end
add_index :opportunities, ... |
class ChangeKoefcalcMeters < ActiveRecord::Migration[5.0]
def change
remove_column :meters, :koefcalc, :integer
add_column :meters, :koefcalc, :float, null: false, default: 1
end
end
|
class AddTrendScoreToOffers < ActiveRecord::Migration
def change
add_column :offers, :trend_score, :float
end
end
|
require 'miw'
require 'miw/point'
require 'miw/scroll_bar'
module MiW
module Scrollable
SCROLL_BAR_IDS = [:__miw_scrollable_h_sc, :__miw_scrollable_v_sc]
def initialize_scrollable(horizontal, vertical)
scroll_bar = ScrollBar.new :__miw_scrollable_h_sc, orientation: :horizontal
range = (extent.l... |
require "spec_helper"
include RSpec
RSpec.describe Alimento::Frutas do
before :all do
@ali1 = Alimento::Frutas.new("Manzana", 0.3, 12.4, 0.4)
@ali2 = Alimento::Frutas.new("Plátanos", 1.2, 21.4, 0.2)
@ali3 = Alimento::Frutas.new("Pera", 0.5, 12.7, 0.3)
end
describe "#Comprobar que se c... |
class CarsController < ApplicationController
before_action :set_car, only: [:show, :update, :destroy]
# GET /cars
def index
@cars = Car.all
render json: @cars
end
# GET /cars/1
def show
render json: @car
end
# POST /cars
def create
@car = Car.new(car_params)
if @car.save
... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Example User", email: "user@example.com",
password: "foobar", password_confirmation: "foobar")
end
test "should be valid" do
assert @user.valid?
end
test "name should be present" d... |
# == Schema Information
#
# Table name: votes
#
# id :integer not null, primary key
# listing_id :integer not null
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Vote < ActiveRecord::Base
validates :user_... |
Rails.application.routes.draw do
root to: 'movies#index', as: 'home'
end
|
require 'gchart'
module WelcomeHelper
def pie_chart_for_solutions(project)
new_projects = project.status(1)
in_progress_projects = project.status(2)
done_projects = project.status(3)
data = [new_projects, in_progress_projects, done_projects]
labels = ["New (#{new_projects})", "In Progress (#{in_... |
require_relative "dish.rb"
require_relative "order.rb"
require_relative "customer.rb"
require 'twilio-ruby'
class Takeaway
def initialize
@customer_list = []
end
def customer_list
@customer_list
end
def add(customer)
customer_list << customer
end
def take_dish_order(customer, dish)
customer.order.a... |
require "sinatra"
require "json"
require_relative "model/fibonacci"
require_relative "model/fibonacci_manager"
configure do
set :bind, '0.0.0.0'
end
get '/fibonacci/:limite/:lista_o_sumatoria' do
begin
sucesion = params['limite'].to_i
fibonacci = Fibonacci.new
resultado = {"fibonacci": { "limite": suc... |
# Fact: infiniband_netdevs
#
# Purpose: Report the network device names and information
#
# Resolution:
# Returns a hash of netdevice names (ib0) with a hash of data about the device
#
# Caveats:
# Only tested on systems with Mellanox cards
#
require 'facter/util/infiniband'
Facter.add(:infiniband_netdevs) do
c... |
# frozen_string_literal: true
class Api::WelcomeController < Api::BaseController
def show
@seasons = Season.airing(Time.zone.today)
.includes(%i[anime melodies advertisements])
.where('melodies.draft = ?', false)
.references(:melodies)
... |
class Message < ApplicationRecord
# belongs_to :recipient, class_name: 'User'
# belongs_to :sender, class_name: 'User'
belongs_to :user
belongs_to :conversation
# belongs_to :post, optional: true
has_many :comments, dependent: :destroy
end
|
class BanHistory < ApplicationRecord
belongs_to :player
belongs_to :banned_by, foreign_key: 'banned_by_id', class_name: 'Player'
enum ban_types: { none: 0, soft: 1, hard: 2 }, _prefix: :ban_type
end
|
# frozen_string_literal: true
module VmTranslator
class Parser
def initialize(tokens_per_line)
@tokens_per_line = tokens_per_line
end
def commands
@tokens_per_line.each_with_index.filter_map do |tokens, line|
case tokens
in []
nil
in [[:push], [:segment, seg... |
# -*- encoding : utf-8 -*-
module Setting
def self.key
HashWithIndifferentAccess.new(YAML.load_file(File.join(Rails.root, 'config', 'settings.yml')))
end
end |
require 'test_helper'
class SharedPostsControllerTest < ActionDispatch::IntegrationTest
setup do
@shared_post = shared_posts(:one)
end
test "should get index" do
get shared_posts_url
assert_response :success
end
test "should get new" do
get new_shared_post_url
assert_respo... |
Rails.application.routes.draw do
root to: 'home#index'
# ログインまわり
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
#メール機能
get 'inquiry', to: 'inquiry#index' # 入力画面
post 'inquiry/confirm', to: 'inquiry#confirm' # 確認画面
post 'i... |
class Participant < ActiveRecord::Base
belongs_to :health_worker, class_name: "User", foreign_key: :health_worker_id
belongs_to :research_assistant, class_name: "User", foreign_key: :research_assistant_id
has_many :responses
validates :patient_identifier, presence: true
validates :patient_identifier, uniquen... |
class Answer < ApplicationRecord
include Votable
validates :text, presence: true
belongs_to :user
belongs_to :question, counter_cache: true
has_many :answer_votes, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :trust_events, -> { where(object_type: 'Answer') }, foreign_key: :objec... |
module MyServiceName
module Helpers
module RequestMetadata
extend Grape::API::Helpers
def setup_request_metadata
setup_platform_id
setup_request_id
setup_client_ip
setup_account_id
setup_account
setup_user_id
setup_username
end
def ... |
# frozen_string_literal: true
require 'active_support/inflector'
module Rokaki
module FilterModel
class NestedLikeFilters
def initialize(filter_key_object:, prefix:, infix:, db:, mode: :and, or_key: :or, type: :like)
@filter_key_object = filter_key_object
@prefix = prefix
@infix = i... |
class Post < ActiveRecord::Base
belongs_to :tutorial
validates :title, presence: TRUE
validates :link, presence: TRUE
require 'uri'
validates :link, format: {with: /\A#{URI::regexp}\z/} # http://stackoverflow.com/questions/1805761/check-if-url-is-valid-ruby
#def valid?
#if not self.link =~ /\A#{URI:... |
class Giv < ActiveRecord::Base
# for edit many to many relation
# each giv has many editors. each editors can edit givs
has_many :giv_manages
has_many :editors, through: :giv_manages, class_name: 'User'
has_many :giv_comments
# for donation many to many relation
# each giv has many donors. each donors ca... |
class CreateStaticContactListUsers < ActiveRecord::Migration
def change
create_table :contacts_static_contact_lists, :id => false do |t|
t.integer :static_contact_list_id
t.integer :contact_id
t.timestamps
end
end
end
|
# -*- encoding : utf-8 -*-
require 'helper'
class AttributesTest < Test::Unit::TestCase
context "Attributes" do
setup do
@time = Time.now
@args = {
"integer" => 12345,
:string => "foo",
:symbol => :bar,
:boolean => true,
:array => [1,2,3],
:field_ha... |
#!/usr/bin/env ruby
require "net/http"
require "uri"
require "cgi"
$:.push File.expand_path("../lib", __FILE__)
require 'helpers'
usage "Build the given Jenkins project"
project = ARGV.first
unless project
puts "Tell me a project to build, bro"
exit 1
end
uri = URI.parse("http://ci.engineering.strobecorp.com/... |
$:.unshift "."
require 'spec_helper'
require 'linkeddata'
describe RDF::Distiller::Application do
before(:each) do
$debug_output = StringIO.new()
$logger = Logger.new($debug_output)
$logger.formatter = lambda {|severity, datetime, progname, msg| "#{msg}\n"}
end
describe "/doap" do
before(:all) {... |
class ChangePartyHostColumnAgain < ActiveRecord::Migration
def change
rename_column :parties, :host_id, :user_id
end
end
|
class DropParticipantNights < ActiveRecord::Migration
def change
drop_table :participant_nights
end
end
|
class DeleteLocationFromProducts < ActiveRecord::Migration[5.2]
def change
remove_column :products, :location_long
remove_column :products, :location_lat
end
end
|
class AddMediaTypeAndContentToChat < ActiveRecord::Migration
def change
add_column :chats, :media_type, :integer
add_index :chats, :media_type
add_column :chats, :image_content, :text
add_column :chats, :video_content, :text
end
end
|
=begin
Write a method that takes an Array as an argument, and reverses its elements in place; that is, mutate the Array passed into this method. The return value should be the same Array object.
You may not use Array#reverse or Array#reverse!.
Examples:
=end
def reverse!(ary)
ary.sort! { |x,y| y <=> x }
end
... |
class VotesController < ApplicationController
load_and_authorize_resource
def new
@vote = Vote.new
end
def create
@vote = current_user.votes.build(title: "2018年outing", result: params[:vote][:result])
notice = @vote.save ? "提交成功" : "提交失败:不允许重复提交"
redirect_to new_vote_url, notice: notice
end
... |
class FacilityItemsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
before_action :set_facility_item, only: [:show, :edit, :update, :destroy]
# GET /facility_items
# GET /facility_items.json
def index
@facility_items = FacilityItem.where("true").order(... |
class MessagesController < ApplicationController
def index
render json: ReduxDataQuery.call(Message.all, params[:query])
end
def create
message = Message.new(message_params)
# TODO move to JSON API complient responsess
if message.save
render json: message,
status: 201
else
... |
class AddLopIdToStudents < ActiveRecord::Migration[5.1]
def change
add_reference :students, :lop, foreign_key: true, allow_null: true
end
end
|
require "coolxbrl/edinet/presentation/node_set"
require "coolxbrl/edinet/presentation/node"
module CoolXBRL
module EDINET
class Presentation
CONSOLIDATED_BALANCE_SHEET = "rol_ConsolidatedBalanceSheet"
CONSOLIDATED_STATEMENT_OF_INCOME = "rol_ConsolidatedStateme... |
class UsersController < ApplicationController
# register call-backs using before_filter
# ensure only signed-in users can edit and update
before_filter :signed_in_user, only: [:index, :show, :edit, :update, :destroy, :following, :followers]
# ensure signed-in users can only their their own page
before_filter ... |
# require modules here
require "yaml"
require "pp"
def transform_data(data)
transformed_data = {:get_meaning => {}, :get_emoticon => {}}
data.each do |key, value|
transformed_data[:get_meaning].merge!({value[1] => key})
transformed_data[:get_emoticon].merge!({value[0] => value[1]})
end
return transfo... |
# Reverse the words in a given sentence.
class SentenceReverse
attr_reader :sentence
def initialize(sentence)
@sentence = sentence
end
def reverse
words = []
i = 0
start = 0
while i < sentence.length
if sentence[i] == " "
words << se... |
class AddPartyIdToCharacters < ActiveRecord::Migration
def change
add_reference :characters, :party, index: true
add_foreign_key :characters, :parties
end
end
|
class GoodnessValidator < ActiveModel::Validator
def validate(name)
if name.first_name == "Evil"
name.errors[:base] << "This person is evil"
end
end
end |
module OnetableTerminator
module Structures
class Nic
attr_reader :name, :rules
def initialize(name)
@name = name
@rules = []
end
def add_rule(rule)
rules << rule
end
def ==(other)
name == other.name && rules == other.rules
end
end
... |
# encoding: utf-8
require 'spec_helper'
shared_examples "rsvp_new" do
let(:user) { Fabricate(:user) }
before(:each) do
login_in_as(user)
@current_event = Fabricate(:event)
end
context "#rsvp" do
before(:each) do
expect {
xhr :post, :create, rsvp: rsvp_param
}.to change(Rsvp,... |
require 'spec_helper'
describe Project do
before(:each) do
@valid_project = {
name: "Save Unicorns",
description: "Because Unicorns are awesome sauce (duh) we must save them",
category: "Obvious stuff"
}
end
it "should create a project given valid information" do
project = Project... |
require 'nio'
module Microprocess
class NIOSelect
def initialize
@selector = NIO::Selector.new
end
def add(stream)
@selector.register(stream, :rw)
stream.on(:close) do
remove(stream)
end
attach
end
def remove(stream)
@selector.deregister(stream)
... |
class AppService < ActiveRecord::Base
attr_accessible :name, :limit, :description
validates :name, :presence => true, :uniqueness => true
has_many :users
has_many :prices
def self.find_plan(id)
app_service = AppService.find(id)
return BraintreeRails::Plan.find(app_service.name)
end
def unlimit... |
class MessagesController < ApplicationController
def index
@messages_week = Message.sent.msgs_last_week
end
def new
@message = Message.new
if current_user.gifs.empty?
redirect_to user_gifs_path(current_user)
end
end
def create
# binding.pry
if params[:message][:receiver_id].present? && para... |
class AddLongNameToClubs < ActiveRecord::Migration[6.0]
def change
add_column :clubs, :long_name, :jsonb, after: :name, default: {}
add_column :happenings, :description, :jsonb, default: {}
add_column :discipline_happenings, :description, :jsonb, default: {}
remove_column :happenings, :repeating, :in... |
require 'spec_helper'
describe "/cheque_runs resource" do
let(:user) { FactoryGirl.create(:user, first_name: "Don", last_name: "Larsen") }
before do
fill_in_basic_auth
sign_in_as(user)
end
describe '/users/:id/edit' do
before do
visit edit_user_path user
end
it_should_behave_like ... |
class AnnouncementsController < ApplicationController
before_action :set_announcement, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: :homepage
load_and_authorize_resource :except => [:homepage]
# GET /announcements
# GET /announcements.json
def index
@announcements ... |
class UnitSerializer < ActiveModel::Serializer
attributes :id, :unit_name, :description
has_many :weeks
has_many :lessons
end
|
class CartItem < ApplicationRecord
belongs_to :customer
belongs_to :item
validates :item_id, uniqueness: { scoupe: :customer_id }
# 1以上10以下
validates :amount, presence: true, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 10 }
def subtotal
item.add_tax_price * amount
end
end
|
# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
# If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a and b are called amicable numbers.
# For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110;... |
namespace :elasticsearch do
namespace :index do
desc "Create a new index. Specify IMPORT=1 for rebuilding from resource"
task create: :environment do
ENV['INDEX'] = new_index_name = "#{Spot.index_name}_#{Time.now.strftime("%Y%m%d_%H%M%S")}"
puts "========== create #{new_index_name} =========="
... |
require 'rest-client'
require 'json'
class UpdatePlantsJob < ApplicationJob
queue_as :trefle_etl
def perform(*args)
# Do something later
logger.debug 'Starting UpdatePlantsJob'
@refresh_cutoff = 1.week.ago
@etl_version = 1
@api_base_url = "https://trefle.io/api/v1"
@api_token = Rails.applic... |
class Item < ApplicationRecord
has_many :user_item, dependent: :destroy
has_many :user ,through: :user_item
validates :name, presence: true
validates :price, presence: true
validates :status, presence: true
validates :category, presence: true
has_attached_file :image, styles: { medium: "300x300>", t... |
class BaseController < ApplicationController
def index
@page_title = "Base <small>type</small>"
@page_description = "Arguably the most important section of the style guide, where the foundations of the site are set. All modules will be extended from these base styles."
@page_nav = base_nav
end
def li... |
class GroupOfferingsController < WebApplicationController
before_action :set_group_offering, only: [:show, :edit, :update, :destroy]
before_action :set_semester, only: [:index, :lectures, :workshops, :shepperdings, :commissions]
# GET /group_offerings
# GET /group_offerings.json
def index
@group_offering... |
#!/usr/bin/env ruby
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'primes'
require 'prime_table_generator'
describe PrimeTableGenerator, "#to_s" do
it "contains the right number of columns" do
gen = PrimeTableGenerator.new([2])
table = gen.to_s
expect(table.split(/\n/).first.scan(/\d+... |
class WorkerContractDetail < ActiveRecord::Base
belongs_to :worker_contract
belongs_to :worker
end
|
class Scope
attr_accessor :namespace,
:image,
:actions
# Parses a String into an authorization scope.
#
# scope - a String containing an authorization scope in the following format:
# `repository:<namespace>/<image>:<actions>`
#
# Returns a new Scope.
def self.p... |
class CashRegister
attr_accessor :total, :discount, :items, :last_transation
def initialize(discount=0)
@total = 0
@discount = discount
@items = []
end
def add_item(title, price, qty=1)
self.total += price * qty
qty.times do
items << title
end
self.last_transation = price ... |
# Class 9 notes
# Continuing constructing the coffee class from lecture 9
# Coffee Class
class Coffee
@@max_water_level = 32.0 # oz
@@max_coffee_level = 4.0 # oz
@@standard_cup = 8.0 # oz # Amount of coffee
attr_reader :power, :water_level, :coffee_level
def initialize
@power = false ... |
require 'test_helper'
class SubsystemsControllerTest < ActionController::TestCase
setup do
@subsystem = subsystems(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:subsystems)
end
test "should get new" do
get :new
assert_response :succ... |
require 'rails_helper'
describe "edit author page" do
before :each do
@alan = FactoryBot.create :author
visit edit_author_path(@alan)
end
it "should render without error" do
end
it "should display the same information as the new page" do
expect(page).to have_field('author[first_name]')
expe... |
require 'rails_helper'
RSpec.describe 'Set Exercises API', type: :request do
# initialize test data
let!(:exc_types) { create_list(:exercise, 10) }
let(:id) { exc_types.first.id }
# GET /exercises
describe 'GET /exercises' do
before { get '/exercises', params: {} }
it 'returns rep types' do
e... |
module Billing
def self.table_name_prefix
'billing_'
end
end
|
class ConvertCfsDirectoryToHaveParentAssociation < ActiveRecord::Migration
def up
add_column :cfs_directories, :parent_id, :integer, index: true
add_column :cfs_directories, :parent_type, :string
ActiveRecord::Base.connection.execute("UPDATE cfs_directories SET parent_id=parent_cfs_directory_id, parent_ty... |
class Movie < Storage
belongs_to :user, inverse_of: :movies
end
|
Metasploit::Model::Spec.shared_examples_for 'Module::Path' do
named_module_path_factory = "named_#{module_path_factory}"
unnamed_module_path_factory = "un#{named_module_path_factory}"
it { should be_a ActiveModel::Dirty }
it_should_behave_like 'Metasploit::Model::RealPathname' do
let(:base_instance) do
... |
class AddPointToVoters < ActiveRecord::Migration
def change
add_column "demog.voters", :location, :geometry, srid: 4326
end
end
|
# encoding: utf-8
class PlayerDecorator < Draper::Decorator
delegate_all
delegate :current_page, :total_pages, :limit_value
# decorates_association :riders
def player
model
end
def you_badge
if h.player_signed_in? && player.id == h.current_player.id
h.content_tag("span", "Jij" , :class =... |
class CreateBundles < ActiveRecord::Migration
def self.up
create_table "bundles" do |t|
t.column :offering_id, :integer
t.column :workgroup_id, :integer
t.column :workgroup_version, :integer
t.column :content, :text
t.column :created_at, :timestamp
end
end
def self.down
... |
class EasyAttendanceActivity < ActiveRecord::Base
require 'ipaddr'
has_many :easy_attendances
has_many :time_entries, :through => :easy_attendances
belongs_to :mapped_project, :class_name => 'Project', :foreign_key => 'mapped_project_id'
belongs_to :mapped_time_entry_activity, :class_name => 'TimeEntryActivi... |
module Aliyun
class APIConfig
def self.info
raise "Service Name Missing!"
end
def self.endpoint
raise "Service Endpoint Missing!"
end
def self.default_parameters
raise "Service Default Parameters Missing!"
end
def self.separator
"&"
end
def self.http_method
... |
class UsersController < ApplicationController
before_action :set_user, only:[:show,:edit,:update,:destroy]
def index
if logged_in?(:admin)
@users = User.all
else
redirect_to stationeries_path, notice: "You are not authiruzed for listing Users"
end
end
def show
if logged_in?(:admin) || current_us... |
require 'spec_helper'
describe User, :type => :model do
it{is_expected.to have_many :restaurants}
it{is_expected.to have_many :reviews}
end |
class BeerFetcher
def initialize
@conn = Faraday.new(url: "https://api.untappd.com" ) do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with... |
class ProjectCategory < ApplicationRecord
validates :project_id, :category_id, presence: true
belongs_to :project,
primary_key: :id,
foreign_key: :project_id,
class_name: :Project
belongs_to :category,
primary_key: :id,
foreign_key: :category_id,
class_name: :Category
end
|
class PostsController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:create, :update]
before_filter :session_filter
layout 'admin'
def posts
@posts = BlogPost.paginate(:page => params[:page], :per_page => 6).order('id DESC')
end
def show
@post = BlogPost.find_by_id(param... |
# frozen_string_literal: true
require 'serialization'
require_relative 'meta'
require_relative 'session'
module Build
class Configuration
include Serialization
readable(:meta, default: {}, loads: ->(meta) { Meta.new meta })
readable(:session, default: {}, loads: ->(session) { Session.new session })
... |
require 'spec_helper'
describe Judge do
before(:each) do
@valid_attributes = {
:name => "Valid name",
:url => "http://valid.url.com"
}
@invalid_attributes = {
:name => nil,
:url => "ftp://invalid"
}
end
it "should create a new instance given valid attributes" do... |
# Module to sort controller indexes
module SortingConcern
extend ActiveSupport::Concern
ORDER = 'name'.freeze
SORT = 'ASC'.freeze
CASE = true
UNACCENT = true
def setup_sorting
current_order
current_sort
define_order
end
def ignore_case
@ignore_case ||= params.key?(:ignore) ? get_boole... |
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# no... |
class Address < ApplicationRecord
belongs_to :customer
def full_address
self.postcode + self.address + self.name
end
validates :name, presence: true
validates :postcode, presence: true
validates :address, presence: true
end
|
class AddSortableFieldsToElasticSearch < ActiveRecord::Migration
def change
index_alias = CheckElasticSearchModel.get_index_alias
client = $repository.client
options = {
index: index_alias,
body: {
properties: {
linked_items_count: { type: 'long' },
last_seen:... |
class PicturesController < ApplicationController
before_filter :authenticate_user!
def index
#@pictures = Picture.all
#render :json => @pictures.collect { |p| p.to_jq_upload }.to_json
end
def show
authorize! :read, Picture, :message => 'Not authorized to read.'
@picture = Picture.find(params... |
require File.expand_path(File.dirname(File.dirname(__FILE__)) + '/spec_helper')
describe Issue do
it "should load comments with a mock jira" do
@jira=flexmock
@jira.should_receive(:base_url).and_return("http://example.com/jira")
@jira.should_receive(:getIssue).with("EX-5").once
@jira.should_rece... |
module Signatures
class HMAC_SHA256
include Base
protected
def digest(secret, base)
OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, secret, base)
end
end
end
|
class MyStack
def initialize
@collection = []
@end_index = -1
end
def empty?
@end_index < 0
end
def peek
@collection[@end_index]
end
def pop
@end_index -= 1
@collection[@end_index + 1]
end
def push(item)
@collection[@end_index + 1] = item
@end_index += 1
end
end
... |
class AddRubyVersionToBuilds < ActiveRecord::Migration
def change
add_column :builds, :ruby_version, :string
end
end
|
class Sub < ActiveRecord::Base
validates :title, :description, :moderator, presence: true
has_many :post_subs, dependent: :destroy
has_many :posts, through: :post_subs, dependent: :destroy
has_many :subscribers,
foreign_key: :user_id,
class_name: :User
belongs_to :moderator,
class_name: :User,
... |
class Booking < ApplicationRecord
belongs_to :user
belongs_to :gear
has_many :reviews
validates :start_date, presence: true
validates :end_date, presence: true
def check_availability
gear_bookings = self.gear.bookings
bookings = gear_bookings.select{|b| b.start_date <= self.start_date && b.end_dat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.