text stringlengths 10 2.61M |
|---|
require 'spec_helper'
describe ActiveStrategy::Strategy do
let(:dummy_strategy) do
Class.new do
include ActiveStrategy::Strategy
attr_reader :dummy
end
end
describe '.new' do
subject(:strategy) { dummy_strategy.new(:dummy => true) }
it 'assigned dummy' do
strategy.dummy.shoul... |
class Help
attr_accessor :name, :desc, :usage, :tag
def initialize(name, desc, usage, tag)
@name = name
@desc = desc
@usage = usage
@tag = tag
end
end
|
require 'sinatra/base'
class App < Sinatra::Base
get '/newteam' do
# render the form that collects the data
erb :newteam
end
# get '/team' do
# # don't need a get route this time but useful to display params
# erb :newteam
# end
# form is sending the data to here:
post '/team' do
# pas... |
require 'spec_helper'
module Walkon
describe HciTool do
let :results do
[
'Scanning...',
'00:A1:5D:AB:B2:E9 iPhone5'
]
end
before do
allow(subject).to receive(:scan_results).and_return results
end
it "starts with no results" do
expect(subject.results).to ... |
class ExtendBusinessConnections < ActiveRecord::Migration
def change
add_column :business_connections, :initiator_id, :integer
add_column :business_connections, :response_at, :datetime
add_column :business_connections, :viewed_at, :datetime
add_column :business_connections, :message, :text
end
end
|
class CreateCommissions < ActiveRecord::Migration
def change
create_table :commissions do |t|
t.string :commission_no
t.integer :charge_id
t.integer :user_id
t.decimal :bonus_reference
t.decimal :bonus
t.integer :approver_id
t.integer :financer_id
t.string :workflow... |
# frozen_string_literal: true
class MessagesController < ApplicationController
before_action :find_conversation
def create
message = current_user.messages.build(message_params)
message.conversation_id = @conversation.id
message.save!
respond_to do |format|
format.html { redirect_to @conversa... |
class Item < ActiveRecord::Base
belongs_to :list
validates :name, presence: true
def days_left
# This original calculation was wrong.
#(DateTime.now.to_date - created_at.to_date).to_i
((created_at.to_date + 7.days)-DateTime.now.to_date).to_i
end
end
|
class SwimWorkout < Workout
belongs_to :user
validates_numericality_of :distance
def calswimpace
pace = ((self.getworkouttotalminutes.to_f) / ( self.distance.to_f / 100.to_f )).round(2)
end
end |
#encoding:utf-8
module Deepspace
class Loot
attr_reader :nSupplies, :nWeapons, :nShields, :nHangars, :nMedals
def initialize(nSupplies, nWeapons, nShields, nHangars,nMedals)
@nSupplies = nSupplies
@nWeapons = nWeapons
@nShields = nShields
@nHangars = nHangars
@nMedals = nMedals
end
... |
module IdeasHelper
def author_link(name)
user = User.find_by_user_name(name)
if user
link_to name, user_path(user)
else
name
end
end
def author_nick(idea)
idea.author ? idea.author.user_name : idea.author_name
end
def status_indicator(status)
case (status.downcase)
... |
# p018arrays.rb
# Arrays
# Array vazio
var1 = []
# Índice do array inicia em 0
puts var1[0]
puts "================================================================================================="
# Um array armazenando apenas um número
var2 = [5]
puts var2[0]
puts "===================================================... |
#def my_each(array) # put argument(s) here
# # code here
# i =0
# while i < array.length
# yield array[i]
# i = i+1
# end
# array
#end
def my_collect(array)
modified_array = []
i=0
while i <array.length
modified_array.push(yield array[i])
i = i+1
end
modified_array
end
|
require 'rails_helper'
RSpec.describe 'Test to verify if the users opinions' do
before :each do
create_data
end
feature 'User can see other users opinions if he followed the other user' do
scenario 'sign in and go to opinion index' do
visit '/users/sign_in'
fill_in 'Email', with: 'test1@test.... |
module Spree
class Tag < ActiveRecord::Base
has_many :taggings, inverse_of: :tag, dependent: :destroy
has_many :posts, through: :taggings, order: 'published_at DESC'
validates :name, :permalink, presence: true
validates :name, :permalink, uniqueness: { case_sensitive: false }
make_permalink orde... |
class Stock < ActiveRecord::Base
def self.find_stocks_quotes
find(:all, :order => "company_name")
end
validates_presence_of :stck_symbol, :pe, :company_name
validates_numericality_of :price
attr_reader :stck_symbol, :company_name, :price, :pe
attr_writer :price, :pe
def output_stock(stck_symbol)
... |
require 'rails_helper'
RSpec.describe MushroomFeature, type: :model do
it "should not have digits in it's name or scientific name" do
expect(MushroomFeature.new(name: 'magicmushroms')).to be_valid
expect(NumberConversion.new(name: 'magicmushroom8')).to be_invalid
end
|
class Users::Update
include Interactor
delegate :user, :params, to: :context
def call
context.fail! unless user.update(params)
end
end
|
class ItemsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :correct_user, only: [:edit, :update, :destroy]
before_action :set_category, only: [:new, :edit]
before_action :set_item, only: [:show, :edit, :update, :destroy, :purchase, :buy]
before_actio... |
require 'rails_helper'
feature 'Comment Destroy action' do
given(:admin) { create(:user, admin: true) }
given(:user) { create(:user) }
given(:wrong_user) { create(:user) }
given!(:category) { create(:category) }
given!(:post) { create(:post, category: category, user: user) }
given!(:comment) { create(:comm... |
# PHASE I
def my_min(list) # time complexity = O(n)
min_num = list.first
(1...list.length).each do |i|
if min_num > list[i]
min_num = list[i]
end
end
min_num
end
# p my_min([0,3,5,4,-5,10,1,90])
# PHASE 2
def my_min(list) # time complexity = O(n)
min = list.min
end
# p my_min([0,3,... |
# frozen_string_literal: true
module ActiveAny
module Associations
class AssociationScope
def self.scope(association)
INSTANCE.scope(association)
end
def self.create
new
end
INSTANCE = create
def scope(association)
klass = association.klass
r... |
module BuildSpecRunner
# Module for defining objects that provide project sources.
#
# @todo Make a GitSourceProvider implmentation, for referencing
# projects by Git repo.
#
# See {SourceProvider::FolderSourceProvider} for the only implementation so far.
module SourceProvider
# A {SourceProvider... |
class AddStandardCategoriesToUsers < ActiveRecord::Migration[5.1]
def change
default_categories =
%w[Transportation Food House Entertainment Health Other]
User.find_each do |user|
default_categories.each do |category|
user.sub_categories.create(name: category, user: user)
end
en... |
class CreateParticipants < ActiveRecord::Migration[5.2]
def change
create_table :participants do |t|
t.references :schedule, foreign_key: true
t.references :member, foreign_key: true
t.string :mark ,limit:5
t.string :comment
t.timestamps
end
end
end
|
require 'redcarpet'
require 'redcarpet/render_strip'
module ApplicationHelper
def current_user
nil
end
def is_admin
current_user && current_user.email == '875156226@qq.com'
end
def markdown_to_html(markdown_str)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, hard_wrap: true, autoli... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Room, type: :model do
let(:user) { create(:user) }
let(:room) { create(:room) }
it 'room を作成できる' do
expect(room).to be_valid
end
context '多対多の関係' do
before do
@messages = create_list(:message, 3, room: room, user: user)
... |
class Service < ActiveRecord::Base
include SparcShard
belongs_to :organization
has_many :line_items
has_many :pricing_maps
has_many :pricing_setups, through: :organization
has_many :procedures
default_scope { order(name: :asc) }
scope :per_participant, -> { where(one_time_fee: false) }
scope :on... |
class AddApprovalStatusToAllTables < ActiveRecord::Migration[4.2]
def change
add_column :corals, :approval_status, :string
add_column :traits, :approval_status, :string
add_column :locations, :approval_status, :string
add_column :standards, :approval_status, :string
add_column :resources, :approval_sta... |
class AddInfoToOrder < ActiveRecord::Migration
def change
add_column :orders, :address, :string
add_column :orders, :buyer_id, :integer
add_column :orders, :status, :string
end
end
|
# frozen_string_literal: true
module Kafkat
class CLI
attr_reader :config
MERGEABLE_ARGS = [:zk_path, :log_path, :kafka_path].freeze
def self.run!(args)
new.run(args)
end
def run(args)
Command.load!
# Get the category
category_name = args.first
# Get the subcomma... |
class BusinessQuery
attr_accessor :params
def initialize(query_params)
query_params = query_params.to_hash.symbolize_keys
self.params = query_params.extract!(
:name,
:phone,
:email,
:twitter,
:facebook,
:website,
:owner,
:address1,
:address2,
:c... |
require 'open3'
module CommandLineOutputHelper
def output_of_command(cmd, options={})
# because `nginx` seems to work well for most CLI output!
language = options[:language] || options[:lang] || 'nginx'
code(language) do
stdout_and_stderr_of(cmd, options)
end
end
def stdout_and... |
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
private
def devise_parameter_sanitizer
if resource_class == School
School::ParameterSanitizer.new(School... |
class Reply < ApplicationRecord
belongs_to :comment, counter_cache: true
belongs_to :sender, class_name: 'User', counter_cache: true
has_many :reacted_on, class_name: 'Reaction', foreign_key: "reacted_on_id", dependent: :destroy
validates :reply, length: { minimum: 3, maximum: 250 }, presence: true
after_co... |
# Write a method that takes an Array of numbers and then returns the sum of
# the sums of each leading subsequence for that Array. You may assume that the
# Array always contains at least one number.
# LS Solution:
# def sum_of_sums(numbers)
# sum_total = 0
# 1.upto(numbers.size) do |count|
# sum_total += num... |
Rails.application.routes.draw do
get '/get_session', to: 'checkout#get_session'
get 'usuarios_administrador/index'
get 'login/sigin'
get 'login/cadastrar'
get '/login', to: 'login#login'
get '/login_pagamento', to: 'login#login_pagamento'
post 'logar', to: 'login#logar'
get '/logout', to: 'login#logout'... |
class BookInStock
attr_accessor :price,:isbn
def initialize(a, b)
@isbn = a
@price = Float(b)
end
def price_in_cents
Integer(price*100 + 0.5)
end
end
book = BookInStock.new("isbn", 12.34)
puts "ISBN= #{book.isbn}"
puts "Price = #{book.price1}"
book.price = book.price*5
puts "#{book... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'singleton'
module TwitterCldr
module Shared
class DayPeriods
class Timestamp
include Comparable
attr_reader :hour, :min, :sec
def initialize(hour, min, sec)
@hour = h... |
puts 'Loading Schema...'
class Schema < ActiveRecord::Migration
def change
create_table :libraries do |t|
t.string :name
t.string :tag_name
t.string :license
t.string :homepage
t.string :language
t.string :github_user
t.string :github_repo
t.integer :github_id
t.boolean :not_found
t.timestamp... |
module Datapathy::Model
module Links
extend ActiveSupport::Concern
module ClassMethods
def links
@links ||= []
end
def links_to(name, options = {})
define_link_to :single, name, options
end
def links_to_collection(name, options = {})
define_link_to :c... |
class Student < ApplicationRecord
has_and_belongs_to_many :courses
has_many :topics
has_many :posts
end
|
class CreateRailways < ActiveRecord::Migration
def change
create_table :railways do |t|
t.string :board_name
t.string :post_name
t.string :qualification
t.string :last_date
t.string :more
t.timestamps
end
end
end
|
module Reuters
module Namespaces
# Represents namespaces used by Reuters in their internal API for
# managing Access Tokens that are granted when valid credentials
# are used to authenticate.
module Token
# @!parse include Base
include Base
# Year for the TokenManagement endpoint.... |
class CommerceProduct < ActiveRecord::Base
self.table_name = "commerce_Products"
self.primary_key = "ProductId"
has_many :commerce_product_attributes, :foreign_key => "ProductId"
has_many :commerce_categories, :foreign_key => "CategoryId"
end
|
# -*- mode: ruby -*-
github = 'https://github.com/xord'
renames = {reflexion: 'reflex'}
regexp = /add\w+dependency.*['"](\w+)['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/
repos = File.readlines('rubysketch.gemspec', chomp: true)
.map {|s| regexp.match(s)&.values_at 1, 2}
.compact
.to_h
.transform_keys {|name| renam... |
class TrainingSession < ActiveRecord::Base
include TrainingSessionScopes
enum run_type: { easy: 'easy', interval: 'interval', long_run: 'long_run',
tempo_run: 'tempo_run', fartlek: 'fartlek', race: 'race' }
enum time_of_day: { AM: 'AM', PM: 'PM' }
validates :run_type, presence: true
vali... |
require "test_helper"
class AvatarsControllerTest < ActionDispatch::IntegrationTest
setup do
@avatar = avatars(:one)
end
test "should get index" do
get avatars_url, as: :json
assert_response :success
end
test "should create avatar" do
assert_difference('Avatar.count') do
post avatars_... |
class ContactsController < ApplicationController
def index
@contacts = current_user.contacts.paginate(page: params[:page], per_page: 10)
end
def import
@errors = Contact.import(params[:file], current_user.id)
@contacts = current_user.contacts.paginate(page: params[:page], per_page: 10)
if @errors... |
class Submission < ActiveRecord::Base
validates_presence_of :first_phrase, :second_phrase, :third_phrase
end
|
Sequel.migration do
up do
create_table(:access_tokens) do
primary_key :id
String :access_token, :null => false
String :refresh_token, :null => false
DateTime :valid_until
foreign_key :user_id, :users
end
end
down do
drop_table(:access_tokens)
end
end |
module Sword
module Endpoints
class MetsToHyacinthEndpoint < Endpoint
# Some of these can be removed if no need for external access,
# though in that case specs may need to be updated to access
# instance var directly instead of through attr_reader
attr_reader :content_dir
attr_read... |
require 'spec_helper'
describe 'puppetmaster::common' do
extra_facts = { ipv4_lo_addrs: '127.0.0.1',
ipv6_lo_addrs: '::1',
ipv4_pri_addrs: '10.50.0.1',
ipv6_pri_addrs: '::1' }
let(:node) { 'puppet.example.org' }
let(:params) do
{
primary_names: ['p... |
# This mixin defines ActiveRecord style associations (like has_many) for ActiveResource objects.
# ActiveResource objects using this mixin must define the method 'query_params'.
module ActiveResourceAssociations #:nodoc:
class << self
protected
def included(base)
class << base
# a special Active... |
class UsersController < ApplicationController
# before_filter :authenticate_user!
def index
@users = User.order(:name).page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
end
def show
@user = User.find(params[:id])
... |
FactoryBot.define do
factory :phone do
number { Faker::PhoneNumber.cell_phone }
extension { Faker::PhoneNumber.extension }
contact
phone_type
end
end
|
ActiveAdmin.register Dog do
index do
column "file" do |post|
image_tag post.file.thumb.url.to_s
end
column :title
column :introduction
column :sex
column :created_at
column :slug
default_actions
end
show do |dog|
attributes_table do
... |
class CheckinsController < ApplicationController
before_action :set_checkin, only: [:show, :edit, :update, :destroy]
# GET /checkins
# GET /checkins.json
def index
@checkins = Checkin.all
end
# GET /checkins/1
# GET /checkins/1.json
def show
if current_user.id == @checkin.user_id || current_us... |
# == Schema Information
#
# Table name: orders # 订单管理
#
# id :integer not null, primary key
# user_id :integer # 用户id
# product_id :integer # 商品id
# destination_id :integer # 地址id
# total_pr... |
#!/usr/bin/env/ruby
require File.expand_path("../../pwr.rb", __FILE__)
require 'nacl'
class PwrTLS
def self.connect(server, port, conn)
EventMachine::connect(server, port, PwrConnectionHandlerPwrTLS, conn)
return Fiber.yield ? conn : nil
end
def self.listen(server, port, connclass, &block)
EventMachine::star... |
require_dependency 'application'
class CommentsExtension < Radiant::Extension
version "0.0.5"
description "Adds blog-like comments and comment functionality to pages."
url "http://github.com/ntalbott/radiant-comments/tree/master"
define_routes do |map|
map.with_options(:controller => 'ad... |
module CDI
module V1
class TrackReportSerializer < ActiveModel::Serializer
root :reports
attributes :report_updated_at
attributes :enrolled_labels, :enrolled_data
attributes :review_labels, :review_data
attributes :students_reports
ENROLL_LABELS = I18n.t('app.track_enroll... |
module RemoteBiimail
# Use Mash to get hash as an objet and handle
# better on application
class Mashify < Faraday::Response::Middleware
def on_complete(env)
super if Hash === env[:body]
end
def parse(body)
Mail.new_from_hash(body)
end
end
module Connection
def connection
... |
class Garage
attr_reader :name, :doors
def initialize(name, doors)
@name = name
@doors = doors
end
def [](door_name)
@doors.select {|door| door.name.casecmp(door_name) === 0}.first
end
end
|
module ApplicationHelper
def display_user_name(user)
link_to(user.name.blank? ? user.email : user.name, user)
end
def thumbnail_tag(album)
link_to(image_tag(album && album.thumbnail ? "/images/thumbnails/#{album.library}/#{album.thumbnail}" : "no_cover.jpg", :class => 'thumbnail shadow', :title => (... |
# I want a ruby-scriptable editor that isn't in your way
# responsive and powerful.. with good lexing.. (and I mean good lexing)
require 'common_test'
require 'core'
class TestModelLoad < Test::Unit::TestCase
def setup
super
@model = AEditor::Model::Caretaker.new
end
def teardown
super
@model.check_integri... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class AddSpecializationIdToPositions < ActiveRecord::Migration
def change
add_reference :positions, :specialization, index: true
end
end
|
# frozen_string_literal: true
require 'terminal-table'
require 'uri'
require 'pg'
module RubyPGExtras
@@database_url = nil
QUERIES = %i(
bloat blocking cache_hit db_settings
calls extensions table_cache_hit index_cache_hit
index_size index_usage null_indexes locks all_locks
long_running_queries m... |
class RemoveTaglineFromPost < ActiveRecord::Migration
def change
remove_column :posts, :tagline
end
end
|
#blackjack
class Blackjack
def hand()
@cards = ['A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2']
@card_value = {
'A' => 11,
'K' => 10,
'Q' => 10,
'J' => 10,
'10' => 10,
'9' => 9,
'8' => 8,
'7' => 7,
'6' => 6,
'5' => 5,
... |
require 'sinatra/base'
require 'slack-ruby-client'
require 'mongo'
require 'erb'
require 'algoliasearch'
require_relative 'helpers'
Algolia.init
# This code is largely borrowed from the Slack Ruby Events API example here https://github.com/slackapi/Slack-Ruby-Onboarding-Tutorial
# Set up external persistence of Slac... |
require 'rails_helper'
RSpec.describe Vehicle, type: :model do
let(:vehicle) { FactoryGirl.create(:vehicle) }
context 'validation ckecks' do
it 'should be valid' do
expect(vehicle).to be_valid
end
it 'has incorrect registration number and should not be valid' do
vehicle.registration_numbe... |
class Book < ApplicationRecord
belongs_to :user
mount_uploader :image ,ImageUploader
serialize :image , JSON
end
|
module API
module V1
class MultimediaActions < API::V1::Base
helpers API::Helpers::V1::MultimediaHelpers
before do
authenticate_user
end
namespace :multimedia do
desc 'Uploads multimedia content'
params do
use :new_multimedia
end
post ... |
module Chibo
module Riemann
class Adapter
private
attr_reader :connector, :app, :hostname, :dyno
public
def initialize(args = {})
@connector = args.fetch(:connector)
@app = args.fetch(:app)
@hostname = args.fetch(:hostname)
@dyno = args.fetch(:d... |
module HoptoadNotifier
# used to initialize Rails-specific code
class RailsInitializer
def self.initialize
rails_logger = if defined?(Rails.logger)
Rails.logger
elsif defined?(RAILS_DEFAULT_LOGGER)
RAILS_DEFAULT_LOGGER
... |
class Issue
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Search
field :title, type: String
field :description, type: String
field :reason, type: String
field :place_of_occurance, type: String
field :type, type: Integer
field :precaution, type: String
field :solution, type:... |
# frozen_string_literal: true
require 'rails_helper'
describe 'エラーページ', type: :system, js: true do
let(:login_user) { FactoryBot.create(:user) }
context '500エラーページに遷移するとき' do
let(:my_instance) { instance_double(UserSearchForm) }
before do
sign_in_as(login_user)
allow(UserSearchForm).to recei... |
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rake/extensiontask"
require 'readapt/version'
require 'tmpdir'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
# Compile tasks
Rake::ExtensionTask.new "readapt" do |ext|
ext.lib_dir = "lib/readapt"
end
namespace :install do
desc 'Instal... |
class Event < ActiveRecord::Base
belongs_to :venue
belongs_to :category
belongs_to :user
has_many :ticket_types
validate :validate_publish
validates_presence_of :extended_html_description, :venue, :category, :starts_at
validates_uniqueness_of :name, uniqueness: {scope: [:venue, :starts_at]}
def self... |
require 'rails_helper'
RSpec.describe List, type: :model do
context "association" do
it "has many reservations" do
assc = described_class.reflect_on_association(:reservations)
expect(assc.macro).to eq :has_many
end
it "belongs to user" do
assc = described_class.reflect_on_association(:user)
... |
Vagrant.configure("2") do |config|
# hypervisor
config.vm.provider "virtualbox" do |vmp|
vmp.memory = 1024
vmp.cpus = 1
end
# base OS
config.vm.box = "generic/centos7"
# machine specific
config.vm.hostname = "single.vagrant"
config.vm.network "private_network", ip: "192.168.23.10"
end |
class Artist
attr_reader :name, :years_experience
@@all = []
@@total_years_of_experience = 0
def initialize(name, years_experience)
@name = name
@years_experience = years_experience
@@all << self
@paintings = []
@galleries = []
@cities = []
@@total_years_of_experience += years_exp... |
class AddPageUrlToEvents < ActiveRecord::Migration
def change
add_column :events, :page_url, :string
end
end
|
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'welcome'" do
visit root_url
expect(page).to have_content('Welcome')
end
end
end
|
module AnnualReports
module UpdateWithFeaturedCampaigns
class Fetcher
private
attr_reader :annual_report, :campaigns
public
def initialize(annual_report)
@annual_report = annual_report
end
def call
fetch_all_campaigns
categories_with_featured_campaigns... |
Rails.application.routes.draw do
scope '(:locale)', locale: /#{I18n.available_locales.join("|")}/ do
devise_scope :user do
get 'sign_in', to: 'devise/sessions#new', as: :new_user_session
post 'sign_in', to: 'devise/sessions#create', as: :user_session
delete 'sign_out', to: 'devise/sessions#destr... |
cask :v1 => 'gqrx' do
version '2.2.0'
sha256 'b4d81d542ea095bb882d465461d33f75ace2fca8806f8074464e9a586314ed07'
url "http://downloads.sourceforge.net/project/gqrx/#{version}/gqrx-#{version}.dmg"
name 'Gqrx'
homepage 'http://gqrx.dk/'
license :oss
app 'Gqrx.app'
end
|
require 'spec_helper'
describe "blog_data/new" do
before(:each) do
assign(:blog_datum, stub_model(BlogDatum,
:client_id => 1,
:social_network_id => 1,
:unique_visits => 1,
:visit_pages => 1,
:rebound_percent => 1.5,
:new_visits_percent => 1.5,
:total_posts => 1
).as_... |
Given /^I am logged in$/ do
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:cobot] ||= {
'credentials' => {
'token' => '12345'
},
'info' => {
'name' => 'janesmith',
'email' => 'janesmith@example.com'
},
'extra' => {
'raw_info' => {
'memberships' => [],... |
class Api::V1::QuestionsController < ApplicationController
before_filter :restrict_access
def index
@questions = Question.all
end
def show
@question = Question.find(params[:id])
end
private
def restrict_access
# @api_key ||= ApiKey.find_by_access_token(params[:access_token])
# head :u... |
require 'pry'
require 'time'
require 'date'
module Hotel
class Room
attr_reader :room_num, :room_reservations
def initialize(room_num)
@room_num = room_num
@room_reservations = []
end
def add_booking(new_reserv)
unless new_reserv.is_a?(Hotel::Reservation)
raise ArgumentErr... |
#
# Extensions de la classe String
#
# @note: Elle a besoin de BuilderHtml pour fonctionner pleinement
# require 'builder-html'
class String
# Correspondance entre les diacritiques et les caractères simples
unless defined? ACCENTS_MAPPING
ACCENTS_MAPPING = {
'E' => [200,201,202,203],
'e' => [23... |
require 'plato'
class Platoefi < Plato
# def <=>(other)
# @eficiencia <=> other.eficiencia
# end
# Se redefine la comparación para que se realice en base a la huella nutricional
#
# @param other [Plato] tipo del parámetro
# @return [Boolean] verdadero o falso si se cumple la condición o no.
d... |
module Topographer
class Importer
module Logger
class FatalErrorEntry < Topographer::Importer::Logger::LogEntry
attr_reader :message, :timestamp, :model_name
def initialize(input_identifier, message)
@timestamp = DateTime.now
@input_identifier = input_identifier
... |
require 'test_helper'
class PeopleControllerTest < ActionController::TestCase
fixtures :people,:users, :projects, :work_groups, :group_memberships, :project_roles
include AuthenticatedTestHelper
include RestTestCases
include ApplicationHelper
include RdfTestCases
def setup
login_as(:quentin)
end
... |
module RSpec
module ActiveModelSerializers
module Matchers
module RenderSerializer
extend ActiveSupport::Concern
# @privatge
class RenderSerializerMatcher < RSpec::Matchers::BuiltIn::BaseMatcher
def initialize(scope, expected, message=nil)
@expected = expected... |
class WarJob < ApplicationJob
queue_as :default
def perform(war, options)
begin
@war = war
@options = options
type = options[:type]
case type
when "war_start" then @war.start
when "war_end" then @war.end
when "war_time_start" then war_time_start
when "war_time... |
require 'rubygems'
require 'block_chainable'
require 'need'
need{'filter_error'}
module TestSweet
class Page
include BlockChainable
def self.filter(*elements,&block)
elements.each do |element|
(filters[element] ||= []) << block
end
end
def self.element(name,&block)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.