text stringlengths 10 2.61M |
|---|
require 'rails_helper'
feature 'restaurants' do
before do
User.create(email: 'freddy@gmail.lol', password: 'password', password_confirmation: 'password')
visit '/'
click_link 'Sign in'
fill_in 'Email', with: 'freddy@gmail.lol'
fill_in 'Password', with: 'password'
click_button 'Log in'
end
... |
Rails.application.routes.draw do
resources :tracks do
resources :comments
end
root to: "users#index"
# get "/", to: "application#index"
get 'passwords/new'
get 'passwords/create'
get 'passwords/edit'
get 'passwords/update'
resources :users, except: [:new, :edit]
# match "*path", to: "us... |
# frozen_string_literal: true
require_relative 'rest_client'
module Uploadcare
module Client
# client for webhook management
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Webhook
class WebhookClient < RestClient
# Create webhook
# @see https://uploadcare.com/docs/api_reference/... |
# Generated by jeweler
# DO NOT EDIT THIS FILE
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{lifelog}
s.version = "0.2.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_versio... |
class Tour < ActiveRecord::Base
has_many :tours, class_name:"TourTime", foreign_key: "tour_id"
has_many :reviews
has_many :tour_times, class: "TourTime", foreign_key: "tour_time_id"
has_attached_file :image, styles: { medium: "400x245#" }
validates_attachment_content_type :image, con... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe SymmetricDifferenceArray do
let(:challenge) { described_class.new(arr_n, arr_m).call }
describe '.call' do
context 'when result successed' do
let(:arr_n) { [1, 2, 3] }
let(:arr_m) { [3, 4] }
it { expect(challenge).to eq([1,... |
require 'spec_helper'
feature "User contacts sites staff", %q{
As a site visitor
I want to contact the site's staff
So that i can tell them how awesome they are
} do
before(:each) do
visit '/inquiries/new'
click_on "Sign up"
user = "doug"
fill_in "Email", with: "dhgrainger@gmail.com"
... |
class ReviewsController < ApplicationController
def create
@review = Review.new(review_params)
@review.user_id = current_user.id
@review.save
redirect_to movie_path(@review.movie_id)
end
def destroy
@review = Review.find(params[:id])
@review.destroy
redirect_to movie_path(@review.movie_id)
end
protect... |
class ProjectCompletionReportGeneration
def initialize(project)
@project = project
end
def generate_projectcompletion_report
try_create_projectcompletion_full_report
end
private
def create_projectcompletion_full_report
completionreporter.report(@project)
end
def completionreporter
... |
require 'reform/form/coercion'
module OtherInformation
include Reform::Form::Module
property :rate
property :willing_to_travel
validates :rate, numericality: { greater_than: 0, less_than_or_equal_to: 5_000 }, presence: true
validates :willing_to_travel, presence: true
property :entity, populate_if_empty... |
require 'immutable/list'
module Immutable
# A `Deque` (or double-ended queue) is an ordered, sequential collection of
# objects, which allows elements to be retrieved, added and removed at the
# front and end of the sequence in constant time. This makes `Deque` perfect
# for use as an immutable queue or stack... |
class ClientsController < ApplicationController
layout 'ajoke'
skip_before_filter :verify_authenticity_token
before_action :authenticate_user!
before_action :admin_check
def index
@client = Client.new
@Cl = Client.all
@Client = @Cl.order(name: :asc)
@Clients = @Client.paginate(:page => params... |
class UsersController < ApplicationController
# POST /register
def register
@user = User.create(user_params)
if @user.save
response = { token: JsonWebToken.encode(user_id: @user.id)}
render json: response, status: :created
else
render json:... |
class Project < ActiveRecord::Base
STATES = ["closed", "open"]
belongs_to :user
has_many :likes
has_many :pledges
has_many :donations, through: :pledges
before_destroy :ensure_not_referenced_by_any_pledge
validates :title, :description, :contact_email, presence: true
validates :estimate, numericality: {gre... |
require 'yaml'
class PropertiesManager
def initialize(file)
@file = file
end
def getPropertiesHash()
node = YAML::load(File.open(@file))
#puts node
#puts node.class
properties = Hash.new
node.split(' ').each do |item|
k = item.split("=").first
v = item.split("=").last
... |
class ApplicationController < ActionController::Base
include CanCan::ControllerAdditions
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
include CanCan::ControllerAdditions
# protect_from_forgery with: :exception
protect_from_forgery with: :null_sessi... |
class OffersController < ApplicationController
before_action :set_offer, only: [:show, :edit, :update, :promotion, :imaging, :remove]
before_action :authenticate_user!, except: [:show, :index, :promotion, :imaging, :remove]
before_action :require_permission, only: [:edit, :update, :imaging, :remove]
before_acti... |
class CreateWorkorders < ActiveRecord::Migration
def change
create_table :workorders do |t|
t.string :subject
t.date :noticed
t.string :location
t.text :note
t.boolean :action_taken
t.boolean :invoiced
t.boolean :mandatory
t.boolean :denied
t.boolean :m_email_... |
require 'spec_helper'
describe UserMailer do
let :user do
User.new(email: "new-user@example.com", password: "password1", password_confirmation: "password1")
end
let(:welcome_message) { UserMailer.welcome_email(user) }
it 'comes from the proper email address' do
expect(welcome_message.from).to eq ["not... |
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
delete_old_files
make_users
make_charge_types
make_charges
make_charge_aliases
make_surveys
make_bookings
make_booking_details
make_filter_criteria
end
end
def make_users
admin = User.new(#... |
require 'rails_helper'
describe 'sweater weather api' do
it 'returns background image', :vcr do
get "/api/v1/backgrounds?location=denver,co"
expect(response).to be_successful
json = JSON.parse(response.body, symbolize_names: true)
expect(json).to be_a(Hash)
expect(json[:data][:attributes][:back... |
class Snippet < ActiveRecord::Base
belongs_to :user
belongs_to :board
validates :name, :body, :board_id, presence: true
attr_accessible :name, :body, :board_id, :board
scope :search, lambda{|query| where("name LIKE ?", "%#{query}%") }
def author_name
user.username
end
end
|
require 'spec_helper'
describe "Positions" do
context "As signed in user" do
let(:current_user) { FactoryGirl.create(:user) }
before {login_as(current_user, :scope => :user)}
describe "GET /" do
it "should load root dashboard even when no positions added" do
visit root_path
expe... |
class Setor < ApplicationRecord
validates :nome, :sigla, uniqueness: true, presence: true
has_many :estoques
def nome=(nome)
write_attribute :nome, nome.to_s.titleize
self.nome.strip!
end
def sigla=(sigla)
write_attribute :sigla, sigla.to_s[0,3].upcase
end
scope :principal, -> { where(pri... |
class Lifter
attr_reader :name, :lift_total
@@all =[]
def initialize(name, lift_total)
@name = name
@lift_total = lift_total
@@all << self
end
# Get a list of all lifters
def self.all
@@all
end
# Get a list of all the memberships that a specific lifter has
def lifter_membership
Membership.a... |
# Monty Hall Problem Simulaton
# https://en.wikipedia.org/wiki/Monty_Hall_problem
class MontyHallSimulation
def initialize
# Assign Goat to all doors
@doors = %w(Goat Goat Goat)
# Upgrade one random door to Car
@doors[rand(3)] = 'Car'
end
def pick_door
@pick = rand(3)
end
def reveal_door... |
class Api::V1::AuthenticationController < ApplicationController
skip_before_action :authenticate_request
require 'json_web_token'
def register
@user = User.create(user_params)
if @user.save
response = { message: 'User created successfully'}
render json: response, status: :created
else
render json: @... |
# Helper Method
def position_taken?(board, location)
!(board[location].nil? || board[location] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], #horizontal
[3,4,5], #horizontal
[6,7,8], #horizontal
[0,3,6], #vertical
[1,4,7], #vertical
[2,5,8], #vertical
[0,4,8], #diagnol
[6,4,2] #di... |
module Puppet::Parser::Functions
newfunction(:landb_func, :type => :rvalue, :doc => "A puppet funtion to integrate with LanDB") do |args|
require 'rubygems'
require 'yaml'
require 'landb'
option_hash = args[0]
config = begin
YAML.load(File.open("/etc/puppet/landb_config.yml"))
rescue ... |
require_relative 'java_modules'
module Aurora
class Config < JavaModules::AuroraConfig
def initialize
super "/dev/null"
end
def load(config)
config.each do |key, value|
send("#{key}=", value_for_key(key, value))
end
end
def value_for_key(key, value)
return value... |
require 'digest/md5'
module HashFunctions
@@a1 = [18, 39, 3, 37, 12, 29, 7, 30, 23, 2, 5, 39, 24, 12, 26, 12, 27, 0, 25, 24, 9, 12, 9, 18, 32, 27, 38, 30, 18, 27, 12, 25]
@@a2 = [6, 9, 38, 16, 21, 26, 3, 7, 13, 5, 30, 22, 15, 19, 31, 30, 32, 9, 9, 0, 18, 10, 7, 1, 16, 6, 12, 6, 22, 3, 5, 29]
def h1(k)
result = ... |
require 'spec_helper'
describe PredictionsController do
render_views
context "when authenticated through Facebook" do
before do
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:facebook]
request.session[:user] = { info: request.env['omniauth.auth']['info'],
... |
class AddShippableFiles < ActiveRecord::Migration
def change
create_table :orders_files, id: false, force: true do |t|
t.integer :order_id
t.integer :file_object_id
end
end
end
|
# encoding: utf-8
control "V-92749" do
title "The Apache web server must install security-relevant software updates within the configured time period directed by an authoritative source (e.g., IAVM, CTOs, DTMs, and STIGs)."
desc "Security flaws with software applications are discovered daily. Vendors are constantly ... |
require 'spec_helper'
describe Freee::Amount do
let(:client_id) { get_client_id }
let(:secret_key) { get_secret_key }
let(:token) { get_token }
let(:amount) { Freee::Amount }
before(:each) do
Freee::Base.config(client_id, secret_key, token)
end
describe 'should can be able to create instance' do
... |
class ReviewsController < ApplicationController
before_action :check_for_login, :only => [:new]
def index
redirect_to root_path
end
def new
@review = Review.new
end
def create
#need tob build create page.
review = Review.create review_params
redirect_to products_path
end
def edit
... |
module DelayedExecution
def self.after(delay, &block)
Potion::Handler.new.postDelayed(BlockRunnable.new(&block), delay * 1000.0)
end
class BlockRunnable
def initialize(&block)
@block = block
end
def run
@block.call
end
end
end
|
class InvestorFinancing < ApplicationRecord
belongs_to :investor
belongs_to :loan
accepts_nested_attributes_for :investor
accepts_nested_attributes_for :loan
end
|
require 'open-uri'
require 'nokogiri'
require 'data_mapper'
require 'dm-sqlite-adapter'
ENV['DATABASE_URL'] ||= "sqlite://#{Dir.pwd}/students.db"
DataMapper.setup(:default, ENV['DATABASE_URL'])
DataMapper.auto_migrate!
class Student
include DataMapper::Resource
property :id, Serial
property :image, String
... |
class CreateTickets < ActiveRecord::Migration[5.2]
def change
unless table_exists? Ticket.table_name
create_table Ticket.table_name do |t|
t.integer :ticket_id, comment: 'Identifica o id do ticket'
t.string :subject, comment: 'Identifica o assunto do ticket'
t.string :raw_subject, co... |
class AddAllowedVisitationToSubscriptionPlan < ActiveRecord::Migration[5.1]
def change
add_column :subscription_plans, :allowed_visitation_count, :string, default: 'unlimited'
end
end |
=begin
Create method encrypt with argument string
Set index to 0
Create placeholder variable with ""
Loop through each letter of the word until the last letter
Use the .next method to advance every letter of a string one letter forward
Have each letter add to the placeholder variable
Print the final result
=end
def e... |
# == Schema Information
#
# Table name: resources_users
#
# resource_id :integer
# user_id :integer
# created_at :datetime
# updated_at :datetime
#
# Indexes
#
# index_resources_users_on_resource_id_and_user_id (resource_id,user_id) UNIQUE
#
require 'rails_helper'
RSpec.describe ResourceCompletion, type: ... |
class AwardType < ActiveRecord::Base
attr_accessible :code, :name
validates_presence_of :code, :name
end
|
require 'rails_helper'
require 'byebug'
RSpec.describe KepplerFrontend::Urls::Assets, type: :services do
context 'assets urls' do
before(:all) do
@root = KepplerFrontend::Urls::Roots.new
@assets = KepplerFrontend::Urls::Assets.new
end
context 'core urls' do
let(:result) {"#{@root.roc... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
before_validation :downcase_username
before_validation :set_default_role
devise :database_authenticatable, :registerable,
:re... |
# Setup object construction and default behaviors
class DataTable
attr_reader :header
def initialize( header = Array.new )
raise ArgumentError unless header.is_a?( Array )
@header = header
end
def to_s
@header.join( ' ' ) + self.inject( "\n" ) { |str,row| str << row.join( ' ' ) + "\n" }
end
end... |
#encoding: utf-8
class EmailListingsController < ApplicationController
before_filter :authenticate_user!
# GET /email_listings
# GET /email_listings.json
def index
@email_listings = EmailListing.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @email_listi... |
class ImageImporterWorker
include Sidekiq::Worker
def perform(gallery_id)
image_import = Refinery::ImageImporter.new(gallery_id)
image_import.import
end
end |
# frozen_string_literal: true
require 'swagger_helper'
RSpec.describe 'News', type: :request do
before do
FactoryBot.create(:config)
FactoryBot.create_list(:news, 5)
end
let(:news_limit) { 3 }
after do |example|
example.metadata[:response][:content] = {
'application/json' => {
exam... |
Given /^that the app is set up$/ do
# create questions
question1 = Question.find_or_create_by_xml("Why is the sky blue?")
question2 = Question.find_or_create_by_xml("What is the meaning of life?")
# create tags
tag1 = Tag.find_or_create_by_name("meteorology")
tag2 = Tag.find_or_create_by_name("p... |
require 'test_helper'
class ExpenseAccountsControllerTest < ActionDispatch::IntegrationTest
setup do
@expense_account = expense_accounts(:one)
end
test "should get index" do
get expense_accounts_url
assert_response :success
end
test "should get new" do
get new_expense_account_url
assert... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DashboardController, type: :controller do
describe 'GET :index' do
describe 'html' do
let(:user) { create(:user) }
let(:company) { create(:company) }
it 'redirects not signed in user to root' do
get :index
expe... |
require './contact.rb'
# Interfaces between a user and their contact list. Reads from and writes to standard I/O.
class ContactList
# TODO: Implement user interaction. This should be the only file where you use `puts` and `gets`.
def initialize
puts "Here is a list of available commands:
new - Cr... |
require 'test_helper'
class QuestaosControllerTest < ActionDispatch::IntegrationTest
setup do
@questao = questaos(:one)
end
test "should get index" do
get questaos_url
assert_response :success
end
test "should get new" do
get new_questao_url
assert_response :success
end
test "shoul... |
class ValidationTracker
include Mongoid::Document
field :environment_config, type: String
field :server, type: String
field :tag, type: String
end
|
class CreateSharedUploads < ActiveRecord::Migration
def self.up
create_table :shared_uploads do |t|
t.integer "uploadable_id"
t.string "uploadable_type"
t.integer "upload_id"
t.integer "shared_by_id"
t.timestamps
end
add_index "shared_uploads", "uploadable_id"... |
require 'spec_helper'
describe RakutenWebService::Gora::CourseDetail do
let(:endpoint) { 'https://app.rakuten.co.jp/services/api/Gora/GoraGolfCourseDetail/20170623' }
let(:affiliate_id) { 'dummy_affiliate_id' }
let(:application_id) { 'dummy_application_id' }
let(:expected_query) do
{
affiliateId: a... |
require 'spec_helper'
describe GraphQLIncludable::ConnectionIncludesBuilder do
context 'A connection with only nodes' do
context 'with no siblings or deep nesting' do
it 'generates the correct includes pattern' do
builder = subject
builder.nodes(:nodes_a)
expect(builder.includes?).... |
# 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... |
class ProfilesController < ApplicationController
breadcrumb "Profile", :profile_path, match: :exact
def show
end
def edit
breadcrumb "Edit", :edit_profile_path
end
def update
if current_user.update post_params
redirect_to profile_path, flash: {success: 'Data updated successfully!'}
else... |
require 'spec_helper'
module WastebitsClient
describe ForgotPassword do
describe "Attributes" do
it { should respond_to :email }
it { should respond_to :url }
end
describe "Instance methods" do
it { should respond_to :send_instructions }
end
end
end
|
require ("pry")
require('minitest/autorun')
require('minitest/rg')
require_relative('../Room.rb')
require_relative('../Guest.rb')
require_relative('../Song.rb')
class RoomTest < MiniTest::Test
def test_room_number
room1 = Room.new(1,2)
room2 = Room.new(2,2)
room_number_1 = room1.number
room_number_2... |
file "couchdb" => [] do
sh 'git clone git://github.com/halorgium/couchdb.git'
end
desc "Update to the latest version of git://github.com/halorgium/couchdb.git"
task :git_update do
Dir.chdir('couchdb')
begin
sh 'git pull'
ensure
Dir.chdir('..')
end
end
desc "Clean up as though this were a fresh distr... |
require 'rails_helper'
RSpec.feature 'Visiting the permissions page', type: :feature do
scenario 'As an un-authenticated user, loads the login page' do
visit 'permissions'
expect(current_path).to eq('/users/sign_in')
end
scenario 'As a user with the athlete role, there should be a 403 status code' do
... |
#!/usr/bin/env ruby
# @param {String} s
# @return {Integer}
def length_of_longest_substring(s)
str_len = s.size
max_str = ''
max_len = 0
i = 0
while i < str_len
if max_str.empty?
max_str = s[i]
end
cursor = 1
loop do
index = i + cursor
if index == str_len
break
... |
require 'spec_helper'
describe Problem do
it "is valid with a question, an answer, and a difficulty level" do
expect(build :problem).to be_valid
end
it "is invalid without a question" do
problem = build(:problem, question: nil)
expect(problem).to have(1).error_on(:question)
end
it "is invalid w... |
class AddFileuploadToResults < ActiveRecord::Migration
def change
add_attachment :results, :attachment
end
end
|
# == Schema Information
#
# Table name: portfolios
#
# id :integer not null, primary key
# date :string(255)
# title :string(255)
# details :string(255)
# photo :string(255)
# post_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
... |
require 'vanagon/extensions/ostruct/json'
describe "OpenStruct" do
describe "with JSON mixins" do
let(:test_ostruct) { OpenStruct.new(size: "big", shape: "spherical", name: "rover") }
let(:json_ostruct) { %({"size":"big","shape":"spherical","name":"rover"}) }
it "responds to #to_json" do
expect(Op... |
class PostsController < ApplicationController
before_action :find_post, only: [:edit, :update, :show, :delete]
before_action :redirect_if_not_signed_in, only: [:new]
def index
@posts = Post.search(params[:search])
end
def new
@post = Post.new
end
# Create action saves the post into database
def create
... |
class Cordinate < ActiveRecord::Base
reverse_geocoded_by :latitude, :longitude
SAITAMA_KENCHO = { lat: 35.8569444, lng: 139.6488889 }
NORTH_EDGE=36.2833376
EAST_EDGE=139.8652589
SOUTH_EDGE=35.7536154
WEST_EDGE=138.7092002
PRECISION_PAIR = { 11 => 9.5, 12 => 4.5, 13 => 2, 14 => 1, 15 => 0.5, 16 => 0.3, 1... |
class AddTypeToAspectLinks < ActiveRecord::Migration
def change
add_column :aspect_links, :type, :string
end
end
|
class NotificationsController < ApplicationController
def welcome
@message = "Welcome to OutResearch"
end
end
|
class Account < ActiveRecord::Base
has_many :users, :dependent => :destroy
has_one :subscription, :dependent => :destroy
has_many :subscription_payments
accepts_nested_attributes_for :users
# From saas subscription project - not using subdomains yet
#validates_format_of :domain, :with => /\A[a-zA-Z][... |
# frozen_string_literal: true
# Before you leave, the Elves in accounting just need you to fix your expense
# report (your puzzle input);
# apparently, something isn't quite adding up.
#
# Specifically, they need you to find the two entries that sum to
# 2020 and then multiply those two numbers together.
module Day1
... |
class CrawlsController < ApplicationController
def index
crawls = Crawl.all
render json: crawls, include: :bars
end
#A single crawl will include all bars
def show
crawl = Crawl.find(params[:id])
render json: crawl, include: :bars
end
def create
craw... |
require 'garage'
describe Garage do
let(:working_bike) {double :bike, broken?: false, is_a?: Bike}
let(:broken_bike) {double :bike, broken?: true, is_a?: Bike}
let(:van) {double :van, garage_pickup: [working_bike], release: nil}
let(:garage) {Garage.new(:capacity => 30)}
it "should allow setting d... |
# encoding: utf-8
control "V-52249" do
title "Database recovery procedures must be developed, documented, implemented, and periodically tested."
desc "Information system backup is a critical step in maintaining data assurance and availability.
User-level information is data generated by information system and/or a... |
require 'sqlite3'
require 'logger'
class ClientMockup
attr_reader :db, :log, :config, :users
def initialize(options={})
@config = options
@log = Logger.new($stdout)
@db = SQLite3::Database.new('test.db')
@last_send_msg = []
@users = options[:users] || {}
File.o... |
require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
count = 0
self.split.each do |sub_sent|
if sub_sent.sentence? || sub_sent.question? || sub_sent.exclamation?
... |
require 'rails_helper'
#
# Property's route path is to account
#
RSpec.describe 'Property#index', type: :system do
before { log_in }
it 'basic' do
client = client_create
property_create human_ref: 111, client: client, account: account_new
property_create human_ref: 222, client: client, account: accoun... |
#!/usr/bin/env ruby
class Triangel
def initialize(a, b, c)
@a, @b, @c = a, b, c
end
def valid?
@a + @b > @c && @b + @c > @a && @a + @c > @b
end
def circuit
@a + @b + @c
end
def self.create_rectangular(a, b)
c = Math.sqrt(a * a + b * b)
self.ne... |
class AddEmailToAuthors < ActiveRecord::Migration
def change
add_column :authors, :e_mail, :text
end
end
|
#!/usr/bin/ruby
require "optparse"
require "termpic"
options = {}
opt = OptionParser.new
opt.on('-f') {|v| options[:fit_terminal] = true }
opt.on('-s') {|v| options[:show_size] = true }
opt.on('-d') {|v| options[:double] = true }
opt.on('--domain=VAL') {|v| options[:domain] = v }
opt.parse!(ARGV)
Termpic::Image.new(AR... |
module Api
module V1
class ProductsController < ApplicationController
before_action :set_product, only: [:show, :destroy]
def index
render json: Product.all
end
def create
@product = Product.create(product_params)
#Scrape as we send the request
sc... |
$:.push File.expand_path("../lib", __FILE__)
require "amazon_s3_index_proxy/version"
Gem::Specification.new do |s|
s.name = "amazon_s3_index_proxy"
s.version = AmazonS3IndexProxy::VERSION
s.authors = ["Netguru"]
s.homepage = "https://github.com/netguru/amazon_s3_index_proxy"
s.summary ... |
require "application_system_test_case"
class EstoquesTest < ApplicationSystemTestCase
setup do
@estoque = estoques(:one)
end
test "visiting the index" do
visit estoques_url
assert_selector "h1", text: "Estoques"
end
test "creating a Estoque" do
visit estoques_url
click_on "New Estoque"
... |
class AddImageData3ToCatalog4ItemImage < ActiveRecord::Migration
def change
change_column :catalog4_category_item_images, :image_ratio, :float
end
end
|
require 'spec_helper'
describe LinkedList do
before do
@linked_list = LinkedList.new
end
describe "#push" do
it "lets you push on multiple values" do
@linked_list.push(1)
@linked_list.push(2)
@linked_list.push(3)
@linked_list.to_a.should == [1, 2, 3]
end
end
describe "#d... |
def square_array(array)
# Use an Enumerable to square every element in the passed in array
array.map do |element|
element * element
end
# Return a new array of the results
end
def summon_captain_planet(planeteer_calls)
# Use an Enumerable to capitalize and add '!' to every element in the passed in array
... |
Rails.application.routes.draw do
get 'sessions/new'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'top#index'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
get '/logout', to: 'sessions#destroy'
get '/friends/sea... |
class AddInterstatePalletIdToJob < ActiveRecord::Migration
def change
add_column :jobs, :interstate_pallet_id, :integer
end
end
|
require_relative '../constants'
require_relative '../spec/web_resources'
require_relative '../modules/aes'
require_relative '../modules/xor'
require_relative '../modules/utils/hex'
require_relative '../modules/utils/utility'
class Decryptor
# Modules
include AES
attr_accessor :encoded_bytes
attr_reader :input... |
# frozen_string_literal: true
require 'rails_helper'
require_relative 'concerns/date_range'
RSpec.describe Season do
it_behaves_like 'date_range'
describe SeasonValidator do
let(:other) do
start_date = Time.zone.now.change(month: 3).to_date
end_date = Time.zone.now.change(month: 10).to_date
... |
class Pokemon
attr_accessor :name, :type, :db, :id, :hp
@@all = []
def initialize(name: , type: , db:, id:, hp: nil)
@name = name
@type = type
@db = db
@id = id
@hp = hp
@@all << self
end
def self.save(pk_name, pk_type, db)
db.execute("INSERT INTO pokemon (name, type) VALUES (?,... |
require 'forwardable'
require 'diff/lcs'
require 'creola/html'
require 'creola/txt'
class CreolaList < CreolaTxt
def root(content); content.flatten end
def to_a; render end
undef_method :to_txt
end
class CreolaDiff < Creola
extend Forwardable
def initialize(old_creole, new_creole, renderer)
@old_conte... |
module Leagues
module Rosters
class CommentsController < ApplicationController
include ::LeaguePermissions
before_action do
@roster = League::Roster.find(params[:roster_id])
@league = @roster.league
end
before_action only: [:edit, :update, :edits, :destroy, :restore] do
... |
module Super
module Kafka
class Processor
include Super::Component
inst_accessor :adapter, :task
inst_reader :state
interface :run, :start, :stop
def initialize
@state = :offline
end
def run(task)
@task = task
setup_consumer
start
... |
#!/usr/bin/env ruby
VERSION='1.0.0'
$:.unshift File.expand_path('../../lib', __FILE__)
require 'hashie'
require 'devops_api'
require 'pry'
require 'awesome_print'
require 'ruby-progressbar'
class Api
include DevopsApi
end
def get_hz domain, api
hzs = []
marker = ""
while marker.class == String do
resp =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.