text
stringlengths
10
2.61M
class Registration < ApplicationRecord belongs_to :aircraft end
class Gitlab::Client module DeployKeys def list_deploy_keys(project) get("/projects/#{project}/deploy_keys", query: options) end def create_deploy_key(project, title:, key:, readonly: true) body = { title: title, key: key, can_push: !readonly } post("/projects/#{project}/deploy_keys", b...
require "spec_helper" describe Bundle::BrewInstaller do let(:formula) { "git" } let(:options) { { :args => ["with-option"] } } let(:installer) { Bundle::BrewInstaller.new(formula, options) } def do_install Bundler.with_clean_env { installer.install_or_upgrade } end describe ".install" do before d...
class IcseWeightage < ActiveRecord::Base validates_presence_of :name validates_presence_of :icse_exam_category_id validates_presence_of :ea_weightage,:ia_weightage,:grade_type validates_numericality_of :ia_weightage,:ea_weightage,:allow_blank=>true belongs_to :icse_exam_category has_and_belongs_to_many :sub...
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html resources :external_books, only: :index, path: '/external-books' resources :books, only: [:index, :show, :update, :destroy, :create], path: '/api/v1/books', defaults: { format: :json ...
# encoding: UTF-8 require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCRubyCoreSupport < Minitest::Test def test_time_supports_negative if RubyCoreSupport.time_supports_negative assert_equal(Time.utc(1969, 12, 31, 23, 59, 59), Time.at(-1).utc) else as...
class AddNotificableToNotification < ActiveRecord::Migration def change add_reference :notifications, :notificable, index: true, polymorphic: true end end
class SerializableState < SerializableRecord attributes :name belongs_to :country has_many :cities end
class Mix < ActiveRecord::Base has_many :mix_styles has_many :styles, through: :mix_styles end
FactoryGirl.define do factory :user do password "testdrive" password_confirmation "testdrive" password_reset_token SecureRandom.urlsafe_base64 password_reset_sent_at Time.zone.now trait :paul do name "Paul Young" username "@pyoung" email "paul@example.org" end trait :bi...
require 'rails_helper' RSpec.describe 'ラベル機能', type: :system do let!(:user) { FactoryBot.create(:user) } let!(:label_category) { FactoryBot.create(:label_category, name: 'test1') } before do visit new_session_path fill_in 'session[email]', with: 'test1@email.com' fill_in 'session[password]', with: 't...
class MessagesController < ApplicationController before_action :set_group before_action :set_message, only: [:show, :edit, :update, :destroy] include ActionView::Helpers::TextHelper def index if current_user.groups.include? @group if params[:last] != "undefined" @messages = @group.messages.whe...
require 'gtk3' require './Classes/boutonAide.rb' #====== La classe BouonAideHerbe hérite de la classe BoutonAide et représente une aide spécifique aux herbes class BoutonAideHerbe < BoutonAide #=Variable d'instance # @bouton : Le bouton # @coordI, @coordJ : Coordonnées du bouton # @cliquable : booléen # @@pri...
# frozen_string_literal: true module ActionDispatch class RequestId private def internal_request_id RequestStore[:request_id] ||= SecureRandom.base58 end end end
Pod::Spec.new do |s| s.name = "ASUserDefaults" s.version = "0.2.1" s.summary = "ASUserDefaults is an NSUserDefaults wrapper written for Swift 2.0" s.description = <<-DESC ASUserDefaults is an NSUserDefaults wrapper written for Swift 2.0. You may be asking yourself the followin...
# coding: utf-8 require "test_utils" require "socket" require "json" require "http" require "webrick" require 'logstash/inputs/http' describe "inputs/http" do extend LogStash::RSpec describe "basic input configuration for push" do config <<-CONFIG input { http { port => ...
require File.expand_path(File.join(File.dirname(__FILE__), 'helper')) require 'racc/directed_graph' module Racc module GraphTests def setup init @graph.start = @a @graph.add_child(@a, @b) @graph.add_child(@a, @c) @graph.add_child(@c, @d) end def test_reachable assert_...
class UserMailer < ActionMailer::Base default from: "seatbooked@gmail.com" def order_receipt(order) @price, @seat_info, @show, @user, @transaction_id = order.values mail(:to => order[:user].email_id, :subject => "Seats Successfully Booked") end end
# # Cookbook:: gravitee # Recipe:: default # # Copyright:: 2017, The Authors, All Rights Reserved. include_recipe 'yum-epel::default' include_recipe 'java::default' include_recipe 'sc-mongodb::default' include_recipe 'elasticsearch::default' poise_archive 'gravitee.zip' do path node['gravitee']['api_manager'] des...
require "concerns/user_provided_services" class OauthCredentials extend UserProvidedService def self.cg_app_id if use_env_var? ENV["CG_APP_ID"] else credentials(base_name("oauth"))["CG_APP_ID"] end end def self.cg_app_secret if use_env_var? ENV["CG_APP_SECRET"] else ...
class User < ApplicationRecord has_many :tips has_many :combos has_many :tutorials has_many :tier_lists has_secure_password validates :email, presence: true, uniqueness: true end
Rails.application.routes.draw do resources :tasks resources :users post '/login', to: "users#login" get '/tasks-by-duedate', to: "tasks#index_by_due_date" get '/tasks-by-priority', to: "tasks#index_by_priority" get '/tasks-by-description', to: "tasks#index_by_description" get '/filter-by-priority/:priorit...
class AddNoteIdtoAttachment < ActiveRecord::Migration[6.0] def change add_column :attachments, :attachable_id, :integer add_column :attachments, :attachable_type, :string end end
class Api::CommentsController < ApiController before_action :authenticate! before_action :find_comment, only: [ :update, :destroy, :like_toggle ] def update if @comment.update(comments_params) success(data: @comment) else error(message: @comment.errors.full_messages.to_sentence) end end...
class HrReport < ActiveRecord::Base serialize :report_columns, Hash serialize :report_filters, Hash validates_presence_of :name, :report_name validates_uniqueness_of :name, :case_sensitive => false before_validation :strip_leading_spaces Result = Struct.new(:report_name, :row_grouping, :group_count, :col...
# -*- encoding : utf-8 -*- # == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(30) # email :string(255) # password_digest :string(255) # created_at :datetime not null # updated_at :datetime not null...
require File.dirname(__FILE__) + '/../test_helper' class TipoMediosControllerTest < ActionController::TestCase def test_should_get_index get :index assert_response :success assert_not_nil assigns(:tipo_medios) end def test_should_get_new get :new assert_response :success end def test_sh...
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "SharedWorkforce" do describe "#logger" do it "should return the configured logger" do with_configuration do |c| c.logger = logger = double(:logger) SharedWorkforce.logger.should == logger end end end en...
Pod::Spec.new do |s| s.name = 'PPRevealSideViewController-Fork' s.version = '0.0.1' s.platform = :ios s.license = 'MIT' s.summary = 'This is a new controller container, showing views on the side like the Facebook or Path app.' s.homepage = 'https://github.com/ipup/PPRevealSideViewController' s.a...
class CreateProducts < ActiveRecord::Migration def change create_table :products do |t| t.string :name, null: false t.float :price, precision: 5, scale: 2, null: false t.integer :category, precision: 5, limit: 2, null: false t.boolean :published, default: false, null: false t....
class InfluencersGroup < ActiveRecord::Base attr_accessible :name validates :name, presence: true, uniqueness: true has_and_belongs_to_many :influencers, -> { uniq } include PgSearch multisearchable against: [:name] end
class Event < ActiveRecord::Base outpost_model has_secretary include Concern::Validations::SlugValidation include Concern::Associations::AudioAssociation include Concern::Associations::AssetAssociation include Concern::Associations::RelatedLinksAssociation include Concern::Associations::RelatedContentAss...
class Admin::AdminController < ApplicationController require 'csv' respond_to :html before_filter :authenticate_user! before_filter :verify_admin private def verify_admin redirect_to root_path unless current_user.admin? end end
# Convenience class to perform a map style operation across BM3 workers. # # Author: Ben Nagy # Copyright: Copyright (c) Ben Nagy, 2006-2013. # License: The MIT License # (See http://www.opensource.org/licenses/mit-license.php for details.) module BM3 class BM3Map def initialize inserter, messaging @inser...
# Copyright 2007-2014 Greg Hurrell. All rights reserved. # Licensed under the terms of the BSD 2-clause license. require 'walrat' require 'walrat/parslet_combining' class Regexp include Walrat::ParsletCombining # Returns a RegexpParslet based on the receiver def to_parseable Walrat::RegexpParslet.new self ...
class Location < ActiveRecord::Base include Rails.application.routes.url_helpers # neeeded for _path helpers to work in models mount_uploader :image, ImageUploader validates_presence_of :name, :image, :description, :content, :author validates_uniqueness_of :name belongs_to :province end
class AddLikeBoxAttributesToMovies < ActiveRecord::Migration def self.up add_column :movies, :like_box_top, :integer add_column :movies, :like_box_left, :integer end def self.down remove_column :movies, :like_box_left remove_column :movies, :like_box_top end end
class CreatePurchaseOrders < ActiveRecord::Migration def self.up create_table :purchase_orders do |t| t.string :po_no t.datetime :po_date t.string :po_status, :default => "Pending" t.string :reference t.boolean :is_deleted, :default => false t.references :store t.referenc...
ActiveAdmin.register Area do permit_params :name end
class ResourcesController < ApplicationController before_filter :authenticate_user!, :except => [:index, :show, :feed] before_action :set_resource, only: [:show, :edit, :update, :destroy] before_filter :can_edit_resource?, :only => [:edit, :update, :destroy] respond_to :html def index @resources = Resou...
class Product < ActiveRecord::Base belongs_to :user has_many :reviews has_many :product_categories has_many :categories, through: :product_categories accepts_nested_attributes_for :categories has_many :orders, through: :order_products # validates :name, presence: true # validates :user_id, presence: t...
class Favorite < ActiveRecord::Base belongs_to :favable, :polymorphic => true default_scope { where(oreder: 'created_at ASC') } belongs_to :user end
require 'cgi' require 'active_support' class SessionCookieHacker def self.hack(cookie, secret_key_base:) config = Rails.application.config cookie = CGI::unescape(cookie) salt = config.action_dispatch.authenticated_encrypted_cookie_salt encrypted_cookie_cipher = config.action_dispatch.encrypted_cook...
# frozen_string_literal: true FactoryGirl.define do factory :profile do first_name { FFaker::NameJA.first_name } last_name { FFaker::NameJA.last_name } description 'hello' account end end
class Api::V1::PhonesController < Api::V1::BaseController def show @phone = Phone.find(params[:id]) end end
require File.expand_path('../helper', __FILE__) describe "WordEnumerator" do let(:word_enumerator){ Trie::WordEnumerator.new SHAKESPEARE } describe "extracting words" do it "gets one word at a time" do assert_equal "the", word_enumerator.get_word assert_equal "project", word_enumerator.get_word ...
json.array!(@users) do |user| json.extract! user, :id, :id, :username, :email, :encrypt_password, :salt, :role_id, :is_active, :token json.url user_url(user, format: :json) end
class CreateSubcollectionJoins < ActiveRecord::Migration[5.2] def change create_table :subcollection_joins do |t| t.integer :parent_collection_id, null: false, index: true t.integer :child_collection_id, null: false, index: true end add_index :subcollection_joins, [:parent_collection_id, :chil...
class BundlesController < ApplicationController before_filter :find_charity before_filter :find_bundle def show redirect_to @charity unless request.format.js? end private def find_charity @charity = Charity.find params[:charity_id] end def find_bundle @bundle = @charity.bundles.find para...
require 'rack' require 'rbnacl' require 'typhoeus' module EARMMS::Crypto @opslimit = 2**20 @memlimit = 2**24 @tokenlength = 32 def self.keyderiv_url unless ENV.key?("KEYDERIV_URL") raise RuntimeError, "KEYDERIV_URL not specified in environment" end return ENV["KEYDERIV_URL"] end def se...
class ProductsController < ApplicationController before_filter :require_admin, except: [:index, :show, :add_items, :empty_cart, :remove_items, :cart_checkout ] before_filter :require_no_user, except: [:add_items, :remove_items, :empty_cart, :show] def index @cart = setup_cart if params[:packag...
require( 'minitest/autorun') require('minitest/rg') require_relative('../artist.rb') require_relative('../album.rb') class TestAlbum < MiniTest::Test def setup() hash = {"id" => 1, "name" => "Flexicution", "quantity" => "8", "artist_id" => "2"} @album = Album.new(hash) end def test_album_name() asse...
class AddColumnCompanyIdToTfl < ActiveRecord::Migration def change add_column :tfls, :company_id, :integer add_index :tfls, :company_id end end
require 'json' require 'httparty' require 'hashie' module RbWunderground class Base FEATURES = %w[alerts almanac astronomy conditions currenthurricaine forecast forecast10day geolookup hourly hourly10day rawtide satellite tide webcams yesterday] attr_reader :api_key attr_reader :format...
class CreateMatchEntries < ActiveRecord::Migration def change create_table :match_entries do |t| t.references :match_map t.references :user t.references :team t.integer :score t.integer :kills t.integer :deaths t.integer :assists t.timestamps end add_in...
class AccessorExample def its_public puts 'its public' end def calling_protected its_protected end def calling_private its_private end private def its_private puts 'its private' end # It will not be a private method def self.its_private_class_method puts 'its private clas...
require 'spec_helper' describe "charities/edit" do before(:each) do #@charity = assign(:charity) stub_model(Charity)) #checking to see if this helps @charity = assign(:name, :description, :filter_flags, :geographic_region, :area_of_impact, :percent_of_overhead, :religious_affiliation, :how_to_donate, :charity_h...
json.trainings do json.partial! 'api/v1/trainings/show', collection: @trainings, as: :training end
UploadMediaManager::Application.routes.draw do devise_for :users resources :upload_managers root "upload_managers#index" end
#!/usr/bin/env ruby # :title: PlanR::Content::MetadataTree =begin rdoc (c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org> =end require 'plan-r/content_repo/tree' module PlanR module ContentRepo =begin rdoc Tree containing metadata for nodes (files or directories) in ContentTree. =end class MetadataTr...
# -*- encoding: utf-8 -*- require 'csv' module Palmade::Kanned class Controller module Commands class CommandAlreadyDefined < KannedError; end class CommandMethodNotDefined < KannedError; end class CommandMethodAlreadyDefined < KannedError; end class CommandKeyInvalid < KannedError; end ...
=begin (Problem): Write a method that takes two strings as arguments, determines the longest of the two strings, and then returns the result of concatenating the shorter string, the longer string, and the shorter string once again. You may assume that the strings are of different lengths. (Understand the Problem): •...
class Activity < ActiveRecord::Base #:nodoc: validates :stoic, :name, presence: true validates :name, length: { maximum: 3 } validates :name, uniqueness: { scope: :stoic, message: "You already have an activity by this name." } has_one :parent, class_name: "Activity", foreign_key: "activity_id", depen...
class CreateNations < ActiveRecord::Migration def change create_table :nations do |t| t.integer :nation_id t.string :name t.string :ruler t.string :alliance t.decimal :strength t.decimal :infra t.decimal :tech t.decimal :land t.string :color t.string :mo...
# frozen_string_literal: true require 'faker' module Main module Views module Blog module Articles class Index < View::Base expose :articles do (1..20).map { |i| ::Main::Entities::Article.new(id: i) } end end end end end end
class AddSocialComunications < ActiveRecord::Migration def up create_table :social_communications do |t| t.integer :club_id t.string :rss t.string :facebook t.string :twitter t.timestamps end end def down drop_table :social_communications end end
# # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICE...
require 'test_helper' class TopicsControllerTest < ActionDispatch::IntegrationTest setup do @user = users :michael @topic = topics :sample_topic @topic_exists = -> (name) { URI.encode "/topics/exists/#{name}" } end test 'should get index' do get topics_path assert_response :success asse...
class Task < ActiveRecord::Base belongs_to :user has_many :tickets def tickets Ticket.where(:task_id => self.id, :state => 1) end end
require 'spec_helper' describe Cocktail do before :each do @cocktail = Cocktail.new("name", "recipe", :category) end describe "#new" do it "returns a new cocktail object" do @cocktail.should be_an_instance_of Cocktail end it "throws an ArguementError when given less than three paramete...
# -*- encoding : utf-8 -*- class CreateExplanatoryNots < ActiveRecord::Migration def change create_table :explanatory_nots do |t| t.integer :aspirant_id t.string :content t.timestamps end end end
module Services::Spotify class Track < Services::Spotify::Base class << self def all(album_id) req = new("/albums/#{album_id}/tracks") req.class.get( req.service, headers: req.options[:headers] )['items'] end end end end
class ChangeQuotesColumn < ActiveRecord::Migration def change change_column :quotes, :created_at, :timestamp, null: false, default: Time.now end end
module OperaWatir module Compat module Window # Checks whether the body has the given text in it. # # @param [String] str Text to search for. # @return [Boolean] true if the body contains the given text, # false otherwise def contains_text(str) text.index(str) ...
class BaseImageUploader < BaseUploader def initialize(*) super self.aws_acl = 'public-read' end include CarrierWave::MiniMagick version :thumb do process resize_to_fill: [500, 500] end version :small do process resize_to_limit: [150, 150] end version :medium do process resize_t...
module SheetSync module Download class TweetReviewSyncPolicy def initialize(review_tweet, review_attributes) @review_tweet = review_tweet @review_attributes = review_attributes end def sync? tweet_review.nil? || tweet_review.rating.value != review_attributes[:r...
require 'singleton' module Rspec module Rotten class Configuration include ::Singleton class << self attr_accessor :results_file, :time_to_rotten def configure yield self end def register_formatter RSpec.configure do |config| config.a...
# frozen_string_literal: true require 'rails_helper' PaperTrail.request.disable_model(Case) RSpec.describe UserMailer, type: :mailer do before(:each) do ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] end after(:each) do ActionMailer::Base.deliveries.clear end de...
module SessionsHelper # signs in the given teacher. def sign_in(teacher) session[:teacher_id] = teacher.id end # Remembers a teacher in a persistent session. def remember(teacher) teacher.remember cookies.permanent.signed[:teacher_id] = teacher.id cookies.permanent[:remember_token] = teacher.remember...
# frozen_string_literal: true module Pulfalight def config @config ||= config_yaml.with_indifferent_access end private def config_yaml YAML.safe_load(yaml, aliases: true)[Rails.env] end def yaml ERB.new(File.read(Rails.root.join("config", "config.yml"))).result end module_function :confi...
module CapybaraStoreHelpers attr_accessor :current_store def setup_store_admin(user = create(:user)) switch_to_subdomain(user.store.slug) login_as(user) user.store end def setup_store(user = nil) store = create(:store) switch_to_subdomain(store.slug) store end def switch_to_subdom...
require_relative "merge" class MergeSort def sort(to_sort) def merge(left, right) sorted = [] l = 0 r = 0 loop do break if r >= right.length && l >= left.length if r >= right.length || (l < left.length && left[l] < right[r]) sorted << left[l] l += 1 else ...
class RegCompanyController < ApplicationController before_action :authenticate_user! def new @company = Company.new end end
#-- # Copyright (c) 2013 Michael Berkovich, tr8nhub.com # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, ...
class LocationType < ActiveRecord::Base validates :location_type, :presence => true has_many :location end
require_relative '../spec_helper' describe Talis::Feeds::Feed do let(:guid) { ENV.fetch('TEST_USER_GUID', 'fdgNy6QWGmIAl7BRjEsFtA') } before do Talis::Authentication::Token.base_uri(persona_base_uri) Talis::Authentication.client_id = client_id Talis::Authentication.client_secret = client_secret Ta...
# 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 Post < ActiveRecord::Base POSTS_PER_PAGE = 3 include Voteable include Sluggable sluggable_column :title belongs_to :creator, class_name: 'User', foreign_key: 'user_id' has_many :comments has_many :post_categories has_many :categories, through: :post_categories validates :title, :url, :descrip...
def ordered_vowel_words(str) words = str.split(" ") #split the string of words given ordered_vowel_words = words.select do |word| #select words that have ordered vowels already ordered_vowel_word?(word)#store those words in ordered_vowel_words variable(SELECT STORES THE WORDS) end ordered_vowel_words.join...
class Project < ApplicationRecord belongs_to :user has_many :project_skillsets has_many :skillsets, through: :project_skillsets validates :title, presence: true validates :genre, presence: true validates :info, presence: true validates :contact, presence: true scope :search, -> (qu...
class CreateCheckins < ActiveRecord::Migration def up create_table :checkins do |t| t.integer :wall_dispenser_id t.integer :uses t.timestamps end remove_column :wall_dispensers, :uses end def down drop_table :checkins add_column :wall_dispensers, :uses, :integer end end
# frozen_string_literal: true module Slack class Request class Reactions class Add < Slack::Request::Reactions METHOD = ".add" def request_url "#{super}#{METHOD}" end end end end end
module SignHost class Checksum attr_reader :configuration def initialize(configuration) @configuration = configuration end def create(transaction_id, file_id, status) create_checksum(transaction_id, file_id, status) end private def create_checksum(transaction_id, file_id, s...
class ItemsTag include ActiveModel::Model attr_accessor :item_name, :text, :category_id, :state_id, :delivery_id, :area_id, :day_id, :price, :user_id, :name, :image with_options presence: true do validates :item_name validates :text validates :category_id validates :state_id validates :deliv...
module Antlr4::Runtime class Array2DHashSet INITIAL_CAPACITY = 32 # must be power of 2 INITIAL_BUCKET_CAPACITY = 4 LOAD_FACTOR = 0.75 attr_reader :buckets def initialize(comparator = nil, initial_capacity = INITIAL_CAPACITY, initial_bucket_capacity = INITIAL_BUCKET_CAPACITY) comparator.ni...
# frozen_string_literal: true ## --- BEGIN LICENSE BLOCK --- # Original work Copyright (c) 2015-present the fastlane authors # Modified work Copyright 2016-present WeWantToKnow AS # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the...
class BlockchainInfo APP_DOMAIN = 'getcoinhost.com' RECEIVING_ADDRESS = 'YOUR_BITCOIN_PAYMENT_ADDRESS' BLOCKCHAIN_URL = 'https://blockchain.info/api/receive' def self.payment_address_for order_id callback_url = "http://#{ APP_DOMAIN }/process_payment?" + 'secret=' + ENV[ 'SECRET' ] + ...
module SessionsHelper def signed_in? !current_user.nil? end def sign_in(user) session[:user_id] = user.id end def sign_out session[:user_id] = nil end def current_user?(user) current_user == user end def current_user begin @current_user ||= User.find(session[:user_id]) i...
#!/usr/bin/env ruby # This class demonstrates how to use Docopt, which helps provides options to users. require 'docopt' class HelpException < RuntimeError; end SCRIPT = File.basename(__FILE__) CLIENT_DOC = <<DOCOPT Client to interact with the University application. Usage: #{SCRIPT} [options] student create NA...
::SubjectsController class SubjectsController def index repo_id = params.fetch(:rid, nil) if !params.fetch(:q, nil) DEFAULT_SUBJ_SEARCH_PARAMS.each do |k, v| params[k] = v unless params.fetch(k,nil) end end search_opts = default_search_opts(DEFAULT_SUBJ_SEARCH_OPTS) search_opts...