text stringlengths 10 2.61M |
|---|
class VendorDatesController < ApplicationController
before_action :set_vendor_date, only: [:show, :edit, :update, :destroy]
# GET /vendor_dates
# GET /vendor_dates.json
def index
@vendor_dates = VendorDate.all
end
# GET /vendor_dates/1
# GET /vendor_dates/1.json
def show
end
# GET /vendor_dat... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :github_access_token
t.string :github_id
t.string :twitter_oauth_token
t.string :twitter_oauth_token_secret
t.string :twitter_id
t.string :remem... |
module Pacer
module Routes
module RouteOperations
def range(from, to)
args = { :filter => :range }
args[:begin] = from if from
args[:end] = to if to
chain_route args
end
def limit(max)
chain_route :filter => :range, :limit => max
end
alias tak... |
# frozen_string_literal: true
module Utility
# for posting slack
module Slack
extend ActiveSupport::Concern
# class method
module ClassMethods
def notify_slack(message)
return if Rails.application.config.slack_webhook_url.blank?
notifier = ::Slack::Notifier.new(Rails.application.... |
module IOTA
module Multisig
class Address
def initialize(digests = nil)
# Initialize kerl instance
@kerl = IOTA::Crypto::Kerl.new
# Add digests if passed
absorb(digests) if digests
end
def absorb(digest)
# Construct array
digests = digest.class =... |
describe ::PPC::API::Sm::Keyword do
auth = $sm_auth
keyword_service = ::PPC::API::Sm::Keyword
test_keyword_id = 0
test_plan_id = ::PPC::API::Sm::Plan.ids(auth)[:result][0]
test_group_id = ::PPC::API::Sm::Group.search_id_by_plan_id(auth, test_plan_id)[:result][0][:group_ids][0]
it "can get ids by group id" d... |
# encoding: UTF-8
module OmniSearch
# we create this as a singleton
# so that only one connection to the cache exists
#
class Cache < ActiveSupport::Cache::MemCacheStore
include ::Singleton
attr_accessor :timestamp
def initialize
server = OmniSearch.configuration.memcache_server
... |
# Фильмы
# :title
# :year
# :slogan
# :director_id
# :budget
# :rating
# :our_rating
# :duration
# :is_viewed
class Film < ActiveRecord::Base
mount_uploader :image, ImageUploader
scope :has_image, -> { where.not(image: nil) }
scope :viewed, -> { where(is_viewed: true) }
scope :unviewed, -> { where(... |
class PublicationUnpublished < ActiveRecord::Base
belongs_to :publication
belongs_to :unpublished
end
|
class FixOutboards < ActiveRecord::Migration
def change
Boat.inactive.where('created_at > ?', 2.weeks.ago).each do |boat|
boat.save
end
end
end
|
class TiplineNewsletterType < DefaultObject
description "TiplineNewsletter type"
implements GraphQL::Types::Relay::Node
field :dbid, GraphQL::Types::Int, null: true
field :introduction, GraphQL::Types::String, null: true
field :header_type, GraphQL::Types::String, null: true
field :header_file_url, GraphQ... |
class User < ApplicationRecord
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :lockable,
:omniauthable, omniauth_providers: [:google_oauth2]
validates :first_name, :second_name, presence: true
has_many :authentication_methods, depend... |
require 'spec_helper'
require 'kibana'
describe ::Kibana do
include Rack::Test::Methods
def app
::Kibana.new
end
it 'returns kibana stuff on GET /' do
responses = ['/', '', '//', 'index.html'].map { |url|
get(url)
}
# Should all be a 200 and the same
responses.each do |r|
expect(r.status).to e... |
class ChangeIsCompletedToCompleted < ActiveRecord::Migration
def change
remove_column :todos, :is_completed, :boolean
add_column :todos, :completed, :boolean, null: false, default: false
end
end
|
class CreateFeedbackTickets < ActiveRecord::Migration
def change
create_table :feedback_tickets do |t|
t.integer :ticket_id
t.float :ticket_rating
t.float :user_rating
end
end
end
|
require 'test_helper'
require 'redis'
require 'me_redis'
# safety for Redis class, prevents to run test if base is not empty
class RedisSafety < Redis
def initialize(options = {})
options[:db] = ENV['REDIS_TEST_DB'] || 5
super(options).tap do
# preventing accidental connect to existing DB!
raise ... |
# frozen_string_literal: true
require "active_support/core_ext/hash/except"
require "active_support/core_ext/hash/slice"
module ActionController
# This module provides a method which will redirect the browser to use the secured HTTPS
# protocol. This will ensure that users' sensitive information will be
# trans... |
module ZombieApocalypse
class Input
@@creatures = File.readlines("input.txt")[2].scan(/\d+/).map(&:to_i).each_slice(2).to_a
attr_accessor :grid_size, :zombie_origin_x, :zombie_origin_y, :path
def initialize(options={})
inputs = File.readlines("input.txt")
@grid_size = options[:grid_size] || ... |
# frozen_string_literal: true
# exchange_rates.rb
# Author: William Woodruff
# ------------------------
# A Cinch plugin that provides USD currency exchange rates for yossarian-bot.
# Data courtesy of Open Exchange Rates: https://openexchangerates.org/
# ------------------------
# This code is licensed by Willi... |
module WeatherApi
class Units
FAHRENHEIT = 'f'
CELSIUS = 'c'
attr_reader :temperature,
:distance,
:pressure,
:speed
def initialize(payload)
@temperature = payload[:temperature]&.strip
@distance = payload[:distance]&.strip
@pressure =... |
#
# Cookbook Name:: mysql
# Recipe:: default
#
# Copyright (c) 2015 The Authors, All Rights Reserved.
#package 'mysql-server' do
# action :install
#end
#service 'mysqld' do
# action [:start, :enable]
#end
#package "gcc"
#package "gcc-c++"
#package "make"
#package "openssl-devel"
#package "pcre-devel"
mysql_... |
# coding: utf-8
require 'rspec'
require './arangodb.rb'
describe ArangoDB do
api = "/_api/collection"
prefix = "api-collection"
context "dealing with collections:" do
################################################################################
## reading all collections
###################################... |
require "socket"
require "timeout"
class Lxi_device < TCPSocket
# attr_accessor :timeout_seconds
# def initialize()
# @timeout_seconds = 0.1
# end
public :gets
def send_ascii_line(line)
line.chomp
#puts writes each of its arguments, adding a newline after each
self... |
class CreateTiles < ActiveRecord::Migration
def self.up
create_table :tiles do |t|
t.integer :user_id
t.integer :x,:null=>false
t.integer :y,:null=>false
t.integer :page_id,:null=>false
t.boolean :activated
t.integer :points,:null=>false,:default=>0
t.timestamps
end
... |
class ComunesController < ApplicationController
# GET /comunes
# GET /comunes.json
def index
@comunes = Comune.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @comunes }
end
end
# GET /comunes/1
# GET /comunes/1.json
def show
@comune = Comun... |
require 'spec_helper'
module Strumbar
module Instrumentation
module Mongoid
describe RuntimeTracker do
%w(runtime count).each do |attribute|
describe ".#{attribute}" do
it "is a class attribute" do
RuntimeTracker.send("#{attribute}=", 100)
RuntimeTr... |
require 'test_helper'
class V1::OrdersControllerTest < ActionDispatch::IntegrationTest
setup do
@order = orders(:one)
@user = @order.user
@access_token = @user.tokens.where(kind: 'access').first.uuid
end
test 'should get index' do
get v1_orders_url(access_token: @access_token), as: :json
ass... |
class Guide::Fixture
# Fixtures are used to generate content for your Living Guide
# that would otherwise be repetitive, such as view models that are used
# from multiple components. Declaring these in a single place is useful
# because it helps keep a consistent interface between the fake view models
# in th... |
require 'spec_helper'
require 'tempfile'
RSpec.describe FlickrCollage::FileLoader do
before do
FlickRaw.api_key = 'api_key'
FlickRaw.shared_secret = 'shared_secret'
allow_any_instance_of(FlickRaw::Flickr).to receive(:call).and_return([])
allow_any_instance_of(FlickRaw::Flickr).to receive_message_cha... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
NodeCount = 4
(1..NodeCount).each do |i|
config.vm.define "test#{i}" do |demo|
demo.vm.box = "centos/7"
demo.vm.hostname = "temp#{i}"
demo.vm.network "private_network", ip: "10.10.10.1#{i}"
demo.vm.network "forward... |
class Sprite < Draco::Component
attribute :path
attribute :flip_vertically, default: false
attribute :flip_horizontally, default: false
attribute :color, default: nil
attribute :source_w
attribute :source_h
attribute :source_x
attribute :source_y
end
|
module Orocos
module RemoteProcesses
# Representation of a remote process started with ProcessClient#start
class Process < ProcessBase
# The ProcessClient instance that gives us access to the remote process
# server
attr_reader :process_client
# A string describing the host. ... |
Locate the ruby documentation for methods File::path and File#path. How are they different?
Answer:
Both found here: https://ruby-doc.org/core-2.5.0/File.html#method-c-path
File::path returns the string representation of the path
File#path returns the pathname used to create file as a string |
class AddConstraintsToResearchUsers < ActiveRecord::Migration[5.2]
def change
add_index :research_users, [:user_id, :research_id], unique: true
end
end
|
require 'spec_helper'
describe TagsController, :type => :controller do
before(:each) do
c1 = FactoryGirl.create(:character, name: 'Sherlock Holmes')
c2 = FactoryGirl.create(:character, name: 'Catwoman')
c3 = FactoryGirl.create(:character, name: 'Bast')
c4 = FactoryGirl.create(:character, name: 'Batm... |
class CreateHeadachesExistingIllnessesJoinTable < ActiveRecord::Migration
def self.up
create_table :headaches_existing_illnesses, :id => false do |t|
t.references :headache, :existing_illness
end
end
def self.down
drop_table :headaches_existing_illnesses
end
end
|
class AddCommonToUsers < ActiveRecord::Migration
def change
add_column :users, :common, :boolean
end
end
|
require 'process/roulette/croupier/controller_socket'
module Process
module Roulette
module Croupier
# The JoinPending class encapsulates the handling of pending connections
# during the 'join' phase of the croupier state machine. It explicitly
# handles new player and new controller connectio... |
class TravelersController < ApplicationController
def index
@travelers = Traveler.all
end
def show
@traveler = Traveler.find(params[:id])
@favorite_countries = @traveler.vacations.where(favorite: true).map(&:country)
end
end |
# encoding: utf-8
describe Faceter::Coercers, ".prefix" do
subject { described_class[:prefix] }
it "coerces arguments" do
expect(subject[:foo]).to eql(
prefix: :foo,
separator: "_",
nested: false,
selector: nil
)
end
it "coerces arguments" do
attributes = subject[:foo, se... |
# encoding: UTF-8
require_relative 'Damage'
require_relative 'SpecificDamageToUI'
module Deepspace
class SpecificDamage < Damage
def initialize (wl, s) # wl: Array<WeaponType>, s: int
super(s)
@weapons = wl
end
attr_reader :weapons
def self.newCopy (d) # d... |
class ContactFormsController < ApplicationController
before_filter :authenticate_user!, :check_authorization, :except => [ :create ]
def new
@contact_form = ContactForm.new
end
def create
@contact_form = ContactForm.new( params[:contact_form] )
if verify_recaptcha( :model => @contact_form, :messa... |
require 'rails_helper'
describe 'User OAuth tokens' do
describe 'should be properly encrypted with the attr_encrypted gem' do
before do
@user = User.create(email: 'test01@test.com',
password: '123456',
password_confirmation: '123456')
end
it 's... |
#========================================================================
#
# init settings
#
#========================================================================
class Game_Config
attr_accessor :debug_info
attr_accessor :flag_output_info
attr_accessor :clean_output_data #... |
# -*- encoding: utf-8 -*-
# stub: image-inspector-client 2.0.0 ruby lib
Gem::Specification.new do |s|
s.name = "image-inspector-client".freeze
s.version = "2.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s... |
# frozen_string_literal: true
class AddIsPublishedToBooks < ActiveRecord::Migration[5.2]
def change
add_column :books, :is_published, :boolean, default: true
end
end
|
# frozen_string_literal: true
module Dotloop
class Authenticate
include HTTParty
base_uri 'https://auth.dotloop.com/oauth/'
attr_accessor :app_id
attr_accessor :app_secret
attr_accessor :application
def initialize(app_id:, app_secret:, application: 'dotloop')
@app_id = app_id
... |
class Splam::Rules::Fuzz < Splam::Rule
class << self
attr_accessor :bad_word_score
end
self.bad_word_score = 10
def run
patterns = [/^(\d[a-z])/, /(\d[a-z][A-Z]\w+)/, /(\b\w+\d\.txt)/, /(;\d+;)/ ]
ignore_if = [%r{vendor/rails}, /EXC_BAD_ACCESS/, /JavaAppLauncher/, %r{Contents/MacOS}, %r{/Library... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: thermostats
#
# id :bigint not null, primary key
# household_token :string not null
# location :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes... |
module Anticipate
module DSL
def trying_every(amount)
anticipation.trying_every(amount)
end
def failing_after(amount)
anticipation.failing_after(amount)
end
def sleeping(amount)
anticipation.sleeping(amount)
end
def default_tries
@default_tries ||= 1
end
... |
# encoding: UTF-8
namespace :omnisearch do
desc 'builds all indexes'
task build: :environment do
OmniSearch::Indexes.build
end
desc 'rebuilds all indexes, clears memcache'
task reindex: :environment do
OmniSearch::Indexes.destroy
OmniSearch::Indexes.build
OmniSearch::Cache.refresh
end... |
module Pages
class NewTodo
include Capybara::DSL
include Formulaic::Dsl
def initialize(attributes)
@attributes = attributes
end
def create
fill_form_and_submit :todo, attributes
end
private
attr_reader :attributes
end
end
|
class IssuesController < ApplicationController
def index
@client = Octokit::Client.new(access_token: ENV["github_token"])
@issues = @client.issues("#{ENV["org_name"]}/#{ENV["repo_name"]}", state: "all")
@projects = @client.org_projects(ENV["org_name"])
@project = @projects.first
@columns = @clien... |
# require 'scraperwiki'
require 'mechanize'
require File.dirname(__FILE__) + '/lib_icon_rest_xml/scraper'
starting_url = "https://www2.bmcc.nsw.gov.au/DATracking/Pages/XC.Track/SearchApplication.aspx"
case ENV['MORPH_PERIOD']
when 'lastmonth'
period = "lastmonth"
when 'thismonth'
period = "thismonth"
whe... |
require 'rails_helper'
describe League::Match::CommEdit do
before(:all) { create(:league_match_comm_edit) }
it { should belong_to(:comm).class_name('League::Match::Comm') }
it { should belong_to(:created_by).class_name('User') }
it { should validate_presence_of(:content) }
end
|
module Cosy
module Event
class Note
attr_accessor :pitch, :velocity, :duration, :channel
def initialize(pitch, velocity, duration, channel=nil)
@pitch, @velocity, @duration, @channel = pitch.to_i, velocity.to_i, duration.to_i, channel
end
def eql?(other)
... |
module Fog
module Google
class SQL < Fog::Service
autoload :Mock, File.expand_path("../sql/mock", __FILE__)
autoload :Real, File.expand_path("../sql/real", __FILE__)
requires :google_project
recognizes(
:app_name,
:app_version,
:google_application_default,
... |
class Groups::PostsController < GroupsController
before_action :find_group
before_action :check_privileges
def create
@post = current_user.posts.build(post_params)
@post.group = @group
respond_to do |format|
if @post.save
@posts = @group.posts.order('created_at DESC').paginate(page: par... |
require 'rails_helper'
module V1
RSpec.describe TargetsController, type: :controller do
describe 'GET #most_targeted' do
it 'returns a collection of targets' do
target = create :target, :with_club
get :most_targeted, format: :json
first = assigns(:targets)[:targets].first
... |
module Users
class UserRepository
UserNotFound = Class.new(StandardError)
attr_reader :adapter
def initialize adapter: Users::Model
@adapter = adapter
end
def create_user params
adapter.create(params)
end
def destroy_user id
user = adapter.find(id)
user.destroy
end
def fetch offset, ... |
#
# Be sure to run `pod lib lint TGLPullToRefresh.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'TGL... |
# Copyright © 2011-2019 MUSC Foundation for Research Development~
# All rights reserved.~
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~
# 1. Redistributions of source code must retain the above copyright notice, this l... |
require 'line/bot'
class Sugarcoat::BotController < BaseController
protect_from_forgery
def callback
case request.method_symbol
when :get
if params["hub.verify_token"] == "taptappun"
render json: params["hub.challenge"]
else
render json: "Error, wrong validation token"
en... |
class JobLiteSerializer < ActiveModel::Serializer
attributes :name, :environment
has_many :steps, serializer: JobStepLiteSerializer
def name
object.job_template.name
end
def environment
return nil unless object.environment
object.environment.each_with_object([]) do |env_vars, arr|
arr << ... |
module RailsAdmin
module Config
module Actions
class Delete < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :member do
true
end
register_instance_option :route_fragment do
'delete'
end
... |
require 'time'
require_relative './string/str_paint.rb'
# Returns foreground id for color given.
def get_fg(str)
return Color.get_t("fg")[str]
end
class Logger
@software_version = "v1.0"
@_24HourTime = Time.new.strftime("%H:%M")
def self.get_head()
return "[Logger #{@_24HourTime.to_s}]"
end
#TODO: Metaprogr... |
class Follower < ActiveRecord::Base
has_many :user_followers
has_many :users, through: :user_followers
end
|
require 'spec_helper'
describe ValidationsController do
describe '#last_digit_valid?' do
it 'should return a boolean' do
expect(ValidationsController.new.last_digit_valid?(9782895406976)).to eq(true||false)
end
it 'should return true if the last digit is valid ISBN' do
expect(ValidationsCon... |
require 'rails_helper'
feature 'User attmpts to create a paste', js: true do
context 'with valid attributes' do
scenario 'when clicking on the save button on the homepage' do
ruby_code = load_fixture 'ruby.rb'
visit root_path
fill_in 'Try some code', with: ruby_code
click_button(t('help... |
module Humble
class DefaultDataRowMapper
def initialize(configuration)
@configuration = configuration
end
def map_from(row)
result = @configuration.type.new
row.each do |key, value|
result.send("#{key}=", value)
end
result
end
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Tag do
let(:tag_object) { tag }
let(:subject) { described_class.new(tag_object) }
it 'should create a tag object' do
expect(subject).to be_kind_of(Tag)
end
it 'should have an id attribute' do
expect(subject.id).to be_truthy
end
... |
class CorrectFirstNameForUser < ActiveRecord::Migration[5.0]
def change
remove_column :users, :firts_name
add_column :users, :first_name, :text
end
end
|
class ApplicationMailer < ActionMailer::Base
default reply_to: Settings.mailer.default_reply_to, from: Settings.mailer.default_from, bcc: Settings.mailer.try(:bcc_email) || []
layout 'mailer'
end
|
class CreateCourses < ActiveRecord::Migration[5.2]
def change
create_table :courses do |t|
t.string :title
t.monetize :price
t.integer :status, null: false, default: 0
t.integer :period, null: false, default: 30
t.text :slug, index: { unique: true }
t.text :description
t.... |
colors = 'blue pink yellow orange'
if colors.include? 'yellow'
puts true
else
puts false
end
if colors.include? 'purple'
puts true
else
puts false
end
# Much easier and most simple way
# colors = 'blue pink yellow orange'
# puts colors.include?('yellow')
# puts colors.include?('purple') |
class AddInUser < ActiveRecord::Migration[6.1]
def change
add_column :users,'room_no','string'
add_column :users,'role','string'
end
end
|
require 'spec_helper'
module OCR
describe CheckSum do
Given(:checker) { CHECKER }
describe "#checksum" do
Then { checker.check_sum("000000000").should == 0 }
Then { checker.check_sum("777777777").should == 7 }
Then { checker.check_sum("123456789").should == 0 }
Then { checker.check... |
class Order < ActiveRecord::Base
has_many :line_items, dependent: :destroy
belongs_to :user
accepts_nested_attributes_for :line_items
validates :firstname, :lastname, :street_address, :city, :zipcode, :state, :country, :email, :user_id, :status, presence: true
validates :state, inclusion: ::STATES, if: :is_us... |
require 'test/unit'
require 'pp'
require 'miw/layout/box'
require 'miw/rectangle'
require 'miw/size'
require 'miw/view'
class Test_Layout_Box < ::Test::Unit::TestCase
def test_vbox_do_layout_item1_resize_both
box = MiW::Layout::VBox.new
items = [
[ MiW::Rectangle.new(0, 0, 100, 100), resize: [true, tr... |
def is_multiple_of_3_or_5?(i)
i % 3 == 0 || i % 5 == 0
end
p (0..999).inject { |sum, n| is_multiple_of_3_or_5?(n) ? n + sum : sum }
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# :nocov:
module GraphqlDoc
extend ActiveSupport::Concern
included do
swagger_controller :graphql, 'GraphQL'
swagger_api :create do
summary 'GraphQL interface'
notes 'Use this method in order to send queries to the GraphQL server'
param :query, :query, :string, :required, 'GraphQL query'... |
# code here!
class School
attr_reader :roster
def initialize(school)
@school = school
@roster = Hash.new { |h, k| h[k] = []}
end
def add_student(name, grade)
@roster[grade] << name
end
def grade(student_grade)
@roster[student_grade]
end
def sort
@roster.each { |grade, names| n... |
module Treasury
class DelayedIncrementJob
include Resque::Integration
queue :base
retrys
# Public: Отложенный инкремент поля
#
# params - Hash:
# 'object' - Integer идентификатор
# 'field_name' - String название поля
# 'field_class' - String класс... |
require 'rails_helper'
RSpec.describe 'Passenger show page', type: :feature do
before(:each) do
@airline = Airline.create!(name: "Delta")
@flight1 = @airline.flights.create!(number: "1727", date: "08-03-20", time: "3:30pm MST", departure_city: "Denver", arrival_city: "Reno")
@flight2 = @airline.flights.c... |
class Ranking < ActiveRecord::Base
belongs_to :option
belongs_to :user
end
|
Rails.application.routes.draw do
get "/user_recipes" => "user_recipes#index"
get "/user_recipes/new" => "user_recipes#new"
post "/user_recipes" => "user_recipes#create"
get "/user_recipes/:id" => "user_recipes#show"
get "/user_recipes/:id/edit" => "user_recipes#edit"
patch "/user_recipes/:id" => "user_recip... |
class GroupMembership < ApplicationRecord
belongs_to :user
belongs_to :group
# after_create :create_notifications
private
# def recipients
# membership = current_user.group_memberships
# groups = Group.where(language: self.card_set.language).to_set.superset?(self.to_set)
# recipients = User.w... |
class PagerGroupDestinationSerializer < ActiveModel::Serializer
embed :ids, :include => true
end
|
require 'csv'
require 'bigdecimal'
require_relative '../lib/invoice_item'
require_relative '../lib/modules/findable'
require_relative '../lib/modules/crudable'
class InvoiceItemRepository
include Findable
include Crudable
attr_reader :all
def initialize(path)
@all = []
create_items(path)
end
d... |
require 'socket'
module SocketSpecs
# helper to get the hostname associated to 127.0.0.1
def self.hostname
# Calculate each time, without caching, since the result might
# depend on things like do_not_reverse_lookup mode, which is
# changing from test to test
Socket.getaddrinfo("127.0.0.1", nil)[0]... |
Rails.application.routes.draw do
root 'books#index'
resources books, only: [:index, :new, :create]
resources authors, except: [:destroy]
end
|
#!/usr/bin/env ruby
#
# Author: z0mbix (zombie@zombix.org)
#
# Description:
# zup is a wrapper for unison to easily sync a directory recursively
# with a remote host usually over ssh.
#
# Requirements:
# unison, rsync, openssh, ruby
#
# Version: 0.1.1
#
require 'fileutils'
# Main user config file:
$CONFIG_FILE... |
#
# Cookbook Name:: chef_dotfiles
# Recipe:: default
#
node["dotfiles"]["users"].each do |username|
home_path = File.expand_path("~#{username}")
install_path = "#{home_path}/dotfiles"
git install_path do
repository node["dotfiles"]["repo"]
user username
group username
reference "master"
actio... |
class Booking < ApplicationRecord
belongs_to :pool
belongs_to :user
end
|
require 'eb_ruby_client/configuration'
RSpec.describe EbRubyClient::Configuration do
subject(:configuration) { EbRubyClient::Configuration.new }
before do
config_file_path = File.expand_path("../../../config/eventbrite.yml", __FILE__)
EbRubyClient::Configuration.config_file_path = config_file_path
end
... |
module SwProjectCustomerQnax
class RoleAccessRight < ActiveRecord::Base
attr_accessor :user_role_name
attr_accessible :action, :brief_note, :last_updated_by_id, :resource, :user_role_id, :processed,
:user_role_name,
:as => :role_new
attr_accessible :action, :brief_n... |
require 'rails_helper'
RSpec.describe Stock, type: :model do
context 'when defining the model' do
it { is_expected.to belong_to :product }
it { is_expected.to validate_presence_of :amount }
end
context 'when saving the model' do
subject(:stock) { create(:stock) }
it 'saving a valid stock' do
... |
require("spec_helper")
describe(Store) do
it{ should have_and_belong_to_many(:brands) }
it { should validate_presence_of(:name) }
describe('#capitalize_name') do
it "capitalizes the name of a store" do
store = Store.create({:name => "demo store"})
expect(store.name()).to (eq("Demo store"))
en... |
class Poll < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :micropost_id, :poll_type, :question
# Associations
belongs_to :micropost
has_many :proposals
# Validations
validates_presence_of :poll_type
validates_presence_of :question
validates_presence_of :micropost_id
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.