text stringlengths 10 2.61M |
|---|
# Scrapes Greyhound Site for trip cost.
# Watir depends on Selenium Webdriver
# Date must be in 'yyyy-mm-dd' format.
# Example:
# depart_date = '2016-06-01'
# depart_from = {city: 'Vancouver', state: 'BC'}
# return_date = '2016-06-02'
# return_from = {city: 'Los Angeles', state: 'CA'}
# trip_type = "Round Trip"
# ghou... |
require 'formula'
class Ipcalc < Formula
homepage 'http://jodies.de/ipcalc'
url 'http://jodies.de/ipcalc-archive/ipcalc-0.41.tar.gz'
sha1 'b75b498f2fa5ecfa30707a51da63c6a5775829f3'
def install
bin.install "ipcalc"
end
end
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
require 'rspec/its'
describe Biggs::Format do
describe '.find' do
context 'known country with format' do
subject { Biggs::Format.find('cn') }
it { is_expected.to be_kind_of(Biggs::Format) }
its(:country_name) { should eql('China') ... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'splaytreemap/version'
Gem::Specification.new do |spec|
spec.name = "splaytreemap"
spec.version = Splaytreemap::VERSION
spec.authors = ["Kirk Haines"]
spec.email ... |
module Haenawa
module Commands
class Wait < Command
def validate
if target.blank?
@step.errors.add(:target, :missing)
elsif '_blank' == target
elsif !VALID_STRATEGIES.include?(strategy) || locator.blank?
@step.errors.add(:target, :invalid)
else
b... |
module SessionsHelper
# 渡されたユーザでログインする
def log_in(user)
session[:user_id] = user.id
end
# 渡されたユーザがログインしていれば true を返す
def current_user?(user)
user == current_user
end
# 現在ログイン中のユーザを返す (いる場合)
def current_user
@current_user ||= User.find_by(id: session[:user_id])
end
# ユーザがログインしてい... |
class AddPacksToCards < ActiveRecord::Migration
def change
add_belongs_to :cards, :pack
end
end
|
describe 'Sign in', type: :feature do
before :each do
@user = User.create(email: 'user@example.com', password: 'password', name: 'user')
end
after :each do
@user.destroy
end
it 'sign in user' do
visit '/users/sign_in'
fill_in 'Email', with: 'user@example.com'
fill_in 'Password', with: 'pa... |
require 'test_helper'
class StatementsControllerTest < ActionDispatch::IntegrationTest
def setup
@admin = users(:admin)
@user = users(:user)
@statement = statements(:statement1)
@name = 'Extracto junio 2018'
@date = '01-06-2018'
end
#################
# #
# FUNCTIONS #... |
require 'minitest'
require 'minitest/autorun'
require 'delve/widgets/key_value'
class KeyValueWidgetTest < Minitest::Test
def setup
@x = 1
@y = 1
@label = 'Name'
@value = 'Hero'
@widget = KeyValueWidget.new @x, @y, @label, @value
@display = mock('object')
end
def test_initialising_witho... |
class Restaurant < ApplicationRecord
has_many :map_object, through: :is_open
end
|
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validat... |
require 'rails_helper'
describe StructureChangeCreator do
def audit_payload(data)
payload = { 'audit' => data }
expect(payload).to match_response_schema('retrocalc/audit')
payload
end
let!(:measure_selection) { create(:measure_selection) }
let!(:measure) { measure_selection.measure }
let!(:audit... |
class AddEmailFieldToDeployment < ActiveRecord::Migration
def up
add_column :deployments, :email, :text
end
def down
add_column :deployments, :email
end
end
|
class RenameUserTaskLabelToLabelAttachedTask < ActiveRecord::Migration[5.2]
def change
rename_table :user_task_labels, :label_attached_tasks
end
end
|
class RenameMessageToTextMessages < ActiveRecord::Migration[5.2]
def change
rename_column :comments, :message, :text_comments
end
end
|
require 'rails_helper'
RSpec.describe "eu_vous/edit", type: :view do
before(:each) do
@eu_vou = assign(:eu_vou, EuVou.create!(
:euvou => false,
:user => nil,
:event => nil
))
end
it "renders the edit eu_vou form" do
render
assert_select "form[action=?][method=?]", eu_vou_path(... |
module Openra
class IRCBot < Cinch::Bot
module Plugins
class PointOne
include Cinch::Plugin
match '.1'
def execute(m)
m.reply "Gotta go, my #{nouns.sample} #{verbs.sample}"
end
private
def nouns
@nouns ||= Openra::IRCBot.dict('point_one... |
class GamesController < ApplicationController
def index
@games = current_user.games
end
def create
@game = Game.create
@game.user_id = current_user.id
@game.save
redirect_to @game
end
def show
@game = Game.find(params[:id])
unless @game.user == current_user
flash[:alert]... |
# frozen_string_literal: true
require 'singleton'
require_relative './validation'
module Departments
module Analysis
module Services
##
# Consumes the {Workers::Analysis::CodeInjection::Sql::CyberReportProducer}.
class SqlInjectionReport
include Singleton
# Queues a job for a ... |
require 'dry-validation'
module ValidationHelper
# Бросать в случае ошибки валидации с помощью dry-validation
class ValidationError < StandardError
attr_reader :errors
# @param [Hash] errors
def initialize(errors)
@errors = errors
end
end
# Переопределенный метод call бросает исключен... |
# frozen_string_literal: true
def prime?(num)
return false if num < 2
(2...num).each do |i|
return false if (num % i).zero?
end
true
end
|
# -*- coding: utf-8 -*-
require 'spec_helper'
describe Glossary do
describe "#generate" do
context "one word" do
it "adds a glossary to the database" do
lambda do
Glossary.generate('data/edict_one_word.txt')
end.should change(Glossary,:count).by(1)
end
it "sets the glo... |
require 'spec_helper'
require 'capybara'
feature "signing up" do
it "has a sign up page" do
visit new_user_url
expect(page).to have_content("Sign Up")
end
feature "signs up a user" do
before(:each) do
sign_up
end
it "should have sign in input boxes" do
visit new_user_url
... |
class Publisher < ActiveRecord::Base
has_many :books
validates_length_of :name, :in => 2..255
validates_uniqueness_of :name
attr_accessible :name
end
|
require 'open-uri'
require 'rubygems'
require 'digest/md5'
class Admin::ArticleParse
private
@article
@article_to_parse
public
def initialize(feed, article)
@article = Article.new()
@article.feed_id = feed.id
@article_to_parse = article
self
end
def parseTitle
title = @article_... |
class Flat < ApplicationRecord
validates :name, :address, :price_per_night, :number_of_guests, presence: true
validates :price_per_night, :number_of_guests, numericality: true
end
|
module Balance::Cell
class Index < Index.superclass
# An .hpanel with a table of balances for a specific person. Has a link to
# add a new balance for the person.
#
# If the person belongs to a couples account, the header will say "(Person
# name)'s points". If it's a solo account, it will simply ... |
require 'rails_helper'
RSpec.describe 'Vote', type: :model do
it 'is not valid without an article_id' do
vote = Vote.new(user_id: 1)
expect(vote.save).to be(false)
end
it 'is not valid without an password' do
vote = Vote.new(article_id: 1)
expect(vote.save).to be(false)
end
it 'belongs to art... |
module BasicObjectBehavior
def private_features
[ :initialize, :method_missing, :singleton_method_added, :singleton_method_removed, :singleton_method_undefined ]
end
def protected_features
[]
end
def public_features
[ :"!", :"!=", :==, :__send__, :equal?, :instance_eval, :instance_exec ]
end
e... |
require 'spec_helper'
describe HyperTraverser::HyperInterpreter do
describe ".create" do
it "creates an appropriate HyperState object out of the provided data" do
raw_data = {
"barney" => "stinson",
"blarney" => "stone",
"cool_stuff" => [
{ "thing" => "beans" },
... |
require 'spec_helper'
describe 'openldap::server::slapdconf' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context 'with no parameters' do
let :pre_condition do
"class {'openldap::server':}"
end
it { is_expected... |
class DropSessionsTable < ActiveRecord::Migration
def self.up
drop_table :sessions
end
def self.down
raise ActiveRecord::IrreversibleMigration
end
end
|
class Reputable::BadgeAward < ActiveRecord::Base
set_table_name :reputable_badge_awards
belongs_to :badge, :class_name => "Reputable::Badge"
end
|
class Calculator
attr_reader :number, :operation, :number_2
def initialize(number, operation, number_2)
@number = number
@operation = operation
@number_2 = number_2
end
def calculate
case operation
when "addition"
result = number + number_2
when "subtraction"
result ... |
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.references 'sub'
t.references 'user'
t.text 'title'
t.text 'text'
t.text 'link'
t.boolean 'visible', :default => false
t.integer :sub_comments, :default => 0
t.integer :votes_diff, :... |
require 'rspec'
require './lib/Sudoku/puzzle'
require './lib/Solver/solver'
describe 'Sudoku solver feature' do
it 'should be able to solve via Only Possibility' do
m = Puzzle.new(9).set("5 0 0 0 8 0 0 6 0 \n9 7 2 0 0 1 0 0 0 \n8 6 0 0 3 0 5 0 0 \n4 9 0 8 1 0 0 2 6 \n6 0 0 0 0 0 0 0 8 \n3 2 0 0 6 5 0 9 7 \n0 0 9... |
require 'rails_helper'
RSpec.describe Role, type: :model do
before :each do
@role = Role.new
end
describe '#new' do
it 'nimmt Parameter fuer Rollen an' do
@role.should be_an_instance_of Role
end
end
end
|
#todos estos son métodos de instancia
class Persona
#con esto estamos creando sus respectivos getters y setters
attr_accessor :nombre,:sexo,:edad
#si no queremos que se pueda cambiar un atributo, como el dni por ejemplo
#damos permisos de solo lectura
attr_reader :dni
#también tenemos de sol... |
class ChangeTableInspectsMeterAnomaly < ActiveRecord::Migration
def change
change_column :inspects, :meter_anomaly, :text, :limit => 4294967295
end
end
|
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV['AWS_ACCESS_KEY'], # required
:aws_secret_access_key => ENV['AWS_SECRET_KEY'],
:region => 'us-west-2'
}
config.cac... |
# frozen_string_literal: true
module Halcyoninae
class ArgumentsParser
def initialize(argv)
@left, @right = argv.slice_after(DOUBLE_DASH).to_a
end
def run
parse_arguments
end
private
attr_reader :left, :right
DASH = "-"
DOUBLE_DASH = "--" # https://goo.gl/qTPnwx
de... |
require('capybara/rspec')
require('./app')
Capybara.app = Sinatra::Application
set(:show_exceptions, false)
describe('add a new word from index path', {:type => :feature}) do
it ("allows a user to submit a new word and adds it to the list of words") do
visit('/')
fill_in('word_name', :with => 'Socialism')
... |
require "nokogiri"
require_relative "kanji"
class Kanjidic
end
class Kanjidic::Parser < Nokogiri::XML::SAX::Document
DEFAULT_FILENAME = "/usr/share/kanjidic2/kanjidic2.xml"
def initialize(filename = DEFAULT_FILENAME)
@kanji = []
@current_kanji = nil
parser = Nokogiri::XML::SAX::Parser.new(self) do |... |
class CreateContact
def initialize(params)
@params = params
end
def call
return Result.failure("Invalid phone number") unless phone_number.valid?
contact = initialize_contact
if contact.update(params.merge(saved: true))
Result.success(contact: contact)
else
Result.failure(contact... |
class CreateNoticia < ActiveRecord::Migration[5.2]
def change
create_table :noticia do |t|
t.string :titulo
t.string :texto
t.string :foto
t.string :fotografo
t.references :usuario, foreign_key: true
t.timestamps
end
end
end
|
class AddConfirmationToOrder < ActiveRecord::Migration
def change
add_column :orders, :confirmation, :string, limit: 32
add_index :orders, :confirmation, unique: true
end
end
|
require 'test_helper'
class ApiControllerTest < ActionDispatch::IntegrationTest
test "should get state of the app" do
get api_state_url
assert_response :success
body = JSON.parse(response.body, symbolize_names: true)
assert_equal body[:app_state], 'running'
end
test "card info should return 40... |
require File.expand_path('../../../helpers/compute/data_helper', __FILE__)
module Fog
module Compute
class ProfitBricks
class Nic < Fog::Models::ProfitBricks::Base
include Fog::Helpers::ProfitBricks::DataHelper
identity :id
# properties
attribute :name
attribute :... |
RSpec.describe 'assorted sanity checks' do
let(:resource_methods) { Yaks::Resource.public_instance_methods.sort }
let(:collection_resource_methods) { Yaks::CollectionResource.public_instance_methods.sort }
let(:null_resource_methods) { Yaks::NullResource.public_instance_methods.sort }
specify ... |
class MeetingDetail < ApplicationRecord
belongs_to :meeting, optional: true #alae001 - need to remove optional statement to ensure rule is enforced.
belongs_to :role, optional: true #alae001 - need to remove optional statement to ensure rule is enforced.
belongs_to :user, optional: true #alae001 - need to remove... |
require 'test_helper'
class TokenizerTest < Minitest::Test
def test_tokenize_strings
assert_equal [' '], tokenize(' ')
assert_equal ['hello world'], tokenize('hello world')
end
def test_tokenize_variables
assert_equal ['{{funk}}'], tokenize('{{funk}}')
assert_equal [' ', '{{funk}}', ' '], tokeni... |
require 'rails_helper'
RSpec.describe "txns/new", type: :view do
before(:each) do
assign(:txn, Txn.new(
:amount => "9.99",
:bank_number => "MyString",
:debit_account => 1,
:credit_account => 1,
:payment => false,
:ledger => nil,
:apt => nil
))
end
it "renders ne... |
require File.join(Dir.pwd, 'spec', 'spec_helper')
describe 'UserSkillList' do
before do
simulate_connection_to_server
end
after do
end
it 'should pass if user skill list attribute is not specifed' do
user_id = 123
request_data = FactoryGirl.attributes_for(:user_skill_list, {
:total_ent... |
require 'rails_helper'
describe Review, type: :model do
describe 'Validations' do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:body) }
it { should validate_presence_of(:rating) }
it { should validate_presence_of(:user_id) }
it { should validate_presence_of(:book_id)... |
module RequestsHelper
def format_date(date,short=nil)
return if date.nil?
time = Date.parse(date.to_s)
time.strftime("%-m/%-d")
end
def format_time(time)
return if time.nil?
time = Time.parse(time.to_s)
time.strftime("%l:%M%p").sub!('M','').downcase
end
def format_availability(a)
... |
class CreateBackgroundrbQueueTable < ActiveRecord::Migration
def self.up
create_table :bdrb_job_queues do |t|
t.column :args, :text
t.column :worker_name, :string
t.column :worker_method, :string
t.column :job_key, :string
t.column :taken, :int
t.column :finished, :int
... |
module GroupDocs
class Document::View < Api::Entity
# @attr [GroupDocs::Document] document
attr_accessor :document
# @attr [String] short_url
attr_accessor :short_url
# @attr [Time] viewed_on
attr_accessor :viewed_on
#
# Converts timestamp which is return by API server to Time object... |
# In Order
def in_order?(array)
array.each_with_index do |el, idx|
next if idx == 0
return false unless el >= array[idx - 1]
end
true
end
# ------------------------------------------------------------------------------
# Boolean to Binary
def boolean_to_binary(array)
binary = ""
array.each do |bo... |
require 'test_helper'
class CustomerBookingsControllerTest < ActionDispatch::IntegrationTest
setup do
@customer_booking = customer_bookings(:one)
end
test "should get index" do
get customer_bookings_url, as: :json
assert_response :success
end
test "should create customer_booking" do
assert_... |
# frozen_string_literal: true
# The InstrumentParser is responsible for the <Instrmt> mapping. This tag is one of many tags inside
# a FIXML message. To see a complete FIXML message there are many examples inside of spec/datafiles.
#
# Relevant FIXML Slice:
#
# <Instrmt PxQteCcy="USD" Exch="NYMEX" PutCall="0" UOM="MMB... |
class CreateContactPages < ActiveRecord::Migration
def change
create_table :contact_pages do |t|
t.text :address
t.text :working_hours
t.text :contacts
t.string :map_coordinates
t.timestamps
end
end
end
|
class AddOnMainToGoods < ActiveRecord::Migration
def change
add_column :goods, :on_main, :boolean
end
end
|
# == Schema Information
#
# Table name: match_answers
#
# id :integer not null, primary key
# answer_id :integer
# match_id :integer
# team_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# match_question... |
# Euler problem 44
class Problem44
def main
pentagnoal_numbers = generate_pentagnoal_numbers(10_000)
pairs = prepare_pairs(pentagnoal_numbers)
puts 'Start'
pairs.each do |pair|
if pentagnoal_numbers.include?(pair_sum(pair)) && pentagnoal_numbers.include?(pair_difference(pair))
puts "pai... |
class AddToToRingGroupCalls < ActiveRecord::Migration[5.2]
def change
add_column :ring_group_calls, :to, :string, array: true, default: [], null: false
end
end
|
class Array
def sorted?
(self.length-1).times do |index|
if self[index] > self[index+1]
return false
end
end
return true
end
end
[4, 6, 23, 63, 7, 234, 75, 234, 7543]
def bogosort(array)
ary = array.dup
while not ary.sorted?
ary.shuffle!
end
return ary
end
def bubblesort(array)
ary = array.d... |
def input_students
puts "Please enter the names of the students."
puts "To finish, just hit return twice."
# crate an empty array
students = []
# get the first name
name = gets.chomp
# while the name is not empty, repeat this code
while !name.empty? do
# add the student hash to the array
student... |
class AddComunidadIdToProvincia < ActiveRecord::Migration[5.0]
def change
add_column :provincia, :comunidad_id, :integer
end
end
|
class CommitFetcher
def self.fetch_and_save
events = Github.new(basic_auth: TokenMaster.get_token).activity.events.public(per_page: 40).map{ |e| [e.id, e.created_at, e.actor.login] }
events.each do |event|
event_id = event[0]
Commit.create(event_id: event_id, commit_time: event[1], author: event[... |
module UserImageHelper
DEFAULT_IMAGE_URL = "guest_image.png"
def user_image(user)
image_or_default(user.avatar_url, DEFAULT_IMAGE_URL, "profile-image")
end
def user_thumbnail(user)
image_or_default(user.avatar_url, DEFAULT_IMAGE_URL, "thumbnail-image")
end
private
def image_or_default(url, def... |
require 'spec_helper'
describe TweetBatch do
subject(:batch) { TweetBatch.new }
it "should have the correct constant list url" do
TweetBatch::LIST_URL.should eq 'https://twitter.com/cspan/members-of-congress'
end
context "initialization" do
before do
@tweet_id = 123456789
@new_batch = TweetBatch.new(@... |
class Libuv < Formula
homepage "https://github.com/libuv/libuv"
url "https://github.com/libuv/libuv/archive/v1.4.2.tar.gz"
sha1 "85882c7e0b6ce77c30240a895c62d158e04b361e"
head "https://github.com/libuv/libuv.git", :branch => "v1.x"
bottle do
cellar :any
sha1 "b2698a14753dfe1adc790472ad88a271b9aaf435"... |
# Studies Controller
class StudiesController < PlatformController
require 'will_paginate/array'
before_action :authenticate_researcher, only: [:new, :create]
before_action :authenticate_admin, only: [:feature]
def index
@section = params[:section]
@section ||= 'featured_studies'
@section_title = p... |
class Movie
attr_accessor :id, :name, :studio, :reviews
def ==(other)
return false unless other
return false if other.id == -1
return false if @id == -1
@id == other.id
end
end
class MovieMapping < Humble::DatabaseMapping
def run(map)
map.table :movies
map.type Movie
map.primary_ke... |
class Artist
def initialize(name)
@name = name
@albums = []
end
def name
@name
end
def assign(album)
@albums << album
end
def album_names
name_strings = []
@albums.each do |a|
name_strings << a.name
end
name_strings.join(", ")
end
end
|
class Character < ActiveRecord::Base
validates_presence_of :name, :game_id, :user_id
belongs_to :user
belongs_to :game
belongs_to :player
has_many :traits
has_many :game_traits, through: :traits
before_create :starting_points
def starting_points
self.available_points = self.game.starting_points
... |
require "test_helper"
require "search_scoring"
class SearchScoringTest < ActiveSupport::TestCase
test "#name prioritizes exact matches" do
query = "donald"
good_match = "Donald"
bad_match = "Donald Vladimir"
assert_operator SearchScore.name(good_match, query),
:<,
... |
require_relative 'repository'
module Peel
module Modelable
def initialize(**args)
args.each do |attribute, value|
if self.class.columns.include?(attribute)
instance_variable_set("@#{attribute.to_s}", value)
else
raise ArgumentError, "Unknown keyword: #{attribute}"
... |
# Object that acts like a routeable ActiveRecord model
class Leaf
def initialize(attributes)
@attributes = attributes
end
def to_param
@attributes[:id]
end
def self.model_name
self
end
def self.singular_route_key
"leaf"
end
end
|
class AddTallnessToPlant < ActiveRecord::Migration[5.1]
def change
add_column :plants, :tallness, :integer
end
end
|
class RegistrationsController < Devise::RegistrationsController
skip_before_filter :require_no_authentication, :only => [:new, :create, :setup_account]
before_filter :go_to_dashboard_if_signed_in, :except => [:deactive_account, :reactive_account, :update, :new, :create, :setup_account, :create_cashier]
before_fil... |
class AuthenticationController < ApplicationController
skip_before_action :authenticate_request
def login
command = AuthenticateUser.call(params[:email], params[:password])
if command.successful?
render(
json: {
success: true,
code: 200,
message: "Login success... |
require 'pry'
class Pokemon
attr_accessor :name, :id, :type, :db
def initialize(id:, name:, type:, db:)
@id = id
@name = name
@type = type
@db = db
end
def self.save(pname, ptype, db)
query = "INSERT INTO pokemon (name, type) VALUES ('#{pname}', '#{ptype}');"
# binding.pry
db.execu... |
class CalculateAmortizationSchedule
def initialize(loan_detail)
@loan_detail = loan_detail
@interest = ((@loan_detail.interest * 0.01 )/ 12) * @loan_detail.loan_amount
@monthly_payment = calculate_monthly_payment(@loan_detail.loan_amount, @loan_detail.term)
@principal_amount = @monthly_payment - @int... |
class AddAntecedentesFieldsToCandidates < ActiveRecord::Migration[5.2]
def change
add_column :candidates, :dm2, :json
add_column :candidates, :hta, :json
add_column :candidates, :ecv, :json
add_column :candidates, :iam, :json
add_column :candidates, :irc, :json
add_column :candidates, :evc, :j... |
module ActiveSesame::TransactionBuilder
def self.object_to_triples(object)
base_class = object.class.base_uri_location.gsub(/<|>/,"") + object.class.rdf_class
full_transaction = self.build_triple(object.instance, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", base_class)
object.class.simple_attribute... |
require '3scale/backend/validators/base'
require '3scale/backend/validators/oauth_setting'
require '3scale/backend/validators/key'
require '3scale/backend/validators/oauth_key'
require '3scale/backend/validators/limits'
require '3scale/backend/validators/redirect_uri'
require '3scale/backend/validators/referrer'
requir... |
RSpec.configuration.before(:suite) do
# override zip_dir method to write zip file to tmp dir
class Opendata::App
class << self
alias_method :zip_dir_orig, :zip_dir
@@tmp_dir = Pathname(::Dir.mktmpdir)
def zip_dir
@@tmp_dir
end
end
end
end
RSpec.configuration.after(:suite) ... |
require 'spec_helper_acceptance'
describe 'ksplice class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'ksplice': }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_... |
class Group < ApplicationRecord
validates :name, presence: true
has_many :members
has_many :users, through: :members
has_many :messages
def memberlist
str = "Member: "
users.each do |user|
str += "#{user.name} "
end
return str
end
end
|
class MoveAreaIdsToArea < ActiveRecord::Migration
# Area has been removed so we have to define it here
class Area < ActiveRecord::Base
end
class User < BaseUser
belongs_to :area
end
def change
# map some descriptions to what one-app has
mapping = {
'South East Asia' => 'SouthEast Asia',
... |
class Article < ActiveRecord::Base
belongs_to :user
has_many :comments
validates :title, length: {
minimum: 5,
maximum: 20,
too_short: "Please lengthen title",
too_long: "Please shorten title" }
validates :body, length: {
minimum: 50,
maximum: 5000,
too_short: "Please write a little... |
module MessageStore
module Postgres
class Settings < ::Settings
def self.instance
@instance ||= build
end
def self.data_source
Defaults.data_source
end
def self.names
[
:dbname,
:host,
:hostaddr,
:port,
:user... |
json.array!(@piece22s) do |piece22|
json.extract! piece22, :id, :name, :user_id, :pnameform_id
json.url piece22_url(piece22, format: :json)
end
|
Pod::Spec.new do |s|
s.name = "LogicService"
s.version = "0.0.1"
s.summary = "LogicService: logic service"
s.description = <<-DESC
工具库:通过pod管理,控制耦合度
DESC
s.homepage = "https://github.com/zhu410289616"
# s.screenshots = "www.example.com/screenshots_1.gif", "ww... |
require "socket"
require "logger"
# This class represents the ProjectRazor configuration. It is stored persistently in
# './conf/razor_server.conf' and editing by the user
module ProjectRazor
module Config
class Server
include(ProjectRazor::Utility)
# (Symbol) representing the database plugin mode ... |
require 'travis/github_sync/config'
describe Travis::GithubSync::Config do
before { ENV['ENV'] = 'test' }
it 'has an env on instances' do
expect(subject.env).to eql('test')
end
it 'has an env on the class' do
expect(described_class.env).to eql('test')
end
end
|
require "rails_helper"
describe "Merge Call API", :graphql do
describe "mergeCall" do
let(:query) do
<<-GRAPHQL
mutation($input: MergeCallInput!) {
mergeCall(input: $input) {
participants {
sid
}
}
}
GRAPHQL
end
it "mo... |
FactoryGirl.define do
factory :property do
name Faker::Name.first_name
address1 Faker::Address.street_address
city Faker::Address.city
zip Faker::Address.zip_code
state Faker::Address.state
after(:build){|p| p.property_type = FactoryGirl.create(:multi_family)}
after(:build){|p| p.user = Fa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.