text stringlengths 10 2.61M |
|---|
require "test_helper"
describe ProductsController do
let(:fred) { merchants(:fred) }
let(:category) { categories(:africa) }
let(:kiki) { merchants (:kiki) }
let(:product) { products(:fannypack) }
describe "index" do
it "succeeds when there are products" do
get products_path
must_respond_with... |
module Spree
class UsersWhoHaveNotRecentlyPurchasedReport < Spree::Report
DEFAULT_SORTABLE_ATTRIBUTE = :user_email
HEADERS = { user_email: :string, last_purchase_date: :date, last_purchased_order_number: :string }
SEARCH_ATTRIBUTES = { start_date: :start_date, end_date: :end_date, email_cont: :email }
... |
class FavoritesController < ApplicationController
def create
if current_user_login == nil
render json: {errors: ["Log in or create an account to save it to your favorites"]}, status: 422
else
restaurant = Restaurant.find_by(id: params[:restaurant_id])
if... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PagesController do
describe "routing" do
it "should route /project to pages#project" do
{ :get => "/project" }.should route_to(:controller => 'pages',
:action => 'project')
end
... |
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
require 'kaitai/struct/struct'
unless Gem::Version.new(Kaitai::Struct::VERSION) >= Gem::Version.new('0.7')
raise "Incompatible Kaitai Struct Ruby API: 0.7 or later is required, but you have #{Kaitai::Struct::VERSION}"... |
#!/usr/bin/env ruby
require 'optparse'
require_relative '../lib/fasta_parser'
# ========== MAIN
def initialize_component
# load options
options = parse_options
@sep = options[:sep] == 'csv' ? ',' : options[:sep] == 'nsv' ? "\n" : "\t"
# output random?
if !options[:rnd].nil?
count = ... |
class QuizzesController < ApplicationController
before_action do
if @current_user.blank?
redirect_to login_path
end
end
def index
session[:quiz] = nil
@published_quizzes = Quiz.published.select do |quiz|
quiz.completed_quizzes.where(user_id: @current_user.id).exists? == false
... |
require 'lingua'
require 'find'
require 'stringio'
require 'colorize'
task :process do
path = '../app/_process'
puts "! Starting process".yellow
# Create a simple function to do this
def calculate_flesch_score(content)
puts "> Calculating flesch score".yellow
# Remove the frontmatter, and codeblocks,... |
require 'test/unit'
require 'wsdl/parser'
require 'soap/mapping/wsdlencodedregistry'
require 'soap/marshal'
require 'wsdl/soap/wsdl2ruby'
class WSDLMarshaller
include SOAP
def initialize(wsdlfile)
wsdl = WSDL::Parser.new.parse(File.open(wsdlfile) { |f| f.read })
types = wsdl.collect_complextypes
@opt ... |
require 'rails_helper'
RSpec.describe "Edit Categories", type: :system do
before do
driven_by(:rack_test)
end
User.destroy_all
before :each do
# Devise gem rspec helper
user = User.create(:email => 'test123@example.com', :password => 'f4k3p455w0rd')
login_as(user, :scope => :user)
end
it... |
require 'spec_helper'
describe Echo::Client do
let(:connection) { Object.new }
let(:req) { double(headers: {}) }
let(:echo_client) { Echo::EchoClient.new('http://example.com', '1234') }
let(:cmr_client) { Echo::CmrClient.new('http://example.com', '1234') }
let(:extended_client) { Class.new(Echo::BaseClient) ... |
module Nagios
OK = 0
WARNING = 1
CRITICAL = 2
UNKNOWN = 3
def crit(message)
"Critical: #{message}"
end
def warn(message)
"Warning: #{message}"
end
def ok(message)
"OK: #{message}"
end
class Probe
include Nagios
attr_reader :retval, :message
def initialize(opts = {})
... |
namespace :db do
desc "Populate database"
task populate: :environment do
make_users
make_quote
make_categories
puts "All data loaded to db"
end
end
def make_users
User.create!(first_name: "Logan",
last_name: "Foos",
email: "lfoos24@gmail.com",
password: "Password... |
# 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... |
module FiltersHelper
def filter_form_for(filter, *args, &block)
options = args.extract_options!
simple_form_for(filter, *(args << options.merge(builder: FilterFormBuilder)), &block)
end
class FilterFormBuilder < SimpleForm::FormBuilder
include ActionView::Helpers::TagHelper
attr_accessor :filter... |
ENV['RAILS_ENV'] ||= 'production'
require "coverage"
Coverage.start
require_relative 'config/environment'
top_n = (ENV['TOP'] || 20).to_i
app = Rails.application
possible_routes = ['/posts', '/posts.json']
possible_routes.concat((1..100).map { |i| "/posts/#{i}"})
visit_count = 2000
rng = Random.new(0x1be52551fc15299... |
class CreateOpportunities < ActiveRecord::Migration[5.0]
def change
create_table :opportunities do |t|
t.string :org_title
t.string :summary
t.string :zipcode
t.string :borough
t.string :category_desc
t.integer :vol_requests
t.string :recurrence_type
t.string :start... |
require 'spec_helper'
# Sanity checks that remind me to change a template when I change the corresponding code, or
# to add a file that I might otherwise forget.
describe :sparkly do
def self.it_should_generate_and_match(to_gen, existing = to_gen)
it "should generate #{to_gen} which matches #{existing}" do
... |
class ProductsController < ApplicationController
def index
@products = ProductPresenter.new
end
def show
@product = Product.find(params[:id])
@product_request = @product.product_requests.new
end
def search
if params[:products]
@products = Product.search(params[:products][:name]).order(... |
RailsAdmin.config do |config|
config.authorize_with :cancan
# config.attr_accessible_role do
# :admin
# end
# If your default_local is different from :en, uncomment the following 2 lines and set your default locale here:
# require 'i18n'
# I18n.default_locale = :de
config.current_user_method { cur... |
class BetaInvitationsController < ApplicationController
before_filter :signed_in_user
def index
@beta_invitations = BetaInvitation.paginate(page: params[:page])
end
def new
@beta_invitation = BetaInvitation.new()
end
def create
@beta_invitation = BetaInvitation.new(beta_invite_params)
... |
class FontNotoSansCjkJp < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKjp-hinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans CJK JP"
homepage "https://www.google.com/get/noto/#sans-jpan"
def install
(share/"fonts").install "NotoSansCJKjp-Black.otf"... |
require 'rugged'
require_relative '../exceptions.rb'
require_relative '../build.rb'
module Crew
def self.env(args)
origin = Rugged::Repository.new(Global::BASE_DIR).remotes['origin'].url
case args.length
when 0
puts "DOWNLOAD_BASE: #{Global::DOWNLOAD_BASE}"
puts "PKG_CACHE_DIR: #{Global::... |
class Tournament < ActiveRecord::Base
has_many :entries, -> {order 'created_at, nick'}
def result
if open == false && entries.count > 1
Tournament::Result.new entries
else
Tournament::NotReady.new
end
end
end
|
class ChatMessage < ApplicationRecord
after_create_commit { MessageBroadcastJob.perform_later self }
belongs_to :from, class_name: "User"
belongs_to :to, class_name: "User"
validates :from_id, presence: true
validates :to_id, presence: true
validates :room_id, presence: true
validates :content, presence... |
require 'tsort'
module Constrained
# This implements a directional unweighted graph.
class Graph
def initialize
# relationships directed away from the given vertices
@edges_from = Hash.new { |h, k| h[k] = Set.new }
# relationships directed to the given vertices
@edges_to = Hash.new... |
require 'test_helper'
class AdminEnergyApplicationsControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test 'requires user authentication' do
assert(defines_before_filter?(Admin::EnergyApplicationsController, :authenticate_user!))
end
test 'requires an admin user' do... |
module SkeletorApi
class Config
attr_accessor :api_key, :api_version
def initialize(api_key: '', api_version: LATEST_API_VERSION)
@api_key = api_key
@api_version = api_version
end
end
end
|
require 'rails_helper'
RSpec.describe Step, type: :model do
it { should validate_presence_of(:operation) }
it { should validate_length_of(:operation).is_at_least(3) }
it { should have_many(:uses) }
it { should have_many(:utilities) }
it { should belong_to(:recipe) }
it { should accept_nested_attributes_for... |
require 'redis'
module Caches
class ChecksController < ::Caches::ApplicationController
def index
redis = Redis.new(host: 'redis')
redis.set("a", 'ok')
redis.get("a")
end
private
def redis_up?
end
end
end
|
require_relative '../lib/vws.rb'
describe Vws do
VWS_ACCESSKEY = "your_vws_server_database_access_key"
VWS_SECRETKEY = "your_vws_server_database_secret_key"
#code below between begin and end was an attempt to read env variables from file
=begin
describe "should connect to webservice and fail otherwise" do
... |
class AddCountParseApiToAllUsers < ActiveRecord::Migration
def change
add_column :all_users, :count_parse_api, :integer, default: 0, null: false
end
end
|
class Grade < ActiveRecord::Base
belongs_to :subject
validates :courseItem, :worth, :mark, :courseMark, :subject_id, presence: true
validates :mark, :courseMark, :numericality => {:greater_than_or_equal_to => 0, only_float: true}
validates :worth, :numericality => {:greater_than_or_equal_to => 0, only_f... |
class RxesController < ApplicationController
before_action :set_rx, only: [:show, :edit, :update, :destroy]
semantic_breadcrumb :index, :rxes_path
respond_to :js, :html, :json
# GET /rxes
# GET /rxes.json
def index
@rxes = Rx.all
end
# GET /rxes/1
# GET /rxes/1.json
def show
end
# GET /rx... |
class Prodcuto < ActiveRecord::Base
validates :codigo, :uniqueness=>{message:"Codigo ya se encuentra registrado"}
validates :codigo,:presence=>{message: "No puede estar en blanco"}
validates :nombre,:presence=>{message: "No puede estar en blanco"}
validates :fecha_vencimiento,:presence=>{message: "No puede estar en... |
class CashFlowStatement
include ActiveModel::Model
def initialize(forecast, opts = {})
@forecast = forecast
@options = opts
@start_date = @forecast.forecast_start_date
@end_date = @start_date + 60.months
@accounts_totals = AccountTotals.new(forecast, frequency)
end
def frequency
if @op... |
module Fog
@interval = lambda { |retries| [2 ** (retries - 1), @max_interval].min }
def self.interval
@interval
end
def self.interval=(interval)
if interval.kind_of?(Proc)
raise ArgumentError, "interval proc must return a positive" unless interval.call(1) >= 0
else
raise ArgumentError, ... |
class Payload
include Mongoid::Document
field :ref, type: String
field :ref_type, type: String
field :master_branch, type: String
field :description, type: String
field :pusher_type, type: String
end
|
class Timer
def initialize
@sec = 0
end
def seconds
@sec
end
def seconds=(s)
@sec += s
end
def time_string
seconds = @sec % 60
minutes = seconds != 0 ? @sec / 60 : 0
hours = minutes != 0 ? minutes / 60 : 0
minutes = minutes % 60 if minutes > 60
time_arr = [hours, minutes, s... |
require_relative 'robot_face'
# Executes the robot command instructions
class Robot
# @param [Integer] max_x - Max x coordinate
# @param [Integer] max_y - Max y coordinate
# @param [Integer] min_x - Min x coordinate
# @param [Integer] min_y - Min Y coordinate
# @param [RobotFace] robot_face - Robot face ob... |
require File.dirname(__FILE__) + '/../test_helper'
require 'contacts_controller'
# Re-raise errors caught by the controller.
class ContactsController; def rescue_action(e) raise e end; end
class ContactsControllerTest < Test::Unit::TestCase
fixtures :contacts, :users
def setup
@controller = ContactsControlle... |
require 'yap/addon'
require 'yap-shell-addon-keyboard-macros/version'
require 'yap-shell-addon-keyboard-macros/cycle'
require 'yap-shell-addon-keyboard-macros/pretty_print_key'
module YapShellAddonKeyboardMacros
class Addon < ::Yap::Addon::Base
self.export_as :'keyboard-macros'
include PrettyPrintKey
D... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'translation#index'
get '/', to: 'translation#index', as: 'inicio'
get 'translation/new', to: 'translation#new', as: 'new_translation'
post 'translation/new', to: 'tran... |
#
# Cookbook Name:: databox
# Recipe:: postgresql
#
# Install Postgresql and create specified databases and users.
#
root_password = node["databox"]["db_root_password"]
if root_password
Chef::Log.info %(Set node["postgresql"]["password"]["postgres"] attributes to node["databox"]["db_root_password"])
node.set["post... |
class NtVolume < ActiveRecord::Base
validates :node_type_id, :t_path, :s_path, presence: true
validates :t_path, uniqueness: {scope: :node_type_id}
belongs_to :node_type
end
|
FactoryGirl.define do
factory :collection_space_object do
batch 'cataloging1'
category 'Procedure'
converter 'CollectionSpace::Converter::Core:CoreCollectionObject'
type 'CollectionObject'
subtype nil
identifier_field 'id_number'
identifier '1'
title 'An object'
end
end
|
def sluggish_octopus(arr)
biggest_fish = ''
arr.each do |fish1|
arr.each do |fish2|
biggest_fish = fish1 if fish1.length > fish2.length
biggest_fish = fish2 if fish1.length < fish2.length
end
end
biggest_fish
end
class Array
def dominant_octopus(&prc)
prc ||= Proc.new { |x, y| x <=> y }
... |
class Response
OK = 200
CLIENT_ERR = 400
SERVER_ERR = 500
REDIRECT = 301
NOT_FOUND = 404
def initialize(status, type, body = nil, location = nil)
@status = status
@type = type
@location = location
@body = body
end
def write(socket)
socket.write "HTTP/1.1 #{@status}\r\n"
socket.... |
require "./dinner.rb"
class ThanksgivingDinner < Dinner
def proteins
if @diet == :vegan
["Tofurkey", "Hummus"]
else
["Turkey"]
end
end
def veggies
[:ginger_carrots , :potatoes, :yams]
end
def desserts
{:pies => [:pumkin_pie], :other => ["Chocolate Moose"]... |
require "rspec/rest/http/mime"
require "rspec/rest/http/content_type"
require "forwardable"
module RSpec
module Rest
module Http
class Response
include RSpec::Rest::Http::ContentType
extend Forwardable
def initialize(http_response)
@http_response = http_response
... |
class CreateClinicalBloodRecords < ActiveRecord::Migration
def change
create_table :clinical_blood_records do |t|
t.belongs_to :user, index: true, foreign_key: true
t.date :report_date
t.date :specimen_collected
t.text :clinic_name
t.string :blood_type
t.string :text
t.fl... |
class RemoveNftFromAsks < ActiveRecord::Migration[6.0]
def change
remove_column :asks, :nft_id
add_reference :asks, :collectible, foreign_key: true
end
end
|
class Address < ApplicationRecord
validates :street, :city, :state, :zip_code, :user_id, presence: true
belongs_to :user,
class_name: 'User',
foreign_key: :user_id
has_many :damages,
class_name: 'Damage',
foreign_key: :address_id
end
|
# This class is a rails controller for subscrition objects
# Author:: Mark Grebe
# Copyright:: Copyright (c) 2013 Mark Grebe
# License:: Distributes under the same terms as Ruby
# Developed for Master of Engineering Project
# University of Colorado - Boulder - Spring 2013
class SubscriptionsController < Applicat... |
def remove_nonletters(arr)
arr.map do |word|
word.delete('^a-zA-Z')
end
end
def word_sizes(input)
array = input.split
array = remove_nonletters(array)
hash = {}
array.each do |word|
if hash.keys.include?(word.length)
hash[word.length] += 1
else
hash[word.length] = 1
end
end
... |
class Indexes < ActiveRecord::Migration
def change
add_index :sent_mails, :subscriber_id
add_index :sent_mails, :article_id
end
end
|
module Ojo
class Manager
MAGNITUDE_MAX = 24
def location
puts "Ojo file location: #{::Ojo.configuration.location}"
end
def data_sets
data_sets = ::Ojo::DataSets.new.sets_available
::Ojo.display_data_sets(data_sets)
end
def clear_diff
FileUtils.rm_rf File.join(::Ojo.c... |
class CreateStats < ActiveRecord::Migration
def change
create_table :stats do |t|
end
end
end
class CreateStats < ActiveRecord::Migration
def change
create_table :stats do |t|
t.integer "blood_pressure_systolic"
t.integer "blood_pressure_diastolic"
t.integer "sugar"
t.boolean "water_eight", :... |
json.array!(@advert2s) do |advert2|
json.extract! advert2, :id, :image, :link
json.url advert2_url(advert2, format: :json)
end
|
class RoomsController < ApplicationController
before_action :get_room, :get_subjects, only: [:show]
def index
@rooms = Room.where(active: true)
end
private
def get_room
@room = Room.find(params[:id])
end
def get_subjects
@subjects = @room.subjects
end
end
|
class CreateDataStats < ActiveRecord::Migration
def change
create_table :data_stats, :id => false do |t|
t.uuid :id, :primary_key => true, default: "uuid_generate_v4()"
t.uuid :app_id
t.uuid :content_id
t.string :content_type
t.string :action
t.datetime :timestamp
t.inte... |
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Opinions
describe MarkdownToOpinions do
def should_parse_and_produce_opinions(num_opinions)
opinions = Decidim::Opinions::Opinion.where(component: component)
expect { parser.parse(document) }.to change { opinions.cou... |
require 'test_helper'
class SortSpecTest < Minitest::Spec
describe SimpleJsonapi::Parameters::SortSpec do
it "interprets a field name as ascending" do
spec = SimpleJsonapi::Parameters::SortSpec.new("orders" => "customer_name")
assert_equal [:customer_name], spec[:orders].map(&:field)
assert_eq... |
require 'rails_helper'
class MockController
def controller_name
"mock"
end
def action_name
"action"
end
end
class AdminController; end
class MockAdminController < AdminController
def controller_name
"mock"
end
def action_name
"action"
end
end
describe Titler do
describe '#title' d... |
# Exercise 24: More Practice
puts "Let's practice everything."
puts 'You\'d need to know \'bout escapes with \ that do \n newlines and \t tabs.'
# the <<END is a "heredoc". See the student questions.
poem = <<END
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend pas... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Language::Nodes::AbstractNode do
describe ".visit_method" do
# `.visit_method` is really helpful for generating methods in
# custom visitor classes -- make sure this API keeps working.
it "names a method on the visitor class" do
... |
FactoryGirl.define do
factory :letra do
titulo 'Heathens'
contenido 'All my friends are heathens, take it slow...'
association :usuario, factory: :usuario
end
end |
# 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... |
require "active_support"
require "typecaster/version"
module Typecaster
extend ActiveSupport::Concern
module ClassMethods
def attribute(name, options={})
attribute_name = name.to_sym
raw_attributes[attribute_name] = options
attributes[attribute_name] = nil
define_method(name) do
... |
require 'rails_helper'
RSpec.describe WelcomeController, :type => :controller, skip: true do
describe "GET index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
end
it "uses WIP layout" do
get :index
expect(response).to render_template(... |
module Paginable
extend ActiveSupport::Concern
def paginate(collection)
paginator.call(
collection,
params: pagination_params,
base_url: request.url
)
end
def paginator
JSOM::Pagination::Paginator.new
end
def pagination_params
params.permit![:page... |
class Logging::ItemsController < ApplicationController
layout 'tabbed'
before_action :authenticate_user!
include LoggingNodesHelper
before_action :_nav_items
def index
query = params[:query] ? JSON.parse(params[:query], symbolize_names: true) : {match_all: {}}
@size = params[:size] ? params[:size].to... |
# Write a method named get_squares that takes an array of numbers
# and returns a sorted array containing only the numbers whose square is also in the array
#
# get_squares [9] # => []
# get_squares [9,3] # => [3]
# get_squares [9,3,81] # => [3, 9]
# get_squares [... |
require 'rails_helper'
RSpec.describe "QuestionPages", type: :request do
subject { page }
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
describe "GET /question create" do
before { visit new_question_path }
it "should not create a question" do
expect { click_button "Ask" }.not_t... |
# Copyright:
# (c) 2006 syncPEOPLE, LLC.
# Visit us at http://syncpeople.com/
# Author: Duane Johnson (duane.johnson@gmail.com)
# Description:
# Helper module for accesing ruble facilities such as environment variables.
require 'uri'
require 'ruble/ui'
require 'ruble/editor'
require 'ruble/project'
module Ruble... |
namespace :load do
task :defaults do
# Setup capistrano
set :user, 'app'
set :deploy_to, -> { "/home/#{ fetch(:user) }/app" }
set :ssh_options, -> { { user: fetch(:user), forward_agent: true } }
set :log_level, :info
set :linked_files, %w[ config/database.yml ]
set :linked_dirs, %w[ log t... |
cask :v1 => 'ibrowse' do
version '1.0.0.5'
sha256 'c3cae297d676e64c3d21638c21583f7c30a8fdbe6a4e127adb0857bafcd8037d'
url "http://cdn.macroplant.com/release/iBrowse-#{version}x.dmg"
name 'iBrowse'
homepage 'http://www.ibrowseapp.com/'
license :unknown # todo: change license and remove this comment; ':unk... |
class AddDateComparisonToCustomerSet < ActiveRecord::Migration
def change
add_column :customer_sets, :date_comparison, :string
end
end
|
require 'minitest/autorun'
require 'nebrija'
MOCKS_DIR = "#{File.expand_path(File.dirname(__FILE__))}/mocks"
class TestMockedParserBasic < Minitest::Test
def test_error_basic
assert_equal FileRae.new.search("#{MOCKS_DIR}/error.html")[:status]
end
def test_single_basic
assert !FileRae.new.search("#... |
#! /usr/bin/env ruby
# frozen_string_literal: false
#
# metrics-chrony
#
# DESCRIPTION:
#
# OUTPUT:
# metric data
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
# gem: socket
#
# USAGE:
#
# NOTES:
#
require 'sensu-plugin/metric/cli'
require 'socket'
class ChronyMetrics < Sensu::Plugin::Metric... |
require 'rails_helper'
describe 'Gardens' do
it "can add a plant if it doesn't exist in the database" do
garden = create(:garden)
plant_params = {
image: 'image.url',
name: 'plant name',
species: 'plant species',
description: 'plant description',
light_requirements: 'light neede... |
#!/usr/bin/env ruby
# usage: stripiT.rb file1.m4a file2.m4a file3.m4a
# automatically outputs to file1 - stripped.m4a, file2 - stripped.m4a, and so on.
# Script to remove extraneous/unwanted atoms from iTunes purchased files by way of AtomicParsley.
# Output should be comparable to the atoms left over after reencodin... |
class RemovePlayerIdFromGoals < ActiveRecord::Migration[5.1]
def change
remove_column :goals, :player_id, :integer
remove_column :goals, :assist_id, :integer
remove_column :goals, :penalty_id, :integer
add_column :goals, :start_appearance_id, :integer
add_column :goals, :substitute_appearance_id, ... |
module Validators
class DisposableHostnames
FILE_PATH = File.expand_path("../../../data/disposable.json", __FILE__)
def self.all
@tld ||= JSON.load(File.read(FILE_PATH))
end
end
end
|
class Protein < Food
attr_accessor :animal_type
def initialize(c, s, p, a)
@calories = c
@servings = s
@prep_time = p
@animal_type = a
end
def to_s
"#{servings} servings of #{animal_type} has #{calories} calories and takes #{prep_time} min to prepare"
end
end |
# frozen_string_literal: true
module GraphQL
class Backtrace
# A class for turning a context into a human-readable table or array
class Table
MIN_COL_WIDTH = 4
MAX_COL_WIDTH = 100
HEADERS = [
"Loc",
"Field",
"Object",
"Arguments",
"Result",
]
... |
# == Schema Information
#
# Table name: exif_translations
#
# id :integer not null, primary key
# name :string(255) default(""), not null
# value :string(255) default(""), not null
# exif_name :string(255) default(""), not null
# exif_value :string(255) default(""),... |
require 'spec_helper'
describe Movie do
before do
@movie = Movie.new(name: "The Avengers")
end
subject { @movie }
it { should respond_to(:name) }
it { should respond_to(:description) }
it { should respond_to(:image_URL) }
it { should respond_to(:average_rating) }
it { should respond_to(:genres) }
it { s... |
class Search < ActiveRecord::Base
def ads
@ads ||= find_ads
end
def find_ads
ads = Ad.order(:title)
ads = ads.where("title like ?", "%#{keywords}%") if keywords.present?
ads = ads.where(category_id: category_id) if category_id.present?
ads = ads.where("price >= ?", min_price) if min_price.pre... |
module ProductHelper
def show_status(product)
product.site == '21vek.by' ? vekby_status(product) : check_if_exist(product)
end
def find_same_products(product)
Product.by_type(product.group_type).by_maker(product.maker).by_model(product.model)
end
def sorted_products(products)
products.sort_by {|... |
class Tag < ApplicationRecord
has_many :task_tags
validates :name, presence: true
end
|
require 'spec_helper'
describe Dap::Cli do
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
let(:connection) do
Faraday.new do |builder|
builder.adapter :test, stubs
end
end
subject { Dap::Cli.new(connection: connection) }
it 'creates new experiment' do
stubs.post('api/v1/threat_assessm... |
class Item < ApplicationRecord
enum status: {disabled: 0, active: 1}
has_many :option, dependent: :destroy
has_many :like, dependent: :destroy
has_many :liked_user, through: :likes, source: :user
has_many :review, dependent: :destroy
has_many :reviewed_user, through: :reviews, source: :user
has_many :line... |
# from_file, to_file = ARGV
# puts "Copying from #{from_file} to #{to_file}"
# in_file = open(from_file)
# indata = in_file.read
# puts "The input file is #{indata.length} bytes long."
# puts "Does the output file exist? #{File.exist?(to_file)}"
# puts "Ready, hit RETURN to continue, CTRL-C to abort."
# $stdin.get... |
require 'rspec'
require_relative '../model/calendario'
require_relative '../model/validador_evento'
require_relative '../model/evento_id_ya_existente_error'
require_relative '../model/../model/evento_ya_existente_en_calendario_error'
require_relative '../model/../model/../model/calendario_sin_nombre_error'
require_rel... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: quiz_questions
#
# id :integer not null, primary key
# quiz_id :integer not null
# content :text not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
#... |
require "rails_helper"
RSpec.describe BetMailer, :type => :mailer do
let(:inviter) { build(:user, first_name: "John", last_name: "Doe") }
let(:invitee) { build(:user, first_name: "Mike", last_name: "Jones") }
let(:bet) { create(:bet, inviter: inviter, invitee: invitee) }
describe "#invitee_confirmation" d... |
# frozen_string_literal: true
class Assets
def self.instance
@instance ||= Assets.new(ASSETS_PATH)
end
def self.invalidate!
@instance = nil
end
attr_reader :path, :manifest
def initialize path
@path = Pathname.pwd.join path
@manifest = (parse_manifest! rescue {})
end
def exists? as... |
class ApplicationMailer < ActionMailer::Base
default from: 'semee@coderschool.com'
layout 'mailer'
end
|
class Term < ActiveRecord::Base
has_many :lessons
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.