text stringlengths 10 2.61M |
|---|
module Endpoints
class Medias < Grape::API
resource :medias do
# test medias api
get :ping do
{success: "Media Endpoints"}
end
# Get all media
# GET: /api/v1/medias
# parameters:
# token String *required
get do
user = User.find... |
module ProfileBaseHelper
def link_to_profile_controller(user, profile_mode = nil, controller = nil, url_opts = nil, html_opts = nil)
profile_mode ||= :aboutme
controller ||= 'profile_home'
url_opts ||= {}
url_opts[:controller] ||= controller
url_opts[:profile_mode] ||= profile_mode
ur... |
require 'logger'
module Raven
module Breadcrumbs
module SentryLogger
LEVELS = {
::Logger::DEBUG => 'debug',
::Logger::INFO => 'info',
::Logger::WARN => 'warn',
::Logger::ERROR => 'error',
::Logger::FATAL => 'fatal'
}.freeze
def add(*args)
add_bre... |
class Triptrack < ActiveRecord::Base
attr_accessible :name, :location, :latitude, :longitude, :clip, :address,
:description
has_attached_file :clip
belongs_to :user
class << self
def within_box(north, south, east, west)
sw_string = "(#{west}, #{south})"
ne_string = "(#{east},... |
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'barby/outputter/prawn_outputter'
include Barby
describe PrawnOutputter do
before :each do
@barcode = Barcode.new
def @barcode.encoding; '10110011100011110000'; end
@outputter = PrawnOutputter.new(@barcode)
end
it "should register to... |
module ApplicationHelper
FLASH_TYPES = {
alert: 'warning',
notice: 'info'
}.freeze
def flash_messages
flash.map do |type, message|
content_tag :div, sanitize(message), class: flash_type(type), role: 'alert'
end.join("\n").html_safe
end
def link_cache_key(link)
link_type = link.gist... |
require 'rails_helper'
describe Voucher do
it "has a valid factory" do
expect(build(:voucher)).to be_valid
end
it "is valid with a code, valid_from, valid_through, amount, unit_type, max_amount" do
expect(build(:voucher)).to be_valid
end
it "is invalid without a code" do
voucher = build(:vouch... |
def sum_even_number_of_row(row_number)
rows = [] #step 1
start_integer = 2
(1..row_number).each do |current_row_number| #steps 2 & 3 used a range instead of a loop
rows << create_row(start_integer, current_row_number)
start_integer = rows.last.last + 2
end
# final_row_sum = 0
# rows.last.each{ |num|... |
# U2.W6: Create a Car Class from User Stories
# I worked on this challenge by myself.
# 2. Pseudocode
=begin
Methods:
initialize(model, color)
accelerate(acceleration)
decelerate(deceleration)
stop
turn left
turn right
previous action
drive(speed, distance)
Attributes:
distance travelled
speed
model
... |
class Zoo
@@all = []
attr_reader :name, :location
def initialize(name, location)
@name = name
@location = location
@@all << self
end
def self.all
@@all
end
def animals
Animal.all.select{ |animal|
self == animal.zoo
}
end
... |
require 'test_helper'
class CostDetailsControllerTest < ActionDispatch::IntegrationTest
setup do
@cost_detail = cost_details(:one)
end
test "should get index" do
get cost_details_url
assert_response :success
end
test "should get new" do
get new_cost_detail_url
assert_respo... |
class AddAttachmentsToGallery < ActiveRecord::Migration[5.0]
def change
add_column :galleries, :attachments, :string, array: true, default: []
end
end
|
class AddAndRenameColumnToEntities < ActiveRecord::Migration
def change
rename_column :entities, :surname, :paternal_surname
add_column :entities, :maternal_surname, :string
end
end
|
# Modelo Episodio
# Tabla episodios
# Campos id:integer
# medico_id:integer
# paciente_id:integer
# fecha:date
# hora:time
# historia_enfermedad_actual:text
# aparatos_sistemas:string
# fuma:boolean
# fuma_frecuencia:string
# toma:boolean
# toma_fre... |
class AddColumnUserIdToRepeatExceptions < ActiveRecord::Migration[4.2]
def change
add_column :repeat_exceptions, :user_id, :integer
add_index :repeat_exceptions, :user_id
end
end
|
class Event < ApplicationRecord
belongs_to :user
# belongs_to :place
belongs_to :sport
has_many :participations, dependent: :destroy
has_many :messages
validates :name, presence: true
validates :name, uniqueness: true
validates :required_level, presence: true
#validates :status, presence: true
val... |
class AddEndsOnToExchangeRates < ActiveRecord::Migration
def change
add_column :exchange_rates, :ends_on, :date, null: false
end
end
|
class ResumePresenter
def initialize view, &block
@view = view
yield(self)
end
def resume organization, type
text = Resume.translate organization, type
return if text.blank?
h.content_tag(:p, class: type) {
h.content_tag(:span, I18n.t("documents.resume.#{type}")) + text
}
end
... |
Rails.application.routes.draw do
root 'dashboard#index'
resources :users
resources :rooms
resources :bookings
end
|
require 'rails_helper'
require 'support/factory_girl'
describe "Artists new interface", :type => :feature do
describe "page" do
before do
visit new_artist_path
end
it { expect(page).to have_title("Add artist") }
# it { expect(page).to have_content("Add artist") }
end
describe "with valid ... |
module AadhaarAuth
class Encrypter
ENC_ALGO = 'AES-256-ECB'
def session_key
@session_key ||= begin
aes = OpenSSL::Cipher.new(ENC_ALGO)
aes.encrypt
aes.random_key
end
end
def encrypted_session_key
@encrypted_session_key ||= begin
public_key = public_c... |
class Haiku
include ActiveModel::Validations
include HaikuChecker
attr_accessor :line1, :line2, :line3
attr_accessor :line1_valid, :line2_valid, :line3_valid, :valid, :checked
def initialize
@line1 = "An old silent pond,"
@line2 = "A frog jumps into the pond,"
@line3 = "Splash! Silence again.... |
require 'spec_helper'
feature 'Removing Member from Project', js: true do
scenario 'persisted user' do
project = factory!(:project)
member = factory!(:user)
surety = factory!(:surety, project: project)
factory!(:surety_member, user: member, surety: surety)
surety.generate!
surety.activate!
... |
module Worker
class DepositCoinAddress
def process(payload, metadata, delivery_info)
payload.symbolize_keys!
payment_address = PaymentAddress.find payload[:payment_address_id]
return if payment_address.address.present?
currency = payload[:currency]
if currency == 'tlcp'
c =... |
# 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 Reports::FastRegionTreeComponent < ViewComponent::Base
attr_reader :region_tree, :parent, :children
def initialize(region_tree:, parent:, children:)
@region_tree = region_tree
@children = children
@parent = parent
end
OFFSET = 2
# Note that we short circuit facility access checks because ... |
NET = "192.168.90."
Vagrant.configure("2") do |config|
vm_no = 5
(1..vm_no).each do |machine_id|
config.vm.define "hadoop0#{machine_id}" do |machine|
machine.vm.hostname = "hadoop0#{machine_id}"
machine.vm.box = "centos/7"
machine.vm.network "forwarded_port", guest: 22, host: "269#{machine_i... |
require "pry"
module Api::V1
class UsersController < ApplicationController
before_action :set_user, only: [:show, :update, :destroy, :user_matches]
skip_before_action :authorized, only: [:create]
# GET /users
def index
@users = User.all
render json: @users
end
def user_matches
render json: @user.matches.... |
module Rpodder
class Runner < Base
def initialize(*args)
load_config!
load_database!
parse_options
end
def parse_options
trap_interrupt
Rpodder::CLI.start
remove_unused!
clean_history
end
def trap_interrupt
Signal.trap('INT') do
error "\n\n... |
class CreateServiceLinks < ActiveRecord::Migration
def change
create_table :service_links do |t|
t.references :linked_to_service, index: true
t.references :linked_from_service, index: true
t.string :alias
t.timestamps
end
add_index :service_links, [:linked_from_service_id, :linke... |
class OrderController < ApplicationController
before_filter :find_order, only: [ :show, :edit, :update, :destroy ]
def index
@order = Order.all
end
def show
if @order.client_id.nil?
@msg = "No client found for this order"
else
@clie = @order.client
@msg= @clie.name... |
# There are several types of bodies we're concerned about in our solar system:
# planets, stars (like our sun), and moons. We'll ignore asteroids and smaller
# planetoids (sorry Pluto).
#
# Each of our body types needs a class: Planet, Star, and Moon.
# All of these bodies have some similarities: they all have a name a... |
require 'spec_helper'
require_relative '../../../lib/scrapers/berlinale_programme'
RSpec.describe Scrapers::BerlinaleProgramme do
subject { described_class.new(page) }
let(:page) { 20 }
describe '#data' do
it 'returns some data' do
VCR.use_cassette("berlinale_page_#{page}") do
expect(subject.d... |
class AddCreatedByIdToEuDecisions < ActiveRecord::Migration
def change
add_column :eu_decisions, :created_by_id, :integer
end
end
|
FactoryGirl.define do
factory :treatment_type do
sequence(:name) { |n| "Treatment type #{n}" }
treatment_types_group
end
end
|
require 'spec_helper'
describe "Proxy + WebDriver" do
let(:driver) { Selenium::WebDriver.for :firefox, :profile => profile }
let(:proxy) { new_proxy }
let(:wait) { Selenium::WebDriver::Wait.new(:timeout => 10) }
let(:profile) {
pr = Selenium::WebDriver::Firefox::Profile.new
pr.proxy = proxy.selenium_... |
module Perpetuity
class IdentityMap
def initialize
@map = Hash.new { |hash, key| hash[key] = {} }
end
def [] klass, id
@map[klass][id]
end
def << object
klass = object.class
id = object.instance_variable_get(:@id)
@map[klass][id] = object
end
def ids_for kl... |
class ImportTrail < ApplicationRecord
belongs_to :import
scope :with_errors, -> { where.not(error_msg: nil) }
scope :without_errors, -> { where(error_msg: nil) }
scope :last_day, -> { where('created_at > ?', 1.day.ago) }
def duration_time
time_span = (finished_at || Time.current) - created_at
Tim... |
class Inquiry
include ActiveModel::Model
attr_accessor :name, :tel, :email, :inquiry_details
validates :name, presence: true, length: { maximum: 20 }
validates :tel, presence: true, numericality: true, length: { maximum: 15 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates... |
class CreateListedCitizens < ActiveRecord::Migration
def change
create_table :listed_citizens do |t|
t.references :citizen
t.references :list
t.timestamps
end
add_index :listed_citizens, [:citizen_id, :list_id]
add_index :listed_citizens, [:list_id, :citizen_id]
end
end
|
# == Schema Information
#
# Table name: logs
#
# id :uuid not null, primary key
# guest_id :integer
# access_token :string
# created_at :datetime not null
#
class Log < ApplicationRecord
belongs_to :guest
validates :guest, presence: true
validates :access_token, pres... |
require "spec_helper"
describe Lita::Handlers::Redmine, lita_handler: true do
before do
Lita.configure do |config|
config.handlers.redmine.url = "https://redmine.example.com"
config.handlers.redmine.type = :chiliproject
config.handlers.redmine.apikey = "0000000000000000000000000000000000000000... |
require 'spec_helper'
describe Survey do
it 'should create a survey with a correct ID' do
VCR.use_cassette 'models/survey/survey_success' do
FactoryGirl.create(:survey).should be_valid
end
end
it 'should not create a survey with a incorrect ID' do
VCR.use_cassette 'models/survey/surv... |
class Author < ApplicationRecord
has_and_belongs_to_many :books, autosave: true
accepts_nested_attributes_for :books
validates :first_name, :last_name, presence: true
validates_format_of :group, with: %r{([A-Z]+)-(\d+)/(\d+)}i
def as_json(_options = {})
super(include: { books: { except: [] } })
end
en... |
class ArticlesController < ApplicationController
respond_to :html
skip_before_action :authenticate_user!, only: [:show, :index]
before_action :set_article, only: [:show, :edit, :update, :destroy]
impressionist actions: [:show]
def index
@articles = Article.all
respond_with(@articles)
end
def sho... |
require "test_helper"
class AdminUserTest < ActiveSupport::TestCase
def test_should_be_valid
assert FactoryBot.create(:admin_user).valid?
end
def test_send_reset_password_email
admin_user = FactoryBot.create(:admin_user)
old_perishable_token = admin_user.perishable_token
mailer = mock
maile... |
class HomeController < ApplicationController
def index
if session.has_key? :url_after_oauth
redirect_to session[:url_after_oauth]
end
end
end
|
class CreateUtilityCharges < ActiveRecord::Migration
def change
create_table :utility_charges do |t|
t.string :utility_name
t.decimal :utility_charge, precision: 6, scale: 2
t.string :utility_charge_date
t.references :property, index: true
t.timestamps
end
end
end
|
class NestCommand
def self.command(settings)
new.command(settings)
end
def command(settings)
return unless Rails.env.production? || Rails.env.test?
ActionCable.server.broadcast(:nest_channel, { loading: true })
get_devices if DataStorage[:nest_devices].blank?
settings = settings.to_s.squish... |
class Song < ApplicationRecord
belongs_to :user
has_many :counts,dependent: :destroy
has_many :users, through: :counts,dependent: :destroy
validates :artist, presence:true
validates :title, presence:true
validates :artist, length: { minimum: 2 }
validates :title, length: { minimum: 2 }
end
|
require 'rails_helper'
RSpec.describe 'Chat stories' do
before do
allow(REDIS).to receive(:incr).with('user_count').and_return(1, 2, 3)
end
it "displays chat app" do
visit root_url
expect(page).to have_selector('h1', text: 'Public chat')
within('#message-input') do
expect(page).to have_se... |
=begin
This class describes triangles. An object of type triangle is defined by
3 numbers called edges, which values are between 0 and 20,
and they satisfy the following relationship:
The sum of any two numbers is greater or equal with the third number.
=end
class Triangle
def initialize(array)
@lat1 = ... |
class FiatShamir
attr_accessor :p, :q, :s, :it, :n, :v, :x
def initialize(prime_p, prime_q, s, iterations)
@p = prime_p # numero secreto primo p
@q = prime_q # numero primo secreto q
@s = s # numero secreto
@it = iterations # numero de iteraciones
@n = @p * @q # numero pu... |
require 'net/ldap/dn'
module LDAPUtils
# https://github.com/ruby-ldap/ruby-net-ldap/issues/222
@B32 = 2**32
def self.get_sid_string(data)
sid = data.unpack('b x nN V*')
sid[1, 2] = Array[nil, b48_to_fixnum(sid[1], sid[2])]
'S-' + sid.compact.join('-')
end
def self.get_sid_strings... |
class StdInfo < ActiveRecord::Base
attr_accessible :std_id, :std_language, :std_name_cn, :std_name_en, :std_org, :std_release_time, :std_tag1, :std_tag2, :std_path
validates :std_id, :presence => true, :uniqueness => true
validates :std_name_cn, :presence => true
validates :std_name_en, :presence => true
h... |
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test "full title helper" do
assert_equal full_title, "stokedbiz: bound to be insanely stoked"
assert_equal full_title("contact us"), "contact us | stokedbiz: bound to be insanely stoked"
end
end |
require 'rails_helper'
RSpec.describe OrderAddress, type: :model do
before do
@user = FactoryBot.build(:user)
@item = FactoryBot.build(:item)
@order = FactoryBot.build(:order_address, user_id: @user, item_id: @item)
end
context 'ユーザー登録ができる時' do
it "全ての情報があれば保存ができること" do
expect(@ord... |
class JobPosting < ApplicationRecord
has_many :job_board_metros
has_many :candidates, through: :job_board_metros
end
|
class AddPractitionerIdToServices < ActiveRecord::Migration
def change
remove_column :services, :practitioner_id, :int
end
end
|
# == Schema Information
#
# Table name: app_rating_items
#
# id :integer not null, primary key
# comment :text
# rating :integer
# created_at :datetime not null
# updated_at :datetime not null
# app_rating_id :integer
# rating_item_id :integer
#
class... |
# 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... |
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/support
# encoding: utf-8
# frozen_string_literal: true
require 'pagy/extras/shared'
class Pagy
def to_h
{ count: defined?(@count) && @count,
page: @page,
items: @items,
pages: @pages,
last: @last,
offset: ... |
require 'spec_helper'
describe 'kdump_kernel_arguments fact' do
before :each do
Facter.clear
end
context 'kernel is linux' do
it 'returns output from /proc/cmdline' do
expected_value = my_fixture_read('cmdline1')
allow(Facter::Core::Execution).to receive(:exec).with('uname -s').and_return('L... |
class CreateProjectGoals < ActiveRecord::Migration[5.2]
def change
create_table :project_goals do |t|
t.integer :project_id, null: false
t.text :content, null: false
t.datetime :by_when, null: false
t.boolean :is_private, null: false
t.timestamps
end
end
end
|
require 'pry'
require 'colorize' #using this gem for color output in terminal...
#after reviewing rock paper scissorlesson video....
#learned the loop do, loop
CHOICES = { '1' => "Paper", '2' => "Rock", '3' => "Scissors"}
CHEAT = {'5' => "BFG"}
#added a new array for the cheat for the computer...
def say(msg)
pu... |
require 'rails_helper'
RSpec.describe InvoicingIndexDecorator do
it '#created_at' do
Timecop.travel(Time.zone.local(2008, 9, 1, 10, 5, 1)) do
property_create human_ref: 1, account: account_new
invoicing_dec = described_class.new \
invoicing_create property_range: '1-2'
expect(invoicing... |
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
def test_should_get_index
get :index, {}, { :user_id => users(:fred).id }
assert_response :success
assert_not_nil assigns(:users)
end
def test_should_get_new
get :new, {}, { :user_id => users(:fred).id }
assert_resp... |
require "rails_helper"
describe Toolbox::Tools::Dictionary do
it "appears in the list of tools" do
expect(Toolbox::Tools.all).to include Toolbox::Tools::Dictionary
end
context '#will_handle' do
[
{ matches: true, text: "define sauce" },
{ matches: true, text: "define pasta sauce" },
{ ma... |
class AllowNullVariantPrice < ActiveRecord::Migration
def self.up
change_column :variants, :price, :decimal, :precision => 8, :scale => 2, :null => true
end
def self.down
change_column :variants, :price, :decimal, :precision => 8, :scale => 2, :null => false
end
end
|
require 'spec_helper'
describe Panel do
context "with no fields" do
let(:panel) { Panel.new }
it "saves the record" do
panel.save.should be_true # false positive, catches it later
end
end
context "with one field" do
let(:panel) { Panel.new(:title => "Test Panel") }
it "does not ... |
class Song < ApplicationRecord
has_many :album_songs
has_many :albums, through: :album_songs
has_many :song_artists
has_many :artists, through: :song_artists
validates :name, presence: {message: "Debe tener nombre."}, length: {in: 3..20}, uniqueness: {message: "La cancion ya existe"}
validates ... |
# == Schema Information
#
# Table name: activities
#
# id :integer not null, primary key
# name :string(255)
# address :string(255)
# phone :string(255)
# biz_url :string(255)
# thumbnail_photo :string(255)
# rating :string(255)
# created_at ... |
class ContactMailer < ActionMailer::Base
default from: "no-reply@ski-lines.com"
def contact_form_submit(contact)
@contact = contact
@url = 'https://www.ski-lines.com'
mail(to: 'mark@ski-lines.com', subject: 'New Contact Form Submission')
end
end
|
class Song < ActiveRecord::Base
belongs_to :user, required: true
has_many :playlists
has_many :added_by, through: :playlists, source: :user
validates :title, :artist, presence: true, length:{minimum: 2}
end
|
require 'rails_helper'
RSpec.describe PaymentIndexDecorator do
let(:source) { payment_new }
let(:decorator) { described_class.new source }
describe 'attributes' do
it '#amount' do
expect(decorator.amount).to eq '£88.08'
end
end
end
|
class List < ActiveRecord::Base
include PublicActivity::Common
validates_presence_of :title
belongs_to :user
delegate :username, to: :user
has_many :tasks, dependent: :destroy
accepts_nested_attributes_for :tasks, allow_destroy: true, reject_if: proc { |attributes| attributes['title'].blank? }
end
|
Gem::Specification.new do |s|
s.name = 'bicycle_report'
s.version = '0.0.0'
s.platform = Gem::Platform::RUBY
s.authors = ['Mateusz Konieczny']
s.email = ['matkoniecz@gmail.com']
s.homepage = 'https://github.com/matkoniecz/bicycle_report'
s.summary = 'Generates bicycle report... |
module ActivityHelpers
def page_displays_an_activity(activity_presenter:)
click_on t("tabs.activity.details")
expect(page).to have_content t("activerecord.attributes.activity.organisation")
expect(page).to have_content activity_presenter.organisation.name
expect(page).to have_content t("activerecord... |
class Article < ActiveRecord::Base
belongs_to :author, class_name: 'User'
has_many :comments, dependent: :destroy
def authored_by?(someone)
author == someone
end
end
|
class Reg < ApplicationRecord
has_secure_password
self.primary_key = 'Regid'
validates :Regid, :presence => {:message => "cannot be blank ..."}
validates_uniqueness_of :Regid
validates_uniqueness_of :Emailid
validates :name, :presence => {:message => "cannot be blank ..."}
validates :contactno, :presence =... |
class AddStartedAtToMatches < ActiveRecord::Migration
def change
add_column :matches, :started_at, :datetime, null: false, after: :name
end
end
|
require 'rails_helper'
feature 'User Authentication' do
scenario 'allows a user to signup' do
visit '/'
expect(page).to have_link('Signup')
click_link 'Signup'
fill_in 'First name', with: 'bob'
fill_in 'Last name', with: 'smith'
fill_in 'Email', with: 'bob@smith.com'
fill_in 'Password'... |
class User < ApplicationRecord
has_secure_password
has_many :appointments
has_many :events, through: :appointments
def upcoming_events
events.all.select do |event|
event.start_time > Time.now
end
end
end
|
require 'digest/md5'
module Wechaty
def self.sign(params)
key = params.delete(:key)
query = params.sort.map do |key, value|
"#{key}=#{value}" if value != "" && !value.nil?
end.compact.join('&')
Digest::MD5.hexdigest("#{query}&key=#{key || Wechaty.config.api_key}").upcase
end
... |
# == Schema Information
#
# Table name: bwc_codes_group_retro_tiers
#
# id :integer not null, primary key
# discount_tier :float
# industry_group :integer
# public_employer_only :boolean default(FALSE)
# created_at :datetime not null
# updated_at ... |
module Locomotive
class EditableSelectInput < SimpleForm::Inputs::CollectionSelectInput
def link(wrapper_options)
if _options = options[:manage_collection]
label = _options[:label] || I18n.t(:edit, scope: 'locomotive.shared.form.select_input')
url = _options[:url]
template.link_to... |
require 'csv'
module Parser
ASSETS_PATH = Rails.root.join('app/assets/')
CSV_PATH = Rails.root.join('app/assets/csv')
CSV_UPLOAD_PATH = Rails.root.join('app/assets/csv/upload')
CSV_EXPORT_PATH = Rails.root.join('app/assets/csv/export')
FILE_ROOTS = [CSV_PATH, CSV_EXPORT_PATH,CSV_EXPORT_PATH,CSV_UPLOAD_PATH].m... |
# frozen_string_literal: true
module Guard
class I18nJson < Plugin
VERSION = "0.0.1"
end
end
|
class SessionsController < ApplicationController
def new
end
def create
user = User.where(email: params[:session][:email]).first
if user && user.authenticate(params[:session][:password])
login_as(user) && redirect_to(url_after_login, notice: t("sessions.create.notice"))
else
flash.now.ale... |
require "rails_helper"
RSpec.describe "Static", :type => :request do
before(:each) do
objects = RequestsHelper.prepare_requests()
@user = objects[:user]
end
it "receives a feed after correct token" do
get "/feed", headers: {
'Accept' => 'application/json',
'Authorization' => "Token #{@us... |
# CRUD вариантов товара
class Admin::VariantsController < Admin::BaseController
include MultilingualController
before_action :set_variant, only: [:show, :edit, :update, :destroy]
before_action :set_good, only: [:new, :edit, :create, :update, :destroy]
# GET /variants
# GET /variants.json
def index
@va... |
ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 5843, "Eddie" => 10, "Marilyn" => 22, "Spot" => 237}
p ages.values.sum
p ages.values.reduce(:+)
total_ages = 0
ages.each { |_,age| total_ages += age }
p total_ages
total_ages = 0
ages.each do |_, age|
total_ages += age
end
p total_ages |
require 'rails_helper'
RSpec.describe Beer, type: :model do
let!(:style) { FactoryGirl.create :style, name:"Lager" }
it "is created when name and style are set" do
beer = Beer.create name:"Test Beer", style:style
expect(beer).to be_valid
expect(Beer.count).to eq(1)
end
it "is not created when na... |
require('minitest/autorun')
require_relative('../room')
require_relative('../guest')
require_relative('../song')
class TestRoom < MiniTest::Test
def setup
@room = Room.new("Prince", 2)
@guest1 = Guest.new("Steve", 20.00)
guest2 = Guest.new("Bob", 20.00)
guest3 = Guest.new("Alan", 20.00)
@group1 ... |
#! /usr/bin/env ruby
# vim:
def say_hello
puts "hello!"
end
alias :again :say_hello
say_hello
again
def say_hello
puts "hello! #2"
end
say_hello
again
|
# -*- encoding: utf-8 -*-
require File.dirname(__FILE__) + '/lib/omniauth-google-authenticator/version'
Gem::Specification.new do |gem|
gem.add_runtime_dependency 'omniauth', '>= 1.3.2'
gem.add_development_dependency 'maruku', '~> 0.6'
gem.add_development_dependency 'simplecov', '~> 0.4'
gem.add_development_d... |
shared = proc do
let(:rack_key_value) { :Value }
let(:default_env) do
{
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => 'example.org',
'SERVER_PORT' => '80',
'PATH_INFO' => '/',
'rack.url_scheme' => 'http'
}
end
let(:expected_value) { rack_key_value ... |
class AddPaymentProductIdToSpreeGlobalCollectCheckout < ActiveRecord::Migration
def change
add_column :spree_global_collect_checkouts, :payment_product_id, :integer
end
end
|
class AddChapteridToAnswerSpaces < ActiveRecord::Migration[5.2]
def change
add_column :answer_spaces, :chapter_id, :string, after: :user_answer
end
end
|
class Bid < ActiveRecord::Base
validates_inclusion_of :price, :in => 100..500, message: "The price must be an integer > 100 and <= 500"
validates :phone_number, :alias, presence: true
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.