text stringlengths 10 2.61M |
|---|
class Resource < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :exam_id
belongs_to :exam
end
|
module Raven
module Utils
module RequestId
REQUEST_ID_HEADERS = %w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze
# Request ID based on ActionDispatch::RequestId
def self.read_from(env_hash)
REQUEST_ID_HEADERS.each do |key|
request_id = env_hash[key]
return req... |
module ApplicationHelper
def header_hero?
params[:controller] == 'centres' && params[:action] == "show"
end
def in_lightbox?
false #TODO Add logic here to check if we are in a lightbox.
end
def page? page
params[:controller] == page.to_s
end
def current_url
"#{request.protocol}#{reques... |
describe "User Model - Validation" do
it "Email" do
user = User.new(:name => "YukihiroMatz", :email => 'ajaja@abc.com', :password => "my_password")
user.should be_valid
user.email = "yukihiro.matz@abc.com"
user.should be_valid
user.email = "ajajaabc.com"
user.should_not be_valid
... |
class Post < ApplicationRecord
belongs_to :user
validates :title, presence: true
validates :body, presence: true, length: { maximum: 200 }
# validates :body, length: { maximum: 200 }
end
|
json.array! @friends do |friend|
json.id friend.id
json.first_name friend.first_name
json.last_name friend.last_name
json.email friend.email
# json.friend_id friend.friend_id
json.gender friend.gender
json.profile_pic friend.profile_pic
json.cover_pic friend.cover_pic
end
|
class RenameMatchIdToPlayerIdInStatistics < ActiveRecord::Migration
def change
rename_column :statistics, :match_id, :player_id
end
end
|
require 'spec_helper'
feature 'executing Paloma controller', :js => true do
describe 'after rendering' do
it 'executes the corresponding Paloma controller action' do
visit foo_path(1)
called = page.evaluate_script 'window.called'
expect(called).to include 'MyFoo#show'
end
context ... |
Rails.application.routes.draw do
devise_for :users
get '/step_1', to: 'steps#step_1'
get '/step_2', to: 'steps#step_2'
get '/step_3', to: 'steps#step_3'
get '/about', to: 'pages#about'
get '/about_us', to: 'pages#about_us'
root to: 'pages#home'
get 'dashboard', to: 'dashboards#index'
# For details on... |
require "language/go"
class Jid < Formula
desc "Json Incremental Digger"
homepage "https://github.com/simeji/jid"
url "https://github.com/simeji/jid/archive/0.7.2.tar.gz"
version "0.7.2"
sha256 "a16932049fb617fd7490742fcd3b5f131873309a12d97adbaf41a882cd1b99d1"
head "https://github.com/simeji/jid.git"
de... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'EventsController#index' do
subject(:index) { page }
let(:user) { create :user }
before do
sign_in(user)
visit events_path
end
it 'has a calendar feed url' do
feed_url = events_feed_url token: user.calendar_access_token,
... |
require 'rails_helper'
RSpec.describe Guide::Document do
let(:document) { Guide::Document.new }
describe "#template" do
subject(:template) { document.template }
it { is_expected.to eq "guide/document" }
end
describe "#partial" do
subject(:partial) { document.partial }
it { is_expected.to be... |
require "metacrunch/hash"
require "metacrunch/transformator/transformation/step"
require_relative "../aleph_mab_normalization"
require_relative "./add_short_title"
class Metacrunch::ULBD::Transformations::AlephMabNormalization::AddShortTitleSort < Metacrunch::Transformator::Transformation::Step
def call
target ?... |
class Shop < ActiveRecord::Base
belongs_to :marketplace, class_name: "Shop"
has_many :shops, foreign_key: "marketplace_id"
has_many :methods, class_name: 'ShippingMethod', dependent: :destroy
has_many :zip_rules, through: :methods
has_many :map_rules, through: :methods
has_many :delivery_types, dependent: :... |
# frozen_string_literal: true
class Api::PlanetsController < ApplicationController
def index
SwapiCache::PlanetCache.ensure_planets_cached
@planets = Planet.all
end
def show
id = params.require(:id).to_i
SwapiCache::PlanetCache.ensure_planet_cached id
@planet = Planet.find id
end
end
|
class VPuestoPersona < ActiveRecord::Base
self.table_name="v_puestos_personas"
scope :ordenado_nombre_apellido, -> {order("nombre, apellido")}
end
|
class Hotel < ApplicationRecord
has_many :fees
mount_uploader :image, ImageUploader
end
|
FactoryGirl.define do
factory :recharge do |f|
f.phonenumber "9501499829"
f.circlecode 0
f.operatorcode 0
order
end
end |
class Netty::Handler::HttpInbound < org.jboss.netty.channel.SimpleChannelUpstreamHandler
java_import org.jboss.netty.util.CharsetUtil
java_import org.jboss.netty.buffer.ChannelBuffers
java_import org.jboss.netty.channel.ChannelFutureListener
java_import org.jboss.netty.handler.codec.http.HttpChunk
java_import... |
class AddFinishDateToItems < ActiveRecord::Migration[6.0]
def change
add_column :items, :finish_date, :date
end
end
|
require 'aws-sdk-rds'
module Stax
module Aws
class Rds < Sdk
class << self
def client
@_client ||= ::Aws::RDS::Client.new
end
def clusters(opt)
client.describe_db_clusters(opt)&.db_clusters
end
def instances(opt)
client.describe_db_i... |
require 'spec_helper'
module OCR
describe Recognizer do
Given(:recog) { RECOGNIZER }
Then { expect(recog).not_to be_nil }
describe "recognizing" do
Recognizer::SCANNABLE_CHARS.each.with_index do |sc, i|
context "a scanned character '#{sc}'" do
Then { expect(recog.recognize(sc)).... |
class ServicosController < ApplicationController
before_action :authenticate_user!, only: [:index, :show, :edit, :update, :destroy, :ativos]
before_action :verifica_admin, only: [:index, :show, :edit, :update, :destroy, :ativos]
before_action :set_servico, only: [:show, :edit, :update, :destroy]
# GET /servico... |
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "replicat"
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../dummy/config/environment", __FILE__)
require "rspec/rails"
require "database_cleaner"
RSpec.configure do |config|
copy_master_to_slave = proc do |adapter|
3.times do |i|
c... |
# frozen_string_literal: true
# name = 'Tyler Caceres'
# def say_hi(name)
# puts "Hi, #{name}"
# end
# say_hi(name)
an_array = ['Hello','nurse','and','world']
an_array.each {|word| puts word}
an_array.each do |word|
puts word
end |
# general class to handle comparing and pushing data to the remote end
class UpdateAgent
MAX_HASHES_AT_A_TIME = 500
MAX_TO_BATCH_AT_A_TIME = 10
SLEEP_PERIOD = 3
RETRIES = 5
RETRY_SLEEP = 15
def initialize(data=nil, options={})
@options = options
@options['debug'] = true
@attributes = []
@d... |
# Match -ft
class MatchesFt
def self.===(item)
item.include?('-ft') || item.include?('-FT-')
end
end |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def apply_webkit_hack(stylesheets)
css = stylesheets.collect do |fn|
File.read("#{RAILS_ROOT}/public/stylesheets/#{fn}.css")
end.join("\n")
content_tag("style", css.scan(/^.*?!wk-hack.*?$... |
class Payment < ActiveRecord::Base
validates :amount, presence: true, numericality: true
belongs_to :user
attr_accessor :first_name, :last_name, :number, :month, :year, :verification_value
end
|
class Usuario < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable, :validatable
has_many :seguir
has_many :medicos, through: :seguir
ha... |
require 'open-uri'
class PagesController < ApplicationController
# GET /pages
def index
pages = Page.all
jsonapi_render json: pages
end
# POST /pages
def create
page = Page.new(resource_params)
if Page.exists?(url: page.url)
jsonapi_render_errors json: error_url_already_exists, statu... |
class Backoffice::ServicesController < Backoffice::BackofficeController
def index
@services = Service.order(:id)
end
def new
@service = Service.new
end
def create
service = Service.new(service_params)
if service.save
flash[:success] = 'Produto cadastrado com sucesso!'
redirect_t... |
module Api
module V1
class WithdrawsController < ApplicationController
def withdraw
withdraw_request = AccountWithdrawService.new(
token: request.headers['Authorization'],
amount: withdraw_params[:amount]
).withdraw
if withdraw_request
cash_possibilitie... |
class Contact
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
# == Accessors
attr_accessor :email, :subject, :body
# == Valdiations
validates :email, :subject, :body, presence: true
validate :check_emails
# == Initializer
def initialize(attributes = {})... |
require 'spec_helper'
describe Navigation::PhaseStrategy do
describe "#next" do
it "returns the first section's path" do
phase = FactoryGirl.create(:phase_with_sections)
s = Navigation::PhaseStrategy.new(phase, User.new)
path = double(:path)
s.should_receive(:full_section_path)
... |
class AddHathiTrustAccessColumnToBookTrackerItems < ActiveRecord::Migration[5.1]
def change
add_column :book_tracker_items, :hathitrust_access, :string
add_index :book_tracker_items, :hathitrust_access
end
end
|
require './lib/file_calculator'
class ParsedFile
MEGABYTE = 1024 * 1024
attr_reader :file, :calculator
def initialize(file_hash)
@calculator = FileCalculator.new
@file = file_hash
end
def name
file['name']
end
def extension
file['extension']
end
def author
file['creator']['email']
end
def w... |
# encoding: utf-8
control "V-52225" do
title "The DBMS must limit the use of resources by priority and not impede the host from servicing processes designated as a higher-priority."
desc "Priority protection helps prevent a lower-priority process from delaying or interfering with the information system servicing any... |
require 'sinatra'
require 'csv'
require 'redis'
require 'json'
def get_connection
if ENV.has_key?("REDISCLOUD_URL")
Redis.new(url: ENV["REDISCLOUD_URL"])
else
Redis.new
end
end
def find_articles
redis = get_connection
serialized_articles = redis.lrange("slacker:articles", 0, -1)
articles = []
... |
class AddRimNameToPods < ActiveRecord::Migration
def self.up
add_column "pods", :rim_name, :string
end
def self.down
remove_column "socks", :rim_name
end
end
|
class Api::ApiController < ApplicationController
# include Doorkeeper::Controller
skip_before_filter :verify_authenticity_token
respond_to :json
def render_error(error, error_description, messages)
render :json => ApiError.json(error, error_description, messages)
end
private
def current_user
... |
module HidCore
class Configuration
attr_accessor :identifier, :recorder
def initialize(persistence=:memory)
case persistence
when :memory
require 'hid_core/persistence/memory/identifier'
require 'hid_core/persistence/memory/recorder'
@identifier = HidCore::Persiste... |
class CreateEmployers < ActiveRecord::Migration
def change
create_table :employers do |t|
t.string :name, null: false
t.string :email
t.datetime :dob
t.string :location
t.string :phone_number
t.string :email_token
t.string :phone_token
t.boolean :is_email_verified, ... |
=begin
Заполнить хеш гласными буквами, где значением будет являтся
порядковый номер буквы в алфавите (a - 1)
=end
letters = []
vowels = ["а", "е", "и", "о", "у", "ы", "э", "ю", "я"]
hash = {}
("а".."я").each { |d| letters << d }
# letters.each_with_index do |letter, index|
# vowels.each do |vowel|
# h... |
# encoding: utf-8
module Faceter
module Functions
# Removes selected keys from hash if they values are empty
#
# @example
# selector = Selector.new(only: /b/)
# function = Functions[:clean, selector]
#
# function[foo: {}, bar: {}, baz: :BAZ]
# # => { foo: {}, baz: :BAZ }
... |
module Jawbone
class DailySummary
attr_accessor :data
def initialize(data)
@data = data
end
def steps
@data["move"]["bg_steps"]
end
def kilometers
@data["move"]["distance"]
end
def workout?
!@data["move"]["goals"]["workout_time"].empty?
... |
class AddFieldnameToMeta < ActiveRecord::Migration
def change
add_column :meta, :action, :string
add_column :meta, :url, :string
end
end
|
class AddForumsPostsCounterCacheToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :forums_posts_count, :integer, null: false, default: 0
add_column :users, :public_forums_posts_count, :integer, null: false, default: 0
reversible do |dir|
dir.up do
ActiveRecord::Base.connec... |
class CreateRequestsStoreBalances < ActiveRecord::Migration
def change
create_table :requests_store_balances do |t|
t.decimal :hold_credit_amount, :default => 0.0, :precision => 8, :scale => 2
t.decimal :actual_credit_amount, :default => 0.0, :precision => 8, :scale => 2
t.decimal :credit_amount, :... |
class AddInputOutputToTask < ActiveRecord::Migration[7.0]
def change
add_column :jarvis_tasks, :input, :text
add_column :jarvis_tasks, :output_type, :integer, default: 1
end
end
|
require 'rails_helper'
RSpec.describe Game, type: :model do
before(:each) do
@sport = create(:sport)
@sub_sport = create(:sub_sport, sport_id: @sport.id)
@home_team = create(:home_team, sub_sport_id: @sub_sport.id)
@away_team = create(:away_team, sub_sport_id: @sub_sport.id)
@home_team1 = create(... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "evergreen"
s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jonas Nicklas"]
s.date = "2011-11-02"
s.description = "Run Jasmine JavaScript unit tests, i... |
class DriverService < ActiveRecord::Base
has_many :driver_service_assignations
has_many :drivers, through: :driver_service_assignations
end
|
class WebpagesController < ApplicationController
def index
@webpage = Webpage.new
render :new
end
def show
@webpage = Webpage.friendly.find(params[:id])
@webpage.save_to_database
render layout: 'uglifier'
end
def new
@webpage = Webpage.new
end
def create
@webpage = Webpage.n... |
class Javarepl < Formula
homepage "https://github.com/albertlatacz/java-repl"
url "https://s3.amazonaws.com/albertlatacz.published/repo/javarepl/javarepl/272/javarepl-272.jar"
sha256 "f23a2635adee8dee17099a857d4544105ac1bb21d2bb05480162f1c1e0c525fd"
def install
libexec.install "javarepl-#{version}.jar"
... |
class Cliente
attr_accessor :nombre, :dni
def initialize(nombre, dni)
@nombre, @dni = nombre, dni
end
def calcular_factores
factores = 100.0 * (3.0/10.0)
return factores.round(2)
end
def presentarse
puts "Los datos del cliente con Número de DNI: #{dni}, son lo siguientes:"
puts "Bombre: "... |
require 'spec_helper'
describe Cupcakinator::Base do
before :all do
class CupcakinatorBaseSpecFoo
include Cupcakinator
cupcakinate dir: File.expand_path(File.join(File.dirname(__FILE__), '..')), method: 'el_config', file: 'el_config.yml'
end
end
describe 'cupcakinate' do
# a better ... |
require 'rails_helper'
RSpec.describe Admin, type: :model do
let(:admin) { Admin.create!(email: "user@example.com", password: "password", role: "admin")}
it { is_expected.to have_many(:services) }
it "has an email and password"do
expect(admin).to have_attributes(email: admin.email, password... |
require "application_system_test_case"
class OperadesviaprodusTest < ApplicationSystemTestCase
setup do
@operadesviaprodu = operadesviaprodus(:one)
end
test "visiting the index" do
visit operadesviaprodus_url
assert_selector "h1", text: "Operadesviaprodus"
end
test "creating a Operadesviaprodu"... |
# frozen_string_literal: true
class CreateStudentTableRows < ActiveRecord::Migration[6.0]
def change
create_view :student_table_rows
end
end
|
class MunchieSerializer
include FastJsonapi::ObjectSerializer
set_id { nil }
attributes :destination_city, :travel_time, :forecast, :restaurant
end
|
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold... |
feature "User votes on a review (with AJAX)" do
before(:each) do
user = create(:user)
item = create(:item)
create(:review, item: item)
visit root_path
click_link "Log in"
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Log in"
visit item_pa... |
module DoceboRuby
class Parameters
def initialize(hash)
@hash = hash.to_h
end
def to_s
@hash.values.join(',')
end
end
end
|
class AddEasyColorSchemeColumnToEnumerations < ActiveRecord::Migration
def change
add_column IssuePriority.table_name, :easy_color_scheme, :string, :null => true
add_column IssueStatus.table_name, :easy_color_scheme, :string, :null => true
add_column Tracker.table_name, :easy_color_scheme, :string, :null ... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.role? :admin
can :manage, [User, Setting, Page]
end
if user.role? :moderator
can :manage, [Block, Navigator, Banner]
end
if user.role? :author
can :manage, [Ar... |
class Api::V1::PostResource < Api::V1::ApplicationResource
attributes :title, :body, :published_at, :author_nickname
model_name 'Post'
has_one :user
def author_nickname
@model.user.nickname
end
def fetchable_fields
super - [:updated_at] + [:author_nickname]
end
def self.sortable_fields(context)
... |
class Scrabble
def initialize(word)
@word = word_prep(word)
end
def self.score(word)
Scrabble.new(word).score
end
def score
score = 0
@word.chars.each do |char|
case char
when /[aeioulnrst]/ then score += 1
when /[dg]/ then score += 2
when /[bcmp]/ then score += ... |
class Interest < ActiveRecord::Base
attr_accessible :interest
has_many :user_interests
has_many :users, :through => :user_interests
end
|
class Idea < ActiveRecord::Base
belongs_to :user
has_many :photos
has_many :comments
validates :price, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :name, presence: true
end
|
class DailyExercise < ApplicationRecord
belongs_to :day
belongs_to :exercise
end |
class Location < ActiveRecord::Base
attr_accessible :address, :club_name, :gmaps, :latitude, :longitude, :logo
acts_as_gmappable
def gmaps4rails_address
#describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
address
end
def gmaps4rail... |
class Admin::StoresController < ApplicationController
before_action :set_admin_store, only: [:show, :edit, :update, :destroy]
# GET /admin/stores
# GET /admin/stores.json
def index
@admin_stores = Store.all
end
# GET /admin/stores/1
# GET /admin/stores/1.json
def show
end
# GET /admin/stores/... |
json.array!(@students) do |student|
json.extract! student, :id, :firstname, :lastname, :birthdate, :description, :age
json.url student_url(student, format: :json)
end
|
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :commentable, :polymorphic => true
belongs_to :group, :class_name => "Stream", :foreign_key => "commentable_id"
def set_uuid
self.uuid = SecureRandom.uuid
end
def id
self.uuid
end
def find(uuid)
Comment.find_by_uuid(uuid)
end... |
# frozen_string_literal: true
require_relative 'connection'
module Engine
class Hex
attr_reader :connections, :coordinates, :layout, :neighbors, :tile, :x, :y, :location_name
DIRECTIONS = {
flat: {
[0, 2] => 0,
[-1, 1] => 1,
[-1, -1] => 2,
[0, -2] => 3,
[1, -1]... |
require_relative 'season_stat_helper'
class SeasonStatistics < SeasonStatHelper
def winningest_coach(season)
winningest_coach_name = nil
highest_percentage = 0
coaches_per_season(find_all_seasons)[season].each do |coach, results|
total_games = 0
total_wins = 0
results.each do |game_resu... |
require_relative 'helper'
class Test_Striuct_Subclass_Instance_KeyVallidatable < Test::Unit::TestCase
Sth = Striuct.new :foo, :bar
def test_valid_keys?
sth = Sth.new
assert(sth.valid_keys?(must: [:foo, :bar]))
assert(sth.valid_keys?(let: [:foo, :bar]))
assert(sth.valid_keys?(must: [:foo], let: ... |
# Helper Method
def position_taken?(board, location)
!(board[location].nil? || board[location] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
def won?(board)
WIN_COMBINATIONS.detect do |winning_array|
... |
class WelcomeController < ApplicationController
# layout 'application'
def index
@page_title = "Welcome to MCP!"
end
end
|
require 'test_helper'
class StoreFlavorTest < ActiveSupport::TestCase
should belong_to(:flavor)
should belong_to(:store)
context "Creating a context for store_flavors" do
# create the objects I want with factories
setup do
@teststore=FactoryBot.create(:store)
@testflavor=FactoryBot.create(:... |
# Migration to create notebooks table
class CreateNotebooks < ActiveRecord::Migration[4.2]
def change
create_table :notebooks do |t|
t.string :uuid, index: { unique: true }, null: false
t.string :title, index: true, null: false
t.text :description, null: false
t.boolean :public, null: fals... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
before_action :configure_devise_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
# Define the before_action elements
... |
class Trip < ApplicationRecord
include SearchTrip
geocoded_by :address
after_validation :geocode
# バリデーション
validates :place_detail, length: {maximum: 300}
#アソシエーション
has_many :favorites, dependent: :destroy
has_many :reviews, dependent: :destroy
has_many :wannagos, dependent: :destroy
has_many ... |
class Temporaltask < Simpletask
validates :fecha_inicio, :fecha_fin, presence: true
validate :valid_date_range_required
def valid_date_range_required
if (fecha_inicio && fecha_fin) && (fecha_fin < fecha_inicio)
errors.add(:fecha_fin, "Debe Ser Mayor La Fecha de Valido Hasta")
end
end
end
|
module IControl::Networking
##
# The ProfileIPIP interface enables you to manipulate an IP-IP tunnel profile to configure
# the IP-within-IP tunneling protocol. The IP-within-IP protocol (RFC2003) specifies
# how to encapsulate an IP packet within another IP packet.
class ProfileIPIP < IControl::Base
set... |
# frozen_string_literal: true
class PictureUploader < CarrierWave::Uploader::Base
storage Rails.env.production? ? :fog : :file
def store_dir
"anime-music-uploads/#{model.class.to_s.underscore}/#{model.id}"
end
def extension_whitelist
%w[jpg jpeg gif png]
end
end
|
class AddDisplayPositionToBody < ActiveRecord::Migration
def change
add_column :bodies, :display_position, :integer
end
end
|
require 'active_support/concern'
require 'active_support/core_ext/class/attribute.rb'
require 'active_support/core_ext/object/blank.rb'
module IContact
module Model
extend ActiveSupport::Concern
extend ActiveModel::Naming
included do
include ActiveModel::Conversion
include ActiveModel::Valid... |
class LinksController < ApplicationController
def visit
time_now = Time.now
link = Link.find_by_unique(params[:link])
history = EmailHistory.find_by_unique(params[:history])
timestamps = {:open_at => time_now}
timestamps.merge!(:visit_at => time_now) if params[:activity] == 'visit'
history.up... |
# == Schema Information
#
# Table name: people
#
# id :integer not null, primary key
# location_id :integer
# pfid :string(255)
# name :string(255)
# date_of_birth :string(255)
# place_of_birth :string(255)
# description :string(255)
#
require 'nokogiri'
require '... |
class Gamer < Player
NAME = 'Игрок'
def initialize(name = NAME)
@name = name
super
end
end
|
class GildedRose
attr_accessor :items
SULFURAS = 'Sulfuras'
AGED_BRIE = 'Aged Brie'
BACKSTAGE = 'Backstage passes'
CONJURED = 'Conjured'
ZERO = 0
TEN = 10
FIVE = 5
QUANTITY_LIMIT = 50
def initialize(items)
@items = items
end
def update_quality()
@items.each do |item|
next ... |
require 'test_helper'
class RunnerTasksControllerTest < ActionDispatch::IntegrationTest
setup do
@runner_task = runner_tasks(:one)
end
test "should get index" do
get runner_tasks_url
assert_response :success
end
test "should get new" do
get new_runner_task_url
assert_response :success
... |
RSpec.shared_examples 'class methods' do
let(:subject_1) { create_subject.call }
let(:step) { subject_1.next_position_step }
def fetch_models
subject_1.class.all.order('position ASC')
end
describe 'reinit positions' do
before do
10.times do
model = create_subject.call
model.mov... |
require 'spec_helper_acceptance'
describe 'bluejeans class' do
describe 'running puppet code' do
pp = <<-EOS
if $::osfamily == 'RedHat' {
class { 'epel': } -> Class['bluejeans']
}
include ::bluejeans
EOS
it 'applies the manifest twice with no stderr' do
apply_manifest(pp... |
class CreateAnswers < ActiveRecord::Migration
def self.up
create_table :answers do |t|
t.column :user_id, :integer
t.column :question_id, :integer
t.column :text, :text
end
add_index :answers, :user_id
add_index :answers, :question_id
end
def self.down
drop_table... |
# Value object that goes to canvas api calls
class ParamsForCanvasApi
attr_accessor :canvas_api, :canvas_token, :course_id, :data
def initialize(canvas_api, canvas_token, course_id, data)
@canvas_api = canvas_api
@canvas_token = canvas_token
@course_id = course_id
@data = data
end
end
|
require 'test/unit'
require 'parser'
require 'stringio'
require 'semantic_analysis'
class TestVariableReferenceDecorator < Test::Unit::TestCase
def test_defun_varref
program = get_program("(defun myfun (a b) (+ (+ 1 1) (+ a b)))" +
"(defun second (z) z)")
decorator = VariableRefer... |
class Pin < ActiveRecord::Base
belongs_to :user
validates :user_id, presence: true
belongs_to :user
validates :user_id, presence: true
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.