text stringlengths 10 2.61M |
|---|
class Idea < ApplicationRecord
validates :title, presence: true
validates :body, presence: true
validates :quality, presence: true
def self.all_descending
all.order("created_at DESC")
end
end
|
class FixRelationshipForCompanyAndEmployees < ActiveRecord::Migration[5.1]
def change
add_column :company_employees, :employee_id, :integer
add_column :company_employees, :unemployee_id, :integer
add_index :company_employees, :employee_id
add_index :company_employees, :unemployee_id
add_index :co... |
module Smtp
class HeaderWithParams < Header
def initialize(key, value, params)
@key = key
@value = value
@params = params
super @key, value_with_params
end
private
def value_with_params
([@value] + converted_params).join(';')
end
def converted_params
@con... |
require 'yaml'
require 'digest'
class Station
def initialize(config_file_path='./config.yml')
@config_file_path = config_file_path
load_config
end
def config_file_path
@config_file_path
end
def config_file_data
File.open(config_file_path).read
end
def load_config
@config = YAML.loa... |
class FontLemon < Formula
head "https://github.com/google/fonts/raw/main/ofl/lemon/Lemon-Regular.ttf", verified: "github.com/google/fonts/"
desc "Lemon"
homepage "https://fonts.google.com/specimen/Lemon"
def install
(share/"fonts").install "Lemon-Regular.ttf"
end
test do
end
end
|
# frozen_string_literal: true
require 'rails_helper'
describe Transfer::CreateService, type: :module do
describe '#perform!' do
subject { described_class.perform!(params, user) }
let(:params) do
ActionController::Parameters
.new(
transfer: {
source_account_id: source_acc... |
ActiveAdmin.register_page "Dashboard" do
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
content :title => proc{ I18n.t("active_admin.dashboard") } do
div :class => "blank_slate_container", :id => "dashboard_default_message" do
end
# Here is an example of a simple dashboard wi... |
class TypesController < ApplicationController
def index
@types = Type.paginate(per_page: 10, page: params[:page])
end
def new
@type = Type.new
end
def create
@type = Type.create(type_params)
render "new"
end
private
def type_params
params.require(:type).permit(:name, :desc)
end
end
|
# == Schema Information
#
# Table name: decs_tube_type
#
# id :integer(4) not null, primary key
# name :string(255)
# max_volume :float
#
class DecTubeType < ActiveRecord::Base
has_many :tubes
end
|
class Ride
attr_reader :passenger, :driver, :distance
@@all = []
@@premium = []
def initialize(passenger,driver,distance)
@passenger = passenger
@driver = driver
@distance = distance
@@all << self
current_milage = passenger.rides.inject(0){|sum,ride| s... |
RSpec.describe 'grafana2::default' do
let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) }
it 'converges successfully' do
expect(chef_run).to include_recipe(described_recipe)
end
end
|
class State
include Mongoid::Document
field :name, type: String
has_many :cities
end
|
class GardensController < ApplicationController
def show
@garden = Garden.find(params[:id])
@all_vegetables = @garden.vegetables
end
def index
@gardens=Garden.all
end
def new
@gardens = Garden.new
end
def create
@gardens = Garden.new(params.require(:garden).permit(:name, :location))
if... |
require 'asciidoctor'
require 'json'
if Gem::Version.new(Asciidoctor::VERSION) <= Gem::Version.new('1.5.1')
fail 'asciidoctor: FAILED: HTML5/Slim backend needs Asciidoctor >=1.5.2!'
end
unless defined? Slim::Include
fail 'asciidoctor: FAILED: HTML5/Slim backend needs Slim >= 2.1.0!'
end
# Add custom functions to... |
# frozen_string_literal: true
module KeycloakAdapter
class OidcConfiguration
def initialize(issuer:, **opts)
@issuer = issuer
@options = ActiveSupport::OrderedOptions.new.merge(opts)
@configuration = ActiveSupport::OrderedOptions.new.merge(fetch_configuration.symbolize_keys)
@certs = fetc... |
class AddStatusesToNotifications < ActiveRecord::Migration[5.2]
def change
add_column :notifications, :read, :boolean
add_column :notifications, :read_at, :datetime
add_column :notifications, :delivered, :boolean
add_column :notifications, :delivered_at, :datetime
add_column :notifications, :deliv... |
############################################################
#
# Name: Chad Ohl
# Assignment: Character Fight - Character Class
# Date: 5/20/14
# Class: CIS 283
#
############################################################
class Character
include Enumerable
attr_reader(:name,:race,:hit... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# Copyright 2014 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 ... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
BOX_IMAGE = "centos8"
ES_COUNT = 8
MA_COUNT = 3
NODE_COUNT = 4
Vagrant.configure("2") do |config|
#设置所有 guest 使用相同的静态 dns 解析 /etc/hosts
#config.vm.pr... |
require 'test_helper'
class TimeRangeTest < ActiveSupport::TestCase
def test_correct_time_range
range = TimeRange.new 'begin' => Time.now, 'end' => Time.now - 1.day
range.valid?
assert range.errors[:end]
end
end
|
require 'rubygems'
require 'spec/rake/spectask'
task :default => :spec
desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = %w(-fs --color)
end
desc "Run all examples with RCov"
Spec::Rake::SpecTask.new(:rcov) do |t|
t.spec_files = FileList['spec/**/*_spec... |
#!/usr/bin/ruby
=begin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be ... |
class CreateContactrequests < ActiveRecord::Migration[5.0]
def change
create_table :contactrequests do |t|
t.string :firstname
t.string :lastname
t.string :phone_number
t.string :email
t.string :company
t.string :contact_message
t.timestamps
end
end
end
|
class ActiveRecord::Relation
# Asserts that the collection contains exactly one record, and returns it.
#
# If the collection is empty, it raises <tt>ActiveRecord::NoRecordFound</tt>.
# If the collection contains more than one record, it raises
# <tt>ActiveRecord::MultipleRecordsFound</tt>.
def one!
cas... |
class Artist < ActiveRecord::Base
has_many :songs
has_many :genres, through: :songs
def slug
@name = name.downcase.split.join("-")
end
def self.find_by_slug(name)
new_artist = nil
@artists = Artist.all
@artists.each do |artist|
artist.slug == name ? new_artist = artist : nil ... |
require "rails_helper"
RSpec.describe User, type: :model do
describe "Validations:" do
before(:each) do
@user = User.new(
first_name: "Joe",
last_name: "Shmoe",
email: "Joe@shmoe.com",
password: "test",
password_confirmation: "test",
)
end
it "the user... |
class CreateDoubts < ActiveRecord::Migration[6.1]
def change
create_table :doubts do |t|
t.references :user, index: true, foreign_key: true
t.string :title
t.text :description
t.integer :state, default: 0, index: true
t.timestamps
end
end
end
|
class Library < ActiveRecord::Base
audited
belongs_to :library_category
belongs_to :state
belongs_to :city
has_many :attachments, :as => :attachmentable, dependent: :destroy
accepts_nested_attributes_for :attachments, allow_destroy: true, :reject_if => proc { |attrs| attrs[:attachment].blank? }
has_many :word... |
require 'rails_helper'
RSpec.describe 'Users', type: :feature do
let!(:user) { FactoryBot.create(:user, name: "Yamada", email: "yamada@sample.com") }
it 'user can login' do
visit new_user_session_path
fill_in 'メールアドレス', with: user.email
fill_in 'パスワード', with: user.password
click_button 'ログイン'
... |
class FontImFellEnglish < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/imfellenglish"
desc "IM Fell English"
homepage "https://fonts.google.com/specimen/IM+Fell+English"
def install
(share/"fonts").install "IMFeENit28P.ttf"
(sha... |
class SubscribersController < ApplicationController
def index
@subscribers = Subscriber.all
end
def new
@subscriber = Subscriber.new()
end
def edit
@subscriber = Subscriber.find(params[:id])
end
def show
@subscriber = Subscriber.find(params[:id])
end
def create
@subscriber = Su... |
require_relative 'questionsdatabase'
require_relative 'modelbase'
class Like < ModelBase
def self.likers_for_question_id(question_id)
likers = QuestionsDatabase.instance.execute(<<-SQL, question_id)
SELECT
users.*
FROM
users
JOIN
question_likes ON users.id = question_li... |
class Customer
attr_reader :name, :wallet, :age, :drunk_level
def initialize(name, wallet, age)
@name = name
@wallet = wallet
@age = age
@drinks = []
@drunk_level = 0
end
def buy_drink(drink)
@wallet -= drink.price
@drunk_level += drink.units
en... |
class RubyocracyController < ApplicationController
def index
@page_title = 'Welcome to Rubyocracy'
@stories = Story.ordered.paginate :page => params[:page], :include => [:site, :categories], :per_page => 20
respond_to do |format|
format.html { render 'stories/index' }
format.xml { render :... |
require "rails_helper"
RSpec.describe GovukDesignSystem::CheckboxesHelper, type: :helper do
describe "#govukCheckboxes" do
it "returns the correct HTML for the default example" do
html = helper.govukCheckboxes({
idPrefix: "waste",
name: "waste",
fieldset: {
legend: {
... |
Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'users/registrations' }
root to: "recipes#index"
get '/' => 'recipes#index'
get '/recipes' => 'recipes#index'
get '/recipes/new' => 'recipes#new'
get '/recipes/pending' => 'recipes#pending'
patch '/recipes/:id/approval_s... |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/*_test.rb'
t.verbose = true
end
# Generate the RDoc documentation
Rake::RDocTask.new { |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "LDAP ActiveRecord Gateway"
rdoc.options << '--li... |
require 'rails_helper'
RSpec.feature 'Deleting vacation request' do
before do
initialize_app_settings
@employee = create(:employee)
login_as(@employee, scope: :employee)
@vacation_request = create(:vacation_request, requester: @employee)
visit admin_vacation_requests_path
end
scenario 'shoul... |
class Periodicity
ONCE = 0
DAILY = 1
WEEKLY = 2
FORTNIGHTLY = 3
MONTHLY = 4
BIMONTHLY = 5
QUARTERLY = 6
BIANNUALLY = 7
ANNUALLY = 8
def self.options_hash
{ '--Select frequency--' => '', 'Once' => ONCE, 'Daily' => DAILY, 'Weekly' => WEEKLY, 'Fortnightly' => FORTNIGHTLY,
'Monthly' => MON... |
require 'rails_helper'
RSpec.describe 'Merchant API' do
before(:all) do
@merchants = create_list(:merchant, 5)
end
def get_merchant(id)
get "/api/v1/merchants/#{id}"
expect(response).to be_successful
expect(response.content_type).to eq 'application/json'
expect(response.status).to eq 200
... |
class Game < ActiveRecord::Base
attr_accessible :correct_answers_count, :earned_points, :current_question_index
has_many :assignments
has_many :questions, through: :assignments
belongs_to :user
serialize :answered_right, Array
def answer_question(question, answer)
success = false
if question.answ... |
class ApplicationController < ActionController::API
include CanCan::ControllerAdditions
include Authenticable
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit( :email, :pas... |
require 'hyperclient/attributes'
require 'hyperclient/link_collection'
require 'hyperclient/resource_collection'
module Hyperclient
# Public: Represents a resource from your API. Its responsability is to
# ease the way you access its attributes, links and embedded resources.
class Resource
extend Forwardabl... |
class FileReader
def read(file_name: )
@raw_file_text = File.read(File.join(File.dirname(__FILE__), file_name))
end
end |
class Backoffice::SendMailController < ApplicationController
# Nuff said
# POST /backoffice/sendmail
def send_mail
@mail_params = set_params_send_mail
begin
AdminMailer.message_mail(current_admin,@mail_params).deliver_now
@notify_flag = 'success'
@notify_message = 'E-mail enviado com suc... |
module Gitorinox
class GithubAPI
def initialize(login, password)
@client ||= Github.new(login: login, password: password)
end
def matched_repositories(match)
result = []
@client.activity.watching.watched.each_page do |page|
page.each do |repo|
if match
... |
class CreateAssistentAppointments < ActiveRecord::Migration[5.0]
def change
create_table :assistent_appointments do |t|
t.integer :person_id
t.references :appointment, foreign_key: true
t.text :obs
t.timestamps
end
end
end
|
#
# Cookbook Name:: squid
# Recipe:: default
#
# Copyright 2012, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
package "squid" do
action :install
not_if "test -f /etc/init.d/squid"
end
execute "squid.conf" do
command "echo http_port 3128 transparent >> /etc/squid/squid.conf"
action :run
not_if... |
module Effect
class BloodClaws
attr_reader :family
attr_reader :hit_chance
attr_reader :damage_type
attr_reader :damage
attr_reader :name
attr_reader :parent
attr_reader :costs
attr_reader :armour_pierce
def initialize(parent, damage = 6)
@costs = {ap: 1}
@parent = parent
@family = :specia... |
class Admin::CitiesController < ApplicationController
before_action :authenticate_user!
authorize_resource
before_action :load_model, only: [:edit, :update, :destroy]
def index
@cities = City.order("name")
end
def new
@city = City.new
end
def create
@city = City.new city_params
if @... |
class Quest < ActiveRecord::Base
belongs_to :user
belongs_to :trail
belongs_to :trail_location
validates :trail_location_id, :trail_id, :user_id, :presence => true
validates :trail_location_id, :uniqueness => { :scope => [:trail_id, :user_id] }
scope :done, where(:done => true)
scope :todo, where(:don... |
#!/usr/bin/env ruby
# Copyright (c) 2009-2011 VMware, Inc.
#
# This script is used to backup mysql instances used in MyaaS.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
require 'bundler/setup'
require 'vcap_services_base'
$:.unshift(File.expand_path("../../lib", __FILE__))
require 'mysql2'
m... |
mydir = File.expand_path(File.dirname(__FILE__))
begin
require 'psych'
rescue LoadError
end
require 'i18n'
I18n.load_path += Dir[File.join(mydir, 'locales', '*.yml')]
I18n.reload!
module NameGenerator
class Base
attr_writer :locale
def initialize(options={})
self.locale = options[:locale]
end
... |
choices = { 'noun' => %w(man elf orc hobbit dwarf goblin),
'transitive_verb' => %w(stabs kicks ignites hugs trips throws),
'intransitive_verb' => %w(cries yelps collapses roars smiles rebounds),
'adverb' => %w(clumsily drunkenly skillfully cautiously bravely mightily),
'a... |
# == Schema Information
#
# Table name: services_users
#
# id :integer not null, primary key
# service_id :integer
# organization_id :integer
# phone :string(255)
# cost :integer
# showing_time :integer
# created_at :datetime not null
# updated_at ... |
class TorBrowser < Cask
url 'https://www.torproject.org/dist/torbrowser/3.5/TorBrowserBundle-3.5-osx32_en-US.zip'
homepage 'https://www.torproject.org/projects/torbrowser.html'
version '3.5'
sha1 '0b7645421c0afa42fa1e2860f3aa1d978f5d8aed'
link 'TorBrowserBundle_en-US.app'
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV["LC_ALL"] = "en_US.UTF-8"
Vagrant.configure("2") do |config|
# config.vm.box_check_update = true
# config.vbguest.auto_update = false
config.vm.network "private_network", type: "dhcp"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = ... |
module OneDBFsck
def init_cluster
cluster = @data_cluster = {}
@db.fetch("SELECT oid, name FROM cluster_pool") do |row|
cluster[row[:oid]] = {}
cluster[row[:oid]][:name] = row[:name]
cluster[row[:oid]][:hosts] = []
cluster[row[:oid]][:da... |
class S3Storage
def self.url(m)
"#{CLOUDFRONT_BASE_URL}/#{s3_key(m)}"
end
def self.s3_key(m)
"#{m.app}/#{m.context}/#{m.locale}/#{m.file_name}"
end
def invalidate_cloudfront_caching(m)
$cf.create_invalidation({
distribution_id: CLOUDFRONT_DISTRIBUTION_ID,
invalidation_batch: {... |
class FontIosevkaSs13 < Formula
version "18.0.0"
sha256 "74f34822c7ba73455d876543f0720145bc7f88ccef4b38d1ff3dd1e96a386a4f"
url "https://github.com/be5invis/Iosevka/releases/download/v#{version}/ttc-iosevka-ss13-#{version}.zip"
desc "Iosevka SS13"
desc "Sans-serif, slab-serif, monospace and quasi‑proportional ... |
require 'open-uri'
require 'nokogiri'
module Services
class TacoBellScraper
MENU_URI = 'http://www.tacobell.com/nutrition/information'
ROW = 'tbody tr'
CATEGORY = 'nutStatCategoryRow'
def menu
@menu ||= scrape_menu
end
private
def scrape_menu
with_http_error_handling do
... |
class PostsController < ApplicationController
before_filter :require_authentication, :except => [:index, :show, :archive, :articles, :media]
def show
if params[:permalink]
@post = Post.find_by_permalink(params[:permalink])
else
@post = Post.find(params[:id])
end
end
def edit
@p... |
module Paymark
class Object
def initialize(attributes)
attributes.each do |key, value|
send("#{key_map(key)}=", value_map(key, value))
end
end
def self.build(array_or_hash)
if array_or_hash.is_a? Array
array_or_hash.map do |hash|
self.new(hash)
end
... |
class Api::V1::UsersController < ApplicationController
def signup
result = sign_able params
if result[:valid]
@user = User.new(
:username => params[:username],
:lastname => params[:lastname],
:firstname => params[:firstname],
:password => params[:password],
:user_type => params[:u... |
require 'spec_helper'
describe Layout, type: :model do
it { is_expected.to belong_to :keyboard }
it { is_expected.to have_many :layers }
it { is_expected.to validate_presence_of :name }
it { is_expected.to accept_nested_attributes_for :layers }
describe 'kind reader' do
it 'reads the name of the Keyboar... |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.category_name(category_name)
define_method(:category_name) { category_name }
end
end
|
# coding: utf-8
require 'wicked_pdf'
require_relative './htmlentities'
require_relative './helpers'
module DocumentGenerator
class VatCertificate
include DocumentGenerator::Helpers
def initialize
@inline_css = ''
end
def generate(path, data)
coder = HTMLEntities.new
language = s... |
class CreateTubes < ActiveRecord::Migration
def self.up
create_table "tubes", :force => true do |t|
t.string "bar_code"
t.string "clinic_id"
t.integer "sample_type_id"
t.integer "tube_type_id"
t.string "parent_id"
t.string "position"
t.integer "box_id", ... |
class MediaList < ActiveRecord::Base
attr_accessible :address, :circulation, :city, :company, :email, :fax, :phone, :state, :url, :zip
validates :company, presence: true
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: {... |
require 'chemistry/element'
Chemistry::Element.define "Barium" do
symbol "Ba"
atomic_number 56
atomic_weight 137.327
melting_point '1002K'
end
|
module Library
# TODO Comments are needed here to explain how these routines use information
# from the 'env' object and their arguments and how they satisfy return-
# value requirements. For now, please consult Section 5 in ../README
# when reading this code. Other sections of the README may be... |
class CommentsController < ApplicationController
before_action :authenticate_user!
def create
@place = Place.find(params[:place_id])
@comment = @place.comments.create(comment_params.merge(user: current_user))
if @comment.invalid?
flash[:error] = "Could not save: #{@comment.errors.messages}"
redirect_to... |
class Url < ActiveRecord::Base
before_validation :set_token, on: :create
validates :token, presence: true, uniqueness: true
validates :long_url, presence: true, url: true
def to_param
token
end
def self.with_token(token)
tokens = TokenMachine.conversion_token(token)
where(token: tokens).firs... |
module Lolita
module Configuration
# Lolita::Configuration::Tabs is container class that holds all
# tabs for each lolita instance.
# Also it has some useful methods.
class Tabs < Lolita::Configuration::Base
include Enumerable
include Lolita::ObservedArray
attr_reader :excluded
... |
class ImagesController < ApplicationController
before_action :authenticate_user!
before_action :set_image, only: [:show, :edit, :update, :destroy]
def new
@image = Image.new
end
def edit
end
def create
if params[:project_id]
@imageable = Project.find(params[:project_id])
@image =... |
class Api::V1::EventsController < ApplicationController
def index
@events = Event.all
render json: @events
end
def show
@event = Event.find(params[:id])
render json: @event, status: :ok
end
def create
@event = Event.create(event_params)
render json: @event, status: :created
end
... |
class Interest < ActiveRecord::Base
belongs_to :user
validates :interest_name, :presence => true
end
|
module Kernel
def wait_for(conf)
start = Time.now
defaults = {
:timeout => nil,
:step => 0.125
}
conf = defaults.update conf
condition = false
loop do
condition = yield
break if condition
break if conf[:timeout] and Time.now - start > conf[:timeout]
... |
require 'forwardable'
module Gurobi
class Var
extend Forwardable
class << self
# @return [Gurobi::Var]
# @see Gurobi::Model#add_binary_var
def create_binary(*args)
keyword_args = args.last.is_a?(Hash) ? args.pop : {}
keyword_args = { lb: 0.0, ub: 1.0 }.merge(keyword_args)
new(*args, ... |
require 'application_system_test_case'
class OpinionsTest < ApplicationSystemTestCase
setup do
@opinion = opinions(:one)
end
test 'visiting the index' do
visit opinions_url
assert_selector 'h1', text: 'Opinions'
end
test 'creating a Opinion' do
visit opinions_url
click_on 'New Opinion'
... |
require File.dirname(__FILE__) + '/../test_helper'
class ContactsTest < ActionMailer::TestCase
tests Contacts
def test_signup
@expected.subject = 'Contacts#signup'
@expected.body = read_fixture('signup')
@expected.date = Time.now
assert_equal @expected.encoded, Contacts.create_signup(@expect... |
require 'rails_helper'
describe 'As a logged in user' do
before(:each) do
user_logs_in
end
context 'when I visit a company show page' do
let(:company) { company = create_approved_company("Test Company") }
scenario 'I see add findings box' do
visit company_path(company)
expect(page).to... |
class InvestorsUsers < ActiveRecord::Migration
def change
create_table :investors_users do |t|
t.references :user
t.references :investor
t.string :position
t.timestamps
end
add_index :investors_users, :user_id
add_index :investors_users, :investor_id
end
end
|
class Judge::LogReporter
def initialize(logger)
@log = logger
end
def start(solution)
@log.puts "start processing of #{solution.unique_name(:global)}"
end
def compiling
@log.puts "compiling"
end
def compilation_error(output)
@log.puts "compilation error, compiler output is:"
... |
class QuotesController < ApplicationController
def index
@quotes = Quote.all
json_response(@quotes)
end
def search
@quotes = Quote.search_by_term(params[:query])
json_response(@quotes)
end
def show
@quote = Quote.find(params[:id])
json_response(@quote)
end
def create
@quot... |
require 'rails_helper'
feature "cart" do
fixtures :categories
fixtures :items
fixtures :users
before(:each) do
visit "/"
end
it "can visit the cart page" do
click_link("Cart")
expect(current_path).to eq("/cart")
end
it "can add items" do
click_link("All Products")
first(:button, ... |
=begin
* DJKSTRA ALGORITHM
* Description :Calculate the shortest path within the graph depends on the calculate cost
For Time : Every fligth add
=end
class Shortestpath
#Variable to penalyze every layover/stops
TIME_PER_AIR = 2
TIME_AVG_DELAY = 0.5
TOTAL = TIME_AVG_DELAY + TIME_PER_AIR
... |
class Milestone < ApplicationRecord
include Filterable
enum target_type: { revenue: 0,
deals: 1 }
enum status: { active: 0,
archived: 1 }
has_many :user_milestones, inverse_of: :milestone
has_many :users, through: :user_milestones
scope :status, ->(status) { where ... |
require File.join(File.dirname(__FILE__), '..', 'unit_test_helper')
# initialize
# ----------
class IQ::Processor::Adapters::Base::InitializeTest < Test::Unit::TestCase
def test_should_raise_when_no_block_given
assert_raise(ArgumentError) { IQ::Processor::Adapters::Base.new('/path/to/file') }
end
def test... |
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.references :food, index: true, foreign_key: true
t.references :order, index: true, foreign_key: true
t.string :cheese
t.string :sauce
t.string :crust
t.string :size
t.integer :slices... |
class Cluster < ActiveRecord::Base
belongs_to :user
has_many :posts
validates_presence_of :name, :description, :user
default_scope :order => 'clusters.created_at DESC'
end
|
class CreatePesticideApplications < ActiveRecord::Migration
def change
create_table :pesticide_applications do |t|
t.datetime :StartDateTime
t.datetime :EndDateTime
t.string :RestrictedEntryInterval
t.string :ApplicationRate
t.references :Location, index: true, foreign_key: true
... |
require 'uri'
require 'ping'
def check_vars(name,url)
returns = []
begin
uri = URI.parse(url)
uri_url = "#{uri.scheme}://#{uri.host}"
url_return = `wget -O/dev/null -q "#{uri_url}" && echo "1" || echo "0"`
if url_return[0] != 49 # 1
returns << :url_not_exist
end
rescue URI::Inva... |
# Write a method consonant_cancel that takes in a sentence and returns a new
# sentence where every word begins with it's first vowel.
def consonant_cancel(sentence)
words = sentence.split(" ")
new_words = []
vowels = "aeiou"
words.each do |word|
word.each_char.with_index do |c,i|
if vowels.include?... |
require 'rails_helper'
describe ScribblesController do
it "should have a canvas element" do
visit "scribbles/new"
expect(page).to have_css "canvas"
end
describe "interactions" do
before(:each) do
Capybara.current_driver = :selenium
visit new_scribble_path
subject { page }
@be... |
require 'rails_helper'
# http://matthewlehner.net/rails-api-testing-guidelines/ used as a starting point
describe "Sales API" do
describe 'GET' do
before(:each) do
# sale = FactoryGirl.create(:sale) # FactoryGirl could be used when this project grows
sale_params = single_sale[:sales].first
@s... |
class CreateMods < ActiveRecord::Migration[6.0]
def change
create_table :mods do |t|
t.belongs_to :event
t.belongs_to :mod_section
t.integer :participation_limit, null: false, default: 0
t.string :name, null: false
t.string :timeframe, null: false
t.text :description, null: tr... |
require 'rails_helper'
RSpec.describe SendMassMessageJob, active_job: true, type: :job do
describe '#perform' do
let(:department) { create :department }
let(:user) { create :user, department: department }
let!(:client_1) { create :client, user: user }
let!(:client_2) { create :client, user: user }
... |
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'ideapool'
set :repo_url, 'git@github.com:tka/ideapool.git'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/ideapool'
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.