text stringlengths 10 2.61M |
|---|
class Emails::FormDataSerializer < ApplicationSerializer
object_as :email
attributes(
:email,
:contact_id,
:category_id,
)
end
|
class PortraitsController < ApplicationController
before_action :signed_in_user, only: [:new, :create, :edit, :update, :destroy]
before_action :correct_user, only: :destroy
def index
@portraits = Portrait.paginate(page: params[:page])
end
def create
@portrait = current_user.portraits.build(portrait_... |
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'potatochop/version'
Gem::Specification.new do |gem|
gem.name = "potatochop"
gem.version = Potatochop::VERSION
gem.authors = ["John Mertens"]
gem.email ... |
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
devise_for :users, controllers: {
sessions: 'users/sessions',
passwords: 'users/passwords',
registrations: 'registrations'
}
get "/pages/:page" => "pages#show"
root "pages#show", page: "home"
resourc... |
require 'spec_helper'
describe Restfulie::Client::Formatter::Xml::Driver do
context "when looking up the handler" do
it "should accept pure application/xml" do
Restfulie::Client::Formatter::Xml::Driver.new.can_handle?("application/xml").should be_true
Restfulie::Client::Formatter::Xml::Driver.n... |
require 'rails_helper'
describe "Transactions API" do
it "sends a list of transactions" do
transaction_list = create_list(:transaction, 3)
get '/api/v1/transactions'
expect(response).to be_success
transactions = JSON.parse(response.body)
expect(transactions.count).to eq(transaction_list.coun... |
# frozen_string_literal: true
module TimeStreamer
class VersionViewModel
attr_reader :id, :title, :metadata, :changes
def initialize(id:, title:, metadata:, changes:)
@id = id
@title = title
@metadata = metadata
@changes = changes
end
end
end
|
class AddSecretKeyToArticles < ActiveRecord::Migration[5.2]
def change
add_column :articles, :secret_key, :string
end
end
|
require 'spec_helper'
describe Conference do
before do
@conference = FactoryGirl.create(:conference)
end
subject { @conference }
it { should respond_to(:name) }
it { should respond_to(:league) }
it { should respond_to(:teams) }
end
|
class AddImageableToImages < ActiveRecord::Migration[5.1]
def change
add_reference :webinius_cms_images, :imageable, polymorphic: true, index: true
remove_column :webinius_cms_images, :webinius_cms_page_id
end
end
|
# frozen_string_literal: true
require_relative './../spec_helper'
RSpec.describe ALGOSEC_SDK::Client do
include_context 'shared context'
let(:path) { '/fake' }
let(:data) { { 'name' => 'Fake', 'description' => 'Fake Resource', 'uri' => path } }
describe '#init_http_client' do
before :each do
fake_... |
class Tree
attr_accessor :node_name, :children
def initialize(tree)
@children = []
@node_name = @node_name = tree.keys[0]
tree.values[0].each { |name, child| @children.push Tree.new({name => child}) }
end
def visit_all(&block)
visit &block
children.each... |
# frozen_string_literal: true
class Board
attr_reader :b
WIN_POS = [[0, 1, 2], [3, 4, 5], [6, 7, 8],
[0, 3, 6], [1, 4, 7], [2, 5, 8],
[0, 4, 8], [2, 4, 6]].freeze
def initialize
@b = Array.new(9)
end
def push(player:, pos:)
raise "Invalid input: #{pos}" unless pos.is_a?(In... |
require 'test_helper'
class ServerTest < Test::Unit::TestCase
def test_should_have_a_clean_state
with_server do
assert_equal Deadpool::OK, @server.instance_eval { @state.status_code }
end
end
def test_should_load_handlers
with_server do
handlers = @server.instance_eval { @handlers }
... |
require 'spec_helper'
require_relative 'support/data_helper'
describe GroupBuzz::SlackMessagePreparerV2 do
RSpec.configure do |c|
c.include DataHelper
end
context "test messages" do
it "simple case - WIP until truncate processor complete" do
status, message = message_preparer.prepare(test_mess... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "calliope"
s.version = "0.1.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygem... |
require 'chemistry/element'
Chemistry::Element.define "Fluorine" do
symbol "F"
atomic_number 9
atomic_weight 18.9984032
melting_point '53.63K'
end
|
# = pdf/merger/rjb.rb -- PDF template stamping.
#
# Copyright 2010-14 Paul Schreiber
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'ext'))
require 'java'
require 'iText-4.2.0.jar'
java_import 'java.io.FileOutputStream'
java_import 'com.lowagie.text.pdf.PdfReader'
java_import 'com.lowagie.text.pdf.Pd... |
module Wisper
module Broadcasters
describe LoggerBroadcaster do
describe 'integration tests:' do
let(:publisher) { publisher_class.new }
let(:listener) { double }
let(:logger) { double.as_null_object }
it 'broadcasts the event to the listener' do
publisher.su... |
maintainer "Headshift Ltd."
maintainer_email "support@headshift.com"
license "All rights reserved"
description "Installs/Configures confluence"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.1.9"
depends "apache2"
depends "java"
|
class ExpensesController < ApplicationController
require 'csv'
before_action :set_variables, only: [:index, :filter_category]
def create
valid_params = fill_param_gaps
added_transaction = Transaction.find_or_create_by!(valid_params).as_json
added_transaction["category_name"] = Category.find(added_tran... |
# frozen_string_literal: true
require 'json'
require_relative 'model'
# BambooHR's comment
class Comment < Model
def initialize(hash)
read_from_hash!(hash)
self.id = hash['type']['id']
self.author = hash['type']['authorUser']['preferredName']
application = hash['_application']
self.application ... |
class Serializers::Demand < Serializers::Base
structure(:default) do |arg|
{
id: arg.id,
user: Serializers::User.new(:default).serialize(arg.user),
state: arg.state,
name: arg.name,
description: arg.description,
distance: arg.values[:distance],
created_at: arg.created_at.... |
Pod::Spec.new do |spec|
spec.name = 'BubbleView'
spec.version = '1.2.0'
spec.summary = 'Custom BubbleView'
spec.description = <<-DESC
Custom BubbleView
DESC
spec.homepage = 'https://github.com/woshishui... |
class Recipe < ActiveRecord::Base
belongs_to :user
has_many :recipe_ingredients
has_many :ingredients, through: :recipe_ingredients
has_many :comments, inverse_of: :recipe, dependent: :destroy
has_many :commenters, through: :comments
has_many :replies, inverse_of: :recipe, dependent: :destroy
accepts_nest... |
class HomeworkAssignRule < ActiveRecord::Base
attr_accessor :deleting
after_save :enqueue_build_assign
belongs_to :homework
belongs_to :creator,
:class_name => 'User',
:foreign_key => 'creator_id'
def build_expression(options = {})
options.assert_valid_keys :courses
optio... |
require 'test_helper'
require 'ox'
require File.expand_path 'app/views/page/full_navbar', Rails.root
require File.expand_path 'app/views/page/widget_selector', Rails.root
describe 'Widgets::Page::FullNavbar' do
let(:described_class) { Widgets::Page::FullNavbar }
let(:user_name) { 'John Q Public' }
describe 'r... |
FactoryBot.define do
factory :neightborhood do |p|
p.name { Faker::Company.name }
p.city
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'Projects', type: :feature do
let!(:account_a) { FactoryGirl.create(:account) }
let!(:account_b) { FactoryGirl.create(:account) }
let!(:account_a_project) { FactoryGirl.create(:project, name: 'Account A Project', account: account_a) }
let!(:ac... |
require "application_system_test_case"
class TicketAttachmentsTest < ApplicationSystemTestCase
setup do
@ticket_attachment = ticket_attachments(:one)
end
test "visiting the index" do
visit ticket_attachments_url
assert_selector "h1", text: "Ticket Attachments"
end
test "creating a Ticket attach... |
class Category < ApplicationRecord
belongs_to :user
has_many :word_categories, dependent: :destroy
has_many :words, through: :word_categories
validates :user, presence: true
validates :name, presence: true, uniqueness: { scope: :user_id }
def words_count
# TODO: Extract to counter cache
@words_cou... |
require 'pry'
class Series
def initialize(nums)
@nums = nums
end
attr_reader :nums
def slices(n)
raise ArgumentError if n > nums.length
nums.split(//).map(&:to_i).combination(n).to_a.uniq.select do |series|
nums.include? series.join
end
end
end
|
Rails.application.routes.draw do
devise_for :users
resources :recipes
# get 'recipes', to:'recipes#index'
# get 'recipes/new', to:'recipes#new', as:'new_recipe' # precede greedy 'recipes/:some_variable'
# post 'recipes', to:'recipes#create'
# get 'recipes/:id', to:'recipes#show',... |
class CreateFinalRankings < ActiveRecord::Migration
def change
create_table :final_rankings do |t|
t.references :fantasy_player, index: true, foreign_key: true
t.integer :year
t.integer :rank
t.timestamps null: false
end
end
end
|
require 'representable'
module Radriar
module Roar
module KeyTranslation
extend ActiveSupport::Concern
included do
unless ::Representable::Hash.instance_methods.include?(:__radriar_old_to_hash)
::Representable::Hash.module_eval do
# TODO: Module#prepend giving too much h... |
class AddLearnToUserWords < ActiveRecord::Migration
def change
add_column :user_words, :know, :boolean
end
end
|
require 'test_helper'
class UserModelsControllerTest < ActionController::TestCase
setup do
@user_model = user_models(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:user_models)
end
test "should get new" do
get :new
assert_response :s... |
# This is the controller that provides CRUD functionality for the Group model.
class ActiveRbac::GroupController < ActiveRbac::ComponentController
before_filter :protect_controller
protected
def protect_controller
if current_user.has_role?("Admin")
return true
else
redirect_to "/devices/index"
... |
require 'spec_helper'
class ApiSpecGetTester
include ApiSpec
api_url(:get, 'api/v1/pages/:organization_slug/:space_foo_slug')
attr_accessor :last_response
def organization
OpenStruct.new(slug: 'death-star')
end
def space_foo
OpenStruct.new(slug: 'dark-side')
end
end
class ApiSpecPostTester < A... |
######
# Exercise 2, HW1
# Each time exercise2.rb is run from the command line it displays a random fortune.
# Eugene Wolfson
# No preconditions
# At the prompt in the containing folder enter:
# > ruby exercise2.rb
######
# Holds a list of fortunes and can return a random fortune
class Fortune
FORTUNES = ["You ... |
require 'rails_helper'
RSpec.describe "Products", type: :request do
let(:product) { create(:product) }
describe "GET/potepan/products/id" do
before { get potepan_product_path(product.id) }
it "200レスポンスを返す" do
expect(response.status).to eq 200
end
it "商品名が表示される" do
expect(response.body)... |
# == Schema Information
#
# Table name: articles
#
# id :integer not null, primary key
# title :string(255)
# author_id :integer
# status :string(255)
# publish_date :datetime
# created_at :datetime
# updated_at :datetime
# department_id :integer
# issue_id :i... |
class TransactionController < ApplicationController
require 'json'
require 'httparty'
include TransactionHelper
#The main page function
def index
unless(params[:hash])
@request = "get"
end
#initialize variables
@txInfo = {}
@txInfo['hash'] = params[:hash]? params[:hash].strip : 0
@txI... |
require "t/cli"
require "time"
module T
class << self
# Convert time to local time by applying the `utc_offset` setting.
def local_time(time)
time = time.dup
utc_offset ? (time.utc + utc_offset) : time.localtime
end
# UTC offset in seconds to apply time instances before displaying.
#... |
require_relative "operations/Sum"
require_relative "operations/Difference"
require_relative "operations/Multiplication"
require_relative "operations/Division"
require_relative "operations/Inverse"
require_relative "operations/Square"
require_relative "operations/SquareRoot"
class Calculator
def add_operand(operand)
... |
# frozen_string_literal: true
# Screen objects for the Initial screen
class InitialScreen < BaseScreen
identificator(:try_us_out) { find_element(:id, 'txtTryUsOut') }
identificator(:see_how_it_works) { find_element(:id, 'seehowitwork') }
identificator(:get_started) { find_element(:id, 'getstarted_layout') }
id... |
module Veda
module Response
class IndividualCrossReference < XmlDataObject
def reference_number
xml_obj.find_first('bureau-reference').content
rescue
'(Not found)'
end
alias :bureau_reference :reference_number
def family_name
xml_obj.find_first('individual-na... |
require 'rubygems'
require 'httpclient'
require 'mdb/serializer'
module MDB
# Manages the REST communication to MDB and serialization
class REST
# HTTP headers used for post with marshaled data
POST_ENCODINGS = {
'Content-Type' => 'application/mdb',
'Content-Transfer-Encoding' => "binary" }
... |
# frozen_string_literal: true
class UserIgnore < ApplicationRecord
validates_presence_of :user
validates_presence_of :ignored
validates_uniqueness_of :ignored_id, scope: :user
belongs_to :user
belongs_to :ignored, class_name: 'User'
end
|
feature "Contract Step 1 - Edit" do
context 'Visitor' do
scenario "Access invalid" do
contract = (create :contract)
visit edit_contract_path contract
expect(current_path).to eq new_session_path
end
end
context 'Admin' do
let(:user) { create :user}
background do
login use... |
class Micropost < ActiveRecord::Base
belongs_to :user
validates :content, length: { maximum: 300 }
end
|
class CreateCards < ActiveRecord::Migration
def change
create_table :cards do |t|
t.string :link_to_ticket
t.string :ticket_title
t.boolean :migration
t.boolean :rake_task
t.string :other_prod_concern
t.string :string
t.boolean :regression_concern
t.string :regressi... |
module Auth
class Admin::UserTaggedsController < Admin::BaseController
before_action :set_user_tag
before_action :set_user_tagged, only: [:show, :edit, :update]
def index
@user_taggeds = @user_tag.user_taggeds.page(params[:page])
end
def new
@user_tagged = @user_tag.user_taggeds.buil... |
# frozen_string_literal: true
require 'test_helper'
class ProfileTest < ActiveSupport::TestCase
def setup
@profile = Profile.new(
user: users(:lydia)
)
end
# Validation tests
test 'should be valid' do
assert @profile.valid?
end
test 'returns education' do
@profile.education = 'Mas... |
require 'feedjira'
module UnsFeeder
class RefreshFeedJob < ActiveJob::Base
attr_accessor :jid
queue_as Rails.application.config.app_domain
def perform(*args)
begin
@feed = self.arguments.first
@timestamp = self.arguments.second
@feed_jira = self.arguments[2] if (self.argume... |
class RemoveSalesStatusI18nFromSalesStatuses < ActiveRecord::Migration[5.2]
def change
remove_column :sales_statuses, :sales_status_i18n, :integer
end
end
|
module Rmega
module Nodes
module Traversable
def children
storage.nodes.select { |node| node.parent_handle == handle }
end
def folders
children.select { |node| node.type == :folder }
end
def files
children.select { |node| node.type == :file }
end
... |
# Alan wrote the following method, which was intended to show all of the factors of the input number:
# def factors(number)
# dividend = number
# divisors = []
# begin
# divisors << number / dividend if number % dividend == 0
# dividend -= 1
# end until dividend == 0
# divisors
# end
# p factors(30)
... |
class SeriesSerializer < ActiveModel::Serializer
attributes :id, :name, :license, :race_type, :cars
has_many :series_tracks
end
|
class CreateMedianExpenditures < ActiveRecord::Migration[5.0]
def change
create_table :median_expenditures do |t|
t.integer :total
t.integer :instruction_related
t.integer :support_services
t.references :school_type, foreign_key: true
t.references :state, foreign_key: true
t.t... |
# EDSC-190 As a user, I want to see information about the accuracy of GIBS
# information so I may understand areas where it does not precisely
# correspond to the data I retrieve
require "spec_helper"
describe "Collection GIBS help", reset: true do
extend Helpers::CollectionHelpers
gibs_collect... |
class Report < ApplicationRecord
scope :latest, -> { where(batch_id: maximum(:batch_id)) }
def self.bump_batch_id
new_batch_id = self.maximum(:batch_id) + 1
self.where(batch_id: 0).update_all(batch_id: new_batch_id)
end
end
|
cask :v1 => 'amazon-zocalo' do
version :latest
sha256 :no_check
url 'https://dpfrknqwmbop6.cloudfront.net/mac/Amazon%20Zocalo.pkg'
name 'Amazon Zocalo'
homepage 'http://aws.amazon.com/zocalo/'
license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder
... |
class ScenariosController < ApplicationController
skip_before_action :authenticate_user!, only: [:index,:show]
before_action :find_scenario, only: [:show]
def index
@scenarios = Scenario.all.order(id: :asc)
end
def show
# raise
@record = Record.new
end
private
def find_scenario
@sce... |
# frozen_string_literal: true
describe Zafira::Handlers::TestCase::Cucumber do
let(:example) { build(:example, :new) }
let(:wrapped_example) { Zafira::Handlers::TestCase::Cucumber.new(example) }
context 'built object' do
describe '#test_class' do
it { expect(wrapped_example.test_class).to eq('des_cla... |
class Api::V1::PostsController < ApiController
before_action :set_post
def show
if @post.present?
render json: PostSerializer.new(@post).serializable_hash.to_json, status: 200
else
render json: {errors: ["Not found"]}, status: 404
end
end
private
... |
json.day do
json.partial! 'api/v1/days/show', day: @day
end
|
class Comment < ActiveRecord::Base
attr_accessible :body, :commenter_id, :request_id, :travel_id
belongs_to :travel
belongs_to :commenter, :class_name => "User",
:foreign_key => :commenter_id
validates :travel_id, :commenter_id, :body, :presence => true
end
|
# == Schema Information
#
# Table name: headlines
#
# id :integer not null, primary key
# name :string
# picture :string
# body :string
# league_id :integer
#
class Headline < ActiveRecord::Base
belongs_to :league
end
|
Pod::Spec.new do |s|
s.name = "MyEOSWalletSDK"
s.version = "0.0.3"
s.swift_version = '4.2'
s.summary = "Access EOS account information, send EOS transfers"
s.description = <<-DESC
MyEOSWallet SDK allows to securely access EOS account information and send EOS transfers by implementing the v... |
require 'active_record/connection_adapters/abstract/connection_specification'
require 'dynamic_record/connection_adapters/abstract_adapter'
#https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/connection_specification.rb
module ActiveRecord
class Base
class ConnectionSp... |
require 'debugger'
class Class
def my_attr_accessor(*args)
args.each do |inst_var|
self.send(:define_method, inst_var) do
self.instance_variable_get("@#{inst_var.to_sym}")
end
self.send(:define_method, (inst_var.to_s + '=').to_sym) do |value|
self.instance_variable_set( "@#{ins... |
class Api::AsksController < Api::ApplicationController
before_filter :authenticate!, :except=>%w(index show)
before_filter :get_follow_user_ids, :only=>[:follow]
# ==获取问答列表。
# [路径]: asks
# [HTTP请求方式]: GET
# [URL]: http://your.api.domain/asks.json
# [是否需要登录]: true
#
# ====参数
# - source 申请应用时分... |
# 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
class FontNotoNaskhArabicUi < Formula
head "https://github.com/google/fonts/raw/main/ofl/notonaskharabicui/NotoNaskhArabicUI%5Bwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Noto Naskh Arabic UI"
homepage "https://fonts.google.com/specimen/Noto+Naskh+Arabic+UI"
def install
(share/"fonts").install ... |
class AddFieldsToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :user_id, :integer
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :school, :string
add_column :users, :class_year, :integer
add_column :users, :major, :string
... |
class CitiesController < ApplicationController
before_filter :find_city, :only => [:destroy, :add_tag]
def index
@cities = City.all
respond_to do |format|
format.html
end
end
def show
@city = City.includes(:tags).find(params[:id])
#@nearest_cities = @city.get_nearest_cities()
res... |
class AddMaterialAndNotesToPart < ActiveRecord::Migration
def change
add_column :parts, :material, :text
add_column :parts, :notes, :text
end
end
|
class SubmissionsController < ApplicationController
before_action :admin_only, :only => [:index, :problem]
before_action :signed_in_users_only, :only => :create
before_action :users_allowed_to_submit_only, :only => :create
before_action :correct_user_or_admin, :only => :user
before_action :owner_or_admin, :on... |
require_relative './coins'
require_relative './products'
require_relative './coin_validator'
require_relative './calculate_change'
class VendingMachine
def initialize
@current_amount = 0
# Coins as objects; machine identifies coin / determines value based on physical attributes.
@nickels, ... |
class InfrastructuresController < ApplicationController
before_action :set_infrastructure
before_action do
authorize @infrastructure
end
def show
@infrastructure_components = @infrastructure.infrastructure_components.order(:sequence)
end
def retry_provision
@infrastructure_component = Infrastr... |
require_relative 'utils'
module CocoapodsPruneLocalizations
class Pruner
def initialize(context, user_options)
@user_options = self.class.user_options(context, user_options)
@pruned_bundles_path = File.join(context.sandbox_root, "Pruned Localized Bundles")
FileUtils.mkdir @pruned_bundles_path u... |
class UpdateDropdownsController < ApplicationController
def create
org_ids = params[:org_ids]
@protocols = []
@protocols = org_ids.flat_map{ |id| find_protocols(id) }
end
private
def find_protocols(org_ids)
Protocol.find_protocols_by_org_id(org_ids)
end
end
|
require 'spec'
require 'ui/console_style'
require 'board/board'
describe Ui do
before(:each) do
@board = Board::Board.new
end
it "should print out the play command" do
Ui::ConsoleStyle.print_play_move('O', 4).should == 'play O 4'
end
it "should print the board" do
Ui::ConsoleStyle.print_board(@... |
# Extend Resque::Server to add tabs
module ResqueScheduler
module Server
def self.included(base)
base.class_eval do
helpers do
def format_time(t)
t.strftime("%Y-%m-%d %H:%M:%S")
end
def queue_from_class_name(class_name)
Res... |
# web elements and functions for page
class FramesPage
include Capybara::DSL
include RSpec::Matchers
include Capybara::RSpecMatchers
def initialize
# basic
@home = Element.new(:css, '#simpleLink')
@dynamic_home = Element.new(:css, '#dynamicLink')
# api links
@created = Element.new(:css, '#c... |
require File.dirname(__FILE__) + '/spec_helper'
describe Domainatrix do
describe ".parse" do
it "should convert a string into a url object" do
Domainatrix.parse("http://pauldix.net").should be_a Domainatrix::Url
end
it "should canonicalize" do
Domainatrix.parse("http://pauldix.net").canonica... |
require_relative "queue"
require_relative "stack"
class StackQueue
include Enumerable
def initialize(value = nil)
@stack_a = Stack.new
@stack_b = Stack.new
if !value.nil?
if value.is_a?(Array)
value.each { |el| @stack_a.push(el) }
else
@stack_a.push(value)
end
end
... |
require 'spec_helper'
module SonyCameraRemoteAPI
describe SonyCameraRemoteAPI::Camera, HDR_AZ1: true do
let(:cam) { @cam }
describe '#preparing data for contents API tests' do
it 'generates 210 still images, 10 movie files (6 MP4, 4 XAVCS) for 3 days ( (210+10)*3=660 all)' do
dates = []
... |
class CreateCharities < ActiveRecord::Migration
def change
create_table :charities do |t|
t.string :name
t.string :display_name
t.string :ein, null: false
t.string :care_of
t.string :address
t.string :city
t.string :state
t.string ... |
require "application_system_test_case"
class StudentsTest < ApplicationSystemTestCase
setup do
@student = students(:one)
end
test "visiting the index" do
visit students_url
assert_selector "h1", text: "Students"
end
test "creating a Student" do
visit students_url
click_on "New Student"
... |
class Participation < ApplicationRecord
belongs_to :user
belongs_to :pouss, polymorphic: true #participation.pouss
scope :administrators, -> { where(admin: true) }
end
|
class Oystercard
attr_reader :balance
CAPACITY = 90
MINIMUM_FARE = 1
def initialize
@balance = 0
@swipe = false
@location = []
end
def top_up(money)
fail 'Cannot input that amount! Maximum balance of $90 will be exceeded' if full? or @balance + money > CAPACITY
@balance += money
end... |
class ChangesToPosts < ActiveRecord::Migration[5.2]
def change
remove_column :posts, :postable_type
remove_column :posts, :postable_id
end
end
|
class CreateStatusesTagsJoin < ActiveRecord::Migration
def up
create_table :statuses_tags, :id => false do |t|
t.integer "status_id"
t.integer "tag_id"
end
add_index :statuses_tags, ["status_id", "tag_id"]
end
def down
drop_table :admin_statuses_tags
end
end
|
require_relative "base"
class Geocodize::Lookups::OSM < Geocodize::Lookups::Base
require 'net/http'
require 'json'
SEARCH_URL = "http://nominatim.openstreetmap.org/search?";
EMPTY_PAARAMS = -999
HTTP_ERROR = -1
JSON_ERROR = -2
NO_DATA = -3
PER_SECOND = 1
@last_queried = 0
def self.if_op... |
# Hack BufferedLogger to add timestamps to messages
module ActiveSupport
class BufferedLogger
alias_method :old_add, :add
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
time = Time.now
... |
class AddcolumnToPlace < ActiveRecord::Migration[5.0]
def change
add_column :places, :latitude, :string
add_column :places, :longitude, :string
end
end
|
# -*- encoding : utf-8 -*-
Dado /^que se encuentra en la página para introducir la nueva palabra$/ do
visit new_palabra_path
end
Dado /^que se cuenta con al menos dos significados$/ do
@significados = [ FactoryGirl.create(:significado), FactoryGirl.create(:significado) ]
end
Cuando /^se introduce una palabra vá... |
class Cli
def call
welcome
PlacesQuery.query_to_hash #debatable where in the flow control to load this volume of data
main_menu
goodbye
end
def welcome
puts "Welcome to the Country Information Gem! .\nHello User!"
end
def main_menu
input = nil
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.