text stringlengths 10 2.61M |
|---|
require File.dirname(__FILE__) + '/spec_helper'
class Book < YamlModel::Base
fields :title, :author, :content
data_dir File.dirname(__FILE__) + '/data'
end
def fn
File.expand_path(File.dirname(__FILE__) + '/data/book.yml')
end
describe Book, '(setup)' do
before(:each) do
File.delete(fn) rescue ''
end
... |
# frozen_string_literal: true
class AddTimestampsToAssignments < ActiveRecord::Migration[5.0]
def change
add_column :assignments, :created_at, :datetime
add_column :assignments, :updated_at, :datetime
change_column :assignments, :created_at, :datetime, null: false
change_column :assignments, :update... |
require 'spec_helper'
RSpec.describe Pick::Widget::PickMany do
describe '#pick_many' do
subject do
build_config :interests
end
it 'question is registered' do
expect(subject.questions.count).to eq(1)
end
it 'question is right type' do
expect(subject.questions.first).to be_a(Pic... |
module IControl::ASM
##
# The ObjectParams interface enables you to manipulate Object Parameters
class ObjectParams < IControl::Base
set_id_name "policy_name"
class AttackSignatureDefinition < IControl::Base::Struct; end
class MetacharDefinition < IControl::Base::Struct; end
class AttackSignatur... |
module Exceptions
class InvalidGameUpdate < StandardError; end
class InvalidGameAttributes < StandardError; end
class UnauthorizedResource < StandardError; end
end |
require 'test_helper'
require 'rails/generators'
require 'rails/generators/migration'
require 'generators/multi_recipient_threaded_messages/scaffold/scaffold_generator'
class ScaffoldGeneratorTest < Rails::Generators::TestCase
tests MultiRecipientsThreadedMessages::Generators::ScaffoldGenerator
destination File.ex... |
class User < ApplicationRecord
has_secure_password
has_one :cart, dependent: :destroy
has_many :orders
validates :email, presence: true, uniqueness: true
before_save :downcase_fields
# Finds a User for Knock auth controller
def from_token_request(request)
find_by email: request[:email].dow... |
require 'yaml'
require 'dot-properties'
module Traject
# A TranslationMap is basically just something that has a hash-like #[]
# method to map from input strings to output strings:
#
# translation_map["some_input"] #=> some_output
#
# Input is assumed to always be string, output is either string
# or... |
class User < ActiveRecord::Base
has_many :questions
has_many :answers
has_secure_password
validates :username, presence: true
end
|
class House
include Comparable
attr_reader :price
def initialize(price)
@price = price
end
def <=>(other)
price <=> other.price
end
def to_s
"House cost: #{price}"
end
end
home1 = House.new(150_000)
home2 = House.new(100_000)
home3 = House.new(170_000)
puts "Home 2 is cheaper" if home2 ... |
module Alf
module Tools
#
# Provides a handle, implementing a flyweight design pattern on tuples.
#
class TupleHandle
# Creates an handle instance
def initialize
@tuple = nil
end
#
# Sets the next tuple to use.
#
# This method installs the ha... |
class InventoryDatasetsWorker
include Sidekiq::Worker
def perform(inventory_id)
inventory = Inventory.find(inventory_id)
create_inventory_dataset(inventory)
end
private
def create_inventory_dataset(inventory)
return unless inventory.valid?
generator = OpeningPlanDatasetGenerator.new(invento... |
shared_examples_for 'Metasploit::Model::Authority seed' do |attributes={}|
attributes.assert_valid_keys(:abbreviation, :extension_name, :obsolete, :summary, :url)
abbreviation = attributes.fetch(:abbreviation)
context "with #{abbreviation}" do
subject(:seed) do
seed_with_abbreviation(abbreviation)
... |
module ApplicationHelper
def google_analytics
tracking_code = <<~JS
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefo... |
require 'spec_helper'
require 'puppet_forge_worker'
describe MaestroDev::Plugin::PuppetForgeWorker do
let(:workitem) { {'fields' => fields} }
let(:path) { File.dirname(__FILE__) + '/data' }
let(:fields) { {
'forge_username' => 'maestrodev',
'forge_password' => 'mypassword',
'name' => 'maven',
'p... |
class RenameUserCareer < ActiveRecord::Migration
def change
rename_table :user_careers, :career_suggestions
end
end
|
require 'bindata'
require 'set'
require 'stringio'
require 'netlink/attribute'
require 'netlink/coding_helpers'
require 'netlink/constants'
require 'netlink/types'
module Netlink
# Raw netlink messages are fairly simple: they consist of a mandatory header
# (Netlink::NlMsgHdr) followed by an optional payload. Th... |
require 'pry'
class JobsController < ApplicationController
def index
if params[:location]
@jobs = Job.filter_by_location(params[:location])
elsif params[:level_of_interest]
@jobs = Job.sort_by_level_of_interest
else
@jobs = Job.all
end
end
def new
@companies = Company.all
... |
require 'unicode'
class String
def self.compare(a, b, do_not_compare_as_downcase = false)
if do_not_compare_as_downcase
Unicode::strcmp(a, b)
else
Unicode::strcmp(Unicode::downcase(a), Unicode::downcase(b))
end
end
if RUBY_VERSION < '1.9'
def <=>(value)
self.class.compare(self... |
# frozen_string_literal: true
class AnotherUserSerializer
include FastJsonapi::ObjectSerializer
attributes :email
end
|
fastlane_version "2.3.1"
REQUIRED_XCODE_VERSION = “8.3.2”
default_platform :ios
platform :ios do
before_all do
# git_pull(only_tags: true)
end
after_all do
# push_git_tags
end
lane :test do
scan
end
def change_log_since_last_tag
# http://git-scm.com/docs/pretty-formats
# <short has... |
class Bookmark < ActiveRecord::Base
attr_accessible :description, :url, :title, :category_id, :snapshot
has_attached_file :snapshot, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/missing.png"
default_scope order('created_at DESC')
self.per_page = 10
belongs_to :categor... |
module Recliner
module Associations
class Reference
attr_reader :id
def initialize(id=nil)
@id = id
end
def ==(other)
other.is_a?(Reference) && id == other.id
end
def to_s
id.to_s
end
def blank?
id.blank?
e... |
# Copyright 2012 Square Inc.
#
# 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 License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
require 'fileutils'
include FileUtils
NAME = "hpricot"
REV = File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
VERS = ENV['VERSION'] || "0.3" + (REV ? ".#{REV}" : "")
CLEAN.include ['ext/hpr... |
class StaffController < ApplicationController
def initialize
super
@var = StaffDecorator.new
@var.link = {
t("cmn_sentence.listTitle", model:Staff.model_name.human) => {controller:"staff", action:"index"},
t("cmn_sentence.newTitle", model:Staff.model_name.human) => {controller:"staff", action:"new"}
}
e... |
class Admin::DashboardController < Admin::BaseController
def index
@logged_users = User.last_logged
end
end
|
FactoryGirl.define do
factory :attachment do
name 'MyString'
category 'MyString'
type ''
link_url ''
end
end
|
module DataPlugins::Contact
class Contact < ApplicationRecord
include Jsonable
include FapiCacheable
# ASSOCIATIONS
belongs_to :owner, polymorphic: true
has_many :contact_persons, class_name: ::DataPlugins::Contact::ContactPerson, dependent: :destroy
belongs_to :location, class_name: ::DataPl... |
module LatoPages
# Classe che gestisce il pannello di backoffice del modulo
class Back::PagesController < Back::BackController
before_action :control_permission
before_action :set_unique_name
def index
@pages = LatoPages::Page.where(visible: true)
end
def edit
@page = LatoPages::P... |
# encoding: utf-8
control "V-52283" do
title "The DBMS must support organizational requirements to enforce the number of characters that get changed when passwords are changed."
desc "Passwords need to be changed at specific policy-based intervals.
If the information system or application allows the user to consecu... |
require File.expand_path('../../../helpers/compute/data_helper', __FILE__)
module Fog
module Compute
class ProfitBricks
class Lan < Fog::Models::ProfitBricks::Base
include Fog::Helpers::ProfitBricks::DataHelper
identity :id
# properties
attribute :name
attribute :... |
require_relative '../test_helper'
require_relative '../../lib/lapis_webhook'
class LapisWebhookTest < ActiveSupport::TestCase
def setup
url = URI.join(random_url, '/webhook/')
WebMock.stub_request(:post, url).to_return(status: 200)
@lw = Lapis::Webhook.new(url, { foo: 'bar' }.to_json)
super
end
... |
module CategoriesHelper
def link_to_edit_category(category)
"/categories/#{category.id}/edit"
end
def category_delete_button(id)
link_to "Delete", category_path(id), :method => 'delete', class: 'btn btn-danger'
end
end
|
require 'PushRadar/version'
require 'PushRadar/Targeting'
require 'PushRadar/APIClient'
require 'json'
require 'digest/md5'
module PushRadar
# A realtime push notifications API service for the web, featuring advanced targeting
class Radar
# Creates a new instance of PushRadar with the specified API secret
... |
class ProcessController < ApplicationController
before_action :authenticate_user!
include SimpleStomp::Helper
include SimpleStomp
RAILS_ROOT = Rails.root
def show_train
@workflow_information = WorkflowInformation.find(params[:id])
end
def update
# 保存权限
@process_id = ... |
class Admin::Kwk::KwkSalesController < Admin::AdminController
before_action :set_kwk_sale, only: [:show, :edit, :update, :destroy]
layout 'admin/fixed'
def index
@kwk_sales = KwkSale.by_deadline
end
def show
@kwk_orders = @kwk_sale.orders.sorted.limit(5)
@products = @kwk_sale.products.sorte... |
namespace :random do
desc 'Добавляет указанное количество пользователей'
task :add_users, [:num] => [:environment] do |_t,arg|
arg[:num].to_i.times do |n|
user = User.new
user.name = SecureRandom.hex(5)
user.email = SecureRandom.hex(2)+'@'+SecureRandom.hex(2)
user.save if user.valid?
... |
# frozen_string_literal: true
require_relative '../customs-declaration-reader'
RSpec.describe CustomsDataCalculator do
let(:customs_data_calculator) { described_class }
let(:group1) {
TravellerGroupCustomsData.new(travellers: [
TravellerCustomsData.new(customs_data: 'abc'),
TravellerCustomsData.ne... |
#==============================================================================
# ** Window_TacticCommand
#------------------------------------------------------------------------------
# After a battler is selected in tactic mode, this window will display the
# commands for controlable battler.
#===================... |
class CirclesController < ApplicationController
respond_to :json
before_filter :auth_user
before_filter :group_admin, only: [:create]
before_filter :circle_group_admin, only: [:destroy, :update]
after_filter :clear_all_data
# params: access_token, group_id, name
# admin's right
def create
@circle = @g... |
require 'rails_helper'
describe Order do
it "has a valid factory" do
expect(build(:order)).to be_valid
end
end
|
require 'rails_helper'
RSpec.describe Blue, type: :model do
it "has a valid factory" do
expect(FactoryBot.build(:blue).save).to be_truthy
end
it "is not valid without a heat_id" do
expect(FactoryBot.build(:blue, heat_id: nil).save).to be_falsy
end
it "is not valid wit... |
class PostMailer < ApplicationMailer
def post_confirm_mail(user)
@user = user
mail to: "@user.email", subject: "Post confirming"
end
end
|
if RUBY_ENGINE == 'rbx'
require_relative 'rbx/unbound_method'
end
require_relative '../source_code/unbound_method_source_code'
require_relative '../to_atomic/atomic_unbound_method'
class UnboundMethod
def source_code
UnboundMethodSourceCode.new(self)
end
def to_atomic
AtomicUnboundMethod.from(self)
... |
class Dojo
attr_reader :team
def initialize(team = Array.new)
@team = team
end
def discount(price, func)
func.call(price)
end
def stats
raw =[]
groups = []
5.times do |i|
raw << i * 10
groups << [{ :avg => i}]
end
{:raw => raw, :groups => groups}
end
def hire(*names)
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :verify_user
helper_method :current_user
helper_method :authenticated_user?
skip_before_action :verify_user, only: [:welcome]
def welcome
@recent = Submission.recent_stories
@random_prompt = Prompt.order... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
#resources :users
#resources :Password
#root "users#show"
get 'users/show', to: 'users#show'
get 'users/create', to: 'users#create'
get 'users/welcomepage', to: 'users#welco... |
class AddUuidIndex < ActiveRecord::Migration[5.2]
def change
add_index :events, [:uuid], name: "index_events_on_uuid", length: 36, unique: true
end
end
|
module Checklist::Json::Document
def ext
'json'
end
def document
File.open(@download_path, "wb") do |json|
yield json
end
@download_path
end
end |
class TicketsMailer < ApplicationMailer
def due_date_reminder
@ticket = params[:ticket]
mail(to: @ticket.assigned_user.email, subject: "You got a new order!")
end
end
|
require 'rails_helper'
RSpec.describe PostsController, type: :controller do
let (:my_post){FactoryGirl.create(:post)}
describe "#new" do
it "renders the new template" do
get :new
expect(response).to render_template(:new)
end
it "instanitiates a new post variable" do
get :new
... |
class CcDeville
class CloudflareResponseError < StandardError; end
def self.clear_cache_for_url(url)
if CheckConfig.get('cloudflare_auth_email')
# https://api.cloudflare.com/#zone-purge-files-by-url
uri = URI("https://api.cloudflare.com/client/v4/zones/#{CheckConfig.get('cloudflare_zone')}/purge_ca... |
def longest_fish(arr)
longest_str=""
arr.each_index do |i|
arr.each_index do |j|
next if i==j
longest_str=arr[j] if arr[i].length < arr[j].length && arr[j].length > longest_str.length
end
end
longest_str
end
arr=['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fii... |
##
# The steps belonging to a task.
# * *Attribute* :
# - +component+ -> string, saving the ID of the component associated with this step.
# - +description+ -> text, saving the description of what the reviewer should do in this step (can't be empty).
# - +event+ -> string, saves the event that should be done in this... |
require 'bundler/setup'
Bundler.require
require 'sinatra/reloader' if Sinatra::Base.development?
require 'sinatra/activerecord'
require './models'
enable :sessions
helpers do
def current_user
User.find_by(id: session[:user])
end
end
before '/tasks' do
if current_user.nil?
redirect '/'
end
end
get '... |
require "nokogiri"
# ReplayIndex stores a replay index in XML format
# It includes all Enumerable features that only require each to be defined.<br />
#
# @example Creating and saving
# index = ReplayIndex.new("index.idx")
# index.add_replay({ :id => 1, :sentinel => "EHOME", :scourge => "LGD" })
# index.replay_... |
class Links::Game::HockeyVizMatchups < Links::Base
def site_name
"Hockey Viz"
end
def description
"5v5 Matchups"
end
def url
"http://hockeyviz.com/game/#{game.game_number}/matchups"
end
def group
4
end
def position
5
end
end
|
class RelationType < ActiveRecord::Base
validates :name, :presence => true
after_destroy :destroy_all_friendship_relations
private
def destroy_all_friendship_relations
FriendshipRelationType.delete_all relation_id: self.id
end
end |
#
# Cookbook Name:: pacemaker
# Recipe:: node_prepare
#
# Copyright 2016, Target Corporation
#
# 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 License at
#
# http://www.apache.org/licenses/LICENSE-2.0... |
class GenericSheet
def initialize(file)
@path = file
end
def path
return @path
end
end |
require_relative 'piece'
require_relative 'steppable'
class King < Piece
include SteppingPiece
def initialize(position, board)
super(position, board)
@value = 0
end
def move_dirs
king_steps
end
end
class WhiteKing < King
def color
"white"
end
def symbol
"\u2654".encode('utf-8')... |
class AddIsInfoToNotifications < ActiveRecord::Migration
def change
add_column :notifications, :is_information, :boolean
end
end
|
class User < ActiveRecord::Base
has_many :jobs
before_save :encrypt_password
def has_password?(submitted_password)
encrypted_password == encrypt(submitted_password)
end
private
def encrypt_password
self.salt = make_salt if new_record?
self.encrypted_password = encrypt(password)
e... |
class Event
# Calls Eventbrite API to retrieve all the
# events for the user authenticated, grabs the attendees
# and the venue, and then caches to entire array.
def self.all
Eventbrite.token = Rails.application.secrets.eventbrite_token
# Cache block
events_json_cache = Rails.cache.fetch('events', ... |
# What we have to do:
# 1) Open a file and extract the text from it
# 2) We have to analyze the text and count how many times
# every word appears
# 3) We have to return this information
# dog eats dog
# { "dog" => 2, "eats" => 1 }
# create an array with the phrase split into words
# hash = {}
# iterate over the ... |
module SuperFormatter
module Hct
Head = Struct.new(:data) do
def indexes
@indexes ||= {
global_order_id: data.index("訂單號碼") || data.index("清單編號"),
mobile: data.index("收貨人電話") || data.index("收貨人電話1"),
recipient: data.index("收貨人") || data.index("收貨人名稱"),
trackin... |
class Municipio < ApplicationRecord
belongs_to :provincia, primary_key: 'id_provincia'
def self.search(search)
if search
where('nombre LIKE ?', "%#{search}%")
else
all
end
end
end
|
require 'rails_helper'
RSpec.describe 'Products API', type: :request do
let!(:products) { create_list(:product, 3) }
let(:product) { products.first }
let!(:variant) { create(:variant, product: product) }
describe 'GET /products' do
before { get '/products' }
it 'returns HTTP status 200' do
expe... |
class AddIntervalToPledges < ActiveRecord::Migration
def change
add_column :pledges, :interval, :integer, default: 1
add_column :pledges, :amount, :decimal, precision: 8, scale: 2
end
end
|
Gem::Specification.new do |s|
s.name = 'external_media'
s.version = '0.0.0'
s.date = '2014-07-12'
s.summary = "Methods for simplifying the use of external pics, videos, sounds"
s.description = "Methods for simplifying the use of external pics, videos, sounds"
s.authors = ["Avi Teve... |
# Copyright (c) 2015 - 2020 Ana-Cristina Turlea <turleaana@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS... |
require 'curb'
require 'nokogiri'
require 'csv'
def get_additive index
return "?p=#{index}&content_only=1&infinitescroll=1"
end
def generate_url (url, index)
return url + get_additive(index)
end
def get_html (url)
http = Curl.get(url)
Nokogiri::HTML(http.body_str)
end
def get_product_links url
result = []... |
require 'raven/version'
require "raven/helpers/deprecation_helper"
require 'raven/core_ext/object/deep_dup'
require 'raven/backtrace'
require 'raven/breadcrumbs'
require 'raven/processor'
require 'raven/processor/sanitizedata'
require 'raven/processor/removecircularreferences'
require 'raven/processor/utf8conversion'
r... |
# frozen_string_literal: true
class TalksController < ApplicationController
def index
@talks = Talk.all
render json: {
data: @talks
}, except: %i[created_at updated_at]
end
end
|
require 'ruble'
command t(:bloginfo_feeds) do |cmd|
cmd.scope = 'source.php'
cmd.trigger = 'blog'
cmd.output = :insert_as_snippet
cmd.input = :none
cmd.invoke do
items = [
{ 'title' => 'RDF', 'insert' => %^rdf_url^},
{ 'title' => 'RSS', 'insert' => %^rss_url^},
{ '... |
module Jekyll
module SlugifyFilter
def slugify(input)
input.gsub(/\./, '').gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase
end
end
end
Liquid::Template.register_filter(Jekyll::SlugifyFilter) |
module FranchiseHelper
def display_ratings
if @franchise.ratings.count.zero?
"No ratings yet"
else
"#{@franchise.average_rating} - #{@franchise.count_ratings} votes"
end
end
def display_user_rating
@rating ? "Your Rating: #{@rating.stars}" : "Your Rating: None"
end
def display_... |
class PlaylistsController < ApplicationController
before_action :set_playlist, only: [:show, :update, :destroy]
# GET /playlists
def index
playlist = Playlist.all
render json: playlist
end
# GET /playlists/1
def show
render json: @playlist
end
# POST /playlists
def create
playlist ... |
class SessionsController < ApplicationController
def create
reset_session
user = User.from_omniauth(request.env["omniauth.auth"])
session[:user_id] = user.id
redirect_to boards_path
end
def destroy
session[:user_id] = nil
reset_session
if flash[:expired]
flash[:message] = "Login... |
require 'test_helper'
class PaymentModesControllerTest < ActionDispatch::IntegrationTest
setup do
@payment_mode = payment_modes(:one)
end
test "should get index" do
get payment_modes_url, as: :json
assert_response :success
end
test "should create payment_mode" do
assert_difference('PaymentM... |
class User < ActiveRecord::Base
has_many :recipes
has_many :allergies
has_many :ingredients, through: :allergies
end
|
#
# Cookbook Name:: kafka
# Attributes:: default
#
# Install
default[:kafka][:version] = "0.8.1.1"
default[:kafka][:version_scala] = "2.9.2"
default[:kafka][:mirror] = "http://www.us.apache.org/dist/kafka"
default[:kafka][:checksum] = "cb141c1d50b1bd0d741d68e5e21c090341d961cd801e11e42fb693fa53e9aaed"
default[:kafka][... |
class RemoveRegimeNameFromHairControls < ActiveRecord::Migration
def change
remove_column :haircontrols, :sessionNumber, :float
remove_column :haircontrols, :regimeName, :string
end
end
|
require "open-uri"
require "net/http"
class Scraper::Aws
DATA_TRANSFER_URL = 'http://aws.amazon.com/ec2/pricing/pricing-data-transfer.json'
EBS_URL = 'http://aws.amazon.com/ec2/pricing/pricing-ebs.json'
S3_URL = 'http://aws.amazon.com/s3/pricing/pricing-storage.json'
S3_REQUESTS_URL... |
require 'thor'
require 'richcss'
module RichcssCLI
class Part < Thor
desc "init <PART_NAME>", "Generate a skeleton directory for your new Rich CSS part"
# part_name
# |--- lib
# | |--- elements
# | | |--- ...
# | |--- box
# | | |--- ...
# |--- part_name.spec
# |---... |
class Plane
attr_reader :flying, :status
def initialize
@flying = true
@status = :landed
end
def flying?
@flying
end
def take_off
@flying = true
@status = :flying
end
def land
@flying = false
@status = :landed
end
end
|
#!/usr/bin/env ruby
# Eventually we want to migrate this to lua or something smaller for
# embedded services.
#
# TODO update the IP address if it's set to be dynamic
# TODO test for error, owns.yml sanity, etc.
require 'yaml'
require 'mustache'
require 'open3'
require 'net/https'
@cur_dir = File.dirname(__FILE__)
... |
class AddPrioridadeToUsers < ActiveRecord::Migration
def change
add_column :users, :prioridade, :integer, :default=>1
end
end
|
class CreateQualityIssues < ActiveRecord::Migration
def change
create_table :quality_issues do |t|
t.string :name
t.integer :project_id
t.integer :production_id
t.integer :installation_id
t.integer :sourcing_id
t.integer :purchasing_id
t.date :report_date
t.integer ... |
class OsxNotifier
CMD = "osascript"
SCRIPT_TEMPLATE = "display notification \"%{message}\" with title \"%{title}\""
def notify(message:, title: 'Pizza Bot')
system(CMD, '-e' , SCRIPT_TEMPLATE % {title: title, message: message})
end
end
|
require 'spec_helper'
describe Api::V1::LocationsController, type: :controller do
it 'calls the location bulk create function and responds with output' do
date_str = '20131016153201'
attrs = attributes_for(:loc_no_user1)
attrs['recorded_time'] = date_str
attrs.stringify_keys!
attrs.each {|k,v| at... |
class Project < ActiveRecord::Base
validates :name, presence: true
validates :person_in_charge, presence: true
validates :contact_address, presence: true
# def check_ruby_version(target_version)
# return 0 if ruby_version == target_version
# target_version_num = Project.version_to_number(target... |
require_relative 'hand.rb'
class Player
attr_reader :name, :chips, :folded
attr_accessor :hand
def initialize(name = "Jeff")
@name, @chips = name, chips
@folded = false
@hand = Hand.new
end
def fold
@folded = true
end
def folded?
@folded
end
def hit(dealer, deck)
dealer.de... |
require 'rails_helper'
RSpec.describe 'the list new page', type: :feature do
xit 'creates a new unarchived list' do
visit '/'
click_link_or_button 'New List'
fill_in 'Title', with: 'Terrible List'
click_link_or_button 'Create List'
expect(page).to have_content('Terrible List')
end
xit 'cre... |
require 'test_helper'
class EnrollmentsControllerTest < ActionDispatch::IntegrationTest
setup do
@enrollment = enrollments(:one)
end
test "should get index" do
get enrollments_url
assert_response :success
end
test "should get new" do
get new_enrollment_url
assert_response :success
end... |
class RenameMathProblemTemplatesToProblemTypes < ActiveRecord::Migration
def self.up
rename_table :math_problem_templates, :problem_types
rename_column :problem_levels, :math_problem_template_id, :problem_type_id
end
def self.down
rename_column :problem_levels, :problem_type_id, :math_problem_templat... |
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../dummy/config/environment.rb', __FILE__)
require 'rspec/rails'
require 'ffaker'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), ... |
json.array!(@identities) do |identity|
json.extract! identity, :name, :password
json.url identity_url(identity, format: :json)
end |
class CDM::EntityDescriptor
DEFAULT_OPTIONS = {
syncable: "YES"
}
attr_reader :name,
:syncable,
:class_name
def initialize(name, options = {})
options = DEFAULT_OPTIONS.merge options
@name = name.to_s.split("_").map(&:capitalize).join
@class_name = optio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.