text stringlengths 10 2.61M |
|---|
class AddLevelToUsers < ActiveRecord::Migration
def change
add_column :users, :user_level, :string, :default => "contributor"
end
end
|
require "rails_helper"
require "spec_helper"
describe Game do
it { should have_valid(:name).when('Pokemon Soon', 'Pokemon Mun')}
it { should_not have_valid(:name).when(nil, '')}
it { should have_valid(:summary).when('Cool pokemon', 'Awesome pokemon')}
it { should_not have_valid(:summary).when(nil, '')}
it ... |
# Optional recipe to build a system wide ruby
# with https://github.com/fnichol/chef-ruby_build
# Prevent ruby_build recipe from compiling git from source
include_recipe "git"
include_recipe "ruby_build"
# Users part of the ruby group will be able to install gems
group "ruby"
group "ruby" do
append true
members... |
Puppet::Type.newtype(:powerdns_record) do
@doc = ' ensure a zone exists.'
newparam(:name, namevar: true) do
desc 'name of the record as namevar'
validate do |value|
raise ArgumentError, 'The name of the zone needs to be a string' unless value.is_a?(String)
end
end
newparam(:target_zone) do
... |
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'blueprints', 'helper'))
require 'shoulda'
class SubmissionTest < ActiveSupport::TestCase
should have_many :submission_files
should 'automatically create a result' do... |
class UsersController < ApplicationController
before_filter :authenticate_user!, only: [:index, :edit, :update, :destroy, :followers, :follow, :unfollow]
before_action :set_user, only: [:documents, :collections, :show, :edit, :update, :destroy, :followers, :follow, :unfollow]
def follow
if request.xhr?
... |
class Message < Sequel::Model
def validate
super
validates_presence %i[type direction from to text state]
%i[from to].each do |side|
number = send(side)
errors.add(side, 'is invalid') unless Phony.plausible?(number, cc: '1')
end
end
def before_validation
super
self.from = Phon... |
require 'spec_helper'
describe "Plans" do
subject { page }
describe "As an admin" do
let(:admin_user) { FactoryGirl.create(:user, :admin => true) }
let(:plan) { FactoryGirl.create(:plan, level: "Basic") }
before(:each) do
sign_in admin_user
visit root_path
end
it { should h... |
Rails.application.routes.draw do
# Session
get "signin" => "session#new", as: "signin"
post "login" => "session#create", as: "login"
delete "logout" => "session#destroy", as: "logout"
# Registration
get "register" => "register#new", as: "register"
post "register" => "register#create", as: "new_registrati... |
class AddLocationAttributesToSearch < ActiveRecord::Migration
def change
add_column :searches, :location_lat, :float
add_column :searches, :location_lng, :float
add_column :searches, :location_type, :string
end
end
|
json.array!(@stage_common_options) do |stage_common_option|
json.extract! stage_common_option, :id, :group_id, :own_equipment, :bgm, :camera_permittion, :loud_sound, :stage_content
json.url stage_common_option_url(stage_common_option, format: :json)
end
|
# -*- encoding: utf-8 -*-
Gem::Specification.new do |gem|
gem.authors = ["Delisa Mason"]
gem.email = ["iskanamagus@gmail.com"]
gem.description = %q{Integer <=> Japanese number converter}
gem.summary = %q{A library for converting between positive integers and Sino-Japanese numbers or text.... |
require 'rails_helper'
class TestException < RuntimeError; end
describe ApplicationController, type: :controller do
context "when an exception is raised" do
controller do
def index
fail TestException
end
end
it 'returns json' do
expect(Bugsnag).to receive(:notify).with(TestExcept... |
class Activity < ActiveRecord::Base
attr_accessible :activity_category_id, :hours
belongs_to :log_entry
belongs_to :activity_category
delegate :code, :name, to: :activity_category
end
|
class Interface::Base
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
@persisted = false
attr_accessor :name, :old_name, :method, :method, :address, :netmask, :gateway, :dns_nameservers
validates :name,
:presence => { :message => 'Podaj nazwe strefy' },
... |
class Appointment < ActiveRecord::Base
# scope :last_appointment, lambda { where("visit_date <= ?", Time.now)}
attr_accessible :visit_date, :requires_reminder, :reason_for_visit, :pet_id
belongs_to :customer
belongs_to :pet
belongs_to :user
validates_presence_of :reason_for_visit
validates_date :... |
# -*- coding: utf-8 -*-
module Susanoo
module Accessibility
class Michecker < Base
def validate(target)
response = send_request(target)
response_to_messages(response)
end
private
#
#=== michecker でHTMLをチェックする
#
def send_request(target)
... |
# frozen_string_literal: true
module Admin
class PostsController < ApplicationController
helper PostsHelper
before_action :authenticate_user!
before_action :set_post, only: %i[edit destroy update]
def index
@posts = policy_scope(Post).page(params[:page])
end
def new
@post = curr... |
#!/usr/bin/env ruby
require "twitter"
# dm2twitter.rb looks up the latest direct messages and posts
# them as a update if the sender was in the whitelist.
#
# Licence: BSD
# Author: Jeena Paradies <spam@jeenaparadies.net>
# Dependences: twitter gem <http://twitter.rubyforge.org/>
#
# You could use it with Postfix and... |
#==============================================================================
# Escape Codes Fix
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: April 23, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# By default, the game would crash... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
# Force signout to prevent CSRF attacks
def handle_unverified_request
sign_out
... |
require 'rails_helper'
describe User do
context "when user gets created" do
let(:user) {User.new(email: "bob@gmail.com", password: "password123") }
end
it "user not valid without an email" do
expect(User.new(email: "", password: "password123")).not_to be_valid
end
context "when user gets created"... |
class CustomersController < ApplicationController
before_action :set_customer, only: [:show, :edit, :update, :destroy, :customer_status]
def show
@customer = current_customer
end
def edit
@customer = Customer.find(params[:id].to_i)
end
def cancel
@customer = Customer.find(params[:id].to_i)
end
def updat... |
module Sumac
module LocalObject
# Methods to put into an instance that is exposed.
module SingletonMethods
# attr_reader :__child_accessor__
# def child_accessor(method_name = nil)
# unless method_name.is_a?(Symbol) || method_name.is_a?(String)
# raise ArgumentError, "'c... |
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Opinions
describe RequestAccessToCollaborativeDraft do
let(:component) { create(:opinion_component) }
let(:state) { :open }
let(:collaborative_draft) { create(:collaborative_draft, state, component: component, users: [a... |
require 'rails_helper'
RSpec.describe "class_rooms/index", :type => :view do
before(:each) do
assign(:class_rooms, [
ClassRoom.create!(),
ClassRoom.create!()
])
end
it "renders a list of class_rooms" do
render
end
end
|
require 'RMagick'
def do_flip(img)
img.flip
end
def do_rotate(img)
img.rotate(45)
end
def do_implode(img)
img = img.implode(0.65)
end
def do_resize(img)
img.resize(120,240)
end
def do_text(img)
text = Magick::Draw.new
text.annotate(img, 0, 0, 0, 0, "51hejia") do
self.gravity = Magick::SouthGravity
... |
desc "Create dummy plants for batches"
# Call this using
# heroku run rake 'generate_plants_for_batch[C18]' -a cannected-beta
task :generate_plants_for_batch, [:batch_no] => :environment do |t, args|
args.with_defaults(:batch_no => "B01")
pp "Generate plants for #{args.batch_no}"
batch_no = args.batch_no.to_s
... |
require "bundler/capistrano"
require "rvm/capistrano"
require "rvm/capistrano/gem_install_uninstall"
require 'capistrano-unicorn'
#server "10.74.0.112", :web, :app, :db, primary: true
server "10.48.252.23", :web, :app, :db, primary: true
set :application, "portal_de_servicos"
set :user, "sistemas"
set :port, 22
set :d... |
class Like < ActiveRecord::Base
acts_as_paranoid
belongs_to :likeable, :touch => true, polymorphic: true, counter_cache: true
belongs_to :creator, class_name: "User"
validates :creator_id, presence: true
private
after_restore do
Object.const_get(likeable_type).reset_counters(likeable_id, :li... |
require 'test_helper'
class Admin::PhonesControllerTest < ActionController::TestCase
setup do
@admin_phone = admin_phones(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:admin_phones)
end
test "should get new" do
get :new
assert_respo... |
require 'javaclass/java_language'
require 'javaclass/delegate_directive'
module JavaClass
# Mixin with logic to work with Java package names. The "mixer" needs to declare a String field @package.
# Author:: Peter Kofler
module PackageLogic
# Return the package name of a classname or the n... |
class Commute < ActiveRecord::Base
has_carbon_data_stored_in_amee :profile => :project, :repetitions => true
cattr_reader :per_page
COLOUR = "#86CE66"
TYPE = {
:bus => AmeeCategory.new("Bus", :journey_distance, "/transport/bus/generic/defra", :type => "typical"),
:cycling => AmeeCategory.new("Cycling"... |
require File.expand_path('../spec_helper', File.dirname(__FILE__))
describe Tr8n::LanguageCase do
describe "language case creation" do
before :all do
@user = User.create(:first_name => "Mike", :gender => "male")
@translator = Tr8n::Translator.create!(:name => "Mike", :user => @user, :gender => "male"... |
require 'dm-core'
require 'cgi'
module DataMapper
class Property
module Legacy
class HTMLText < Text
#
# Unescaped HTML escaped data.
#
# @param [String, nil] value
# The HTML escaped data.
#
# @return [String, nil]
# The HTML unescaped ... |
class Author < ApplicationRecord
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
has_many :books
has_and_belongs_to_many :categories
has_attached_file :photo_author
validates_attachment_content_type :photo_author, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
... |
class BooksController < ApplicationController
load_and_authorize_resource
def create
if @book.save
redirect_to books_path, :notice => "Libro #{@book.title} creado."
else
render :action => 'new'
end
end
def update
if @book.update_attributes(params[:book])
redirect_to books_... |
class Api::V1::DatasetsController < ApplicationController
before_action :set_page_and_dataset
before_action :authorize_account!
# GET /api/v1/pages/*relative_path/dataset
def show
render json: @dataset
end
# PATCH /api/v1/pages/*relative_path/dataset
def update
if !dataset_params
render js... |
class CreateQuizSolutions < ActiveRecord::Migration[6.1]
def change
create_table :quiz_solutions do |t|
t.integer :quize_id
t.integer :student_id
t.float :grade
t.timestamps
end
end
end
|
class Human
def initialize(name, hair_color, programmer, languages, programming_languages=[])
@name = name
@hair_color = hair_color
@programmer = programmer
@languages = languages
@programming_languages = programming_languages
end
def say_hi
p "Hi, my name i... |
# -*- coding: utf-8 -*-
# Symbols table
# Holds the data regarding variable names, their values, and
# function names, their arguments, instructions, and return type.
# May also be queried for a function call's result.
#
# Author: Jonathan Reyes (Alias: Jay Kozatt)
class SymTableError < RuntimeError; end
class Redef... |
class AddAboutToHomes < ActiveRecord::Migration[5.1]
def change
add_column :homes, :titre1_about1, :string
add_column :homes, :texte1_about1, :string
add_column :homes, :image1_about1, :string
end
end
|
class AddAttributesForVotes < ActiveRecord::Migration[5.2]
def change
add_column :votes, :work, :integer
add_column :votes, :user, :integer
end
end
|
class Manage::AttachmentsController < Manage::ApplicationController
inherit_resources
actions :all, :except => [:index, :show, :create]
def create
@attachment = Attachment.create(attachment_params)
if @attachment.save
render :json => { :message => 'success' }, :status => 200
else
render ... |
require 'fileutils'
class CRF
#attr_reader :primaryTables, :subTables
attr_reader :dates, :clean
def initialize(dir=Dir.home)
@home = dir
@clean = "#{dir}/cleaned"
@discard = "#{dir}/discard"
@primaryTables = {
'DI' => 'di_demographics_identifiers_9_6',
'RD' => 'rd_initial_referral_diagnosis_5_1',... |
require 'rails_helper'
describe JobPostingsController do
before(:all) do
# create necessary org, job, and jp test objects
@active_org = create(:organization, :active)
@job_active_org = create(:job, organization: @active_org)
# these cases imply that two job postings can be created for a single job
... |
Foodmatrix01::Application.routes.draw do
root 'welcome#index'
resources :grocery_lists
resources :grocery_list_items
resources :grocery_list_item_lists
resources :ingredients
resources :recipes
resources :recipe_ingredients
resources :users
resources :user_grocery_lists
end
|
class CreatePodcasts < ActiveRecord::Migration
def change
create_table :podcasts do |t|
t.string :title
t.string :url
t.text :description
t.date :pub_date
t.date :last_build_date
t.date :last_refresh
t.timestamps
end
end
end
|
source 'https://rubygems.org'
# Rails Version locked to last 4.2.x
gem 'rails', '4.2.8'
# View support
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bootstrap-sass'
gem 'haml-rails'
gem 'high_voltage'
# Database... |
require 'tmpdir'
require 'tempfile'
require 'securerandom'
require 'twit'
require 'spec_helper'
describe Twit::Repo do
describe "#new" do
before do
@tmpdir = Dir.mktmpdir
# OS X uses /private/tmp and /tmp interchangably, so straight comparison
# of directories sometimes fails. Instead, dete... |
class TransactionBar < ActiveRecord::Base
belongs_to :input_bar
belongs_to :employee
belongs_to :table_bar
belongs_to :product, foreign_key: 'product_code', primary_key: 'code'
after_create :update_stock
validates_presence_of :product_code, :date_t
validates :quantity, numericality: { greater_than: 0 }
... |
# frozen_string_literal: true
describe Kafka::Cluster do
let(:broker) { double(:broker) }
let(:broker_pool) { double(:broker_pool) }
let(:cluster) {
Kafka::Cluster.new(
seed_brokers: [URI("kafka://test1:9092")],
broker_pool: broker_pool,
logger: LOGGER,
)
}
describe "#get_leader" ... |
require 'rails_helper'
RSpec.describe Post, type: :model do
describe 'assosiations' do
it 'can have many likes' do
post = Post.reflect_on_association(:likes)
expect(post.macro).to eql(:has_many)
end
it 'can have many comments' do
post = Post.reflect_on_association(:comments)
expec... |
class UsersController < ApplicationController
include ApplicationHelper
before_action :authenticate_user!
before_action :correct_user, only: [:edit, :update]
def show
@user = User.find params[:id]
@statuses = Status.show_users @user
@status = Status.new
@group = Group.new
@user_friendship = curr... |
require "rails_helper"
RSpec.describe ResetMailer do
before do
user = User.create(name: "jill", email: "jill@jill.com",
password: "password", role: "student", course_name: "GBO INC")
end
describe "sending it" do
let(:mail) { described_class.password_reset(user).deliver_now }
let(:user) { User... |
# frozen_string_literal: true
FactoryGirl.define do
factory :admin_user do
full_name { Faker::Name.name }
email { Faker::Internet.email }
password { SecureRandom.hex }
end
end
|
require 'rails_helper'
RSpec.describe ApplicationForm, type: :model do
let(:job) { Job.create!(name: "foo", description: "bar") }
let(:form) { ApplicationForm.new(email: "foo", name: "bar", job: job, phone_number: "1112223333", address: "123 abc st") }
[
:email,
:name,
:phone_number,
:address,
... |
class FontAndika < Formula
version "6.101"
sha256 "8595a879054a540b24fa942a2621efcd194a9f6468d9cf2541ae693e496b8dd4"
url "https://software.sil.org/downloads/r/andika/Andika-#{version}.zip"
desc "Andika"
desc "Sans-serif font family designed and optimized for literacy use"
homepage "https://software.sil.org/... |
class Command < ApplicationRecord
belongs_to :genre
belongs_to :command_type
belongs_to :user
has_one :command_file, dependent: :destroy
accepts_nested_attributes_for :command_file
validates :description, length: { maximum: 50_000, too_long: '最大5万文字までです' }
validates :title, length: { maximum: 50, too_lon... |
class ChangeDefaultImageUrlToGuilds < ActiveRecord::Migration[6.1]
def change
change_column_default :guilds, :image_url, "assets/lee.png"
end
end
|
require File.dirname(__FILE__) + '/../lib/group_open_id'
describe GroupOpenID do
it "should return nil unless it can't discovers a membership location" do
client = GroupOpenID::Client.new
client.fetcher = fetcher(:head => {})
client.membership_location('').should == nil
end
it "should discover the... |
class LearningTrackReview < ActiveRecord::Base
include Accessable
include AchievementConcerns::LearningTrackReviewAchievementable
belongs_to :learning_track
belongs_to :student_class
belongs_to :user
REVIEWS_TYPES_TEXTS = I18n.t('app.track_review')
REVIEWS_TYPES = {
:all_new => 1,
:something_n... |
class TicTacToeGame < ActiveRecord::Base
has_many :participants
has_many :users, -> { order("participants.created_at") }, through: :participants
has_one :board, dependent: :destroy
end
|
require 'rails_helper'
describe 'Authentication' do
let(:user) { FactoryBot.create(:user) }
it 'allows users to log in' do
sign_in(user)
expect(current_path).to eq(user_path(user))
end
it 'does not allow users to login with incorrect credentials' do
incorrect_sign_in(user)
expect(current_path)... |
# Write a method that takes two Array arguments in which each Array contains a list of numbers, and returns a new Array that contains the product of every pair of numbers that can be formed between the elements of the two Arrays. The results should be sorted by increasing value.
# You may assume that neither argument ... |
require "faraday"
require "faraday_middleware"
module Cielo
class API
using Extensions
attr_reader :environment
delegate :get, :post, :put, to: :@connection
def initialize(merchant_id = nil, merchant_key = nil, environment = nil, logger: nil)
@environment = environment || Cielo.environment |... |
module HitorigotoReporter
class Formatter
def initialize(hitorigoto_list)
@hitorigoto_list = hitorigoto_list
end
def empty?
@hitorigoto_list.empty?
end
def to_markdown
filtered_list, file_comments = filter_list_and_extract_comments
filtered_list
.reverse
... |
class Api::ApplicationController < ActionController::Base
def authentication
if !token || !current_user
error "Authentication ERROR"
end
end
def ok(data = nil, message = nil)
render json: { status: 'SUCCESS', message: message, data: data }
end
def error(mess... |
module Rails
module Rack
module Log
class Level
class Rule
attr_reader :condition, :options
def initialize(condition, options = {}) #:nodoc:
@condition, @options = condition, normalize_options(options)
end
def default_log_level
(optio... |
# frozen_string_literal: true
# this facade presents data for the user dashboard
class UserDashboardFacade
def initialize(user)
@current_user = user
@token = user.token
end
def repos(limit)
return nil if @token.nil? || @token.github_token.nil?
repos = github_service.find_repositories
repo_o... |
class CreateCsvImports < ActiveRecord::Migration[6.0]
def change
create_table :csv_imports do |t|
t.text :filename
t.boolean :imported
t.timestamps
end
end
end
|
class RHQ_config
def initialize(user = 'rhqadmin', password='rhqadmin')
@server = 'localhost'
@port='7080'
@user = user
@password = password
@rest_base = '/rest'
@base_url = "http://#{@user}:#{@password}@#{@server}:#{@port}" + @rest_base + '/'
end
def base_url
@base_url
end
d... |
require 'rails_helper'
RSpec.describe "equipment/index", type: :view do
before(:each) do
@brand = create(:brand)
@model = create(:model, brand: @brand)
assign(:equipment, [
create(:equipment, brand: @brand, model: @model),
create(:equipment, brand: @brand, model: @model)
])
end
it "r... |
require 'securerandom'
module Token
# Generate a friendly string randomically to be used as token.
def self.friendly_token
SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
end
def generate_token(column)
loop do
token = Token.friendly_token
break token unless self.class.exists?( column =>... |
def echo(string)
"#{string}"
end
def shout(string)
"#{string.upcase}"
end
def repeat(string, num=1)
num.times { |string| print string, " " }
end
def start_of_word(string, num)
"#{string[0, num]}"
end
def first_word(string)
"#{string.split(" ").first}"
end
def titleize(word)
array = word.split(" ")
ar... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
post '/pgp/sign', to: 'application#sign'
end
|
require 'forwardable'
module Almanack
class Calendar
ONE_HOUR = 60 * 60
ONE_DAY = 24 * ONE_HOUR
ONE_MONTH = 30 * ONE_DAY
ONE_YEAR = 365 * ONE_DAY
extend Forwardable
def_delegators :@config, :event_sources, :title, :days_lookahead
def initialize(config)
@config = config
end
... |
class Transaction < ActiveRecord::Base
has_one :inspection
belongs_to :quote
belongs_to :bike_shop
accepts_nested_attributes_for :inspection
end
|
class CreateWatches < ActiveRecord::Migration
def change
create_table :watches do |t|
t.integer :user_id, references: :users, on_update: :cascade, on_delete: :cascade
t.integer :episode_id, references: :episodes, on_update: :cascade, on_delete: :cascade
t.timestamps
end
end
end
|
# Asciidoctor
module Asciidoctor
# Public: Methods to perform substitutions on lines of AsciiDoc text.
module Subs
SPECIAL_CHARS_RX = /[<&>]/
SPECIAL_CHARS_TR = { '>' => '>', '<' => '<', '&' => '&' }.freeze
REPLACEABLE_TEXT_RX = /[&']|--|\.\.\.|\([CRT]M?\)/
if ::RUBY_MIN_VERSION_1_9
... |
class CreateTournamentEntries < ActiveRecord::Migration
def change
create_table :tournament_entries do |t|
t.string :entry_reqs
t.string :format
t.boolean :future
t.boolean :past
t.boolean :ongoing
t.string :links
t.string :location
t.string :name
t.string :pr... |
class ReviewComment < ActiveRecord::Base
belongs_to :review
belongs_to :user
end
|
#!/usr/bin/env ruby
#
# Copyright (c) 2017 joshua stein <jcs@jcs.org>
#
# 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... |
class AddColumnsToInvoicesForCurrency < ActiveRecord::Migration
def change
add_column :invoices, :currency_ref, :string
add_column :invoices, :exchange_rate, :integer
end
end
|
class CreateRequests < ActiveRecord::Migration
def up
create_table :requests do |t|
t.string :status
t.references :user
t.references :reservation
t.references :venue
t.string :phone_number
t.datetime :desired_date
t.string :any_flag
t.string :purpose
t.string ... |
class AddAllowPromotToUser < ActiveRecord::Migration
def change
add_column :users, :allow_promot, :string , :limit => 1
end
end
|
class LanguagePack::NodeInstaller
MODERN_NODE_VERSION = "TO_BE_REPLACED_BY_CF_DEFAULTS"
MODERN_BINARY_PATH = "node-v#{MODERN_NODE_VERSION}-linux-x64"
LEGACY_NODE_VERSION = "0.4.7"
LEGACY_BINARY_PATH = "node-#{LEGACY_NODE_VERSION}"
NODEJS_BASE_URL = "https://s3pository.heroku.com/node/v#{MODERN_NODE_VER... |
require 'rails_helper'
RSpec.describe UsersController, :type => :controller do
render_views
describe "GET 'show'" do
before(:each) do
@user = Factory(:user)
end
it "should be successful" do
get :show, :id => @user
response.should be_success
end
it "should find the right user" do
get :show, :id => @user
assigns(:u... |
# frozen_string_literal: true
require 'simplecov'
SimpleCov.start
require 'minitest/autorun'
require 'minitest/emoji'
require 'time'
require './lib/invoice_repository'
# Invoice repository class
class InvoiceRepositoryTest < Minitest::Test
def setup
@invoice_repo = InvoiceRepository.new
@invoice1 = @invoi... |
gem 'ruby-llvm'
require 'llvm/core'
require 'llvm/execution_engine'
require 'llvm/transforms/scalar'
require 'benchmark'
LLVM.init_x86
m = LLVM::Module.new("Factorial")
m.functions.add("fac", [LLVM::Int], LLVM::Int) do |fac, n|
n.name = "n"
bb = fac.basic_blocks
entry = bb.append("entry")
recur = bb.append("... |
# coding: utf-8
require_relative 'helper'
class TestFunctionalApi < Test::Unit::TestCase
context 'reading' do
test 'successful reading only filenames' do
use_fixture 'exiftool -J a.jpg b.tif c.bmp' do
values, errors = MultiExiftool.read(%w(a.jpg b.tif c.bmp))
assert_kind_of Array, values
... |
class Product < ApplicationRecord
belongs_to :product_category, optional: true
mount_uploader :image, ImageUploader
end
|
Rails.application.routes.draw do
scope "(:locale)", locale: /en|vi/ do
root "static_pages#home"
get "about", to: "static_pages#about"
get "login", to: "sessions#new"
post "login", to: "sessions#create"
delete "logout", to: "sessions#destroy"
get "signup", to: "users#new"
post "signup", to:... |
# frozen_string_literal: true
module MLBStatsAPI
# Operations pertaining to leagues
module Leagues
LEAGUES = {
acc: 108,
al: 103,
american: 103,
big_east: 107,
cactus: 114,
california: 110,
eastern: 113,
grapefruit: 115,
international: 117,
midwest: 1... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/asambleistas/show.html.erb" do
include AsambleistasHelper
before(:each) do
@asambleista = mock_model(Asambleista)
@asambleista.stub!(:nombre).and_return("MyString")
@asambleista.stub!(:telefono).and_return("MyString")
@asambleista.... |
Rails.application.routes.draw do
root to: 'home#index'
get 'home' => 'home#index'
get 'users/new' => 'users#new', as: :new_user
post 'users' => 'users#create'
get '/login' => 'sessions#new'
post '/login' => 'sessions#create'
delete '/logout' => 'sessions#destroy'
# For details on the DSL availab... |
require "spec_helper"
RSpec.describe Anonymized::Anonymizer do
after(:each) do
described_class.configure do |anonymizer|
anonymizer.custom_anonymization_functions = nil
end
Anonymizable.class_eval { acts_as_anonymized :skip }
end
describe "#initialize" do
let(:default_functions) { Anonymi... |
require 'open3'
require 'parallel_tests'
require 'rspec/core/rake_task'
desc "Use the basic rspec rake task with no options WARNING: slow"
RSpec::Core::RakeTask.new(:rspec_basic_mode)
AWS_EXCLUDED_NODE_CLASSES = %w[
api_lb
api_mongo
api_redis
development
email_alert_api
email_alert_api_postgresql
licens... |
require 'json'
class Register
attr_accessor :menu, :quantity_for_transaction, :item_index, :closed, :products_purchased, :transactions, :current_time, :current_date, :open
BAR = '============================='
def initialize
@menu = {}
@item_index = nil
@quantity_for_transaction = {:"1" => 0, :"2" ... |
require 'stringio'
module RackRabbit
class Message
#--------------------------------------------------------------------------
attr_reader :delivery_tag, :reply_to, :correlation_id,
:body, :headers,
:method, :uri, :path, :query, :status,
:content_type, :conte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.