text stringlengths 10 2.61M |
|---|
class Api::V1::UserSerializer
include FastJsonapi::ObjectSerializer
attributes :rating, :description
belongs_to :user
end
|
module ModelStack
module DSLClass
class Controller
attr_accessor :identifier
attr_accessor :model
attr_accessor :actions
attr_accessor :child_controllers
def initialize
self.actions = []
self.child_controllers = []
end
def child_controller_with_identifi... |
require 'spec_helper'
describe 'chronos' do
context 'supported operating systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context "chronos class without any parameters" do
let(:params) {{ }}
it { is_expect... |
FactoryBot.define do
factory :project do
project_nm { "MyText" }
start_at { "2018-12-02 17:42:46" }
release_at { "2018-12-02 17:42:46" }
completed_at { "2018-12-02 17:42:46" }
end
end
|
class SchemasController < ApplicationController
def show
collection
end
def search
collection
render :show
end
private
def collection
@database_connection = DatabaseConnection.find(params[:id])
@schema = Schema.new(@database_connection.config)
if @name = params[:na... |
module Catalog
module_function
ProductCard = Struct.new :product, :path do
include ProductBase
def self.call(model, *args)
yield model, new(model, *args)
end
def url
"#{path ? path : product_category_path}/#{product.path_id}"
end
def preview_url
primary_photo && primary... |
# frozen_string_literal: true
module PlayerStatistics
module Models
class LineUp < Sequel::Model
many_to_one :team
many_to_many :players,
adder: proc { |player|
Sequel::Model
.db[:line_ups_players]
.insert(%i[play... |
require 'test_helper'
class PersonDotFindByIdTest < Test::Unit::TestCase
def setup
VCR.use_cassette('person.find_by_id') do
@organisation = CapsuleCRM::Organisation.find organisations(:gov)
@person = CapsuleCRM::Person.find people(:pm)
@person.organisation # to record the request
end
end
... |
class AddDecisionTypeToEuDecisionType < ActiveRecord::Migration
def change
add_column :eu_decision_types, :decision_type, :string
end
end
|
class Product < ApplicationRecord
has_many :reviews
has_many :orderedproducts
has_many :orders, through: :orderedproducts
belongs_to :merchant
validates :name, presence: true,
uniqueness: true
validates :price, presence: true,
numericality: { greater_than: 0 } #two dec... |
require 'rails_helper'
describe User do
describe "attributes" do
let(:user) { User.create!(first_name: "Joe", last_name: "Smith", email: "joe@yahoo.com", password: "password") }
it "has a first_name" do
expect(user.first_name).to eq("Joe")
end
it "has a last_name" do
expect(user.last_nam... |
class RemovePropritaireFromAnnonce < ActiveRecord::Migration
def change
remove_column :annonces, :proprietaire
end
end
|
require 'gmail'
class SendEmailJob < ActiveJob::Base
queue_as :default
def perform(profile_id, campaign_id, user_email, token, user_name)
begin
profile = Profile.find(profile_id)
campaign = Campaign.find(campaign_id)
if Rails.env.production? or Rails.env.development?
gmail = Gmail.co... |
class AddLooseRequirementsToReviewRequirements < ActiveRecord::Migration
def self.up
add_column :review_requirements, :credited_content_length, :integer
rename_column :review_requirements, :categories, :credited_categories
end
def self.down
rename_column :review_requirements, :credited_categor... |
module Diffity
module Dsl
def self.diffity
@diffity ||=
begin
klass =
if Diffity.enable_service
Diffity::Runner
else
Diffity::DummyRunner
end
Diffity.logger.info "Using runner #{klass}"
klass.instance
... |
require 'test_helper'
class QueryingTest < RelixTest
include FamilyFixture
def test_missing_index
model = Class.new do
include Relix
relix.primary_key :key
end
assert_raise Relix::MissingIndexError do
model.lookup{|q| q[:bogus].eq('something')}
end
end
def test_missing_prima... |
require 'fptools'
require 'minitest/autorun'
class TestDocbookValidator < MiniTest::Unit::TestCase
def setup
@dv = Fptools::Xml::DocbookValidator.new
@good_doc = File.expand_path(File.join(File.dirname(__FILE__),'examples','valid_docbook.xml'))
@bad_doc = File.expand_path(File.join(File.dirname(__FILE__)... |
class Make_soda_pyramid
def initialize(bonus, soda_price)
@bonus = bonus
@soda_price = soda_price
@can = "[]"
@result = []
@cans_to_display = []
@num_of_sodas_on_lvl = 1 # Initialize Variable
@level = 1 # Initialize Variable
@total_n... |
#!/usr/bin/env ruby
require 'eventmachine'
require 'forecast_io'
require 'net/http'
require 'socket'
require 'json'
require 'color'
$stdout.sync = true # All logging flush immediately
CUBE_HOST = 'localhost'.freeze
CUBE_PORT = 8300
PositiveInfinity = +1.0 / 0.0
NegativeInfinity = -1.0 / 0.0
ForecastIO.configure do... |
require 'spec_helper'
describe MoneyMover::Dwolla::CustomerDocumentResource do
let(:customer_id) { 123987 }
let(:document_id) { 777 }
it_behaves_like 'base resource list' do
let(:id) { customer_id }
let(:expected_path) { "/customers/#{id}/documents" }
let(:valid_filter_params) { [] }
end
it_beh... |
class Index::UsersController < IndexController
before_action :require_login, only: [:edit]
layout false, only: :new
# GET /index/users/new
def new
@user = Index::User.new
@schools = Manage::School.limit(8)
end
def show
redirect_to v_ucenter_path(params[:id])
end
# GET /index/users/1/edit
... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/student'
class StudentTest < Minitest::Test
def test_it_exists
frank = Student.new("Frank", "Costello", "800 888 8888")
assert_instance_of Student, frank
end
def test_it_has_first_attributes
frank = Student.new("Frank", "Costello", ... |
require "restrictable/version"
require "rails"
require "restrictable/railtie.rb" if defined?(::Rails)
module Restrictable
module ControllerMethods
extend ActiveSupport::Concern
included do
# Controller helper for denying access from user roles
# Example of use:
# prevent :seller, to: :de... |
class Comment < ActiveRecord::Base
belongs_to :course
belongs_to :user
validates :rating, inclusion: { in: 1..5 }, allow_nil: true
validates :content, presence: true
validates :graduate, acceptance: { accept: true }, if: :grad
enum kind: { comment: 1, opinion: 2, question: 3 }
def grad
self.opinion... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.role? "admin"
can :manage, :all
else
can :create, User
can :create, Recipe
can :create, Ingredient
end
end
end
|
# -*- encoding: utf-8 -*-
module SendGrid4r
module Factory
#
# SendGrid Web API v3 Event Factory Class implementation
#
module EventFactory
def self.create(enabled:, url: nil, group_resubscribe: nil,
delivered: nil, group_unsubscribe: nil, spam_report: nil,
bounce: nil, deferred... |
#Escreva uma função chamada fat que retorna o fatorial de um número. A função
#deve verificar se o parâmetro passado é inteiro e maior do que zero, caso contrário
#deve retornar -1.
def fat(x)
if x >= 0
fatorial = 1
for i in 1..x do
fatorial *= i
end
return fatorial
else
return -1
end
end
|
class Auction::ImportRealmDataWorker
include Sidekiq::Worker
sidekiq_options queue: 'important'
def initialize
@wow_client = WowClient.new(logger)
end
def perform(realm_name)
logger.info "Performing realm import, realm_name = #{realm_name}"
raise "'realm' argument is required" unless realm_na... |
require_relative '../app/models/task_metric'
class Analytics
def self.velocity(opts = {})
options = {}.merge(opts)
if (options.has_key?(:from))
velocities = TaskMetric.where { done_at >= options[:from] }.group_by_week(:done_at, :format => '%m/%d/%Y').sum(:estimate)
else
velocities = TaskMetri... |
require "minitest/autorun"
require "minitest/autorun"
require "./spec/helpers/product_helper"
require "./spec/helpers/customer_helper"
require "./lib/product_loan_count"
class ProductLoanCountSpec < MiniTest::Spec
before do
Customer.delete_all
@customer = CustomerHelper.customer2
@product = ProductHelper... |
class E1produccion < ApplicationRecord
belongs_to :e1recurso
belongs_to :e1articulo, optional: true
end
|
require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/mock'
require_relative 'test_helper'
require 'international_trade/sales_totaler'
describe SalesTotaler do
include TestHelper
describe "#initialize" do
it "should configure converter" do
converter = Object.new
totaler = SalesTo... |
module Adminpanel
class AnalyticsController < Adminpanel::ApplicationController
include Adminpanel::Analytics::InstagramAnalytics
skip_before_action :set_resource_collection
before_action :set_fb_token
def index
end
def instagram
authorize! :read, Adminpanel::Analytic
if !@inst... |
require 'test_helper'
class ToddlersControllerTest < ActionDispatch::IntegrationTest
setup do
@toddler = toddlers(:one)
end
test "should get index" do
get toddlers_url, as: :json
assert_response :success
end
test "should create toddler" do
assert_difference('Toddler.count') do
post to... |
require 'spec_helper'
describe "Competition Pages" do
subject { page }
let!(:competitor_set) { FactoryGirl.create(:competitor_set) }
before { valid_login(FactoryGirl.create(:user)) }
describe "competition creation" do
before { visit new_competition_path }
it { should have_selector('h1', text: "Create a... |
require 'net/http'
class FetchYoutubeTranscript
def initialize(options = {})
@video_id = options.delete(:video_id)
end
def download_transcript
Net::HTTP.get(URI("http://video.google.com/timedtext?lang=en&v=#{@video_id}"))
end
def download_transcript_to(output)
File.open(output, "w").write(downl... |
# 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... |
class ExerciseCommentsController < ApplicationController
before_action :authenticate_user!
def index
@exercise_comments = ExerciseComment.all
end
def create
p params
ExerciseComment.create(
content: params[:content],
user: current_user,
exercise: Exercise.find(params[:exercise]... |
require "minitest/autorun"
require './lib/phone_number'
class PhoneNumberTest < MiniTest::Test
def test_it_exists
phone_number = PhoneNumber.new
assert_kind_of PhoneNumber, phone_number
end
def test_it_is_initialized_from_a_phone_number
number = '4236466119'
pn = PhoneNumber.new(number)
a... |
class PeersController < ApplicationController
before_action :set_peer, only: [:show, :edit, :update, :destroy]
# GET /peers
# GET /peers.json
def index
@peers = Peer.all
end
# GET /peers/1
# GET /peers/1.json
def show
end
# GET /peers/new
def new
@peer = Peer.new
end
# GET /peers/1... |
require 'rails_helper'
include Rails.application.routes.url_helpers
resource 'Users' do
let(:raw_post) { params.to_json }
let(:email) { 'sample@example.com' }
let(:user_password) { 'password' }
before do
@user = create(:user, email: email, password: user_password)
header 'Content-Type', 'application/j... |
# frozen_string_literal: true
module Readings
# This class is used in Api:ReadingsController
class Create < Mutations::Command
required do
float :temperature
float :humidity
float :battery_charge
string :household_token
end
def execute
set_reading_stats
set_sum_stat... |
class ApplicationController < ActionController::Base
protect_from_forgery
def is_admin
unless(session[:admin])
redirect_to admin_login_path
end
end
def is_in_blacklist(user_id, block_id)
Blacklist.where(:user_id => user_id, :block_id => block_id).count > 0
end
end
|
# frozen_string_literal: true
class PageViewLog < ::ActiveRecord::Base
class << self
def create_yesterday_data
# 早朝だとまだ昨日のデータは作成されていないため一昨日っぽくなっているがこれでOK
# @type var yesterday: ::Time
yesterday = ::Time.now.beginning_of_day - 2.day
create_from_big_query(yesterday)
end
def create_... |
class CreateElevators < ActiveRecord::Migration[5.2]
def change
create_table :elevators do |t|
t.string :serialNumber
t.references :status, foreign_key: true
t.date :inspectionDate
t.date :installDate
t.string :certificat
t.text :information
t.text :note
t.references :typ... |
require 'spec_helper'
feature 'Create Event' do
let!(:host) { FactoryGirl.create :host }
let!(:event) { FactoryGirl.create :event }
before(:each) do
web_login host
end
context 'on host events display page' do
it 'can create event with valid input' do
visit host_events_path(host)
fill_in... |
class Sermon < ActiveRecord::Base
has_many :notes
validates :book, :s_date, :chapter, :verse_first, :verse_last, presence: true
include PgSearch
pg_search_scope :search, against: [:book, :outline],
using: {tsearch: {dictionary: "english"}}
def self.recent
where(published: [true, nil]).order("s_date DESC").li... |
class SecureController < PutitController
before do
check_token
end
private
def check_token
authorization = request.env['HTTP_AUTHORIZATION']
unless authorization
halt 401, { status: 'error', errors: 'Auth required' }.to_json
end
type, token = authorization.split(' ')
unless type ... |
FactoryBot.define do
factory :facility_business_identifier do
sequence(:id) { |n| n }
identifier { SecureRandom.uuid }
identifier_type { "dhis2_org_unit_id" }
facility
end
end
|
require "twitter"
def getTweets(searchTerm, tweetCount)
begin
data = Hash.new
File.readlines(File.join(File.expand_path(File.dirname(__FILE__)), "twitterToken.txt")).each do |line|
var, val = line.chomp.split("=")
data[var] = val
end
client = Twitter::REST::Client.new do |config|
c... |
require_relative 'base'
module SPV
class Fixtures
module Modifiers
# It takes a fixture and replaces a shortcut path with
# a full path to it.
class ShortcutPath < Base
def modify(fixture)
if shortcut = fixture.shortcut_path
if path = @options.shortcut_path(shortcu... |
Rails.application.routes.draw do
mount Rswag::Ui::Engine => '/api-docs'
mount Rswag::Api::Engine => '/api-docs'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
namespace :api, path: "api" do
namespace :v1, path: "v1" do
#post "/signup", to: "users#s... |
class ApplicationMailer < ActionMailer::Base
default from: 'meaghan.m.jones@gmail.com'
layout 'mailer'
end
|
class CreateMobilizations < ActiveRecord::Migration[6.0]
def change
create_table :mobilizations do |t|
t.string :type_mobilization
t.integer :participants, default: 0
t.integer :new_members_sign_ons, default: 0
t.integer :total_one_time_donations, default: 0
t.integer :xra_donation_s... |
module Rubinius
class ByteArray
def self.mutable_primitive_instances?
true
end
end
end |
# 3 inputs form user:
# 1) number1 and number2 for operation
# 2) arithmatic operation
def say(message)
puts "=> #{message}"
end
# Check if input is a number, which include characters:
# 1. "-" at front if exist
# 2. only one "."
# 3. digits
def check_number(num)
if num =~ /^-?\d+(\.\d+)?$/
true
else
pu... |
class AddPointsNameToLoyaltyConfigs < ActiveRecord::Migration
def change
add_column :loyalty_configs, :points_name, :string, default: "Stars"
end
end
|
class OrangeTree
def initialize stage
@stage = stage
@height = 0
@age = 0 # He's full.
@oranges = 0 # He doesn't need to go.
end
def measure_growth
puts "You measure the height of your orange tree."
puts "It is #{@height} feet tall."
if @height < 5
puts "your tree is a sappling"
@stage = "sappling... |
#!/usr/bin/env ruby
###
#
# This file is part of nTodo
#
# Copyright (c) 2009 Wael Nasreddine <wael.nasreddine@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of t... |
Then /^homepage is displayed$/ do
URI.parse(current_url).path.should == root_path
end
Then /^profile is displayed$/ do
URI.parse(current_url).path.should == user_path(@user)
end
Then /^repeate activation page is displayed$/ do
URI.parse(current_url).path.should == repeate_activation_user_path(@user)
end
... |
require_relative 'test_helper'
class InvoiceRepositoryTest < Minitest::Test
attr_reader :invoice_repository, :sales_engine, :data
def setup
@data = "test/fixtures/invoices_fixtures.csv"
@invoice_repository = InvoiceRepository.new('test/fixtures/invoices_fixtures.csv', self)
@sales_engine = Minitest::... |
require 'spec_helper'
describe DummySonsController, type: :controller do
describe '#index' do
let!(:model_count) { 28 }
let!(:dummy_models) { create_list(:dummy_model, model_count, :with_son) }
let(:expected_list) do
dummy_models.first(25).map do |dummy|
dummy_son = dummy.dummy_model_sons.f... |
require 'json'
require 'mongo'
require 'runners/unified'
Mongo::Logger.logger.level = Logger::WARN
class UnknownOperation < StandardError; end
class UnknownOperationConfiguration < StandardError; end
class Executor
def initialize(uri, spec)
@uri, @spec = uri, spec
@iteration_count = @success_count = @failu... |
class CreateRestaurantCuisines < ActiveRecord::Migration
def change
create_table :restaurant_cuisines do |t|
t.integer :restaurant_id
t.integer :cuisine_id
t.boolean :archived, default: false
t.timestamps
end
add_index :restaurant_cuisines, :restaurant_id
add_index :restaurant... |
require_relative 'web_helpers'
feature 'Signing in' do
scenario 'Users can sign in' do
sign_up
visit '/session/new'
expect(page).to have_content('Please sign in')
fill_in('email', with: 'acav@gmail.com')
fill_in('password', with: 'password')
click_button('Sign me in!')
expect(current_path... |
require 'test_helper'
module Import
class FacebookEventsImportTest < ActiveSupport::TestCase
test 'check element for coordinates in area coordinates' do
element = { place: { location: { latitude: '0', longitude: '0' } } }.deep_stringify_keys
Translatable::AREAS.each do |area|
assert_equal fal... |
class Evil::Client::Middleware
class StringifyForm < Base
private
def build(env)
return env unless env[:format] == "form"
return env if env&.fetch(:body, nil).to_h.empty?
env.dup.tap do |hash|
hash[:headers] ||= {}
hash[:headers]["content-type"] = "application/x-www-form-ur... |
class CreateImages < ActiveRecord::Migration
def change
create_table :images do |t|
t.references :entry
t.timestamps
end
add_index :images, :entry_id
add_attachment :images, :photo
end
end
|
require "rails_helper"
feature "Destroy course" do
subject {page}
let(:supervisor) {FactoryGirl.create :supervisor}
let!(:course){FactoryGirl.create :course, user_ids: [supervisor.id]}
before :each do
course.finished!
login_as supervisor, scope: :user
visit supervisor_courses_path
end
scenario... |
# frozen_string_literal: true
module Types
module Objects
class ArtistObject < ::Types::Objects::BaseObject
description 'アーティスト'
field :id, ::String, null: false, description: 'ID'
field :name, ::String, null: false, description: '名前'
field :status, ::Types::Enums... |
=begin
You don't trust your users. Modify the program below to require the user to enter the same value twice in order to add that value to the total.
Example run:
Hello! We are going to total some numbers!
Enter a negative number to quit.
3
3
2
2
-1
-1
Result: 5
=end
puts "Hello! We are going to ... |
class SecretsController < ApplicationController
before_action :require_login, only: [:new, :create, :destroy]
def new
@secrets = Secret.all
end
def create
Secret.create(content: params[:content], user_id: params[:id])
redirect_to :back
end
def destroy
secret = Secret.find(params[:id])
secret.destroy ... |
class Company < ActiveRecord::Base
has_many :company_reviews
has_many :products
validates :name, :catch_phrase, :suffix, presence: true
end
|
class Admin::ZhangmenjueController < ApplicationController
layout 'admin'
before_filter :validate_login_admin
def index
user = User.find(session[:user_id])
#用户的掌门诀
@zhangmenjues = user.zhangmenjues.paginate(:page => params[:page])
#将用户的掌门诀以字典形式存储
@zhangmenjues_info = {}
@zhangmenjues.ea... |
require 'spec_helper'
require 'machine'
require 'pry'
RSpec.describe Machine, machine: true do
let(:product_name) { "coke 500ml" }
before(:each) do
subject { described_class.new }
subject.stub(:puts).with(anything())
# subject.stub(:p).with(anything())
end
it 'Request user to load products' do
... |
class PostsController < ApplicationController
load_and_authorize_resource
# GET /posts
# GET /posts.json
def index
@d1 = params[:d1].nil? ? (Time.now - 3600*24*7).strftime("%F") : params[:d1]
@d2 = params[:d2].nil? ? Time.now.strftime("%F") : params[:d2]
@posts = Post.where("DATE(created_at) >= ? AN... |
module WorksheetsHelper
def display_problem_number(worksheet_problem)
"#{worksheet_problem.problem_number})"
end
def problem_links_if_editable(worksheet_problem, editable)
if editable
render :partial => "worksheet_problems/worksheet_problem_links", :locals => { :worksheet_problem => worksheet_pro... |
class J1900c
attr_reader :options, :name, :field_type, :node
def initialize
@name = "Number of falls since admission/entry or reentry or prior assessment resulting in major injury (J1900c)"
@field_type = RADIO
@node = "J1900C"
@options = []
@options << FieldOption.new("^", "NA")
@options <... |
class ForecastFacade
attr_reader :id,
:current_weather,
:hourly_weather,
:daily_weather
def initialize(location)
@id = 1
@location = location
@current_weather = current_data
@hourly_weather = hourly_data
@daily_weather = daily_data
end
def lat_long... |
Rails.application.routes.draw do
root 'static_pages#index'
get 'about' => 'static_pages#about'
devise_for :users, :controllers => {registrations: 'registrations'}
resources :users, only: [:show, :index] do
resources :debts, except: [:index, :show]
end
put '/complete', to: 'debts#complete', as: :comple... |
class Admin::Api::BuyerApplicationReferrerFiltersController < Admin::Api::BuyersBaseController
##~ sapi = source2swagger.namespace("Account Management API")
##~ e = sapi.apis.add
##~ e.path = "/admin/api/accounts/{account_id}/applications/{application_id}/referrer_filters.xml"
##~ e.responseClass = "a... |
require File.dirname(__FILE__) + '/../test_helper.rb'
class TestAssociationRulesAndParsingApriori < Test::Unit::TestCase
include Apriori
def setup
end
def test_reading_from_a_file
input = File.join(FIXTURES_DIR + "/market_basket_results_test.txt")
assert rules = AssociationRule.from_file(input)
a... |
require 'test_helper'
class ConditionsControllerTest < ActionController::TestCase
setup do
@city = cities(:montevideo)
end
test "should get show" do
get :show, city_id: @city
assert_response :success
assert_equal @city, assigns(:condition).city
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... |
class CreateLayouts < ActiveRecord::Migration
def self.up
create_table :layouts, :force => true do |t|
t.string :title
t.text :content
t.integer :pages_count, :default => 0
end
end
def self.down
drop_table :layouts
end
end
|
require 'rails_helper'
RSpec.describe Highlight, type: :model do
it { should belong_to :image }
it { should belong_to :key }
it { should belong_to :locale }
it { should belong_to :location }
it { should have_one :project }
end
|
module API
module V1
class CartsController < ApplicationController
before_action :authenticate
# Authenticate with token
def show
info = $redis.hgetall current_user_cart
@cart = Cart.new
info.each do |product_id, quantity|
@cart.add_item(CartItem.new(product_id,... |
class ReferencesController < ApplicationController
load_and_authorize_resource
# GET /works/:work_id/references
# GET /creators/:creator_id/references
def index
@references = Reference.all
render json: @references
end
# GET /references/1
def show
render json: @reference
end
# POST /wor... |
json.array!(@test_cases) do |test_case|
json.extract! test_case, :id, :title, :summary, :manual_process, :automated_test_path
json.url test_case_url(test_case, format: :json)
end
|
require "./lib/human_player"
describe "HumanPlayer" do
it "should set the human player's mark to 'X'" do
human = HumanPlayer.new("human")
human.mark.should == "X"
end
it "should set the human player's mark to 'O'" do
human = HumanPlayer.new("computer")
human.mark.should == "O"
end
end |
module Chocobo
class Screen < Choco
def self.size
{ width: MG::Director.shared.size.width, height: MG::Director.shared.size.height }
end
end
end
|
class TrainerLeadInterviewsController < ApplicationController
def index
@trainer_lead_interviews = TrainerLeadInterview.all
render json: @trainer_lead_interviews
end
def show
@trainer_lead_interview = TrainerLeadInterview.find(params[:id])
render json: @trainer_lead_intervi... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :sprint do
start_at Date.today
finish_at Date.today+15.days
sprint_type 1
project
end
end
|
# == Schema Information
#
# Table name: reps
#
# id :integer not null, primary key
# exercise_id :integer not null, foreign_key
# qty :float not null
# dt :date not null
# created_at :datetime
# updated_at :datetime
# d... |
class AddCountryIdToUserInfo < ActiveRecord::Migration
def change
add_column :user_infos, :country_id, :integer
add_column :user_infos, :state_id, :integer
end
end
|
class Record < ApplicationRecord
validates :order, presence:true
validates :name, presence:true
validates :phone, presence:true
validates :email, format: {with: /.*@.*/}
end
|
module Api
module V1
class ProductResource < JSONAPI::Resource
attributes :name, :sold_out, :category, :under_sale,
:price, :sale_price, :sale_text
filters :category, :min_price, :max_price
class << self
def sortable_fields(context)
super(context) + [:selling... |
require 'rails_helper'
module Annotable
RSpec.describe 'Organizations', type: :request do
context 'with organizations' do
let!(:organization) { Fabricate(:organization) }
describe 'GET /organizations' do
it 'should return the collections' do
get(organizations_path)
expec... |
class AddColumnToEducationalProgram < ActiveRecord::Migration
def change
add_column :educational_programs, :language, :string
end
end
|
module Searchable
extend ActiveSupport::Concern
class_methods do
def search(attrs, &filter)
logger.debug "Searchable::search filter: #{block_given?}"
logger.debug attrs.to_yaml
likes = []
data = []
attrs.each_pair { |(key, query)|
if block_given?
query = filter.c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.