text
stringlengths
10
2.61M
class Status < ActiveRecord::Base validates_presence_of :name end
class Hashtag < ApplicationRecord belongs_to :subject has_many :decks end
module OSMLib # # OSMLib::OSMChange::Change objects consist of OSMLib::OSMChange::Action objects, which contain a # single action as well as one or more Node, Way or Relation. An action # must be created with an action keyword :create, :modify, or :delete) # # change = OSMLib::OSMChange::Change.new ...
require_relative "categories_controller" module Categories def load_categories @categories = CategoriesController.index(@user[:token]) rescue Net::HTTPError => e puts e.response.parsed_response["errors"][0] puts end def delete_category(id) # token = @user[:token] # @categories = Categories...
# frozen_string_literal: true module Hawkins VERSION = "2.0.5".freeze end
class CreateAdventurersItems < ActiveRecord::Migration def change create_table :adventurers_items do |t| t.integer :adventurer_id, index: true t.integer :item_id, index: true t.integer :status t.timestamps end end end
require 'test_helper' class AppsControllerTest < ActionController::TestCase let(:josh) { users(:josh) } test 'can show your apps' do create(:app, creator: josh) sign_in josh get :mine assert_response 200 assert_preloaded "apps" end test 'can get all apps by creator' do create(:app, c...
module Certify class Certificate < ActiveRecord::Base # set the table name self.table_name= 'certify_certificates' # accessor attr_accessible :authority, :ssldata, :uniqueid, :serial, :key_pair # associations belongs_to :authority, :inverse_of => :certificates belongs_to :key_pair, :inv...
class Team < ActiveRecord::Base has_many :dispatchers has_many :drivers has_many :loads end
class WorksController < ApplicationController before_action :authenticate_user!, only: [:show, :new, :create, :edit, :update, :destroy] def index @works = Work.all end def show @work = found_work end def new @work = Work.new end def create work = work_params if verify_create wor...
require 'rails_helper' describe Api::V1::GameResultsController do let!(:default_game) { FactoryBot.create(:game) } let(:game_result_params) do { game_id: default_game.id, home_team_goals: 5, guest_team_goals: 2 } end describe 'POST#create' do it 'has to be success' do process :create, ...
require 'test_helper' class ThoughtsControllerTest < ActionController::TestCase include Devise::TestHelpers test "User can sign in" do sign_in users(:me) assert_response :success end test "should get index when signed in" do sign_in users(:me) get 'index' assert_response :success ...
require "capybara/rspec" require_relative "feature_helpers" require_relative "todo_list/helper" describe "Creating and listing todo items", type: :feature do before :all do Capybara.app = BijouApp end before :each do FeatureHelpers.drop_and_regenerate_table end describe "Listing todo items" do ...
class RealEstate ################# # CLASS METHODS # ################# def self.values Rails.cache.fetch("realestate/values", expires_in: 10.minutes) do file_location = "#{Rails.root}/db/data/real_estate.yml" data = YAML.load(File.read file_location) headers = data.shift #...
class RentExpirationMailer < ApplicationMailer def expired_rent(id_rent) @rent = Rent.find(id_rent) @book = @rent.book @user = @rent.user subject = t('send_mail.mail_expired_rent') mail(to: @user.email, subject: subject) if @book.present? && @rent.present? end end
FactoryBot.define do factory :user_order do card_token { 'tok_321e8dbe8388244b11c68353362b' } postal_code { '111-1111' } prefectures { 4 } city { '面白市' } house_number { '四丁目' } build_number { 'スゴイビル' } phone_number { '11111111111' } end end
# frozen_string_literal: true module ExplodingDots def self.table_name_prefix 'exploding_dots_' end end
class Property::ServiceAppointment < ActiveRecord::Base self.table_name = "service_appointments" belongs_to :landlord belongs_to :property belongs_to :llworkorder belongs_to :serviceworkers end
module Asyncapi module Server class Job < ActiveRecord::Base self.table_name = "asyncapi_server_jobs" enum status: %i[queued success error] def url Engine.routes.url_helpers.v1_job_url(self) end end end end
class Api::UsersController < ApplicationController before_filter :user_not_there! def contacts render json: current_user.contacts end def add_contacts email = params[:contact][:email] if(current_user.email == email) render :json => {error: "You can't add yourself to your contacts."} else...
# frozen_string_literal: true module BeyondCanvas module Generators class CustomStylesGenerator < Rails::Generators::Base # :nodoc: source_root File.expand_path('templates', __dir__) def copy_initializer template 'beyond_canvas_custom_styles.scss', 'app/assets/stylesheets/_beyond_canvas_cust...
require 'test_helper' class SurveyTungsControllerTest < ActionController::TestCase setup do @survey_tung = survey_tungs(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:survey_tungs) end test "should get new" do get :new assert_respons...
require "net/http" module ActionClient module Middleware module Net class HttpClient def call(env) request = ActionDispatch::Request.new(env) method = request.request_method.to_s.downcase response = ::Net::HTTP.public_send( method, URI(request....
class Celebrity < ApplicationRecord has_many :users, through: :bookings has_many :bookings has_one_attached :photo CATEGORIES = ["sport", "music", "history", "politic", "art", "technology"] validates :category, inclusion: { in: CATEGORIES } end
#puts "LOOKING FOR EVMA_HTTPSERVER in #{$LOAD_PATH}" #require 'evma_httpserver' require 'nats/client' require 'vcap/component' $:.unshift(File.dirname(__FILE__)) require 'base' class VCAP::Services::Base::Node < VCAP::Services::Base::Base def initialize(options) super(options) @node_id = options[:node_id] ...
require_relative '../lib/git_hub_client' describe GitHubClient do subject { described_class.new(organization: 'ViniRinaldis', project: 'Sex-Definer-PL-SQL-BRASIL')} describe "#get_commits" do it "return commits for project" do expect(subject.get_commits.count).to eq(2) end end describe "#get_co...
require 'test_helper' module CompanyTest class ValidationTest < ActiveSupport::TestCase test "should raise error for non getmainstreet.com email" do company = Company.new(name: "huffman painting", email: "huffman_painting@coding.com", zip_code: "85015", phone: "4433-898-3324") refute company.valid? ...
class Admin::Menu < ActiveRecord::Base self.table_name = "menus" # action before_save # 後面可接定義的方法 # validate validates :caption, :action, :position, presence: true # relation belongs_to :main_menu, class_name: "Admin::Menu" has_many :menus, -> { order(:seq) }, class_name: "Admin::MenuUser", foreign_key: "paren...
class RemoveColFromHairData < ActiveRecord::Migration def change remove_column :hairdata, :clinic, :string remove_column :hairdata, :regimen, :string remove_column :hairdata, :session, :float end end
require 'roby' require 'rake' require 'rake/tasklib' module Roby module App # Rake task definitions for the Roby apps module Rake # Rake task to run the Roby tests # # To use, add the following to your Rakefile: # # require 'roby/app/...
FactoryGirl.define do factory :telegram_message, class: Telegram::Bot::Types::Message do skip_create sequence(:message_id) { |n| n } association :from, factory: :telegram_user date { DateTime.current.to_i } association :chat, factory: :telegram_private_chat text '/start' end end
require "dotenv/load" require "erubis" require "fileutils" require "pry" require_relative "./integrations/goodreads" require_relative "./integrations/micro_blog" require_relative "./integrations/now" require_relative "./integrations/podcast" require_relative "./integrations/twitter" require_relative "./integrations/you...
class CreateManufactures < ActiveRecord::Migration[5.2] def change create_table :manufactures do |t| t.integer:harvest t.integer:indoor_temperature t.integer:soil_temperature t.integer:humidity end end end
require 'docopt' require 'vanagon/logger' class Vanagon class CLI class List < Vanagon::CLI DOCUMENTATION = <<~DOCOPT.freeze Usage: list [options] Options: -h, --help Display help -c, --configdir DIRECTORY Configuration directory [...
class Series attr_reader :digits, :possible_series def initialize(digits) @digits = digits.chars.map(&:to_i) @possible_series = [] end def slices(num) raise ArgumentError if num > size @digits.each_with_index do |number, index| limit = index + (num - 1) possible_series << @digits[in...
class AddIosAndAndroidToSnapInviteAds < ActiveRecord::Migration def change add_column :snap_invite_ads, :ios, :boolean, null: false, default: false add_column :snap_invite_ads, :android, :boolean, null: false, default: false end end
module Contexts module Availabilities class Creation def initialize(availability, current_user) I18n.locale = :en @availability = availability @current_user = current_user @timezone = current_user[:timezone] @day_index = @availability[:day].to_i @day = I18n....
class CreateServies < ActiveRecord::Migration[5.2] def change create_table :servies do |t| t.string :image t.string :service_name t.string :address t.string :city t.string :contact t.string :description t.timestamps end end end
require 'minitest/autorun' require 'minitest/pride' require './album' require './artist' class AlbumsTest < Minitest::Test def test_album_exists assert Album end def test_can_create_new_album assert Album.new("Chaos and Bunnies") end def test_album_knows_its_name assert_equal "Moonlight Walk...
name 'spoon' maintainer 'maintainer' maintainer_email 'kouzmine_serguei@carnival.com' license 'All rights reserved' description 'Installs/Configures spoon' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.0.2' supports 'windows' # depends ...
require 'spec_helper' describe User do subject(:user) { described_class.new(name: "First Last", email: "test@example.com") } describe 'validations' do it 'should be valid with a name and email' do expect(user).to be_valid end it 'should not be valid without a name' do user.name = " " expect(user).to...
class Api::V1::EventsController < Api::V1::EntriesBaseController def show area = current_api_v1_user.area event = Event.by_area(area).find(params[:id]) # put more details into the event.hosts list @see event#hosts_to_hash hosts_hash = event.hosts.map { |h| h.to_hash } event_hash = event.as_json ...
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'highline/import' describe Scm::Workflow do TMP_PATH = "/tmp/" BAD_PATH = "/adsdsadasdsa" TEST_REPO_PATH = "/tmp/test_git" TEST_REPO_PATH_BARE = "/tmp/test_git_bare" # -----------------------------------------------------------------...
module YamlWebDriver module Action class AlertAction def initialize(action) @action = action end # @param [yaml-web-driver::WatirDriver] driver def run(driver, _) if driver.browser.alert.exists? driver.browser.alert.send(@action) else raise 'no ...
require 'sequel' # SequelSessionStorage is the SessionStorage backend for # Sequel (SQL) database storage class SequelSessionStorage # Opens database connection def db_open # work-around for windows (drive letters causing confusion) if @db_uri.start_with?('sqlite://') @db = Sequel.sqlite( @db_uri.s...
class ListPage attr_accessor :driver def initialize(driver) @driver = driver end def preferencefromcodebutton @driver.find_element(:uiautomator, 'new UiSelector().className("android.widget.TextView").text("5. Preferences from code")') end def preferencedependbutton @driver.find_element(:uiauto...
# 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 OwnersController < ApplicationController def show @owner = Owner.find(params[:id]) end def new @owner = Owner.new end def create @owner = Owner.create(owner_params) redirect_to(@owner) end def edit @owner = Owner.find(params[:id]) end ...
module Navigation class Point attr_reader :lat, :long, :addr alias_method :address, :addr def initialize(info, desc=nil) @lat = info[:lat] @long = info[:lng] @addr = desc end def details { address: addr, coords: coords } end def coords ...
class AddReferencesToTables < ActiveRecord::Migration def change add_reference :climbs, :crag, index: true add_reference :climbs, :section, index: true add_reference :walls, :crag, index: true add_reference :walls, :section, index: true end end
=begin #============================================================================== * Character Afterimages - v1.1 Author: Quack Date: 20/11/2012 #============================================================================== What it does: Allows you to add afterimage effects to player and events....
class Messaging::Error < StandardError def initialize(message) @message = message @reason = nil end attr_reader :message, :reason end
class User < ApplicationRecord has_many :phrases has_many :followers, through: :phrases validates_presence_of :username, :token, :secret validates_uniqueness_of :username, :token, :secret validates_length_of :token, :secret, minimum: 5, too_short: "This entry is too short." end
class TransactionsController < ApplicationController before_action :set_category before_action :set_transaction, except: [:index, :create] def index @transactions = @category.transactions end def show end def create @transaction = Transaction.new(transaction_params) # There has to b...
FactoryBot.define do factory :item do project %i(bib_id oclc_number call_number).each do |identifier| sequence(identifier) {|n| "#{identifier}_#{n}"} end sequence(:barcode) {|n| (n + 30012323456789).to_s} end end
# frozen_string_literal: true require 'grape' require_relative '../exceptions/http_exception' require_relative '../exceptions/validation_exception' require_relative '../exceptions/bad_request_exception' require_relative '../exceptions/unauthorized_exception' require_relative '../helpers/jsender_formatter' require_rela...
class AddMusicToAutomaticCallDistributors < ActiveRecord::Migration def change add_column :automatic_call_distributors, :music, :string end end
json.array!(@customer_orders) do |customer_order| json.extract! customer_order, :id, :name, :address_one, :address_two, :city, :state, :zipcode, :country, :email, :remarks, :gig_id, :buyer_id, :seller_id, :payment_status, :notification_params, :status, :transaction_id, :purchased_at json.url customer_order_url(cust...
require 'date' require 'time' require 'rss' module RssConverter def self.convert(hash_content) rss = RSS::Maker.make('2.0') do |maker| maker.channel.link = hash_content[:link] maker.channel.description = '' maker.channel.title = hash_content[:title] hash_content[:content].each do | i | ...
class AddUserIdToStudios < ActiveRecord::Migration[5.1] def change add_reference :studios, :user, index: true end end
require 'json' require 'chef/node' require 'chef-vault' Chef::Log.info "Using chef-vault #{ChefVault::VERSION}" # # Extra helpers for Chef Vault # module ChefVaultCookbook def chef_vault_item_is_vault?(bag, id) ChefVault::Item.vault?(bag, id) rescue Net::HTTPServerException => http_error http_error.respo...
require 'spec_helper' describe Puppet::Type.type(:address_object).provider(:solaris) do let(:resource) do Puppet::Type.type(:address_object).new( :name => 'myobj', :ensure => :present ) end let(:provider) { described_class.new(resource) } before(:each) do FileTest.stubs(:file?).wi...
class ReviewsController < ApplicationController before_filter :authenticate_user!, only: [:create] before_action :set_review, only: [:edit, :update] # GET /reviews/1/edit def show @review = Review.find_by_token(params[:id]) @tutors = @review.search.present? ? User.where(id: @review.search.requests.repl...
class AddVoucherAndVouchertypeCategory < ActiveRecord::Migration def self.up add_column :vouchertypes, :category, :enum, :limit => [:revenue, :comp, :subscriber, :bundle] add_column :vouchers, :category, :enum, :limit => [:revenue, :comp, :subscriber, :bundle] Vouchertype.reset_column_information Vouc...
require_relative "../lib/person" describe Person do describe "#full_name" do it "returns the first and last names concatenated" do person = described_class.new(first_name: "Dong", last_name: "Huang") expect(person.full_name).to eq("Dong Huang") end end end
class AddVendedorToUser < ActiveRecord::Migration[5.0] def change add_column :users, :vendedor, :string end end
# == Schema Information # # Table name: person_symptoms # # id :uuid not null, primary key # person_id :uuid not null # symptom_id :uuid not null # created_at :datetime not null # updated_at :datetime not null # class PersonSymptom < ApplicationRecord ...
module RouteTranslator module RouteSet module Helpers def available_locales @available_locales ||= I18n.available_locales.map(&:to_s) end def available_locales= locales @available_locales = locales.map(&:to_s) end def default_locale @default_locale ||= I18n....
require 'swagger_helper' RSpec.describe 'api/v1/incidentcategories', type: :request do path "/api/v1/incidentcategories" do post "Create an Incident Categories" do tags "Incident Categories" consumes "application/json" parameter name: :incidentcategories, in: :body, sche...
# encoding: utf-8 require 'spec_helper' describe SrcPlant do it "should reject nil name" do p = FactoryGirl.build(:src_plant, :name => nil) p.should_not be_valid end it "should reject nil short name" do p = FactoryGirl.build(:src_plant, :short_name => nil) p.should_not be_valid end it "...
require 'spec_helper' describe Post do it{ should have_many :feeds} it{ should respond_to :user} it{ should respond_to :title} it{ should respond_to :description} describe "#add_points" do it "increments its points number" do post = Post.new expect{post.add_points} .to change{post.poin...
class StudyMaterial < ActiveRecord::Base has_many :material belongs_to :study end
class Api::UserRecipesController < ApplicationController before_action :authenticate_user, except: [:index, :show] def index @user_recipes = UserRecipe.all @user_recipes.sort_by { |h| h[:vote] }.reverse if params[:search] @user_recipes = @user_recipes.where("name ILIKE ?", "%" + params[:search]....
require "rails_helper" RSpec.describe ExchangeSettingsController, type: :routing do describe "routing" do it "routes to #index" do expect(get: "/exchange_settings").to route_to("exchange_settings#index") end it "routes to #new" do expect(get: "/exchange_settings/new").to route_to("exchange_s...
class HomeController < ApplicationController before_action :authenticate_user! def index @users = User.all @current_user_share_location = {} @current_user_share_location['publicly'] = LocationShare.get_public_share_locations(current_user.id) @current_user_share_location['pr...
#!/usr/bin/env ruby require_relative "lib/github" if $PROGRAM_NAME == __FILE__ if !ENV["GITHUB_ACCESS_TOKEN"] puts "GITHUB_ACCESS_TOKEN environment var needs to be set to a personal access token" exit(1) end if ARGV.length < 1 puts "Usage: #{__FILE__} <github pull request url>" exit(2) end ...
RSpec.describe Rum::Application do subject { Rum.application } describe "::new" do it "initializes with name `rum`" do expect(subject.name).to eq("rum") end end describe "#init" do it "initializes the Rum::Application" do expect { subject.init "rum", [] }.to \ change { subject.to...
################################################# # Vault CLI Tests ################################################# # Chapter 3 - Install Vault autocomplete control 'install-autocomplete' do impact 1.0 desc 'Install Vault autocomplete in our shell' describe powershell( '$HOSTKEY=(ssh-keyscan -H uat-tf-vaul...
require "./test/test_helper" describe OWD do before do OWD.configure do |config| config.client_id = 123 config.client_authorization = 'abc' config.testing = false config.environment = 'production' end end describe 'global configuration' do it { assert_equal OWD.configuration....
class AddAdminToUsers < ActiveRecord::Migration[6.0] def change add_column :users, :admin, :boolean, default: false #setting an admin column to users table with default value of false end end
class Completed < ApplicationRecord belongs_to :contact mount_uploader :proof_image, ProofImageUploader has_attached_file :proof_image, styles: { medium: "300x300>" }, default_url: "/system/medium/image-not-avaliable.png" validates_attachment_content_type :proof_image, content_type: /\Aimage\/.*\z/ valid...
class AddDetailsToUsers < ActiveRecord::Migration def change add_column :users, :level, :string add_column :users, :last, :string add_column :users, :company, :string add_column :users, :address, :string add_column :users, :zip, :string add_column :users, :phone, :string add_column :users,...
class Message < ActiveRecord::Base belongs_to :user belongs_to :friend, :class_name => 'User' validates :body, presence: true, length: {maximum: 2000} end
class RenameTouristIdToNormalUserId < ActiveRecord::Migration def change rename_column :driver_comments, :tourist_id, :normal_user_id end end
=begin Copyright (c) 2013 ExactTarget, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the f...
require 'set' require_relative 'MovieTest' ## #This is the MovieData Class, I store all the data from the test file and the base file in this class, #and also include the predicting algorithm class MovieData attr_reader :movie_data, :user_data, :test_entry, :simi_hash ## #This is the initializer, it first reads...
# frozen_string_literal: true ActiveAdmin.register AllowedUserEmailMasks do menu priority: 100 menu label: "Allowed Emails" index title: "Allowed Emails" # Setting up Strong Parameters # You must specify permitted_params within your AllowedUserEmailMasks ActiveAdmin resource which reflects a allowed_user_e...
require "rails_helper" describe PatientStates::DisaggregatedPatientCountQuery do around do |example| with_reporting_time_zone { example.run } end let(:query) { Reports::PatientState.all } describe ".disaggregate_by_gender" do it "returns the query disaggregated by gender" do Patient::GEND...
Gem::Specification.new do |s| s.name = %q{fxri} s.version = "0.3.6" s.date = %q{2006-12-17} s.summary = %q{Graphical interface to the RI documentation, with search engine.} s.email = %q{markus.prinz@qsig.org} s.homepage = %q{http://rubyforge.org/projects/fxri/} s.rubyforge_project = %q{fxri} s.d...
module WLang class RuleSet module Utils # Regexp string for 'dialect' DIALECT = '[-a-z]+' # Regexp string for 'encoder' ENCODER = '[-a-z]+' # Regexp string for 'qualified/dialect' QDIALECT = DIALECT + '([\/]' + DIALECT + ')*' # Regexp string for 'q...
class ChangeDefaultAdminToUsers < ActiveRecord::Migration[6.0] def change change_column_default :users, :admin, true end end
class PostsController < ApplicationController def show render locals: { post: post.decorate } end private def post return @post if defined?(@post) @post = Post.find(params[:id]) end end
class AccountsController < ApplicationController before_filter :authenticate_user! def create @account = Account.new({:user => current_user, :name => params[:account][:name], :starting_balance => params[:account][:current_balance], ...
class CreateGoalParts < ActiveRecord::Migration def change create_table :goal_parts do |t| t.integer :big_goal_id t.integer :small_goal_id t.timestamps null: false end end end
class CreateUsersBlogs < ActiveRecord::Migration[6.0] def change create_table :users_blogs, id: false do |t| t.belongs_to :user t.belongs_to :blog end end end
class Api::V1::OrgaResource < Api::V1::EntriesBaseResource model_name 'Orga' attributes *(ATTRIBUTES + [:orga_type_id]) has_one :parent_orga, class_name: 'Orga', foreign_key: 'parent_id' has_many :sub_orgas, class_name: 'Orga', foreign_key: 'children_ids' has_many :events, class_name: 'Event' has_many :...
desc "Pull game data for season" task :game_dump, [:season] => :environment do |_t, args| season = if args[:season].present? Season.find_by_year_start(args[:season]) else Season.last end season.games.find_each do |game| puts formatted_game_info(season, game) en...
require 'dry-struct' require_relative 'speaker' module Types include Dry.Types() end class Presentation < Dry::Struct attribute :talk_name, Types::Strict::String attribute :speaker, Speaker attribute :notes, Types::String.default(''.freeze) attribute :subtitle, Types::String.meta(omittable: true).optional ...
# Read about factories at http://github.com/thoughtbot/factory_girl Factory.define :series_metainfo do |f| f.association(:series) f.rmr "MyString" f.series_description "MyString" f.path "MyString" f.scanned_file "MyString" f.timestamp "2011-06-20 12:39:05" f.glob "MyString" f.rep_time "9.99" f.bold_r...
class RenameMyColumnTypeBySocialShares < ActiveRecord::Migration def up rename_column :social_shares, :type, :socai_type end def down end end