text stringlengths 10 2.61M |
|---|
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# content :string
# user_id :integer
# post_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Comment < ActiveRecord::Base
belongs_to :user
belon... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/enlace_urls/show.html.erb" do
include EnlaceUrlsHelper
before(:each) do
@enlace_url = mock_model(EnlaceUrl)
@enlace_url.stub!(:nombre).and_return("MyString")
@enlace_url.stub!(:descripcion).and_return("MyString")
@enlace_url.stub!(... |
require 'set'
RSpec.describe RangeCompressor do
it 'has a version number' do
expect(RangeCompressor::VERSION).not_to be nil
end
describe '::compress' do
it 'takes any kind of sorted set' do
expect { RangeCompressor.compress(SortedSet[1, 2]) }.not_to raise_error
end
it 'takes enumerables t... |
require 'spec_helper'
describe MaintainerTeam do
# describe 'Associations' do
# it { should have_many :teams }
# it { should have_many :gears }
# it { should have_many :ftbfs }
# end
describe 'Validation' do
it { should validate_presence_of :name }
it { should validate_presence_of :email }
... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
mount PgBouncerHero::Engine, at: "pgbouncerhero"
get '/', to: redirect('/pgbouncerhero')
end
|
require 'test_helper'
class Chatbot::GeolocationTest < ActiveSupport::TestCase
test 'Geolocation creation' do
statement = ChatStatement.new(
speaker: :bot,
nature: :geolocation,
content: {
text: 'Where are you ?'
},
chat_session: chat_sessions(:one)
)
assert stateme... |
require 'spec_helper'
describe MultipleMan::Runner do
let(:mock_channel) { double("Channel", prefetch: true, queue: true) }
let(:mock_connection) { double("Connection", create_channel: mock_channel) }
let(:mock_consumer) { double("Consumer", listen: true) }
it 'boots app and listens on new channel' do
exp... |
class AddCustomerToProducts < ActiveRecord::Migration[6.0]
def change
add_column :orders, :customer, :string
add_column :orders, :billingaddress_id, :integer
add_column :orders, :first_name, :string
add_column :orders, :last_name, :string
add_column :orders, :email, :string
end
end
|
class BookingsController < ApplicationController
def index
end
def create
@equipment = Equipment.find(params[:equipment_id])
authorize @equipment
@booking = Booking.new(review_params)
authorize @booking
@booking.equipment = @equipment
@booking.price = @equipment.daily_price.to_i * ((@boo... |
class AddCursoToSalon < ActiveRecord::Migration
def change
add_reference :salons, :curso, index: true, foreign_key: true
end
end
|
# frozen_string_literal: true
# Recipes Controller
class RecipesController < ApplicationController
before_action :authenticate_user!
def index
@recipes = Recipe.my_recipes
end
def show
@recipe = Recipe.my_recipes.find(params[:id])
@ingredient = Ingredient.new
@utensil = Utensil.new
end
de... |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.winner_pattern
[
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
]
end
end
|
module Notifiers
class NotificationClient
attr_reader :url
def initialize(url)
@url = url
end
def post(payload)
client.post('', payload.to_json)
end
private
def client
Faraday.new(url: url, headers: { 'Content-Type' => 'application/json' }) do |f|
f.request :r... |
module RSpec::HaveAttributeMatcher
RSpec::Matchers.define :have_attributes do |attrs|
description do
if attrs.keys.size > 1
"have attributes #{attrs.inspect}"
else
key, value = attrs.keys.first, attrs.values.first
text = "have attribute #{key}"
text << "with value #{va... |
class CreateDiscussions < ActiveRecord::Migration
def change
create_table :discussions do |t|
t.belongs_to :user, null: false
t.belongs_to :publisher, polymorphic: true, null: false, index: true
t.belongs_to :discussion_poll
t.belongs_to :cover
t.belongs_to :parent
t.string :di... |
def reverse_sentence(str)
str.split.reverse.join(' ')
end
puts reverse_sentence('')
puts reverse_sentence('Hello World')
puts reverse_sentence('Reverse these words')
# Brute force version:
# def reverse_sentence(str)
# reversed = []
# str.split.each do |element|
# reversed.unshift(element)
# end
# reve... |
class FontAsapCondensed < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/asapcondensed"
desc "Asap Condensed"
homepage "https://fonts.google.com/specimen/Asap+Condensed"
def install
(share/"fonts").install "AsapCondensed-Black.ttf"
... |
module Errors #:nodoc:
# = FlatFileError
#
# Generic error class and superclass of all other errors raised by Flat.
#
class FlatFileError < StandardError; end
# = LayoutConstructorError
#
# The specified layout definition was not valid.
#
class LayoutConstructorError < FlatFileError; ... |
# frozen_string_literal: true
class CreateV2Streams < ActiveRecord::Migration[6.0]
def change
create_table :v2_streams do |t|
t.string :code, null: false
t.string :category, null: false
t.string :unit_code, null: false
t.string :origin_code, null: false
t.jsonb :time_series, null: ... |
module QBIntegration
module Service
class Customer < Base
attr_reader :order
def initialize(config, payload)
super("Customer", config)
@order = payload[:order]
end
def find_or_create
name = use_web_orders? ? "Web Orders" : nil
fetch_by_display_name(name) ... |
class CreatePayments < ActiveRecord::Migration
def change
create_table :payments do |t|
t.belongs_to :user
t.string :payment_to
t.integer :amount
t.string :note
t.string :venmo_payment_id
t.string :venmo_payment_status
t.timestamps
end
end
... |
# == Schema Information
#
# Table name: informes
#
# id :integer not null, primary key
# descripcion :text
# es_final :boolean
# fecha :date
# tipo :integer
# proyecto_id :integer
# created_at :datetime
# up... |
class ChangePaidOnRegistrations < ActiveRecord::Migration[5.0]
def change
change_column :registrations, :paid, :string
end
end
|
require 'spec_helper'
describe 'heat::clients::aodh' do
shared_examples 'heat::clients::aodh' do
context 'with defaults' do
it 'configures defaults' do
is_expected.to contain_heat__clients__base('clients_aodh').with(
:endpoint_type => '<SERVICE DEFAULT>',
:ca_file => '<SER... |
module Concerns::HelpAction::Validation
extend ActiveSupport::Concern
included do
validates :name, presence: true
validates :action_master_id, presence: true
end
end
|
class ItemsController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => :create
def index
@collections = current_user.collections.uniq
@items = current_user.items
if !params[:collection_id].blank?
@items = Item.by_collection(params[:collection_id])
else
@i... |
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
require 'browser'
class AutoRunLabrun
attr_reader :browser
attr_accessor :labruns
def initialize
e = Integration::Environment.new
@browser = e.browser
end
def get_labruns file
@labruns = IO.readlines(file)
end
def run... |
class AddIdColumnsToOrders < ActiveRecord::Migration[6.1]
def change
add_reference :orders, :user, index: true
add_reference :orders, :item, index: true
end
end
|
class AddCartItem < ActiveRecord::Migration[5.2]
def change
add_column :cart_items, :product_name, :string
end
end
|
require 'rails_helper'
RSpec.describe Authentication, type: :model do
let(:authentication) { create(:authentication) }
describe '項目に不備がない場合' do
it '有効である' do
expect(authentication).to be_valid
end
end
describe '項目に不備がある場合' do
context 'userが紐づかない場合' do
it '無効である' do
authenticat... |
class Utility < ActiveRecord::Base
class << self
# 現在時刻との差分日数を算出
def to_days(target_at)
(target_at.to_i - Time.now.to_i) / 60 / 60 / 24
end
# 現在時刻との差分時間数を算出
def to_hours(target_at)
(target_at.to_i - Time.now.to_i) / 60 / 60
end
# 現在時刻との差分分数を算出
def to_minutes(target_at)
... |
class PocketsController < ApplicationController
# GET /pockets
# GET /pockets.json
def index
pockets = Pocket.all#.map{|p|p.as_json}
@pockets = pockets.map{|p|
pocket = "#{count ||= nil; count.nil? ? '' : ','}{\"picture\": \"#{p.picture}\", \"latitude\": \"#{p.latitude}\", \"longitude\": \"#{p.longi... |
class AddLawFile < ActiveRecord::Migration
def change
add_column :agendas, :law_file_file_name, :string
add_column :agendas, :law_file_content_type, :string
add_column :agendas, :law_file_file_size, :integer
add_column :agendas, :law_file_updated_at, :datetime
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
helper_method :current_user_session, :current_user
before_filter :authenticate
before_filter :set_gettext_locale
... |
class User
def self.find_by_id(id)
results = QuestionsDatabase.instance.execute(<<-SQL, id)
SELECT
*
FROM
users
WHERE
id = ?
SQL
User.new(results.first)
end
def self.find_by_name(fname, lname)
results = QuestionsDatabase.instance.execute(<<-SQL, fname,... |
class ConversationsController < ApplicationController
before_action :authenticate_user!
before_action :get_mailbox
before_action :get_conversation, except: [:index]
helper_method :mailbox, :conversation
def index
@inbox = @mailbox.inbox.page(params[:ipage]).per(10)
@trash = @mailbox.trash.page(para... |
module Scorer
class Client
class NoToken < StandardError; end
class << self
attr_writer :token, :ssl_enabled
attr_reader :api_host, :api_projects_path
def get(path)
begin
set_response_headers(connection["#{api_version}#{path}"].get)
rescue
puts "Encoun... |
class InitializeHelpCommand
class << self
def run *args
puts "Options:
You have the availability to skip portions of the
initialize command.
If you would like to skip the initial route nmespace use:
--skip-routes
Run to initialize your project:
'railspp initialize'
"
end
end
e... |
require_relative "uncompressed"
require "vendor/macho/macho"
module UnpackStrategy
class Executable < Uncompressed
def self.can_extract?(path:, magic_number:)
return true if magic_number.match?(/\A#!\s*\S+/n)
begin
path.file? && MachO.open(path).header.executable?
rescue MachO::NotAMa... |
class ApplicationsController < ApplicationController
before_action :set_application, only: [:show, :destroy]
before_filter :allow_iframe_requests
http_basic_authenticate_with name: ENV['USER'], password: ENV['PASSWORD'], only: [ :index, :destroy ]
def index
@applications = Application.all.reverse
end
... |
require "language/haskell"
class HopenpgpTools < Formula
include Language::Haskell::Cabal
desc "Command-line tools for OpenPGP-related operations"
homepage "https://hackage.haskell.org/package/hopenpgp-tools"
url "https://hackage.haskell.org/package/hopenpgp-tools/hopenpgp-tools-0.21.tar.gz"
sha256 "c352c11... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Users', type: :request do
let!(:user) { create(:user) }
before { sign_in(user) }
describe 'GET /users/:id' do
before { get "/users/#{user.id}" }
it 'will return status code 200' do
expect(response).to have_http_status(200)
... |
class ApplicationPolicy
attr_reader :user, # User performing the action
:record # Instance upon which action is performed
def initialize(user, record)
raise Pundit::NotAuthorizedError, "Must be signed in." unless user
@user = user
@record = record
end
def index? ; admin? || age... |
require './lib/fizz_buzz/noizer'
require './lib/fizz_buzz/fizzer'
module FizzBuzz
class NoizePrinter
def initialize max_value
(1..max_value).each do |i|
buzz_rule = lambda{|number| number % 3 == 0}
fizzer = Fizzer.new
buzzer = Noizer.new i, buzz_rule, "Buzz"
Kernel.puts("#... |
class User < ApplicationRecord
has_many :expenses
end
|
Rails.application.routes.draw do
resources :events
resources :users
resources :player_attributes
resources :supplies
resources :piles
resources :card_piles
resources :games
post '/games/:id/add_player' => 'games#add_player'
post '/games/:id/play_card' => 'games#play_card'
post '/games/:id/advanc... |
cask :v1 => 'cmake' do
version '3.1.0'
sha256 'e39c9363868a3e044e8227727705b632118981a63bc8dd1a45024378b7db9ba0'
url "http://www.cmake.org/files/v3.1/cmake-#{version}-Darwin64.dmg"
homepage 'http://cmake.org'
license :bsd
app 'CMake.app'
end
|
require 'rabbit_jobs/publisher/base'
module RabbitJobs
class Publisher
# Publisher for testing.
# Stores AMQP messages to array.
class Test < Base
class << self
def cleanup
messages.clear
end
def publish_to(routing_key, klass, *params)
check_amqp_publish... |
MASTER_REPOSITORY = if ENV['GH_TOKEN']
"https://#{ENV['GH_TOKEN']}@github.com/sapporojs/sapporojs.org"
else
'git@github.com:sapporojs/sapporojs.org.git'
end
PUBLISH_BRANCH = 'gh-pages'
def initialize_repository(repository, branch)
require 'fileutils'
if Dir['build/.git'].empty?
FileUtils.rm_rf 'bu... |
module Nordea
module FileTransfer
module Config
@@keys = [
:cert_file, :private_key_file, :private_key_password,
:sender_id, :receiver_id, :customer_id, :language, :user_agent, :environment, :software_id
]
attr_accessor(*@@keys)
def keys
@@keys
end
def... |
class AddMatchingStaffMessageToProjects < ActiveRecord::Migration[5.0]
def change
add_column :projects, :matching_staff_message, :text
end
end
|
# => Retourne le code HTML pour la date +timestamp+ mise dans un div de
# paramètres +div_params+
#
# @param timestamp Un time stamp (string ou Fixnum ou Bignum)
# @param div_params Hash contenant les attributs pour le div (ou nil)
#
def date_for timestamp, div_params = nil
(div_params ||= {}).add_class ... |
Rails.application.routes.draw do
devise_for :users
root 'sessions#new'
get 'sessions/new'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
resources :users do
resources :messages
end
end
|
module Auth
class Admin::UserTagsController < Admin::BaseController
before_action :set_user_tag, only: [:show, :edit, :update, :destroy]
def index
q_params = {}
q_params.merge! default_params
@user_tags = UserTag.default_where(q_params).page(params[:page])
end
def new
@user_... |
# Intermediate Assignment 2
=begin
If you get stuck, consult the attr_accessor tab above.
Create a class Student that has the following attributes: @name, @dojo_location @belt_level
Create an instance of class Student and assign its attributes via the initialize function
Try to alter the values of your instance outsi... |
class ArtworkSharesController < ApplicationController
def index
render json: ArtworkShare.all
end
def create
artwork = ArtworkShare.new(artwork_shares_params)
if artwork_shares.save
render json: artwork_shares
else
render json: artwork_shares.errors.f... |
class SendeesController < ApplicationController
include Response
include ExceptionHandler
before_action :set_sendee, only: [:show, :update, :destroy]
def index
@sendees = Sendee.where(sub_request_id: params[:sub_request_id])
json_response(@sendees, SendeeSerializer)
end
def create
... |
# encoding: UTF-8
class ReviewerTrackValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :organizer_track) unless record.reviewer.can_review?(record.track)
end
end |
if ENV["COVERAGE"]
require 'simplecov'
SimpleCov.start 'rails'
end
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note:... |
#Expanded English number
def english_number number
if number == 0
return "Zero"
end
if number < 0
return "Please provide a positive number!"
num = ""
ones = ["One", "Two", "Three",
"Four", "Five", "Six",
"Seven", "Eight", "Nine"]
tens = ["Ten", "Twenty", "Thirty",
"For... |
require 'minitest_helper'
class TestSubscriptionRequestProcessor < MiniTest::Test
include Zulu
def teardown
Zulu.redis.flushall
end
def test_it_processes_request
processor = SubscriptionRequestProcessor.new
request_mock = MiniTest::Mock.new
request_mock.expect(:process, true)
... |
class ReviewsController < ApplicationController
before_action :authenticate_user!, only: [:create]
include Pundit
after_action :verify_authorized, except: :index, unless: :skip_pundit?
# Uncomment when you *really understand* Pundit!
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
def... |
# 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... |
require 'spec_helper'
describe Susanoo::PagesController do
describe "フィルタ" do
controller do
%w(show new edit create).each do |act|
define_method(act) do
render text: "ok"
end
end
end
let(:top_genre) { create(:top_genre) }
describe "reject_event_page" do
l... |
# frozen_string_literal: true
class CitationResolverService
def self.config_path
Rails.root.join("config", "citations.yml")
end
def self.citation_values
config = File.read(config_path)
document = YAML.parse(config)
document.to_ruby
end
def self.resolve(repository_id:)
return unless cita... |
require 'rails_helper'
RSpec.describe User, type: :model do
subject { build :user }
it { is_expected.to be_valid }
it 'requires role' do
subject.role = nil
expect(subject).not_to be_valid
end
it 'requires login' do
subject.login = nil
expect(subject).not_to be_valid
end
it 'requires p... |
class ItemsController < ApplicationController
def index
@items = Item.all
render json: @items
end
def create
Item.create(item_params)
end
private
def item_params
params.require(:item).permit(:name, :description, :user_id, :category, :asking_price, :image)
e... |
#!/usr/bin/env jruby
require 'rubygems'
require 'optparse'
require 'ostruct'
require 'rbconfig'
require 'rspec'
require 'operawatir'
# Encoding fix
$KCODE = "UTF8"
class Options
def self.parse(args)
options = OpenStruct.new
options.ng = false
options.inspectr = ENV['OPERA_INSPECTR'] ||... |
class Project < ActiveRecord::Base
#TODO: validates presence of properly formatted url
validates_presence_of :name
has_many :builds
end
|
class RenameColumnToRaces < ActiveRecord::Migration[5.0]
def change
rename_column :races, :distance, :total_distance
change_column :races, :total_distance, :float
end
end
|
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
html = <<-HTML
<!-- <div class="alert alert-message-error alert-message-danger" style="text-align:left;">
<p>#{messages}</p>
... |
# encoding: UTF-8
module API
module V1
class SupportingCoursesCacheable < API::V1::Base
helpers API::Helpers::V1::SupportingCoursesHelpers
helpers API::Helpers::V1::PresentationsHelpers
before do
authenticate_user
end
with_cacheable_endpoints :supporting_courses do
... |
require 'rake'
require 'json'
desc 'Link vscode settings'
task :install do
%w[settings.json keybindings.json snippets].each do |setting|
link_path setting
end
stored_extensions = JSON.parse(File.read(extensions_file_path))
not_yet_installed = stored_extensions - installed_extensions
if not_yet_installe... |
class Brand < ActiveRecord::Base
has_many :variants
has_many :products
validates :name, :presence => true, :length => { :maximum => 255 }, :uniqueness => true
end
|
RSpec::Matchers.define :respond_json_of do |origin|
match do
response.body == origin.body
end
description do
"respond with a JSON representation of #{origin.infer_resource_name}"
end
failure_message_for_should do |actual|
"expected \n#{origin.body} \n to be \n#{actual.body}"
end
failure_me... |
module Darksky
class Flag
attr_accessor :sources, :nearest_station, :units
def initialize(params)
@sources = params.fetch(:sources, [])
@units = params.fetch(:units, nil)
@nearest_station = params.fetch(:"nearest-station", nil)
end
end
end |
class Municipality < ActiveRecord::Base
include AlphabeticalOrder
belongs_to :state
has_many :towns
validates :code, presence: true, uniqueness: true
validates :name, presence: true
validates :state_id, presence: true
end
|
# frozen_string_literal: true
class Api::QuizTrials::ResultsController < Api::ApplicationController
def show
user_answer = current_user.quiz_trials.find(params[:quiz_trial_id])
render_json props: QuizTrial::ResultSerializer.new(model: user_answer).as_json
end
end
|
class FontGlowSansScWide < Formula
version "0.93"
sha256 "036eca2916a3636b32d006937d498cc33873317c8bf01057580b21526f59e79b"
url "https://github.com/welai/glow-sans/releases/download/v#{version}/GlowSansSC-Wide-v#{version}.zip"
desc "Glow Sans SC Wide"
homepage "https://github.com/welai/glow-sans"
def instal... |
Rails.application.routes.draw do
devise_for :users, controllers: {registrations: "registrations"}, skip: :registration
root to: 'static_pages#store'
get '/prepare' => 'static_pages#prepare'
get '/store' => 'static_pages#store'
get '/admin' => 'static_pages#admin_main'
get '/usedsummary' => 'admin#used_s... |
name 'sfxc-cookbook'
maintainer 'ServiceRocket'
license 'Apache 2.0'
description 'Cookbook for Salesforce add-on deployments'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.1'
depends 'newrelic'
source_url 'https://github.com/ServiceRocket/sfxc-cookbook' if respond_to?(:source_u... |
require 'test_helper'
class PostsControllerTest < ActionDispatch::IntegrationTest
setup do
@post = posts(:one)
@new_post = Post.new(title: "All about articles", article: "a an the -- These are the articles in English",
status: 1, likes: 17)
end
test "#index renders index view" d... |
class ChangeIdAnFromRepresentative < ActiveRecord::Migration[6.0]
def change
change_column :representatives, :id_an, :string
end
end
|
require 'spec_helper'
module SomeModule
module NestedModule
class AClassInANestedModule
end
end
class ClassInAModule
end
end
module Fakes
class SomeClass
def self.calculate
42
end
end
describe ClassSwaps do
class MySwap
attr_accessor :inititated, :was_reset
def init... |
class AddProductsToPts < ActiveRecord::Migration
def change
add_column :pts, :dye_product, :string
add_column :pts, :dev_product, :string
add_column :pts, :cleaner_product, :string
end
end |
require 'puppet_x/nexus/util'
require 'spec_helper'
describe Nexus::Util do
contrived_original = {
'a' => [],
'b' => {
'b.a' => {
'b.a.a' => 1,
'b.a.b' => {
'b.a.b.a' => [],
'b.a.b.b' => nil
},
'b.b' => {
'b.b.a' => 2,
'b.b.b' => ... |
# frozen_string_literal: true
module Zafira
module Operations
module TestSuite
class Create
include Concerns::Operationable
def initialize(client)
self.client = client
end
def call
super do
chain { start_test_suite }
chain { init... |
class Input_String
def initialize #input string
@input=gets.chomp;
end
def palindrome #palindrome function
forward_index=0;
reverse_index=@input.length-1;
... |
class StaticPagesController < ApplicationController
def home
@students = Student.all
end
end
|
# TODO: test
module PlaybacksHelper
def confidence_label(value)
{
0 => '0 - Not at all confident',
10 => '10 - Extremely confident'
}[value] || value
end
def comment_done_message(comment)
comment.done? ? 'marked as done' : 'commented'
end
def context(playback)
period(playback) + ... |
class AddDownloadedAtToDocuments < ActiveRecord::Migration
# Records the first time the document was downloaded
def change
add_column :documents, :last_accessed_at, :timestamp
end
end
|
require "byebug"
module Slideable
HORIZONTAL_DIRS = [[1,0],[-1,0],[0,1],[0,-1]]
DIAGONAL_DIRS = [[1,1],[-1,1],[1,-1],[-1,-1]]
def horizontal_dirs
HORIZONTAL_DIRS
end
def diagonal_dirs
DIAGONAL_DIRS
end
def moves
possible_moves = []
directions = move_dirs
... |
require 'rails_helper'
RSpec.describe MakersHelper, type: :helper do
describe "find_year" do
it "見つかること" do
year = create :year
expect(find_year(year.id)).to eq 2017
end
end
end
|
class AddSexToAthelete < ActiveRecord::Migration
def change
add_column :atheletes, :sex, :boolean
remove_column :itri_records, :sex
end
end
|
class Setup::OrganizationsController < ApplicationController
include Wicked::Wizard
steps :basics, :invite, :details
def show
@organization = authorize(Organization.find(params[:organization_id]))
render_wizard
end
def create
@organization = authorize(Organization.new(creator: current_user))
... |
# Copyright (c) 2009-2011 VMware, Inc.
require "mysql2"
require "mysql_service/util"
module VCAP; module Services; module Mysql; end; end; end
class VCAP::Services::Mysql::Node
DATA_LENGTH_FIELD = 6
def dbs_size(connection, dbs=[])
dbs = [] if dbs.nil?
if dbs.length == 0
result = connection.query(... |
require 'web_helper'
feature 'Posting Peep' do
scenario 'a user can post a new peep' do
sign_up
visit '/peeps/new'
fill_in 'peep', with: 'First peep'
click_button 'Peep it'
expect(current_path).to eq '/peeps'
expect(page).to have_content 'First peep'
expect(page).to have_content('=> test... |
class DailyMailer < ActionMailer::Base
default from: "solve.simple.app@gmail.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.daily_mailer.digest.subject
#
def digest(user)
@user = user
@questions = Question.latest
mail to: user.email... |
class Assignment < ApplicationRecord
belongs_to :assignor, optional: true
belongs_to :referee, optional: true
belongs_to :game, optional: true
end
|
# TagsController directs the CRUD actions for
# Tag objects
class TagsController < ApplicationController
# GET /tags
# GET /tags.json
def index
@tags = Tag.all
general_static_response(@tags)
end
# GET /tags/1
# GET /tags/1.json
def show
@tag = Tag.find(params[:id])
general_static_response... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.