text stringlengths 10 2.61M |
|---|
require_relative 'moves'
# Class for Queen objects of both colours
class Queen
include Moves
attr_accessor :symbol, :colour, :position
# The position will look like [5,6] which represents row 5 and column 6
def initialize(colour, position)
@colour = colour
@position = position
if @colour == :white
@sym... |
# == Schema Information
#
# Table name: bowler_sets
#
# id :integer not null, primary key
# absent_score :integer
# ending_avg :integer
# handicap :integer
# starting_avg :integer
# this_avg :integer
# created_at :datetime not null
# updated_at :datetime not null... |
module Adminpanel
class AdminpanelFormBuilder < ActionView::Helpers::FormBuilder
include ApplicationHelper
alias_method :text_field_original, :text_field
alias_method :radio_button_original, :radio_button
alias_method :text_area_original, :text_area
alias_method :password_field_original, :password... |
class ScenesController < ApplicationController
include ImportHelper
include ScenesHelper
layout 'admin'
before_filter :authenticate_user!, except: [:preview, :data, :simple_script]
add_breadcrumb 'Scenes', :scenes_path
load_and_authorize_resource except: [:index, :create, :import]
before_filter :load_breadcrumb... |
require 'spec_helper'
class ExistMethodClass
include ::ActiveRemote::Cached
def self.find; nil; end
def self.search; nil; end
cached_finders_for :guid
cached_finders_for :guid, :user_guid
cached_finders_for [:user_guid, :client_guid]
cached_finders_for [:derp, :user_guid, :client_guid]
end
describe Ex... |
#
# Be sure to run `pod spec lint VMessaging.podspec --sources='git@github.com:Vonage/PrivateCocoapodsSpecs.git,https://github.com/CocoaPods/Specs' --verbose --use-libraries' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attribu... |
class UserService < ModelService
def initialize(serviceable)
type = serviceable.class.to_s
@var = "@user"
self.instance_variable_set(@var, serviceable)
end
def profile_views_by_day_for_the_last_30_days
ActiveRecord::Base.connection.select_all("SELECT date(d.datetime) AS date, COUNT(p.user_id)... |
SUBSTANCE_TEMPERATURES = {
'water' => { melting_point: 0, boiling_point: 100 },
'ethanol' => { melting_point: -114, boiling_point: 78.37 },
'gold' => { melting_point: 1064, boiling_point: 2700 },
'silver' => { melting_point: 961.8, boiling_point: 2162 },
'copper' => { melting_point: 1085, boilin... |
module Midishark
class Config
attr_reader :instruments
def initialize
parser Midishark::Parser::Basic
transformer Midishark::Transformer::MappedClient
outputter Midishark::Outputter::Streamy
@instruments = []
end
# Public: sets/gets the tshark command to run when the `midish... |
# frozen_string_literal: true
# The four adjacent digits in the 1000-digit number that have the greatest product
# are 9 x 9 x 8 x 9 = 5832.
BIG_NUMBER =
%w[
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208... |
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'rubygems'
require 'fssm'
require 'grit'
# Setup default path
@@repo_folder = "./repositories" # no trailing /
# Check arguments, only 1 allowed: path to repos
ARGV.each do|a|
@@repo_folder = a
end
# Strip last / if there is one
if(@@repo_folder[-1,1] =... |
require 'rails_helper'
RSpec.describe Song, type: :model do
it { should validate_presence_of(:video) }
it { should validate_presence_of(:title) }
it { should validate_presence_of(:artist) }
it { should validate_presence_of(:year) }
it { should validate_presence_of(:album) }
end
|
require 'spec_helper'
describe User do
before do
stub(LdapClient).enabled? { false }
end
describe ".authenticate" do
let(:user) { users(:default) }
it "returns true if the password is correct" do
User.authenticate(user.username, 'password').should be_true
end
it "returns false if the... |
class Api::ContributedConversations
def self.for_person_by_id(person_id, request)
person = Person.find(person_id)
if person
conversations = person.contributed_conversations.order('created_at DESC')
conversations.map do |conversation|
conversation = ConversationPresenter.new(conversation,... |
require "rails_helper"
describe "Calls Query API", :graphql do
describe "calls" do
let(:query) do
<<-'GRAPHQL'
query($missed: Boolean) {
calls(missed: $missed) {
edges {
node {
id
}
}
}
}
GRAPHQL
... |
require "./spec/spec_helper"
RSpec.describe InvoiceItem, type: :model do
describe 'validations' do
it {should validate_presence_of :quantity}
it {should validate_presence_of :unit_price}
end
describe 'relationships' do
it { should belong_to :invoice }
it { should belong_to :item }
end
descr... |
module OfferHelper
def progress_bar_percentage(offer)
current = offer.stock - offer.remaining
total = offer.stock.to_f
total = ((current / total) * 100).to_i
[0, [100, total].min].max
end
end
|
class AddProviderAndReceiverOrgToTransactons < ActiveRecord::Migration[6.0]
def change
add_reference :transactions, :provider, type: :uuid
add_reference :transactions, :receiver, type: :uuid
end
end
|
FactoryBot.define do
factory :orga do
title {"title#{rand(0..10000)}"}
description { 'this is a description of this orga' }
short_description { 'this is the short description' }
area { 'dresden' }
parent_orga { Orga.root_orga }
locations { [build(:location)] }
contacts { [build(:contact... |
class PaymentcashesController < ApplicationController
load_and_authorize_resource
# GET /paymentcashes
# GET /paymentcashes.json
def index
@paymentcashes = Paymentcash.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @paymentcashes }
end
end
# GET ... |
Rails.application.routes.draw do
resources :cars
resources :people
resources :posts
root 'pages#index' # This is my default homePage. By adding root we made it so. We removed get and added root cuz we dont want to have more thant one url for each page
# For details on the DSL available within this file, see ... |
class BookingsController < ApplicationController
before_action :set_booking, only: [ :destroy, :update, :edit ]
def index
@bookings = Booking.all.sort_by &:start
end
def create
@booking = Booking.new(booking_params)
if @booking.save
flash[:success] = "Booking has been created for room #{@bo... |
require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + '/../lib/couchy'
describe Couchy do
before(:each) do
@couch_rest = Couchy.new(CouchHost)
@database = @couch_rest.database(TestDatabase)
end
after(:each) do
begin
@database.delete!
rescue RestClient::ResourceNo... |
FactoryBot.define do
factory :round, class: Round do
association :tournament, factory: :tournament
sequential_number { 1 }
end
end
|
# == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# letter_opener_web /letter_opener LetterOpenerWeb::Engine
# new_user_session GET /users/sign_in(.:format) devise/sessions#new
# user_session POST /users/sign_... |
#!/usr/bin/env ruby
# Copyright (c) 2016 ActiveState Software Inc.
# DBGP client for debugging Ruby 2.x.
#
# This client is a stand-alone Ruby application that directly debugs client code
# via the Byebug debugger while communicating with an IDE. There are two ways
# the IDE (or user) can use this client:
# (1) Envo... |
class Doctor::PrescriptionsController < ApplicationController
layout 'doctor_layout'
skip_before_action :verify_authenticity_token
before_filter :require_doctor_signin
def show
@consult = Consult.find(params[:consult_id])
@prescription = Prescription.find(params[:id])
end
def download
@prescri... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: attendances
#
# advised :boolean default(FALSE)
# advised_at :timestamptz
# badge_name :string(255)
# city :string(255)
# country :string(255)
# created_at ... |
require 'test_helper'
class CustomerTest < ActiveSupport::TestCase
fixtures :customers
def test_name
customer = Customer.create(:username => 'Administrator',
:first_name => 'Malcolm',
:last_name => 'Clarke')
assert_equal 'Malcolm Clarke', customer.name
end
end |
# Pseudo
# 1. Create Node representing each cell
# 2. Store possible routes from each cell, as edge, on each cell
# 3. Store all nodes, with reference to their coordinate
# 4. Use Dijkstra's to determine shortest path to each cell
# 5. Output data, based on coordinate
#
# Notes:
# All edges will have a cost of 1, so ... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :house do |house|
style House::STYLE.sample
dwelling_type House::DWELLING_TYPE.sample
living_area "Vanier"
square_footage 1500
bedrooms 3
bathrooms 2
year_built 3.years.ago.to_date
prop... |
ROM::SQL.migration do
change do
create_table :matches do
primary_key :id, type: :Bignum
foreign_key :home_team_id, :teams, type: :Bignum, null: false
foreign_key :away_team_id, :teams, type: :Bignum, null: false
column :home_team_goals, Integer
column :away_team_goals, Integer
... |
# encoding 'utf-8'
require_relative 'pb_redis'
require 'mongo'
require 'yaml'
Mongo::Logger.logger.level = ::Logger::WARN
class PBMongo
def initialize
path = __dir__
yml_path = path + '/config.yml'
config = YAML.load_file(yml_path)
usr = ENV['MONGO_USR']
pass = ENV['MONGO_PASS']
m_array = c... |
# 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... |
=begin
https://www.codewars.com/kata/546f922b54af40e1e90001da
=end
# my solution
def alphabet_position(text)
key = Hash.new('')
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
alphabet.each_with_index{|x, i| key[x] = i ... |
class HumanPlayer
attr_reader :color
def initialize(color)
@color = color
end
def play_turn(board)
puts board.render
puts "Current player: #{color}"
from_pos = get_pos('From pos:')
m_seq = translate_sequence(get_pos('Move sequence'))
board.perform_moves(color, from_pos, m_seq)
resc... |
def reformat_languages(languages)
my_hash = {}
languages.each do |style, hash|
hash.collect do |language, type_hash|
if my_hash.has_key?(language)
my_hash[language][:style] << style
else
my_hash[language] = type_hash
my_hash[language][:style] = [style]
... |
class User < ActiveRecord::Base
has_many :boards
has_many :pins
validates :first_name, :last_name, :email, presence: true
def full_name
"#{first_name} #{last_name}"
end
end
|
class Board
attr_reader :move_history
attr_reader :free_positions
attr_reader :winner
def initialize
@cells = ['-']*9
@move_history = []
@current_marker = "x"
@free_positions = [*0..8]
@gameover = false
end
def set_players(x, o)
@x, @o = x, o
end
def print_board(printer)
p... |
class UsersController < ApplicationController
before_filter :authenticate_user!
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
end
end
def edit
@user = User.find(current_user)
end
def update
@user = User.find(current_user)
respond_to do |format... |
class ApiSlugController < ApplicationController
REQUIRED_PARAMS = [:endpoint]
before_action :required_params, only: [:show, :cache]
def index
if current_user
slugs = ApiSlug.where(user_id: current_user.id)
else
slugs = "Create an account to receive webhooks when urls update."
end
... |
require "boot-sequence-tracker/common-re"
class BootSequenceTracker
class NfsdRE < CommonRE
def nfs_mount_re
/mountd\[\d+\]: authenticated mount request from (#{ ip_re }|#{ fqdn_re })/
end
############################################################################
private
##############... |
class EventBasePdf < BasePdf
def initialize(event, current_user)
super({ page_layout: :landscape, page_size: 'LETTER' })
@event = event
@current_user = current_user
header
body
footer
end
def header
@dates = (@event.start.to_date..@event.finish.to_date).map { |d| I18n.l(d) }
s... |
class InteractiveTTYApp
CSI = "\e["
CTRL_C = ?\C-c
CTRL_Z = ?\C-z
def initialize(tty, &run_loop)
@tty = tty
@run_loop = run_loop
@on_key = ->(*_) { } # Do nothing by default
end
def start
@stopped = false
trap_signals
start_input_thread # Start a thread to collect input
@tty.r... |
FactoryGirl.define do
factory :track do
name { Faker::Commerce.product_name }
surface_type { Track.surface_types.keys.sample }
time_zone { ['CET', 'EST', 'Sydney', 'Beijing'].sample }
end
end
|
class Deployment < ApplicationRecord
has_and_belongs_to_many :companies
end
|
class Commentary < ApplicationRecord
belongs_to :user
belongs_to :lien
has_many :comment_to_commentaries
end
|
project_path = File.join(File.dirname(__FILE__), '..')
stylesheets_path = File.join(project_path, 'sass')
if (defined? Compass)
Compass::Frameworks.register(
'support-for',
:path => project_path,
:stylesheets_directory => stylesheets_path
)
else
# Compass not defined, register the Sass path via a... |
json.array!(@tickets) do |ticket|
json.extract! ticket, :email, :subject, :issue, :response
json.url ticket_url(ticket, format: :json)
end
|
class ExpensesController < ApplicationController
before_action :set_expense, only: [:show, :update, :destroy]
def index
respond_to do |format|
format.html
format.json { @expenses = current_user.expenses.order(id: :asc) }
end
end
def show
end
def create
@expense = current_user.expe... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'CRUD operations' do
let(:client) { authorized_client }
let(:collection) { client['crud_integration'] }
before do
collection.delete_many
end
describe 'find' do
context 'when allow_disk_use is true' do
# Other cas... |
class Bookmark
attr_accessor :url, :title
attr_reader :last_visited
def initialize(url, title)
@url = url
@title = title
@last_visited = last_visited
end
def visit!
@last_visited = Time.now
end
end |
module Pacer
module Core
module Route
# Return elements based on a bias:1 chance.
#
# If given an integer (n) > 0, bias is calcualated at 1 / n.
def random(bias = 0.5)
bias = 1 / bias.to_f if bias.is_a? Fixnum and bias > 0
chain_route :pipe_class => Pacer::Pipes::RandomFilt... |
class DesignController < ApplicationController
def index
@quote = Quote.find_by route: 'design'
end
end
|
BEGIN {
class RBat
NEW_RUBY_DIR = "ruby-dist"
def initialize
@pwd = Dir.pwd
@script = $0
@me = __FILE__
end
def make
Dir.chdir(@pwd)
collect_loaded_features
# it's a windows-only script anyway
require 'Win32API'
require 'fileutils'
require 'pathname'
check_ruby
cle... |
require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録がうまくいく時' do
it 'first_name、last_name、first_name_kana、last_name_kana、nickname、email、password、birthdayがあれば登録できる' do
expect(@user).to be_valid
en... |
ActiveAdmin.register CustomField do
menu :parent => 'Categories'
show do
attributes_table :name, :created_at, :updated_at
panel 'Categories' do
table_for custom_field.categories do
column :name do |category|
category.name
end
end
end
active_admin_comments
end
... |
# A presenter class for a tip from the perspective of a purchaser of the tip.
class ConsumerTip < Presenter
alias_method :tip, :model
attr_reader :user
def initialize(tip, user)
super tip
@user = user
end
def purchase
@purchase ||= self.user.purchases.find_by!(tip_id: tip.id)
end
def impac... |
class Candidate < ApplicationRecord
has_many :job_board_metros
has_many :job_postings, through: :job_board_metros
end
|
class GitConfig < Inspec.resource(1)
name :git_config
def initialize(path, options = {})
@path = path
@git_path = options[:git_path] || 'git'
@data = inspec.command("#{git_path} config -f #{path} --list").stdout
end
attr_reader :path, :git_path, :data
# def core
# core_lines = data.split... |
require 'rails_helper'
RSpec.describe DigsiteInfo, type: :model do
let(:digsite_info) { build(:digsite_info) }
context 'validation test' do
it 'ensures well_known_text is RGeo::Geographic::SphericalPolygonImpl' do
expect(digsite_info.well_known_text).to be_a_kind_of(RGeo::Geographic::SphericalPolygonImp... |
FactoryBot.define do
factory :team do
association :tournament, factory: :tournament
name { FFaker::Name.html_safe_name }
end
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# This means these ruotes.
#1. get 'blogs/show'
#2. get 'blogs/index'
#3. get 'blogs/new'
#4. get 'blogs/edit'
resources :blogs
end
|
class WaitersController < ApplicationController
before_action :signed_in_administrator, only:
[:new, :index, :edit, :update, :destory]
def new
@waiter = Waiter.new
end
def index
@waiters = Waiter.where(lang: I18n.locale)
end
def create
@waiter = Waiter.new(waiter_params)
@waiter... |
# == Schema Information
#
# Table name: hooks
#
# id :integer not null, primary key
# name :string(255)
# payload :text
# created_at :datetime
# updated_at :datetime
# repo_id :integer
#
class Hook < ActiveRecord::Base
before_validation :coerce_payload
serialize :payload
belong... |
require 'rails_helper'
RSpec.describe Photo, :type => :model do
before do
@photo = Photo.new(approved: true, url: "http://blog.jimdo.com/wp-content/uploads/2014/01/tree-247122.jpg", caption: "This is a test picture", profile: false)
end
subject(:photo) { @photo }
it { is_expected.to respond_to(:approved)... |
require 'exceptions'
##
## Check for dependencies
##
version = Rails::VERSION::STRING.split(".")
if version[0] < "1" or (version[0] == "1" and version[1] < "2")
message = <<-EOM
************************************************************************
Rails 1.2.1 or greater is required. Please remove ActiveSc... |
require 'spec_helper'
describe "events" do
describe "events#index" do
it "should display a list of events" do
FactoryGirl.create(:event)
visit root_path
expect(page).to have_content("Lincoln Park Run")
end
end
end
describe "create event" do
before do
FactoryGirl.create(:user)
v... |
# Catsylvanian money is a strange thing: they have a coin for every
# denomination (including zero!). A wonky change machine in
# Catsylvania takes any coin of value N and returns 3 new coins,
# valued at N/2, N/3 and N/4 (rounding down).
#
# Write a method `wonky_coins(n)` that returns the number of coins you
# are le... |
module ActiveRecord
class Relation
alias :original_count :count
def count(column_name = nil, options = {})
if !loaded? && (column_name == :all) && (options == {})
associations = klass.reflections.keys.collect(&:to_s)
contains_possible_paths = qry_options.any? do |key, value|
... |
# Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge [by myself, with: ].
# 0. total Pseudocode
# make sure all pseudocode is commented out!
# Input:array
# Outp... |
require_relative 'abstract_parser_factory'
require_relative 'parser_ini'
require_relative 'parser_json'
# Abstract Factory pattern
class Parser
include AbstractParserFactory
PATH = '../../../datafiles/fixtures/'
def initialize(class_name, file_name)
@class_name = class_name
@file_name = file_name
end... |
require 'rails_helper'
RSpec.describe Error, type: :model do
before do
@error = FactoryBot.build(:error)
end
describe '失敗投稿' do
context '投稿できる時' do
it '全てが存在する時' do
expect(@error).to be_valid
end
it 'in_my_head_id以外が存在する時' do
@error.in_my_head = nil
expect(@erro... |
class ChangeColumnLengthOwnRent1910 < ActiveRecord::Migration[4.2]
def change
change_column :census_1910_records, :owned_or_rented, :string, limit: 10
end
end
|
class Scenes::AuthController < SceneController
before_action :redirect_if_user_signed_in
def scene
@user = User.new
end
def signup
@user = User.new(user_params)
if @user.save
sign_in_and_redirect(@user)
else
render_update(:signup_failed)
end
end
def login
@user = User.... |
class Concert < ActiveRecord::Base
validates :artist, presence: true
validates :city, presence: true
validates :state, presence: true
end
|
# frozen_string_literal: true
require 'mail'
class Mail::Message
def store(recipient, tag:)
user = case recipient
when Member
recipient.user
when User
recipient
else
User.find(recipient)
end
html_part, plain_part = parts_by_t... |
require 'test_helper'
class UserActivityTest < ActiveSupport::TestCase
context "cobrand recent activities" do
before do
@existing_activities = UserActivity.all
@cobrand = Cobrand.first
@user = Factory :user, :cobrand => @cobrand
@another_cobrand = Cobrand.last
end
... |
require_relative 'command.rb'
module DBP::BookCompiler::TexToMarkdown
class FinishArgument
include Command
def initialize
@name = '}'
end
def transition(translator, _)
translator.finish_command # the command that the macro interrupted
end
def to_s
"#{self.class}"
end
... |
class MembershipsController < ApplicationController
respond_to :json
before_filter :auth_user
before_filter :group_admin, except: [:destroy]
before_filter :referred_user_is_group_member, only: [:authorize_member, :unauthorize_member]
after_filter :clear_all_data
# params: access_token, group_id, user_id
# a... |
FactoryGirl.define do
module_references_module_types = Metasploit::Model::Module::Instance.module_types_that_allow(:module_references)
sequence :metasploit_model_module_reference_module_type, module_references_module_types.cycle
trait :metasploit_model_module_reference do
ignore do
module_type { gener... |
class Assessment < ActiveRecord::Base
include UUIDRecord
attr_accessible :enrollment_uuid, :type, :uuid, :baseline_assessment_uuid
scope :pre_paywall, where(type:"PrePaywallAssessment") # Ref to subclass. So sue me.
scope :baseline, where(type:"BaselineAssessment") # Ref to subclass. So sue me. (Again)
sco... |
class User < ApplicationRecord
has_secure_password
has_many :items, dependent: :destroy
has_many :bid_items, through: :bid, source: :item
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :email, presence: true, uniqueness: true, format: VALID_EMAIL_REGEX
validates :first_n... |
class ChannelBot < ApplicationRecord
include TwitchConnector
after_initialize :set_defaults
validates :bot_name, :channel_id, :live_status_id, :intended_status_id, presence: true
validates :live_status_id, :intended_status_id, numericality: { less_than: 2 }
STATUSES = [ 'Inactive', 'Active' ]
def live_stat... |
class Api::AuthenticateController < ApplicationController
include ApiResponse
skip_before_action :authenticate_user!
def generate_token
return head(:bad_request) if !request.format.json? && !request.format.xml?
return head(:bad_request) if params[:key].blank? || params[:secret].blank?
@api_user = Ap... |
require_relative '../sudoku'
describe "Sudoku" do
solvable = "1-58-2----9--764-52--4--819-19--73-6762-83-9-----61-5---76---3-43--2-5-16--3-89--"
unsolvable = "--7--8------2---6-65--79----7----3-5-83---67-2-1----8----71--38-2---5------4--2--"
let (:solvable_board) { create_board(solvable) }
let (:unsolvable_board)... |
class SellersController < ApplicationController
def index
seller_id = current_user.userable_id
@garments = Garment.where(seller_id: seller_id)
end
def new
unless current_user
flash[:success] = "Please sign or log in to continue."
redirect_to :back
end
@seller = Seller.new
end
... |
# frozen_string_literal: true
class CreateSessions < ActiveRecord::Migration[6.0]
def change
create_table(:sessions, id: false) do |t|
t.string(:id, limit: 16, primary_key: true, null: false)
t.timestamps
t.string(:user_id, limit: 16, null: false)
t.string(:token, limit: 191, null: false)... |
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'
require 'matrix'
def read_moon_positions
(Pathname(__dir__).parent / 'data' / 'day_12.txt').readlines.map(&:chomp).map do |line|
Vector.elements(/<x=(-?\d+), y=(-?\d+), z=(-?\d+)>/.match(line)[1..3].map(&:to_i))
end
end
class Moon
attr_a... |
class AddCodeListAndCodeListLinkToDistribution < ActiveRecord::Migration
def change
add_column :distributions, :codelist, :text
add_column :distributions, :codelist_link, :string
end
end
|
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
#allow these methods to be used in the views as well
helper_method :current_user, :logged_in?
def curre... |
require 'test/unit'
require_relative 'dijkstras'
class Graph_Test < Test::Unit::TestCase
#Runs before each test
def setup
@graph = Graph.new
end
def test_add_vertex
@graph.add_vertex('A', {'B' => 7, 'C' => 8})
assert_equal({"A"=>{"B"=>7, "C"=>8}}, @graph.instance_varia... |
# frozen_string_literal: true
module Arclight
##
# A simple wrapper class around the SolrEad::Indexer so we can add our own behavior
class Indexer < SolrEad::Indexer
include Arclight::SolrEadIndexerExt
end
end
|
class RemoveActionFromIndicator < ActiveRecord::Migration
def change
remove_column :indicators, :action
end
end
|
# frozen_string_literal: true
module RailsAdmin
module Config
module ConstLoadSuppressor
class << self
@original_const_missing = nil
def suppressing
raise 'Constant Loading is already suppressed' if @original_const_missing
begin
@original_const_missing = Ob... |
require 'spec_helper'
describe "opendata_agents_nodes_appfile", dbscope: :example do
def create_appfile(app, file, format)
appfile = app.appfiles.new(text: "aaa", format: format)
appfile.in_file = file
appfile.save
appfile
end
let(:site) { cms_site }
let(:node) { create_once :opendata_node_app,... |
class ChangeTheColumnInBookings < ActiveRecord::Migration[6.0]
def change
change_column_null :packages, :booking_id, true
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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/autorun'
require 'spec/rails'
# Requires supporting files with custom matchers and... |
class SignupRequests::RequestAcceptedNotifier < Notifier
attr_reader :signup_request
def initialize(signup_request:)
@signup_request = signup_request
super(
convention: signup_request.target_run.event.convention,
event_key: 'signup_requests/request_accepted'
)
end
def liquid_assigns
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.