text stringlengths 10 2.61M |
|---|
# 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... |
module CJSV
class RenderLineParser
def initialize(line, spaces_per_indent, cjsv_instance)
@line = line
@spaces_per_indent = spaces_per_indent
@debug = true
@cjsv_instance = cjsv_instance
parse
end
def indentation
@indentation
end
def line
@line
end
... |
require 'rails_helper'
describe StructureListGrouper do
let!(:measure_selection) { create(:measure_selection) }
let!(:structure_type) do
create(:structure_type, name: 'Lighting', api_name: 'lighting')
end
let!(:structure_type_definition) do
instance_double(
StructureTypeDefinition,
grouping... |
#!/usr/bin/env ruby
TICKET_REGEXP = /[A-Z]+-\d+/ # WEB-12345
TIME_REGEXP = /\d+[.]+\d+h/ # 0.5h, 2.0h
commit_message = File.open(ARGV[0], 'r') do |f|
f.read
end
unless commit_message.match(TICKET_REGEXP)
puts "[ERROR] commit-message-format: JIRA ticket number is not existed."
exit(1)
end
unless commit... |
Rails.application.routes.draw do
root 'application#welcome'
resources :sessions, :users
end
|
# encoding:UTF-8
require 'uri'
require 'pathname'
require 'csv'
require_relative 'config/environment.rb'
require_relative 'lib/workers/http_tool.rb'
require_relative 'lib/workers/sreality.rb'
dt_start = Time.now
puts "Start time: #{dt_start}"
requests_per_second = 50
dt = DateTime.now - 1.minutes
@http_tool = HttpToo... |
#-*- mode: ruby -*-
# vi: set ft=ruby :
ms_jmx_port = 1099
router_jmx_port = 1100
mp_jmx_port = 1101
ingest_jmx_port = 1102
pgserver_jmx_port = 1103
pg_db_port = 5432
zk_jmx_port = 2181
cassandra_jmx_port = 7199
ms_http_port = 8080
router_self_port = 8081
mp_self_port = 8082
qpid_self_port = 8083
pgserver_self_port = ... |
class UsersController < ApplicationController
def index
end
def show
get_user
end
def edit
get_user
end
def update
get_user
if @user.update_attributes(user_params)
redirect_to user_path(@user)
else
redirect_to root_path, notice: "Couldn't save settings"
end
end
def destroy
end
def new... |
module APICoder
module Commands
class InstallPlugin < Thor::Group
argument :plugin_name
include Thor::Actions
source_root File.expand_path('../templates', __FILE__)
def create_config_file
begin
require "api_coder/#{plugin_name}"
rescue LoadError
raise... |
# frozen_string_literal: true
# https://adventofcode.com/2019/day/6
require 'pry'
require './boilerplate'
class Planet
attr_accessor :name, :parent, :children
def initialize(name)
@name = name
@children = []
end
def orbits
parent.nil? ? 0 : parent.orbits + 1
end
def parent?(planet)
... |
class EventsController < ApplicationController
before_action :set_params, only: [:index, :more_events]
def index
api_token = ApiToken.find_by(platform: 'meetup')
begin
if api_token.present?
if api_token.expire_on > Time.now
events = RestClient.get "https://api.meetup.com/#{Settings.... |
class User < ApplicationRecord
include Recommendation
include PublicActivity::Model
tracked
store :settings, accessors: [:birthday, :personal_activity], coder: JSON
has_one_attached :avatar
has_many :user_books
has_many :books, through: :user_books
has_many :lists, dependent: :destroy
has_many :user_... |
class AddFieldsToRepository < ActiveRecord::Migration
def change
change_table :repositories do |t|
t.column :address_1, :string
t.column :address_2, :string
t.column :city, :string
t.column :state, :string
t.column :zip, :string
t.column :phone_number, :string
t.column :e... |
class SessionController < ApplicationController
def create
if open_id?(params[:name])
open_id_authentication(params[:name])
else
password_authentication(params[:name], params[:password])
end
end
protected
def password_authentication(name, password)
if @curren... |
class Columbus
class Feed < Struct.new(:url, :title)
attr_accessor :body
def initialize(*args)
super(*args)
determine_feed_endpoint
end
def determine_feed_endpoint
response = RedirectFollower.new(url).resolve
self.url = response.url
self.body = response.body
... |
class Image < ApplicationRecord
belongs_to :image_type, polymorphic: true
end |
class UsersController < ApplicationController
before_filter :authenticate_user!
after_action :verify_authorized
def index
@users = User.all.where(deleted: false)
authorize User
end
def show
@user = User.find(params[:id])
authorize @user
end
def new
@user = User.new
authorize Use... |
module SpecSupport
module Cars
def fetch_car_brand(index)
all('.car')[-index].find("h2").text
end
def last_car_brand
fetch_car_brand(1)
end
def second_to_last_car_brand
fetch_car_brand(2)
end
def third_to_last_car_brand
fetch_car_brand(3)
end
def fetch_c... |
require "./poker-dice.rb"
describe Die do
describe "#roll" do
it "returns a face value" do
expect(Die.new.roll.length).to eq 1
end
it "returns a string" do
expect(Die.new.roll.class).to eq String
end
it "returns one of the available face values" do
expect(Die.new.roll).to mat... |
class FavoriteSport < ApplicationRecord
belongs_to :user
belongs_to :sport
validates :sport, presence: true
validates :level, presence: true
end
|
class ChangeBeans < ActiveRecord::Migration
def up
add_column :beans, :user_id, :integer
rename_column :beans, :is_checkout, :redeemed
end
def down
end
end
|
class CreateBusinesses < ActiveRecord::Migration[5.2]
def change
create_table :businesses, comment: "業務" do |t|
t.string :name, null:false, comment: "業務タイトル"
t.string :description, null:false, comment: "詳細内容"
t.string :welcome, null:false, comment: "歓迎技術者"
t.references :office, foreign_key... |
# coding: utf-8
module Typus
class << self
def root
File.dirname(__FILE__) + "/../"
end
def locales
{ "ca" => "Català",
"de" => "German",
"en" => "English",
"es" => "Español",
"fr" => "Français",
"hu" => "Magyar",
"pt-BR" => "Portuguese... |
# frozen_string_literal: true
class ChangeSchoolsCodeColumnLength < ActiveRecord::Migration[4.2]
def change
change_column :schools, :code, :string, :limit => 32
end
end
|
require "rails_helper"
RSpec.describe RegisteredPatientsQuery do
let(:user) { create(:user) }
it "counts hypertensive registered patients by period" do
facility = create(:facility)
other_facility = create(:facility)
user1 = create(:user)
user2 = create(:user)
Timecop.freeze("April 15th 2020") ... |
class CopyrightFullService < ExperimentService
PAIR_SIZE = 17 * 3 * 2 # (Full + Melody + Lyrics) * Random
class << self
def create(options)
DB.transaction do
exp = Experiment.create(
username: options['username'],
model: 'CopyrightFullEntry',
)
PAIR_SIZE.times.... |
require 'ncs_navigator/configuration'
module NcsNavigator::Authorization::Core
class Authority
attr_reader :logger
attr_reader :staff_portal_uri
attr_reader :staff_portal_user
attr_reader :staff_portal_password
def initialize(options = {})
@logger = options[:logger] || Logger.new($stderr)
... |
require 'rails_helper'
RSpec.describe Friend, type: :model do
it { should be_activitable }
it { should be_accompaniable }
it { should be_experienceable }
it { should be_learnable }
it { should have_many :activities }
it { should have_many :accompaniments }
it { should have_many :experiences }
it { sho... |
require 'facter'
Facter.add(:shortdcname) do
setcode do
location = Facter.value(:hostname)[1]
case location
when '1' then shortdcname = 'd1'
when '3','gl' then shortdcname = 'd3'
else 'unknown'
end
end
end
|
class CreateCustomers < ActiveRecord::Migration
def change
create_table :customers do |t|
t.string "first_name", :null => false
t.string "last_name", :null => false
t.string "addrStreet1"
t.string "addrStreet2"
t.string "addrCity"
t.string "addrState"
t.string "addrZip"
... |
# frozen_string_literal: true
require 'rails_helper'
# These tests will fail if the test database is rebuilt using db:schema:load
# To fix, run the following from the command line:
# rails db:structure:load RAILS_ENV=test
RSpec.describe 'Visit the best efforts page and search for an effort' do
let(:course) { cour... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cancancan/active_graph/version'
Gem::Specification.new do |spec|
spec.name = 'cancancan-activegraph'
spec.version = CanCanCan::ActiveGraph::VERSION
spec.authors = ['Am... |
class UserGroup < ActiveRecord::Base
attr_accessible :user_id, :group_id
belongs_to :user
belongs_to :group
attr_accessible :edit, :manage, :read
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
layout :layout_by_resource
# API authentication
# http://soryy.com/blog/2014/apis-with-devise/
protect_from_forgery with: :null_sess... |
class CreatePageDesigns < ActiveRecord::Migration
def change
create_table :page_designs do |t|
t.references :site
t.references :folder
t.text :stylesheet
t.string :header_image_file_name
t.string :header_image_content_type
t.integer :header_image_file_siz... |
require "rails_helper"
describe PatientStates::Hypertension::ControlledPatientsQuery do
around do |example|
with_reporting_time_zone { example.run }
end
let(:regions) { setup_district_with_facilities }
let(:period) { Period.current }
describe "#call" do
it "returns all the controlled patients in a ... |
require 'lib/watir-or.rb'
require 'spec_helper'
describe "Read xml-repository" do
before(:all) do
@repository = ObjectRepository::Repository.new("spec/test.xml", BrowserStub.new)
end
it "element with one attribute was readed" do
one = ObjectRepository::RepositoryElement.new("one attribute", "text_field"... |
class CreateProjectGuests < ActiveRecord::Migration
def self.up
create_table :project_guests do |t|
t.integer :guest_id
t.integer :project_id
t.boolean :status,:default=>true
t.timestamps
end
add_index "project_guests", :guest_id
add_index "project_guests", :project_id
end
... |
require 'lims-api/resources/container'
require 'lims-api/core_resource'
require 'lims-api/struct_stream'
require 'lims-laboratory-app/laboratory/tube_rack'
module Lims::LaboratoryApp
module Laboratory
class TubeRack
class TubeRackResource < Lims::Api::CoreResource
include Lims::Api::Resources::Con... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe RequirementsController, 'when integrating' do
integrate_views
before :each do
@requirement = Requirement.generate!
end
describe 'create' do
def do_request
post :create, :requirement => @requirement.attributes
end
... |
class ApplicationController < ActionController::Base
before_action :authentication_required
skip_before_action :authentication_required, only: [:welcome]
protect_from_forgery with: :exception
helper_method :current_user, :logged_in?, :contact_to_relationship, :error_msg
def logged_in?
!!session[:user_id]
end... |
include Support::Php
require 'features/php_interpreter_spec'
describe 'php environment', dev: true do
describe phpcommand('php-fpm --version') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/^PHP \d+\.\d+\.\d+.+fpm-fcgi/) }
end
describe phpcommand('php -m --version') do
# Running ... |
require "rails_helper"
module RequestsHelper
def self.prepare_requests
# Usuwamy wszystkie obiekty, klasa po klasie
User.all.destroy_all
Movie.all.destroy_all
Topic.all.destroy_all
Post.all.destroy_all
# Tworzymy nowego usera, zapisujemy go i uzyskujemy token
user = User.new(
index... |
require_relative "board"
require_relative "opponents"
def menu
puts <<-HERE
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
MAIN MENU
/////////////////////////////... |
# frozen_string_literal: true
require 'date'
module IndieLand
module MinistryOfCulture
# Data Mapper
class MusicEventsMapper
def initialize(gateway_class = MinistryOfCulture::MusicApi)
@gateway_class = gateway_class
@gateway = @gateway_class.new
end
def find_events
... |
class Source < ActiveRecord::Base
has_many :facts, dependent: :destroy
ORIG_SOURCE_OPTIONS = ["No", "Yes"]
accepts_nested_attributes_for :facts, allow_destroy: true, reject_if: lambda { |a| a[:fact_text].blank? }
end
|
module Ricer::Plug::Params
class VariableParam < StringParam
def convert_in!(input, message)
super(input, message).to_sym
end
end
end
|
require 'concerns/intervalable'
class Spree::SubscriptionInterval < ActiveRecord::Base
include Intervalable
attr_accessible :name
has_many :spree_subscription_interval_products,
class_name: 'Spree::SubscriptionIntervalProduct', dependent: :destroy
has_many :products,
through: :spree_subscription_inte... |
class ContactsController < ApplicationController
require 'nokogiri'
require 'open-uri'
before_action :set_contact, only: [:show, :edit, :update, :destroy]
def index
@contacts = current_user.contacts.order("created_at desc").page(params[:page])
# @contacts = Contact.all.order("created_at desc").page(par... |
# == Schema Information
#
# Table name: team_bowlers
#
# id :integer not null, primary key
# total_games :integer
# total_pins :integer
# bowler_id :integer
# bowling_team_id :integer
#
class TeamBowler < ApplicationRecord
end
|
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
include TokyoCabinet
describe QuotientCube::Tree::NodeManager do
before(:each) do
@tempfile = Tempfile.new('database')
@database = TokyoCabinet::BDB.new
@database.open(@tempfile.path, BDB::OWRITER | BDB::OCREAT)
@tree = Quotie... |
require_relative '../lib/cli.rb'
require 'colorize'
RSpec.describe Cli do
xdescribe '#call_api' do
let(:test) {Cli.new}
it 'it expects a string ' do
string = "New York"
result = test.call_api(string)
expect(result).to be true
end
end
xdescribe '#... |
class Customer < ApplicationRecord
validates :first_name, presence: true
validates :email, uniqueness: { scope: :customer_id, message: "should be unique per customer" }
validates :phone, uniqueness: { scope: :customer_id, message: "should be unique per customer" }
class << self
def import_data(csv_text)
... |
require 'rails_helper'
RSpec.describe 'Challenges', type: :request do
# Initialise sample data
let!(:challenges) { create_list(:challenge, 10) }
let(:challenge_id) { challenges.first.id }
# Tests for :index
describe 'index request' do
before { get '/challenges' }
it 'returns JSON' do
expect(j... |
#!/usr/bin/env ruby
# encoding: UTF-8
require 'sinatra'
require 'json'
require 'sqlite3'
require 'yaml'
require "active_record"
require File.join(File.expand_path(File.dirname(__FILE__)), "lib", 'configured_connection')
require File.join(File.expand_path(File.dirname(__FILE__)), "lib", 'stat_data')
require File.join(... |
require "helpers/test_helper"
class UnitTestMonitoringCollections < MiniTest::Test
def setup
Fog.mock!
@client = Fog::Monitoring.new(provider: "google",
google_project: "foo")
# Exceptions that do not pass test_common_methods:
#
# TimeSeries API has no 'get' met... |
class AddPaymentHistoryBalanceCol < ActiveRecord::Migration
def up
add_column :payment_histories, :balance, :decimal , :default => 0.0
end
def down
remove_column :payment_histories, :balance
end
end
|
class ListProduct < ApplicationRecord
belongs_to :list
belongs_to :product
enum status: { added: 1, removed: 2, purchased: 3 }
validates :quantity, numericality: { only_integer: true }
end
|
class SearchGeininByIndexService
def initialize(index_param)
@index = index_param
end
def execute
case @index
when 'a' then
@indexes = "あ%","い%","う%","え%","お%"
when 'ka' then
@indexes = "か%","き%","く%","け%","こ%","が%","ぎ%","ぐ%","げ%","ご%"
when 'sa' then
@indexes = "さ%","し%",... |
class Live::EventGroupsController < Live::BaseController
before_action :set_event_group
def live_entry
authorize @event_group
@presenter = EventGroupPresenter.new(@event_group, params, current_user)
verify_available_live(@event_group)
render :new_live_entry
end
private
def set_event_group
... |
require 'spec_helper'
module MWS
describe XML do
describe '.to_hash' do
subject do
str = <<-XML.gsub!(/>\s+</, '><').strip!
<?xml version=\"1.0\" ?>
<ItemAttributes>
<Title>Anti-Oedipus</Title>
<Author>Gilles Deleuze</Author>
<Author>Felix Guattari</Aut... |
# require 'minitest'
# require 'minitest/autorun'
# require 'chawk'
require 'test_helper'
ts1 = [
['A', 100], ['B', 99], ['C', 95], ['D', 50],
['E', 45], ['F', 30], ['G', 29], ['H', 28]]
ts2 = [
['A', 100], ['B', 85], ['C', 80], ['D', 71],
['E', 70], ['F', 30], ['G', 29], ['H', 28]]
# Temporary harness for qu... |
#===============================================================================
# * Game_Projectile
#-------------------------------------------------------------------------------
# Projectiles in the game, game cannot be saved if any projectile exist
#===============================================================... |
require 'test_helper'
class CmasControllerTest < ActionController::TestCase
setup do
@cma = cmas(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:cmas)
end
test "should get new" do
get :new
assert_response :success
end
test "shoul... |
class CreateNovels < ActiveRecord::Migration[5.0]
def change
create_table :novels do |t|
t.text :sentence
# 外部キー制約
t.references :user, foreign_key: true
t.string :title
t.timestamps
end
end
end
|
# frozen_string_literal: true
require 'rake'
require './rake_extensions.rb'
EXE_NAME = 'enforcer'
HOME = ENV['HOME']
task :default do
puts 'no default task'
create_changelog
end
desc 'Check'
task :check do
sh 'cargo +nightly fmt -- --color=always --check'
sh 'cargo clippy'
sh 'cargo test'
end
desc 'run t... |
class Setting < ApplicationRecord
validates :name, presence: true, uniqueness: true
before_save :generate_slug
def content
saved_content.blank? ? fallback : saved_content
end
def generate_slug
self.slug = name.to_slug.gsub("-", "_")
end
end
|
module Guard
class Jasmine
# The inspector verifies if the changed paths are valid
# for Guard::Jasmine. Please note that request to {.clean}
# paths keeps the current valid files cached until {.clear} is
# called.
#
module Inspector
class << self
# Clean the changed paths and ... |
#!/usr/bin/env ruby
require 'date'
USAGE = <<EOS
Usage: #{$PROGRAM_NAME} <license-file> <code-file> [output-file]
Replaces existing license header, prepends if no license header present, no
changes if license up to date. If no output file is provided, the code file
will be overwritten.
EOS
# The license recognition... |
class AddStoreToOrders < ActiveRecord::Migration[6.0]
def change
add_reference :orders, :store
end
end
|
# @param content [String]
def normalize_content(content)
content.sub /^\!\w+\W/, ''
end
|
class AgendasController < ApplicationController
def index
@agendas = Agenda.all
end
def new
@agenda = Agenda.new
end
def create
Agenda.create(agenda_params)
redirect_to root_path
end
private
def agenda_params
params.require(:agenda).permit(:place, :location, :date)
end
end
|
# 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... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SessionsController, type: :controller do
describe 'GET #new' do
describe 'when user is logged in' do
let(:current_user) { create(:user) }
before(:each) do
session[:user_id] = current_user.id
get :new
end
... |
class ArtworkSharesController < ApplicationController
def create
viewer = User.find(params[:artwork_share][:viewer_id])
artwork = Artwork.find(params[:artwork_share][:artwork_id])
if viewer && artwork
share = ArtworkShare.new(artwork_share_params)
end
if share.sa... |
require 'formula'
class Tinycdb < Formula
homepage 'http://www.corpit.ru/mjt/tinycdb.html'
url 'http://www.corpit.ru/mjt/tinycdb/tinycdb-0.78.tar.gz'
sha1 'ade42ee1e7c56f66a63cb933206c089b9983adba'
def install
system "make"
system "make", "install", "prefix=#{prefix}", "mandir=#{man}"
end
end
|
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# render new.rhtml
def new
if Member.count == 0
redirect_to "/signup"
end
end
def create
self.current_member = Member.authenticate(params[:username], params[:password])
if l... |
require 'cells_helper'
RSpec.describe AdminArea::People::Cell::Balances do
let(:person) { Person.new(id: 123, first_name: 'Erik') }
include ActionView::Helpers::NumberHelper
let(:rendered) { cell(person).() }
example 'when the person has no balances' do
expect(rendered).not_to have_selector 'h3', text: '... |
json.array!(@piece7s) do |piece7|
json.extract! piece7, :id, :name, :user_id
json.url piece7_url(piece7, format: :json)
end
|
# == Schema Information
#
# Table name: pins
#
# id :bigint(8) not null, primary key
# motherboard_id :bigint(8)
# topic_id :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Pin < ApplicationRecord
belongs_to :motherboard
def as_... |
class Student
attr_reader :name, :age, :scores
def initialize(student_info)
@name = student_info[:name]
@age = student_info[:age]
@scores = []
end
def log_score(score)
if score.class == Integer
@scores << score
else
puts "scores must be an integer"
end
return @scores
... |
Rails.application.routes.draw do
#homes
root 'homes#top'
get 'homes/about' => "homes#about"
#devise
devise_for :publics
devise_for :admins, controllers: {
sessions: 'admins/sessions'
}
namespace :public do
#住所
resources :addresses, only: [:index, :create, :edit, :update, :destroy]
#カ... |
class PropertyType < ApplicationRecord
has_many :properties
validates :name, presence: { message: 'não pode ficar em branco' }
validates :name, uniqueness: { message: 'tem de ser único' }
end
|
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), "spec_common"))
require 'bindata/stringz'
describe BinData::Stringz, "when empty" do
its(:value) { should == "" }
its(:num_bytes) { should == 1 }
its(:to_binary_s) { should == "\0" }
end
describe BinData::Stringz, "with value set" d... |
class User < ActiveRecord::Base
has_secure_password
belongs_to :role
#before_create :set_role
Roles = [:cliente, :asesor, :admin]
def role?(role_name)
role = Role.find_by(name: role_name)
self.role_id == role.id
end
end
|
class AddRoomcodeToGameRooms < ActiveRecord::Migration[6.0]
def change
add_column :game_rooms, :roomcode, :string
end
end
|
class User < ApplicationRecord
has_and_belongs_to_many :categories, dependent: :destroy
has_many :active_relationships, class_name: Relationship.name,
foreign_key: "follower_id", dependent: :destroy
has_many :passive_relationships, class_name: Relationship.name,
foreign_key: "followed_id", dependent: :des... |
require 'rack-proxy'
class ServiceProxy < Rack::Proxy
def initialize(app)
@app = app
end
def call(env)
original_host = env["HTTP_HOST"]
rewrite_env(env)
if env["HTTP_HOST"] != original_host
status, headers, response = perform_request(env)
headers.delete "transfer-encoding"
[st... |
Gem::Specification.new do |s|
s.name = 'rsence'
s.authors = [ 'Riassence Inc.', 'Juha-Jarmo Heinonen' ]
s.email = 'info@rsence.org'
s.version = File.read('VERSION')
s.date = Time.now
s.homepage = 'http://www.rsence.org/'
s.rubyforge_project = 'rsence-'
s.license = 'MIT'
prereleas... |
class MailerWorker
include Sidekiq::Worker
def perform(email)
UserMailer.send_report_card(email).deliver_now
end
end
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe LogParser do
subject { described_class.new(file) }
let(:file) { File.read("./spec/fixtures/webserver.log") }
it "takes a file" do
expect {
described_class.new
}.to raise_error(ArgumentError)
end
it "stores a file" do
... |
class Splam::Rules::Bbcode < Splam::Rule
def run
add_score 10 * @body.scan("showpost.php?p=").size, "Linking to a shitty forum"
# add_score 10 * @body.scan("\r\n").size, "Poorly formed POST (\\r\\n)"
add_score 80 * @body.scan(/\n\[url.*?\]\n/).size, "Shitty bbcode url covers entire line"
add_score 40... |
class Api::MembershipsController < ApplicationController
def index
@memberships = Membership.all
render :index
end
def create
@membership = Membership.new(membership_params)
if @membership.save
render :show
else
end
end
private
def membership_params
params.require(:me... |
class AddCustomerIdToAppointments < ActiveRecord::Migration
def change
add_column :appointments, :customer_id, :integer
add_index :appointments, :customer_id
end
end
|
require_relative './pack'
module Schema
class OrderItem < Base
attribute :quantity, Integer
attribute :currency, String, default: "$"
attribute :pack_id, String
attribute :pack, Pack
attribute :amount, Decimal, default: 0.00
end
end
|
# ==========================================================================
# Project: Lebowski Framework - The SproutCore Test Automation Framework
# License: Licensed under MIT license (see License.txt)
# ==========================================================================
module Lebowski
module Foundat... |
module Thing::Cell
class Index < Trailblazer::Cell
include ActionView::RecordIdentifier
private
def new_thing_link
link_to 'New thing', new_thing_path
end
end
end
|
require 'open-uri'
# 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 t... |
require 'spec_helper'
describe "Stage" do
describe "Home page" do
it "should have the content 'Welcome home'" do
visit '/home'
expect(page).to have_content('Welcome')
end
it "should have the content 'Home' " do
visit '/home'
expect(page).to have_title("Home")
end
end
#CAU... |
require File.expand_path("../helper", __FILE__)
class TestConnect < Test::Unit::TestCase
context "Sauce Connect" do
should "be running when ready" do
connect = Sauce::Connect.new(:host => "saucelabs.com", :port => 80)
assert_equal "uninitialized", connect.status
connect.wait_until_ready
a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.