text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe "line_fragments/show", type: :view do
before(:each) do
@line_fragment = assign(:line_fragment, LineFragment.create!(
:working_article => nil,
:paragraph => nil,
:order => 2,
:column => 3,
:line_type => "Line Type",
:x => 4.5,
:y => 5... |
require_relative 'spec_helper'
describe "User class" do
describe "User instantiation" do
before do
@user = RideShare::User.new(id: 1, name: "Smithy", phone: "353-533-5334")
end
it "is an instance of User" do
expect(@user).must_be_kind_of RideShare::User
end
it "throws an argument e... |
default['couchpotato']['data'] = '/var/opt/couchpotato'
default['couchpotato']['home'] = '/opt/couchpotato'
default['couchpotato']['options'] = nil
default['couchpotato']['pidfile'] = '/var/run/couchpotato/couchpotato.pid'
default['couchpotato']['python_bin'] = '/usr/bin/python'
default['couchpotato']['repository'] = '... |
class FontAkshar < Formula
head "https://github.com/google/fonts/raw/main/ofl/akshar/Akshar%5Bwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Akshar"
desc "Supported"
homepage "https://fonts.google.com/specimen/Akshar"
def install
(share/"fonts").install "Akshar[wght].ttf"
end
test do
end
e... |
# db/migrate/003_create_questions.rb
class CreateQuestions < ActiveRecord::Migration[6.1]
def change
create_table :questions do |t|
t.belongs_to :scenario, null: false, foreign_key: true
t.belongs_to :user, null: false, foreign_key: true
t.integer :order
t.string :text
t.string :desc... |
require 'rails_helper'
include AdminHelpers
include ActiveSupport::Testing::TimeHelpers
RSpec.feature 'Viewing leaderboard' do
before do
travel_to Time.zone.parse('2019-09-1')
@hr = create(:hr)
assign_permission(@hr, :read, PerformanceTopic)
assign_permission(@hr, :create, Performance)
login_as(@... |
class LikesController < ApplicationController
before_action :set_male, only: [:create]
before_action :set_lady_doctor
def create
@like = Like.new(male_id: @male.id, lady_doctor_id: @lady_doctor.id)
@like.comment = @lady_doctor.email
respond_to do |format|
if @like.save
format.html { redire... |
class UsersController < ApplicationController
before_filter :admin_user
before_action :set_user, only: [:edit, :update, :destroy]
def show
@title = "Unorganized things..."
@albums = Album.page(params[:page])
end
def edit
@album = Album.new
@photo = Photo.new
@title = "Your Account"
end... |
# Source: https://launchschool.com/exercises/864acdb4
def time_of_day(mins)
return '00:00' if mins.zero?
hrs_out, min_out = mins.divmod(60)
hrs_out %= 24 # To account for more than one day
format('%02d:%02d', hrs_out, min_out)
end
# P:
# Question:
# Write a method that takes a time using this minute-b... |
require 'africansms/configuration'
require 'africansms/client'
module Africansms
class AfricansmsError < StandardError; end
class << self
def configure
yield configuration
end
def configuration
@configuration ||= Configuration.new
end
def reset
@configuration = Configuratio... |
# frozen_string_literal: true
require "rails_helper"
RSpec.describe "Placing an item order" do
let!(:product) { FactoryBot.create(:setup_item) }
let!(:account) { FactoryBot.create(:nufs_account, :with_account_owner, owner: user) }
let(:facility) { product.facility }
let!(:price_policy) do
FactoryBot.creat... |
require_dependency "office_automation_invoice/application_controller"
module OfficeAutomationInvoice
class InvoicesController < ApplicationController
def new
@invoice = Invoice.new
@invoice.items.build
end
def create
event_status, event_error = 200, nil
if params[:commit]... |
class Item < ApplicationRecord
has_one_attached :image
validates :name, presence: true
validates :description, presence: true
validates :value, presence: true
validates :quantity, presence: true
end
|
class Tile
attr_accessor :fringe, :state, :bomb, :flag, :hidden, :explode
def initialize(bomb=false)
@explode = false
@bomb = bomb
@flag = false
@fringe = 0
@hidden = true
end
end
|
# RSPEC SNIPPETS (DOES NOT INCLUDE CAPYBARA)
# nested describe blocks using 'context' method
# 'context' is only an alias for 'describe', more readable when nested
# this will print test output in the terminal indented, better organization
# Example:
#even? method
# with even number
# should return true
... |
class AddProspectPriority < ActiveRecord::Migration
def up
add_column :prospects, :priority, :integer, :default => 0
add_index :prospects, :priority
end
def down
remove_column :prospects, :priority
end
end
|
control "M-3.19" do
title "3.19 Ensure that /etc/default/docker file ownership is set to
root:root(Scored)"
desc "
Verify that the /etc/default/docker file ownership and group-ownership is
correctly set
to root.
/etc/default/docker file contains sensitive parameters that may alter the
behavior of
d... |
class ChangeTypeToTypeOfRoomInRooms < ActiveRecord::Migration[5.0]
def change
rename_column :rooms, :type, :type_of_room
rename_column :furnitures, :type, :type_of_furniture
end
end
|
Given(/^a "(.*?)" named "(.*?)" that is (\d+) years old$/) do |type, name, age|
@animal = Animal.new(name, type, age.to_i)
end
Then(/^it should be named "(.*?)"$/) do |name|
expect(@animal.name).to eq name
end
Then(/^it should be a "(.*?)"$/) do |type|
expect(@animal.type).to eq type
end
Then(/^it should be (\... |
class Visual < ActiveRecord::Base
attr_accessible :topic, :user_id, :vizname
belongs_to :user
validates :user_id, :presence => true
end
|
# frozen_string_literal: true
require '../lib/pieces/pawns.rb'
describe Pawn do
subject(:pawn) { described_class.new }
let(:piece) { instance_double(Piece) }
describe '#initialize' do
context 'when new white pawn instantiated' do
it 'places white piece' do
pawn = Pawn.new(:white)
expec... |
class Event
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :triggerer, polymorphic: true, inverse_of: :events
field :action, :type => String
field :anonymous_id, :type => String
field :properties, :type => Hash
field :broadcast, :type => Boolean, :default => false # whether this event... |
# frozen_string_literal: true
module Decidim
module Opinions
# Class used to retrieve similar opinions.
class SimilarOpinions < Rectify::Query
include Decidim::TranslationsHelper
# Syntactic sugar to initialize the class and return the queried objects.
#
# components - Decidim::Curre... |
class List
@@index = 0
@@calculated_index = 0
def initialize
@list = []
end
def output_list
p @list
puts " "
end
def add(something)
@list << something
@@index += 1
end
def self.calculation_index(value)
for i in 0..@@index
if @list.at(i) == value
@@calculated_index = i
end
end
en... |
# Model
model:
rest_name: healthcheck
resource_name: healthchecks
entity_name: HealthCheck
package: ultros
group: core/monitoring
description: |-
This API allows to retrieve a generic health state of the platform.
A return code different from 200 OK means the platform is not operational.
The hea... |
class AddTemperatureToStudents < ActiveRecord::Migration
def change
add_column :students, :temperature, :string, default: "warm"
end
end
|
class User < ActiveRecord::Base
has_many :created_pingas, class_name: "Pinga", foreign_key: :creator_id
has_many :user_pingas
has_many :pingas, through: :user_pingas
has_many :user_categories
has_many :categories, through: :user_categories
geocoded_by :ip_address
after_create :give_categories
# after_vali... |
RSpec.describe Mutant::Mutation do
class TestMutation < Mutant::Mutation
SYMBOL = 'test'.freeze
end
let(:object) { TestMutation.new(mutation_subject, Mutant::AST::Nodes::N_NIL) }
let(:context) { double('Context') }
let(:mutation_subject) do
double(
... |
require 'spec_helper'
describe Post do
before(:all) do
@user = create(:user)
@topic = create(:topic)
end
before(:each) do
@valid_attributes = {
:text => "text",
:user_id => @user.id,
:topic_id => @topic.id
}
@post = Post.new
end
it "should be valid with valid attribu... |
# Testing app setup
##################
# Database schema
##################
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Schema.define(:version => 0) do
create_table :users, :force => true do |t|
t.column "type", :string
end
create_table :posts, :force => true do |t|
t.col... |
# encoding: UTF-8
module API
module Helpers
module V1
module OthersHelpers
extend Grape::API::Helpers
POSTMON_ENDPOINT = 'http://api.postmon.com.br/v1/cep/%s'
def address_attributes_from_zipcode(zipcode)
address_attributes = zipcode_data(zipcode)
if address_a... |
class AddOtherKindToUnderGraduateDegree < ActiveRecord::Migration[5.1]
def change
add_column :under_graduate_educations, :other_kind, :string
end
end
|
class AddPictureToTestimonials < ActiveRecord::Migration
def change
add_column :refinery_testimonials, :picture_id, :integer
end
end
|
require 'spec_helper'
module LeagueOfLegends
describe Champions do
subject { Champions.instance }
before(:each) do
File.stub(:read =>
'{"data":[{"id": 1, "name":"Annie"}], "success":true}'
)
end
it "should throw exception additional instance" do
expect {
... |
#!/usr/bin/env ruby
# (c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
# Unit tests for PlanR Application Service API
require 'test/unit'
require 'plan-r/application'
require 'plan-r/application/service'
# ----------------------------------------------------------------------
class TC_ServiceApiTest < Tes... |
class Answer < ActiveRecord::Base
attr_accessible :question_id, :answers, :user_id
serialize :answers
belongs_to :question
belongs_to :user
scope :survey_answers, lambda { |survey| where(survey_id: survey.id) }
end
|
class DoneViewController < UIViewController
attr_accessor :doneLabel
def viewDidLoad
super
self.view.backgroundColor = UIColor.yellowColor
self.doneLabel = UILabel.alloc.initWithFrame(CGRectMake(0, 0, 0, 0)).tap do |label|
label.text = "Done! Look at the TV-... |
class BooksController < ApplicationController
def index
@books = if params[:term]
Book.where('title LIKE ? OR author LIKE ? OR genre LIKE ? OR classification LIKE ? OR year = ?',
"%#{params[:term]}%", "%#{params[:term]}%", "%#{params[:term]}%", "%#{params[:term]}%", "#{params[:term].to_i}")
else
... |
require 'rails_helper'
RSpec.describe Sensor, type: :model do
describe 'valdations' do
it { should validate_presence_of :min_threshold }
it { should validate_presence_of :max_threshold }
end
describe 'relationships' do
it { should belong_to :garden }
it { should have_many :garden_healths }
end... |
class Report < ApplicationRecord
has_many :comments, as: :commentable
validates :title, presence: true, uniqueness: true
validates :memo, presence: true
end
|
class AddDefaultToProjects < ActiveRecord::Migration[5.0]
def change
change_column :projects, :status, :integer, default: 0
end
end
|
require 'aws/broker/config'
require 'aws/broker/naming'
require 'aws/broker/publisher'
require 'aws/broker/subscriber'
module Aws
class Broker
class << self
def publish(*params)
Publisher.new(*params).publish
end
def subscribe(*params)
Subscriber.new(*params).subscribe
e... |
class Admin::KidsController < Admin::BaseController
before_action :set_kid, only: [:show, :edit, :update, :destroy]
def new
@kid = Kid.new()
end
def create
kid = current_user.kids.create(kid_params)
if kid.save
flash.notice = "#{kid.name} was successfully created!"
redirect_to admin_ki... |
# frozen_string_literal: true
module Kafka
module Protocol
class CreatePartitionsResponse
attr_reader :errors
def initialize(throttle_time_ms:, errors:)
@throttle_time_ms = throttle_time_ms
@errors = errors
end
def self.decode(decoder)
throttle_time_ms = decoder... |
require 'spec_helper'
describe "31524231 has_sage_flow_transitions adds boolean methods to check whether an object can enter a certain state, e.g. my_object.can_be_locked?" do
before(:each) do
class Foo < Sample
has_sage_flow_states :new, :open, :saved, :locked
has_sage_flow_transitions edit: {:new =... |
class ChangeReportToReports < ActiveRecord::Migration[5.2]
def change
rename_table :report, :reports
end
end
|
class AddColumnsToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :photo, :string
add_column :users, :address, :string
add_column :users, :phone, :string
add_column :users, :rate_cents, :integer, d... |
# frozen_string_literal: true
module AsciiPngfy
# Reponsibilities
# - Uses RenderingRules to interpret settings into a Result object
# - Uses Glyph designs to plot design data into the result png
class SettingsRenderer
def initialize(use_glyph_designs: true)
self.use_glyph_designs = use_glyph_des... |
###--------------------------------------------------------------------------###
# Fade-across Audio script #
# Version 1.0 #
# ... |
# == Schema Information
#
# Table name: diaper_drives
#
# id :bigint not null, primary key
# end_date :date
# name :string
# start_date :date
# created_at :datetime not null
# updated_at :datetime not null
# organization_id :bigint
#
class ... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :custom_master_service do
master_id 1
name "MyString"
cost 1
duration 1.5
end
end
|
#!/usr/bin/env ruby
#
require('pathname')
require('fileutils')
require('tmpdir')
# Make sure we can find where the files we're packing from
testDir = ENV["SKYUIVR_TEST_DIR"]
if not testDir then
puts "Please set a directory to package from using $SKYUIVR_TEST_DIR"
exit
end
# Make sure we have a place to put the ... |
class PigLatinizer
attr_accessor :word
# def initialize(word)
# @word = word
# end
def a_word(word)
letters = word.split("")
new_word = nil
new_letters = letters.dup
if letters[0] =~ /[aeiouAEIOU]/
letters.push("way")
new_word= lette... |
require 'fileutils'
Vagrant.configure(2) do |config|
config.vm.box = "codeguard/codeguard"
config.vm.box_url = "https://cg-meta.s3.amazonaws.com/vagrant/codeguard.box?Signature=9cyhnN1c9WkkysSKmN%2FBfSOf3aw%3D&Expires=1464209192&AWSAccessKeyId=AKIAIKWZKWD2J46TI4TQ"
# Required for NFS to work, pick any local IP
... |
module LinkedIn
class Client
module Profile
# Returns the member's LinkedIn profile.
#
# @see https://developer.linkedin.com/documents/profile-api
# @param options [Hash] A customizable set of options.
# @option options fields [Hash] A list of profile fields
# @return [Hashie:... |
require 'spec_helper'
RSpec.describe CommandHandler do
let(:image_handler) { instance_double("ImageHandler") }
subject(:command_handler) { described_class.new(input, image_handler) }
invalid_input = {
InvalidCommand => "rf",
InvalidParameters => "X J",
}
valid_input = {
Commands::Quit => "X",
... |
class NexmoNCCO
# NCCO Actions
def ncco_play_user_num(from_num)
from_string = "#{from_num[0]},#{from_num[1..3]},#{from_num[4..6]},#{from_num[7..10]}".chars.join(" ")
return [
{
"action": "talk",
"text": "Thank you, Your Number was: #{from_string}"
}
].to_json
end
def ncco_play_recording_greet... |
module Gender
extend ActiveSupport::Concern
included do
enum gender: [:male, :female, :other]
end
end |
class Privilege < ApplicationRecord
has_many :role_privileges
has_many :roles, through: :role_privileges
def create params
privilege = Privilege.create(privilege_parameters(params))
message = { message: 'Privilege created succesfully'}
return [ true, message ]
end
def update params
privilege = Privilege.find... |
require 'bundler/gem_tasks'
desc 'Default: run specs.'
task default: %i[spec rubocop doc]
require 'rspec/core/rake_task'
desc 'Run specs'
RSpec::Core::RakeTask.new
require 'yard'
desc 'Generate API docs'
YARD::Rake::YardocTask.new :doc
require 'rubocop/rake_task'
desc 'Check source code against Ruby style guide'
Ru... |
require_relative '../acceptance_helper'
feature 'create question' do
given!(:current_user) { create(:user) }
scenario 'guest tries create question' do
visit questions_path
expect(page).to_not have_selector 'Создать вопрос'
end
scenario 'user create question' do
sign_in(current_user)
visit qu... |
require 'vagrant-openstack-provider'
Vagrant.configure("2") do |config|
config.vm.box = "openstack"
config.vm.box_url = "https://github.com/ggiamarchi/vagrant-openstack/raw/master/source/dummy.box"
config.ssh.private_key_path = ENV['OS_KEYPAIR_PRIVATE_KEY']
config.ssh.shell = "bash"
config.vm.provider :op... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# The branch build configuration
#
class BranchConfiguration
# @return [Integer]
... |
require '../lib/testcase.rb'
class Parser
def parseInput
@test_cases = get_test_cases
@DEBUG=false
get_blank_line
@all_cases = Array.new
for i in 1..@test_cases
intervals = Hash.new
puts "Test case #{i}, enter m:" if @DEBUG
m = get_m
dest_interval = Interval.new(m)
... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{pagem}
s.version = "1.0.6"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Ben Young"]
s.date = %q{2011-05-02}
s.description = %q{Pagination helper that works off of ... |
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# start :datetime
# stop :datetime
# description :string
# coach_id :integer
# area_id :integer
# order_id :integer
# user_... |
class FontElsie < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/elsie"
desc "Elsie"
homepage "https://fonts.google.com/specimen/Elsie"
def install
(share/"fonts").install "Elsie-Black.ttf"
(share/"fonts").install "Elsie-Regular.t... |
# frozen_string_literal: true
require 'rails/auth/rack'
module BoltServer
class ACL < Rails::Auth::ErrorPage::Middleware
class X509Matcher
def initialize(options)
@options = options.freeze
end
def match(env)
certificate = Rails::Auth::X509::Certificate.new(env['puma.peercert']... |
class CommentNotifier < ApplicationMailer
default from: 'cpeak@psrc.org'
def send_comment_email(admin, comment)
@admin = admin
@comment = comment
mail( to: @admin.email, subject: 'New comment posted' )
end
end
|
# Model representing a hold request in a general sense.
# Refers to a hold request that has an entry in the postgres database and which has information retrievable via API.
# Can be either an NYPL hold or a partner library hold.
class HoldRequest
require 'json'
require 'net/http'
require 'uri'
# Obtains author... |
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up) do | user_params |
user_params.permit(:name, :last_name, :bio, :url, :email, :password, :... |
require 'byebug'
class Array
def my_each(&prc)
i = 0
while i < self.length
prc.call(self[i])
i += 1
end
self
end
def my_select(&prc)
selected = []
my_each { |el| selected << el if prc.call(el) }
selected
end
def my_reject(&prc)
rejected = []
my_each { |el|... |
$imported = {} if $imported.nil?
$imported["EST-RACE"] = true
=begin
==============================================================================
** EST - RACE TRAITS AND FEATURE 1.2
------------------------------------------------------------------------------
Author : ESTRIOLE
Usage Level : E... |
class DayBooking < ActiveRecord::Base
OUT_OF_LENGTH = '資料長度超過限制'
NOT_EMPTY = '不能空白'
MUST_BE_INTEGER = '必須是整數'
validates :restaurant_id, :presence => { :message => "餐廳編號," + NOT_EMPTY } ,
:length => { :maximum => 11, :message => "餐廳編號," + OUT_OF_LENGTH } ,
... |
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.5'
gem 'pg', '~> 1.0'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
g... |
require "fog/core/model"
module Fog
module Compute
class Brkt
class MachineType < Fog::Model
module Provider
AWS = 'AWS'
end
# @!group Attributes
identity :id
attribute :cpu_cores, :type => :integer
attribute :ram, :typ... |
# encoding: UTF-8
class Data_lang
attr_accessor :current_lang,
:languages,
:languages_names
#--------------------------------------------------------------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------... |
class Recommendation < ActiveRecord::Base
include PublicActivity::Model
belongs_to :user
belongs_to :restaurant
attr_accessor :wish
has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy
end
|
class CapacityError < StandardError
def initialize(message="Dock is at capacity. No more bikes can be docked")
super
end
end
|
require 'spec_helper'
require 'shanty/project'
RSpec.describe(Shanty::Project) do
include_context('with tmp shanty')
subject { described_class.new(project_path, env) }
let(:env) do
double('env').tap do |d|
allow(d).to receive(:root) { root }
end
end
let(:plugin) { double('plugin') }
let(:pl... |
# frozen_string_literal: true
require 'statement'
describe '#Statement' do
before(:each) do
@statement = Statement.new
end
it 'instantiates the class' do
expect(@statement).to be_an_instance_of Statement
end
let(:account) { BankAccount.new }
it 'prints an empty list' do
transactions = []
ex... |
# Copyright: Fewbytes Technologies LTD. 2011, 2012
# License: Apache2
module Fewbytes
module Chef
module Utils
module_function
def deprecation_warning(replacement, deprecated=caller[0][/`([^']*)'/, 1])
::Chef::Log.warn("#{deprecated} is deprecated, please use #{replacement} instead!")
... |
class CreateTagTwits < ActiveRecord::Migration
def change
create_table :tag_twits do |t|
t.references :twit, index: true
t.references :tag, index: true
t.timestamp
end
end
end
|
# frozen_string_literal: true
class Profile < ApplicationRecord
belongs_to :chef, optional: true
has_one_attached :image
with_options presence: true do
validates :image
validates :business_hour_begin
validates :business_hour_end
validates :status_id, numericality: { other_than: 1, message: "can'... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# base box
config.vm.box = "ubuntu/trusty64"
config.vm.box_version = "20171113.0.0"
# provisioning sc... |
class Prices
attr_accessor :mon_new, :price_points
def initialize(input_method)
if input_method == :auto
auto_generate_price_points
else
manual_generate_price_points
end
end
def price_points_manual
@price_points = {
:baltic => "",
... |
class Product < ActiveRecord::Base
attr_accessible :datum, :name, :user_id
belongs_to :user
has_one :product_arrangements
end
|
module MiniTest::Assertions
def assert_equal_with_message(exp, act, key)
message = "Expected: #{exp.map(&key)}\n Actual: #{act.map(&key)}"
message += "\n to_sql: #{act.to_sql}" if act.respond_to?(:to_sql)
assert_equal exp, act, message
end
end
|
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :initialize_for_layout
before_action :set_locale
def set_locale
I18n.locale = current_user.tr... |
# encoding: utf-8
require 'test_helper'
module Nls
module EndpointInterpret
class TestAny < NlsTestCommon
def setup
super
Nls.remove_all_packages
Interpretation.default_locale = "en"
Nls.package_update(create_package())
end
def create_package(expression_w... |
class Pessoa
attr_accessor :nome
attr_accessor :idade
def initialize(nome, idade)
@nome = nome
@idade = idade
end
def gritar(texto = "Grrrhhhhh!")
"Gritando... #{texto}"
end
def agradecer(texto = "Obrigado!")
texto
end
end
#######################
... |
# This migration comes from mjbook (originally 20140909192813)
class CreateMjbookProjects < ActiveRecord::Migration
def change
create_table :mjbook_projects do |t|
t.integer :company_id
t.string :ref
t.string :title
t.integer :customer_id
t.text :description
t.integer :invoicem... |
require 'spec_helper'
describe StripeEvent do
let(:event_type) { StripeEvent::TYPE_LIST.sample }
before do
StripeEvent.clear_subscribers!
end
context "subscribing" do
it "registers a subscriber" do
subscriber = StripeEvent.subscribe(event_type) { }
StripeEvent.subscribers(event_type).... |
class AddColumnDeliverySlotToOrders < ActiveRecord::Migration
def change
add_column :orders, :delivery_slot, :string
end
end
|
class Book < ApplicationRecord
validates :title, presence: true
validates :author, presence: true
validates :price, presence: true
validates :publish_date, presence: true
end
|
class BidSet
attr_accessor :bids
def initialize
@bids = []
end
def include(bid)
@bids << bid
end
def count
@bids.size
end
def total_cost
return nil unless common_currency
total = 0.0
@bids.each do |bid|
total += bid.total_cost
end
total
end
def average... |
class Service::Pragmaticly < Service
string :project_uid, :token
white_list :project_uid
def receive_push
raise_config_error "Must provide a project uid." if data['project_uid'].to_s.empty?
raise_config_error "Must provide a token." if data['token'].to_s.empty?
http.headers['Content-Type'] = 'applic... |
class User < ActiveRecord::Base
has_many :recipes
has_many :reviews
has_secure_password
validates :password, length: { in: 6..20 }
validates_presence_of :password, message: "Password cannot be blank."
validates_presence_of :username, message: "Username cannot be blank."
validates :username, length: { in: ... |
class Newsitem < ActiveRecord::Base
belongs_to :newsfeed
belongs_to :user, :class_name =>"Goldberg::User"
validates_presence_of :title, :message => "You must specify a Title"
validates_presence_of :body, :message => "Body of news cannot be blank"
end
|
# encoding: utf-8
module Rack
module Casual
# Mixin module for ActionController
module Controller
# Will send a 401 response to the user if user isn't logged in.
def authenticate!
authenticate_or_request_with_http_token unless logged_in?
end
# Returns true if user is logg... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.