text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
module Rokaki
# include this module for rokaki's filtering dsl in any object
#
module Filterable
def self.included(base)
base.extend(ClassMethods)
end
# class methods such as define_filter_keys which comprise the dsl
#
module ClassMethods
private
... |
class User < ApplicationRecord
has_many :dogs, dependent: :destroy
has_many :bookings, dependent: :destroy
belongs_to :registration
# validates :name, presence: true, on: :update
# validates :city, presence: true, on: :update
def full_name
self.first_name ? self.first_name + " " + self.last_name : "inse... |
require 'spec_helper'
require 'omniauth-linkedin-oauth2'
describe OmniAuth::Strategies::LinkedIn do
subject { OmniAuth::Strategies::LinkedIn.new(nil) }
it 'should add a camelization for itself' do
expect(OmniAuth::Utils.camelize('linkedin')).to eq('LinkedIn')
end
describe '#client' do
it 'has correct... |
class UsersController < ApplicationController
before_action :set_user, only: [:show, :update, :destroy, :seller_score, :buyer_score]
skip_before_action :get_current_user, only: [:index, :show, :create, :seller_score, :buyer_score]
def index
render_ok User.all
end
def show
render json: {
use... |
require_relative 'payments/transactions/transaction'
require_relative 'payments/transactions/supervisor'
module Charger
class Extractor
attr_reader :input, :supervisor, :transaction_supervisor, :tranformation
def initialize(input:, supervisor:)
@input = input || supervisor.class::DEFAULT_FILE
@su... |
# Problem 1
# Add a comment at the beginning of the following code describing in plain English what it does in general, then add a comment before each line explaining what that particular line does specifically.
# General Description: The fizzbuzz method checks if a number fed in as its argument is a multiple of 15,... |
class Book
def initialize(chapter_markers)
@chapter_markers = chapter_markers
end
def has_chapter?(chapter_number)
(1..chapter_count).include?(chapter_number)
end
def chapter_start_timestamp(chapter_number)
@chapter_markers[chapter_number - 1]
end
def chapter_count
@chapter_markers.siz... |
#####################################################################
# tc_security.rb
#
# Test case for the Windows::Security module.
#####################################################################
base = File.basename(Dir.pwd)
if base == 'test' || base =~ /windows-pr/
Dir.chdir '..' if base == 'test'
... |
require "fog/core/collection"
require "fog/google/models/pubsub/topic"
module Fog
module Google
class Pubsub
class Topics < Fog::Collection
model Fog::Google::Pubsub::Topic
# Lists all topics that exist on the project.
#
# @return [Array<Fog::Google::Pubsub::Topic>] list of... |
Rails.application.routes.draw do
root to: 'users#homepage'
resources :contracts
resources :request_jobs
resources :request_services
resources :services
resources :admins
resources :clients
resources :aides
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routin... |
require 'aethon'
module Aethon
class Client
attr_reader :connection
attr_reader :query_options
attr_reader :query_factory
attr_reader :result_factory
attr_accessor :logger
def initialize(connection, query_options = {}, options = {})
@connection = connection
@query_options =... |
class ServicosController < ApplicationController
before_action :authorize
before_action :set_servico, only: [:show, :edit, :update, :destroy]
# GET /servicos
# GET /servicos.json
def index
@unidade = Unidade.all
@tipo_servicos = TipoServico.all
@filterrific = initialize_filterrific(
Ser... |
require 'pp'
class MatlabCalibration
def initialize
@params = Hash.new
end
def read( file_name )
File.open( file_name, 'r' ) do |f|
while (line = f.gets)
if line.respond_to?(:force_encoding)
line.force_encoding "iso8859-1"
end
if line =~ /(\w+) = \[([^... |
def zip(*arrays)
length = arrays.first.length
(0...length).map do |i|
arrays.map { |array| array[i] }
end
end
def prizz_proc(arr, prc_1, prc_2)
arr.select { |ele| (prc_1.call(ele) || prc_2.call(ele)) && !(prc_1.call(ele) && prc_2.call(ele)) }
end
def zany_zip(*arrays)
current_length = 0
... |
######################### Cool numbers #########################
def cool_numbers(n)
ordinal = case n % 100
when 11, 12, 13 then n.to_s + 'th'
else
case n % 10
when 1 then n.to_s + 'st'
when 2 then n.to_s + 'nd'
when 3 then n.to_s + 'rd'
... |
require 'orocos/remote_processes/loader'
module Orocos
module RemoteProcesses
# Client-side API to a {Server} instance
#
# Process servers allow to start/stop and monitor processes on remote
# machines. Instances of this class provides access to remote process
# servers.
class Client
... |
class RenameTablePurchaseOldPurchase < ActiveRecord::Migration
def change
rename_table :purchases, :old_purchases
end
end
|
#! /usr/bin/env ruby
TOML_LINK_REGEX = /^(?<direction>(to|from)).*?["'](?<link>.*?)["']/
def fatal(message)
puts "FATAL! #{message}"
exit -1
end
def warning(message)
puts "WARNING: #{message}"
end
def configure
# defaults
input = 'netlify.toml'
output = 'netlify-redirects.html'
subdomain = 'c66-help-dev.netl... |
class FloofsController < ApplicationController
def index
@floofs = Floof.all
render :index
end
def show
@floof = Floof.find(params[:id])
render :show
end
def new
@floof = Floof.new
render :new
end
def create
@floof = Floof.new(fl... |
class AddColumnEntityIdToWorks < ActiveRecord::Migration
def change
add_column :works, :entity_id, :integer
end
end
|
# frozen_string_literal: true
require 'action_dispatch'
require 'rails/engine'
require 'citizens_advice_components'
# We have a bug somewhere between bridgetown and citizens_advice_components which
# prevents haml from being seen as a tempalte handler. A simple workaround is to
# manually re-register the handler.
req... |
# frozen_string_literal: true
class AttendanceRepository
include Singleton
def search_for_list(event, text, user_disability, statuses)
statuses_keys = statuses.map { |status| Attendance.statuses[status] }
attendances = event.attendances.joins(:user).where(status: statuses_keys).where('((users.first_name I... |
require 'rails_helper'
describe Trip, type: :model do
describe 'validations' do
it {should validate_presence_of(:bike_id)}
it {should validate_presence_of(:subscription_type)}
it {should validate_presence_of(:duration)}
it {should validate_presence_of(:zip_code)}
it {should validate_presence_of(:... |
class UrlsController < ApplicationController
def index
@urls = Url.all
end
def new
@url = Url.new
end
def create
# @url = Url.new(params[:url])
if params[:url][:short_url] == ""
@url = Url.new(:original_url => params[:url][:original_url],
:short_url => short... |
module Line
module Api
module Endpoint
module AccessToken
# @see https://developers.line.me/web-login/integrating-web-login#obtain_access_token
def retrieve_access_token(oauth_code)
res = build_connection(:content_type => :url_encoded).post do |req|
req.url('oauth/acce... |
require "rspec/formatter/beep/version"
require "rspec/core/formatters/progress_formatter"
module RSpec
module Formatter
class Beep < RSpec::Core::Formatters::ProgressFormatter
def example_failed(example)
super(example)
output.print "\a"
sleep 1
end
end
end
end
|
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'state'
describe BoardTraversal do
context "starting with the solved state" do
before :each do
@board = mock("a game board")
@board.stub!(:moves).and_return([:left,:up])
@board_traversal = BoardT... |
require('rspec')
require('word')
describe('Word') do
before() do
Word.clear()
end
describe(".clear") do
it "returns an empty array" do
test_word = Word.new({:word=>"ocean"})
test_word.save()
Word.clear()
expect(Word.all()).to(eq([]))
end
end
describe(".all") do
it "r... |
class RaidsController < ApplicationController
filter_resource_access
before_filter :setup_raidicons, :only => [:edit, :new]
before_filter :setup_guild_id
layout :choose_layout
# GET /raids
# GET /raids.xml
def index
params[:sort] = 'guild_id, start' if params[:sort].nil?
@guild = Gui... |
class GuiElement
attr_accessor :x,:y, :sx, :sy
attr_accessor :shown, :focussed
attr_accessor :children, :parent, :selected
def initialize
# maybe good defaults; if not, inheriting classes
# can set this after after "super()"
margin = 1/0x80
@sx, @sy = 1-2*margin, 1-2*margin
center
# stat... |
class CreateWorkOrders < ActiveRecord::Migration
def change
create_table :work_orders do |t|
t.string :code
t.string :title
t.string :description
t.references :user, index: true
t.integer :user_assigned_id, index: true
t.references :organization, index: true
t.integer :or... |
# Ruby 2.6.5
require 'date'
class VehicleType
VALID_YEARS = 1900..(Date.today.year+2)
VALID_MAKES = {
'Ford' => %w(ford fo),
'Chevrolet' => %w(chevrolet chev)
}.inject({}) do |make_options,(key,values)|
values.each { |value| make_options[value] = key }
make_options
end.freeze
VALID_MODELS =... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :phone do
number { rand(10**9..10**10) }
association :phoneable, factory: :consultant
phone_type
primary false
end
end
|
class Author < ApplicationRecord
has_many :quotes
has_many :themes, through: :quotes
validates :name, presence: true
end
|
class Notice < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notice.create_user.subject
#
def create_user user_id
@user = User.find_by_id user_id
mail to: "ditimmottinhyeu.nd@gmail.com", subject: "having new member for app"
... |
require 'json'
module Lita
module Handlers
class Yurudev < Handler
def self.default_config(handler_config)
handler_config.kina_endpoint = ENV['KINA_ENDPOINT']
handler_config.kina_uuid = ENV['KINA_UUID']
end
route /^devroom users/, :devroom_users, command: false, help: { 'de... |
class CreateChatMessages < ActiveRecord::Migration
def change
create_table :chat_messages do |t|
t.text :body
t.text :meta
t.boolean :game_master
t.integer :character_id
t.integer :campaign_id
t.timestamps
end
end
end
|
# = UserSessionController
# controlling login.
class UserSessionsController < ApplicationController
skip_filter :checks_authenticated
# GET user_sessions
# displaying the login page.
def new
@user_session = UserSession.new
end
# POST user_sessions
# Completion of login.
def create
@user_sess... |
class Api::V1::UsersController < ActionController::API
def create
user = User.new(user_params)
if user.save
user_setup(user)
render json: UserSerializer.new(user).serialized_json
else
render status: 400, json: {message: "Invalid request"}
end
end
private
def user_params
... |
before_everything do
# Setup default test_framework settings
gsub_file "config/initializers/generators.rb", /test_framework.*\n/, "test_framework = :test_unit, :fixture => true\n"
end
__END__
name: Test::Unit
description: "Utilize the default Rails test facilities."
author: mbleigh
exclusive: unit_testing
categ... |
module CustomersHelper
def instant_booking_title(user)
if user.user_profile.present?
"#{user.user_profile.company_name} Instant Booking!"
else
"Instant Booking!"
end
end
end
|
require 'spec_helper'
describe UsersController do
describe "routing" do
before do
@id = SecureRandom.random_number(1e4.to_i)
end
context "when valid" do
it ":get '/users/:id' should route to users#show" do
{ get: "/users/#{@id}" }.should route_to("users#show", id: "#{@id}")
... |
#!/bin/ruby
# Kyle Jorgensen, 16 Feb 2018
# From https://www.hackerrank.com/contests/hourrank-26/challenges/cloudy-day
# Return the maximum number of people that will be in a sunny town after removing exactly one cloud.
def maximum_people(p, x, y, r)
population = p.reduce(0,:+)
# find the towns which have clouds ... |
require 'spec_helper'
require 'natives/catalog/normalizer'
describe "Catalog Normalizer" do
let(:normalizer) { Natives::Catalog::Normalizer.new }
context "Given valid hash input" do
it "converts package provider, platform, platform version to string" do
hash = normalizer.normalize({
:macports =>... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{icehouse-right_aws}
s.version = "2.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? ... |
require 'rails_helper'
RSpec.describe Coupon do
describe 'Relationships' do
it {should have_many :orders}
it {should belong_to :merchant}
end
describe 'validations' do
it {should validate_presence_of :name}
it {should validate_presence_of :code}
it {should validate_inclusion_of(:percent_off)... |
class PeoplesController < ApplicationController
before_action :view_people, only: %i[ show ]
def index
@props = {
component_name: 'peoples'
}
end
def show
@props = {
component_name: 'show_people',
component_data: [@people]
}
end
... |
class ChangeColumnName < ActiveRecord::Migration[5.2]
def change
rename_column :appointments, :careserves_id, :careservice_id
end
end
|
require 'test_helper'
class RegistrationsControllerTest < ActionDispatch::IntegrationTest
test 'should get new' do
get new_user_registration_path
assert_response :success
# assert_not_nil assigns(:user).profile
end
test 'should create user' do
post user_registration_path, params: { user: { email... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "social_pusher/version"
Gem::Specification.new do |s|
s.name = "social_pusher"
s.version = SocialPusher::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Alexander Simonov"]
s.email = ["alex@simonov.m... |
require "rails_helper"
RSpec.describe "trials/site_contact" do
context "contact is displayable" do
it "displays contact" do
site = SitePresenter.new(build(:site))
allow(site).to receive(:contact_displayable?).and_return(true)
render "trials/site_contact", site: site
expect(page).to have... |
FactoryBot.define do
factory :location do
street Faker::Address.street_name
city Faker::Address.city
state Faker::Address.state
zip_code Faker::Address.zip_code
country Faker::Address.country
phone_number Faker::PhoneNumber.phone_number
email Faker::Internet.email
end
end |
#!/usr/bin/ruby
# given array of names, print something like below
=begin
You got 5 names in the 'names' array
The name is 'Michael Choi'
The name is 'John Supsupin'
The name is 'KB Tonel'
...
=end
a = {:first_name => "Michael", :last_name => "Choi"}
b = {:first_name => "John", :last_name => "Supsupin"}
c = {:first_n... |
class Shift < ActiveRecord::Base
validates :day, presence: true
validates :start, presence: true
validates :end, presence: true
validates :day, uniqueness: true
end
|
class ChangeMbtiCreationUsers < ActiveRecord::Migration[5.2]
def change
remove_column :users, :mbti_creation, :string
add_reference :users, :profile_mbti, foreign_key: true
end
end
|
# frozen_string_literal: true
require 'test_helper'
class SchoolsTest < ActionController::TestCase
setup do
@school = schools(:school_one)
end
test 'index' do
assert_routing '/admin/schools', controller: 'admin/schools', action: 'index'
end
test 'show' do
assert_routing "/admin/schools/#{@sch... |
class AddQuestionChoicesColumnToMemoryCard < ActiveRecord::Migration
def change
add_column :memory_cards, :question_choices, :string
end
end
|
ActiveAdmin.register AdminUser do
menu label: "ユーザー管理", priority: 10
permit_params :email, :password, :password_confirmation
controller do
def create
create! do |success,failure|
success.html do
redirect_to(admin_admin_users_path)
end
end
end
end
index do
id... |
require "muffinlib/version"
require "muffinlib/api_getter"
module Muffinlib
# API Constants
GET_RECENT_GAMES_BY_ID = "/api/lol/{region}/v1.3/game/by-summoner/{summonerId}/recent"
GET_LEAGUE_BY_IDS = "/api/lol/{region}/v2.5/league/by-summoner/{summonerIds}"
GET_LEAGUE_ENTRY_BY_IDS = "/api/lol/{region}/v2.5/le... |
require "typhoeus"
require "openssl"
module Riskified
class Request
SANDBOX_URL = "https://sandbox.riskified.com".freeze
ASYNC_LIVE_URL = "https://wh.riskified.com".freeze
SYNC_LIVE_URL = "https://wh-sync.riskified.com".freeze
CONNECTION_TIMEOUT = 5
RESPONSE_TIMEOUT = 5
def initialize(resou... |
namespace :sql_data do
desc "Load data from sql file."
task load: :environment do
fail 'SQL file not found' unless File.exist?('db/import.sql')
#unless Rails.env.production?
connection = ActiveRecord::Base.connection
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
state... |
require 'formula'
class PythonBackportsSslMatchHostname < Formula
homepage 'https://pypi.python.org/pypi/backports.ssl_match_hostname'
url 'https://pypi.python.org/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-3.4.0.2.tar.gz'
sha1 'da4e41f3b110279d2382df47ac1e4f10c63cf954'
head 'h... |
class Film < ActiveRecord::Base
attr_accessible :title, :poster
has_many :showings
mount_uploader :poster, ImageUploader
end
|
class Host < ActiveRecord::Base
include NormalizeNames
has_many :all_deployed_services, :class_name => 'DeployedService', :foreign_key => 'host_id'
has_many :all_deployments, :class_name => 'Deployment', :through => :all_deployed_services, :source => 'deployment', :uniq => true
validates_presence_of :name... |
require 'rails_helper'
RSpec.describe Attendance, type: :model do
subject do
described_class.new(
invited_user_id: ''
)
end
describe 'Validations' do
it 'is not valid without valid attributes' do
expect(subject).to_not be_valid
end
end
describe 'Associations' do
it { should ... |
FactoryGirl.define do
factory :course do
association :user
association :category
sequence(:lesson) { |n| "lesson#{n}" }
sequence(:category_id) { |n| n }
end
end
|
require 'rails_helper'
RSpec.describe ExtractsController, type: :controller do
before { fake_session admin: true }
let(:extractor) { build(:external_extractor, key: 'ext') }
let(:workflow) { create(:workflow, extractors: [extractor]) }
describe "GET #index" do
it "returns http success" do
get :inde... |
# frozen_string_literal: true
task :mas => [:'brew:casks_and_formulae'] do
begin
capture 'mas', 'account'
rescue NonZeroExit
raise 'Not signed in into App Store.' unless ci?
end
APPS = {
'824171161' => 'Affinity Designer',
'824183456' => 'Affinity Photo',
'608292802' => 'Auction Sniper for... |
#
# Cookbook Name:: cubrid
# Attributes:: broker
#
# Copyright 2012, Esen Sagynov <kadishmal@gmail.com>
#
# Distributed under MIT license
#
# Default number of brokers to start.
default['cubrid']['broker_count'] = 1
default['cubrid']['min_num_appl_server'] = 5
default['cubrid']['max_num_appl_server'] = 40
default['cub... |
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 :set_order_items
def set_order_items
order_id = session[:order_id]
if order_id
order = O... |
class PapersController < ApplicationController
before_action :check_activity_valid_for_submit?, only: [:new, :create]
before_action :current_activity, if: lambda{params.has_key?(:activity_id)}
before_action :authenticate_user!
# before_action :require_current_user, only: [:show,:edit]
load_and_authorize_resou... |
class CreateAsteroids < ActiveRecord::Migration[6.0]
def change
create_table :asteroids do |t|
t.integer :hp
t.integer :size
t.column :rock, 'blob'
t.integer :rock_x
t.integer :rock_y
t.boolean :reached_end
t.boolean :collided
t.timestamps
end
end
end
|
module EasyPatch
module JournalsControllerPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
helper :easy_query
include EasyQueryHelper
cache_sweeper :journal_sweeper, :only => [:edit]
alias_method_chain :find_journal, :easy_exten... |
class User < ActiveRecord::Base
has_many :concerts, through: :reviews
has_many :reviews
validates :email, presence: true, uniqueness: true
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerabl... |
# encoding: utf-8
# https://github.com/intridea/omniauth/wiki/Integration-Testing
def mock_fb_testmode()
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
:provider => 'facebook',
:uid => '123545',
:info => {
:name => 'Testing Facebook User'
},... |
class AddBannerToBroProduct < ActiveRecord::Migration
def change
add_column :bro_products, :banner, :string
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end
rescue_from ActiveRecord::RecordNotFound do |exception|
redirect_to home_error_404_path
end
rescue_from ... |
class CurrentCartsController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
rescue_from ActiveRecord::RecordInvalid, with: :render_unprocessable_entity_response
def index
current_carts = CurrentCart.all
render json: current_carts
end
... |
include_recipe 'vayacondios::default'
standard_dirs 'vayacondios.client' do
directories :conf_dir
end
vayacondios = discover(:vayacondios, :server)
Chef::Log.warn "This is the vayacondios you have discovered: #{vayacondios ? vayacondios.private_ip : nil}"
Chef::Log.warn("No Vayacondios organization is set for thi... |
require 'test_helper'
class Buyers::ApplicationsControllerTest < ActionController::TestCase
include WebHookTestHelpers
setup do
@plan = FactoryBot.create(:published_plan)
@service = @plan.service
@provider = @plan.service.account
login_as(@provider.admins.first)
host! @provider.self_domain
e... |
require 'test_helper'
class GameScraperTest < ActiveSupport::TestCase
test "::new should accept no arguments" do
GameScraper.new
end
test "::new should accept a parser object" do
parser = ParserFake.new("regular_season_in_past")
GameScraper.new(parser: parser)
end
test "#url should set date an... |
class User < ApplicationRecord
before_save{self.email = email.downcase}
validates :name,presence: true,length:{maximum:50}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :email,presence: true,length:{maximum:255},
format:{with:VALID_EMAIL_REGEX},
uniquen... |
module Plugins
# Overwrite: package
def self.package
scripts = $TracerCode ? "begin\n" : ""
end_line = 0
@@scripts.each do |s|
begin
code = File.open(s).read + "\n"
scripts += code
line_count = code.count(10.chr)
end_line += line_count
start_line = end... |
require 'test_helper'
class MateriaCarrerasControllerTest < ActionController::TestCase
setup do
@materia_carrera = materia_carreras(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:materia_carreras)
end
test "should get new" do
get :new
... |
gem 'minitest'
require './lib/game_board'
require 'minitest/autorun'
require 'minitest/pride'
require './lib/two_unit_ship'
require './lib/three_unit_ship'
require './lib/game_runner'
require 'pry'
class GameRunnerTest < Minitest::Test
def setup
@game = GameRunner.new
end
def test_it_exists
assert_insta... |
# frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::SyncProductsService do
let(:service) { described_class.new }
describe '#call' do
subject(:call) do
service.call
end
let(:product) { Stripe::Product.construct_from(name: 'Management', id: 'prod_Cmpsds2X8lxkG0') }
let(:products... |
# name: discourse-german-formal-locale
# about: Adds a new locale for formal German
# version: 0.1
# authors: Gerhard Schlager
# url: https://github.com/gschlager/discourse-german-formal-locale
register_locale("de_formal", name: "German (formal)", nativeName: "Deutsch (Sie)", fallbackLocale: "de")
|
brew "fish"
execute "Add fish to /etc/shells" do
command "echo '/usr/local/bin/fish' | sudo tee -a /etc/shells"
not_if "grep -q fish /etc/shells"
end
execute "Set fish as default shell" do
command "sudo chsh -s /usr/local/bin/fish #{node['current_user']}"
only_if "grep -q fish /etc/shells"
end
|
module EasyPatch
module AccountControllerPatch
def self.included(base)
base.class_eval do
helper :attachments
include AttachmentsHelper
accept_api_auth :autologin
before_filter :resolve_layout, :except => [:get_avatar]
def autologin
if Setting.rest_api... |
class AddComuneIdToConsultation < ActiveRecord::Migration
def change
add_column :consultations, :comune_id, :integer
end
end
|
class CreateCoupons < ActiveRecord::Migration[6.0]
def up
create_table :coupons do |t|
t.string :code
t.float :value
t.integer :kind
t.references :purchase
t.timestamps
end
end
def down
drop_table :coupons
end
end
|
#
# Cookbook Name:: monit-ng
# Recipe:: repo
#
# Monit is not in the default repositories
include_recipe 'yum-epel' if platform_family?('rhel') && !platform?('amazon')
include_recipe 'apt' if platform_family?('debian')
include_recipe 'ubuntu' if platform?('ubuntu')
package 'monit'
|
class Platform::PrintersController < Platform::BaseController
# before_filter :get_store
load_and_authorize_resource :store
load_and_authorize_resource through: :store
def index
@printers = @store.printers
end
def create
@printer = end_of_association_chain.new(printer_params)
create! do |succ... |
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by the Rails when you ran the scaffold generator.
describe MediasController do
def mock_media(stubs={})
@mock_media |... |
FactoryGirl.define do
factory :user do
sequence(:username) { |n| "Test user#{n}" }
sequence(:password) { |n| "T1010#{n}" }
sequence(:email) { |m| "john.doe#{m-1}@example.com" }
trait :authorized do
auth_token { SecureRandom.hex }
token_created_at { Time.zone.now + 2.minutes }
end
... |
class Optional
class Some
def initialize(obj)
@obj = obj
end
def get
@obj
end
def none?
false
end
end
class None
def none?
true
end
end
def self.none
None.new
end
def self.some(obj)
Some.new(obj)
end
end
|
#!/usr/bin/env ruby
require 'prime'
class Pell
attr_accessor :x, :y, :d
def initialize(x, y, d)
@x = x
@y = y
@d = d
end
def *(other)
return Pell.new(@x*other.y+@y*other.x,
@d*@x*other.x+@y*other.y,
@d)
end
def **(n)
p = Pell.new(0,1,@d)
... |
source 'https://rubygems.org'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
#gem 'sqlite3' removed this for the production
# And added this for the production
group :development, :test do
gem 'sqlite3'
end
## Pg
ruby '2.3.0'
#gem 'puma'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'c... |
class WorksheetBuilder
def initialize
end
def build(params)
@current_worksheet = Worksheet.new
@problems_to_add = []
begin
params.each_pair do |key, value|
key.to_s == "problem_levels_info" ? find_problems_from_specs_for_current_worksheet!(value) : @current_worksheet.send("#{key}="... |
require "test_helper"
require "pry"
describe UsersController do
describe "create" do
it "logs in and creates a new user with good data" do
user = User.new(provider: "github", uid: 122, username: "brand_new", email: "test@test.com")
perform_login(user)
expect(User.count).must_equal 3
mus... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.