text
stringlengths
10
2.61M
# frozen_string_literal: true module BPS module PDF class Roster class Detailed module Merit def merit @users = User.alphabetized.unlocked load_life_member merit_first_page merit_second_page end private def meri...
class Post < ApplicationRecord require 'obscenity/active_model' belongs_to :user belongs_to :topic has_many :comments, dependent: :destroy has_many :votes, dependent: :destroy has_many :post_tags, dependent: :destroy has_many :tags, through: :post_tags validates :title, presence: true # validates :url...
class ReindexingJob @@my_yaml = ReindexingJob.new.to_yaml BATCHSIZE=10 DEFAULT_PRIORITY=2 TIMELIMIT = 15.minutes def perform todo = ReindexingQueue.order("id ASC").limit(BATCHSIZE).collect do |queued| todo = queued.item queued.destroy todo end if Seek::Config.solr_enabled ...
module Supersaas class BaseModel attr_accessor :errors attr_reader :attributes def initialize(attributes) @attributes = attributes assign_attributes(attributes) end private def assign_attributes(attributes) attributes.each do |key, value| public_send("#{key}=", val...
require 'colorize' class ColorSequence LEVEL_ONE_COLORS = ["red".red, "green".green, "blue".blue ,"white".white] LEVEL_TWO_COLORS = ["red".red, "green".green, "blue".blue, "white".white, "yellow".yellow] LEVEL_THREE_COLORS = ["red".red, "green".green, "blue".blue, "w...
class User < ApplicationRecord has_secure_password # Both password and confirmation required on creation validates :password, presence: true, confirmation: true, on: :create validates :password, length: { minimum: 4, message: "must be at least 4 characters long"}, on: :create validates :password_confirmation...
# frozen_string_literal: true module J8 module Functional VERSION = '0.1.0' end end
require 'rails_helper' RSpec.describe Team, type: :model do describe 'validations' do it {should validate_presence_of(:name)} it {should validate_presence_of(:age_group)} end describe 'relationships' do it {should have_many(:players)} it {should have_many(:users)} it {should have_many(:tourn...
# frozen_string_literal: true require 'test_helper' module Vedeu module Colours describe Colour do let(:described) { Vedeu::Colours::Colour } let(:instance) { described.new(attributes) } let(:attributes) { { background: background, foreground: foreground, ...
class PagesController < ApplicationController def home if logged_in? && current_user?(current_user) @message = current_user.messages.build @feed = current_user.messages end end def help end end
class CreateTracks < ActiveRecord::Migration def self.up create_table :tracks do |t| t.float :lat t.float :long t.string :cstId t.string :cstName t.string :icon t.string :category t.decimal :course t.decimal :speed t.datetime :postime t.timestamps en...
require_relative "../test_helper" class BaseTest < Minitest::Test attr_reader :base def setup @base = Hemp::Routing::Base.new end def test_routes_are_empty assert_empty base.routes end def test_responds_to_http_verbs assert_respond_to base, :get assert_respond_to base, :post assert_r...
####################################################################### # test_bm3_core.rb # # Test suite for the main library. ####################################################################### require 'rubygems' gem 'test-unit' require 'test/unit' require 'bm3-core' class TC_BM3_Core < Test::Unit::TestCase te...
class MakeCall @@calls = {} attr_accessor :number, :org_id, :id def initialize(number,controller,org_id, id=1) @number = number @org_id = org_id @controller =controller # @id = id @status = :not_started @answer =false @@calls[id] = self end def start! @ahn_ca...
class Movie < ActiveRecord::Base attr_accessor :acting, :cinema, :score, :writing, :sfx has_many :reviews has_many :movie_genres has_many :genres, through: :movie_genres validates :title, presence: true, uniqueness: true validates :synopsis, presence: true validates :release_date, presence: true validates :d...
class AddPrimaryAddressContact < ActiveRecord::Migration def change add_reference :contacts, :primary_address, index: true add_foreign_key :contacts, :dsc_addresses, column: "primary_address_id" end end
# frozen_string_literal: true require 'rails_helper' describe 'モデルのテスト' do it "有効な会員内容の場合は保存されるか" do expect(FactoryBot.build(:customer)).to be_valid end end
require 'rails_helper' RSpec.describe Api::UsersController, type: :controller do # describe "GET #index" do # it "renders the users index" do # get :index # expect(response).to be_success # expect(response).to render_template(:index) # end # end # describe "GET #show" do # it "re...
# frozen_string_literal: true class Ability include CanCan::Ability attr_reader :user def initialize(user) @user = user return guest_abilities unless user user.admin? ? admin_abilities : user_abilities end private def guest_abilities can :read, :all end def user_abilities gues...
begin require 'bundler/gem_tasks' rescue LoadError end require 'rake' require 'rspec/core/rake_task' require 'bundler/gem_tasks' desc "Build Gem" task :default do system "gem build mailgun.gemspec" end desc "Run default unit specs" RSpec::Core::RakeTask.new('spec') do |t| t.rspec_opts = %w{--colour --format p...
class HtagsController < ApplicationController # GET /htags # GET /htags.json def index my_htags = current_user.htags @tags_with_count = Hash.new() my_htags.each do |ht| cites_with_tag = Htag.search(ht.name, current_user) @tags_with_count[ht.name] = cites_with_tag.count end @tags_wi...
class User < ApplicationRecord has_many :chooses, dependent: :destroy has_many :likes, dependent: :destroy has_many :comments, dependent: :destroy has_many :posts has_many :books, through: :chooses has_many :books, through: :likes has_many :messages devise :database_authenticatable, :registerable, ...
require 'rails/generators' module TinymceFilemanager class InstallGenerator < Rails::Generators::Base desc "Some description of my generator here" def self.source_root @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates')) end def add_uploader # template('image...
# This implements the azure extension 'enable' command. require 'chef' require 'chef/azure/helpers/shared' require 'chef/azure/service' require 'chef/azure/task' require 'chef/azure/helpers/parse_json' require 'openssl' require 'base64' require 'tempfile' require 'chef/azure/core/windows_bootstrap_context' ...
name 'acpi_wakeup' maintainer 'Danny Guinther' maintainer_email 'dannyguinther@gmail.com' license 'MIT' description 'Adds acpi_wakeup service to manage which devices can cause wakeup' long_description 'Adds acpi_wakeup service to manage which devices can cause wakeup' version '0.0.1' recipe 'acpi_wakeup', 'Installs ac...
class AddPostIdToVideos < ActiveRecord::Migration def change add_column :videos, :post_id, :string add_index :videos, :post_id, :unique => true end end
class FontGfsDidot < Formula head "https://github.com/google/fonts/raw/main/ofl/gfsdidot/GFSDidot-Regular.ttf", verified: "github.com/google/fonts/" desc "GFS Didot" homepage "https://fonts.google.com/specimen/GFS+Didot" def install (share/"fonts").install "GFSDidot-Regular.ttf" end test do end end
require File.join(RAILS_ROOT, 'lib', 'position_mover.rb') class Section < ActiveRecord::Base include PositionMover belongs_to :page has_many :section_edits has_many :editors, :through => :section_edits, :class_name => "AdminUser" CONTENT_TYPES=['text','HTML'] #deklarovaná konštanta validates_pre...
module BadgeConcerns module PostBadgeable extend ActiveSupport::Concern include BadgeConcerns::SimpleBadgeable private def award_on_post_created unless shared_through_attachments? || shared? quantity = self.user.posts.where(parent: nil).count award_on_create "posted_%d_times_in_...
# encoding: utf-8 # # © Copyright 2013 Hewlett-Packard Development Company, L.P. # 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 #...
class PunchesController < ApplicationController # GET /punches # GET /punches.json def index @punches = Punch.all @query = params[:search] if @query @query.downcase! punches_a = Punch.arel_table @punches = Punch.where(punches_a[:alias].matches("%#{@query}%").or(punches_a[:mac].ma...
control "M-4.10" do title "4.10 Ensure secrets are not stored in Dockerfiles (Not Scored)" desc " Do not store any secrets in Dockerfiles. Dockerfiles could be backtracked easily by using native Docker commands such as docker history and various tools and utilities. Also, as a general practice, image p...
require 'file_mover/uri' require 'uri' module FileMover module Dsl module CoreMethods def | arg to_file_mover | arg end end end end class URI::Generic include FileMover::Dsl::CoreMethods def to_file_mover FileMover::Uri.to_file_mover(self) end end class Symbol include Fil...
require 'rails_helper' RSpec.describe "stories/edit", :type => :view do before(:each) do @story = assign(:story, Story.create!( :uploader => "", :title => "MyString", :description => "MyString", :latitude => "9.99", :longitude => "9.99" )) end it "renders the edit story for...
# frozen_string_literal: true module LunaPark VERSION = '0.6.1' end
class Product < ApplicationRecord has_many :variants, -> { where('stock > 0') }, dependent: :destroy accepts_nested_attributes_for :variants # TODO # add validations def to_param name end end
module TransferWise class Transfer < APIResource def create_payment(headers = {}) url = self.class.resource_url(id) + "/payments" response = TransferWise::Request.request(:post, url, { type: 'BALANCE' }, headers) response['status'] == 'COMPLETED' end end end
require 'test_helper' class SessionsHelperTest < ActionView::TestCase def setup @usuario = usuarios(:joao) lembrar(@usuario) end test "usuario_atual retorna o usuario correto quando a sessao for nil" do assert_equal @usuario, usuario_atual assert esta_logado? end test "usuario_atual retorna...
class StarRating < ActiveRecord::Base #validates :rating, 1 to 5 has_and_belongs_to_many :recipes end
class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user if user.role? :su can :manage, :all elsif user.role? :admin can :manage, :all cannot :manage, :assignDivisionCan cannot :manage, User cannot :manage, Proposal can :manage, Us...
require "rails_helper" feature "Completing a Task", js: true do scenario "Identity sets a Task as complete" do given_i_have_an_assigned_task when_i_mark_the_task_as_complete then_i_should_not_see_the_task end def given_i_have_an_assigned_task assignee = Identity.first assignor = create(:ide...
class VideocallController < ApplicationController def vidyoconnector @token = generate_token(params[:user_name]) @resource_id = params[:resource_id] @display_name = params[:display_name] @phone_number_recipient = "<Enter the phone number here>" message = "Click here to open the app: https://ciclo.com/v...
require "securerandom" class Trivia attr_accessor :name, :is_active attr_reader :questions attr_reader :trivia_id def initialize(trivia_id) @trivia_id = trivia_id @questions = [] end def add_question(question, answers, multiple_choice = nil, image = nil) if !answers.is_a? Array...
# -*- coding: utf-8 -*- require 'spec_helper' describe OpensocialWap::Platform do describe "mobage" do context "sandbox用に、mobage用の初期化が正しく行えること(セッションOFF)" do before do @config = Rails::Application::Configuration.new OpensocialWap::Platform.mobage(@config) do consumer_key '(consumer...
class FontTaiHeritagePro < Formula head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/taiheritagepro" desc "Tai Heritage Pro" desc "Available in regular and bold weights, with both opentype and graphite rendering" homepage "https://fonts.google.com/s...
class CreateMissingIndexes < ActiveRecord::Migration def self.up [ :service_id, :dev_url, :qa_url, :stg_url, :prod_url, :repo_url, :contact, :codelang, :external, :pciscope, :created_at, :updated_at ].each do |field| add_index :service_profiles, field end [ :volume_type, :configf, :volume_ser...
module NotificationSharedExamples # CRUD Triggers #---------------------------------------------------------------------------- shared_examples_for "sends notification on create (successful create)" do |factory, notification_mailer| it "delivers notification" do mailer = mock mailer.should_receive...
require 'forwardable' require 'cxbrank/master/base' require 'cxbrank/master/music' require 'cxbrank/master/event' module CxbRank module Master class EventMusic < Base extend Forwardable belongs_to :event belongs_to :music def_delegators :music, :text_id, :title, :max_notes def to_...
class CourseTimeExpressionCollection attr_reader :weekday, :number, :weekday_str, :number_str, :start_time_str, :end_time_str,:class_time, :weekday_number_str, :course_time_expressions def initialize(course_time_expressions) @course_time_expressions = course_time_expressions expression = co...
# ~~~HAVICK WAS HERE ~~~ class Song attr_accessor :name, :artist_name @@all = [] def self.all @@all end def save self.class.all << self end def initialize @name = name @@all << self end def self.all @@all end def self.create song = self.new song.name = name song...
class CarRentalBookingManagement def initialize @company_name = [] @new_booking = [] @view_booking = [] @new_customer = [] @new_car = [] end def run while true print_menu opt = gets.chomp.to_i if opt == 1 add_company_name elsif opt == 2 add_...
require "spec_helper" describe "Login", :type => :request do context "with valids credential" do let!(:user) { create(:user, :paul) } before do visit root_path click_link "Minha conta" fill_in "Seu e-mail", :with => user.email fill_in "Sua senha", :with => "testdrive" click_...
require 'rails_helper' RSpec.describe Address, type: :model do let(:country_attributes){FactoryGirl.attributes_for :country} let(:address){FactoryGirl.build :address} it {should belong_to(:country)} it {should have_one(:profile_billing_address).with_foreign_key("billing_address_id")} it {should have_one(:pr...
require "application_system_test_case" class InvoicesTest < ApplicationSystemTestCase setup do @invoice = invoices(:one) end test "visiting the index" do visit invoices_url assert_selector "h1", text: "Invoices" end test "creating a Invoice" do visit invoices_url click_on "New Invoice" ...
# frozen_string_literal: true module Main module Entities class Author attr_accessor :first_name, :last_name def initialize(args = {}) self.first_name = args[:first_name] || Faker::Name.first_name self.last_name = args[:last_name] || Faker::Name.last_name end end end end
class TestScenarioDatatable delegate :current_user, :content_tag, :check_box_tag, :get_environment_property, :params, :link_to, :button_tag, to: :@view delegate :url_helpers, to: 'Rails.application.routes' delegate :session, to: :@view include ApplicationHelper def initialize(view) @view = view end ...
require 'date' module RTALogger # log data structure class LogRecord def initialize(log_topic, context_id, severity, *message) @log_topic = log_topic @context_id = context_id @severity = severity @message = message @occurred_at = DateTime.now end attr_reader :context_id ...
#!/usr/bin/env ruby # Oui le code est dégueux... Et alors ?! require 'irc-socket' require 'myanimelist' require 'htmlentities' require 'io/console' require 'link_thumbnailer' $:.unshift File.dirname(__FILE__) require 'lib/yuko' require 'lib/myanimelist-x' require 'lib/message' def init(_) load 'config.rb' Yuko.c...
class Admin::ProjectsController < Admin::BaseController def index @order = params[:order] || 'name' @page = params[:page] || '1' @projects = Project.paginate :per_page => 20, :page => @page, :order => "#{@order} ASC" end def edit @project...
module Api class BaseController < ApplicationController skip_before_action :verify_authenticity_token protect_from_forgery with: :null_session, if: -> { request.format.json? } before_action :authenticate, only: [:build, :listen] before_action :spotify_authenticate, only: [:build] def spotify_auth...
class Player KAMAL_RAMZY = "Kamal Ramzy" attr_reader :name attr_writer :birth_date attr_accessor :age attr_accessor :length attr_accessor :skincolor attr_accessor :club attr_accessor :sport def initialize name puts "created a new player" @name = name ...
class AddSkillIdToResource < ActiveRecord::Migration def change add_column :resources, :skill_id, :integer end end
class ChangePrecisionForBetwin < ActiveRecord::Migration def change change_table :records do |t| t.change :bet, :decimal, :precision => 8, :scale => 2 t.change :win, :decimal, :precision => 8, :scale => 2 end end end
class CreateCategoriesPhotos < ActiveRecord::Migration def change create_table :categories_photos do |t| t.integer :category_id t.integer :photo_id end add_index :categories_photos, [:category_id, :photo_id] end end
class PamSqlite3 < Formula desc "PAM Module using a sqlite3 database as a backend" homepage "https://github.com/jkingweb/pam_sqlite3" head "https://github.com/jkingweb/pam_sqlite3.git" depends_on "sqlite" def install args = %W[ --prefix=#{prefix} --bindir=#{bin} --sbindir=#{sbi...
class AddColumnsToUserProfileAttributes < ActiveRecord::Migration[6.0] def change add_column :users, :email, :string, :unique => true add_column :users, :profile_picture_google, :string add_column :users, :profile_picture_local, :string add_column :users, :anonymous, :boolean end end
require 'factory_girl_rails' FactoryGirl.define do factory :user do sequence(:first_name) { |n| "first_name#{n}" } sequence(:last_name) { |n| "last_name#{n}" } sequence(:phone_number){ |n| "555-555-500#{n}" } sequence(:email) { |n| "#{n}@launchacademy.com" } password "abcdef1234" password_con...
class Track < ActiveRecord::Base has_many :playlist_tracks has_many :playlists,:through => :playlist_tracks has_many :likes end
class EventsController < ApplicationController before_action :authenticate_user! def index @events = User.find(params[:user_id]).events.between(params['start'], params['end']) if (params['start'] && params['end']) #eventsに関するpathはuser/eventsのみ respond_to do |format| format.html # index.html.erb ...
require "sinatra" require "sinatra/activerecord" #Dont forget to require your models require_relative './models/course' require_relative './models/ta' require_relative './models/instructor' require_relative './models/student' require_relative './models/courseStudent' #The goal of the app is setup the following relat...
module Api::V1 class EntryController < ApplicationController skip_before_action :authenticate def create @entry = Entry.create(entry_params) updateCategoryTotal(@entry.amount, @entry.category_id) end def destroy @entry = Entry.find(params[:id]) updateCategoryTotal(-@entry.a...
module Referly class LinkProxy def initialize(client) @client = client end def all(params={}) @client.get('/links', params)['links'] end def create(params={}) @client.post('/links', params).parsed_response end end end
class EquipmentController < InheritedResources::Base before_action :set_object, only: [:edit, :update, :destroy] before_action :load_brands, only: [:edit, :new, :create, :update] before_action :load_models, only: [:edit, :new, :create, :update] def index @equipment = Equipment.all.sort_by(&:category) end...
class AddNicknameAndApproved < ActiveRecord::Migration def self.up add_column :pizzas, :nickname, :string add_column :pizzas, :flag_approved, :boolean end def self.down remove_column :pizzas, :nickname remove_column :pizzas, :flag_approved end end
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.4' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.3', '>= 6.0.3.1' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server ...
# frozen_string_literal: true require "rails_helper" require_relative "../../../lib/pulfalight/year_range" require_relative "../../../lib/pulfalight/normalized_date" describe Pulfalight::NormalizedDate do describe ".new" do let(:inclusive) { ["1988", "2020"] } let(:normalized_date) { described_class.new(incl...
#spec/models/book_spec.rb require 'spec_helper' describe Book do it "has a valid factory" do expect(create :book).to be_valid end context "is invalid " do it " without a name" do expect(build :book, name: nil).to_not be_valid end it "without a description" do expect(build :boo...
require 'spec_helper' describe 'Add to project', reset: false do context "in the granule results tab" do before :all do Capybara.reset_sessions! load_page :search fill_in 'keywords', with: 'C179003030-ORNL_DAAC' wait_for_xhr first_collection_result.click wait_for_xhr end ...
# encoding: UTF-8 $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') require 'paperclip-gridfs/version' spec = Gem::Specification.new do |s| s.name = 'paperclip-gridfs' s.version = Paperclip::GridFS::VERSION s.authors = ['Blaž Hrastnik'] s.email = 'blaz.hrast@gmail.com' s.hom...
# frozen_string_literal: true require "spec_helper" describe GraphQL::ExecutionError do let(:result) { Dummy::Schema.execute(query_string) } describe "when returned from a field" do let(:query_string) {%| { cheese(id: 1) { id error1: similarCheese(source: [YAK]) { ... similarCheeseFie...
# encoding: ascii-8bit module OpenAssets class Api include Util include MethodFilter before_filter :change_network, {:include => [:list_unspent, :get_balance, :issue_asset, :send_asset, :send_assets, :send_bitcoin, :send_bitcoins]} attr_reader :config attr_reader :provider attr_reader :tx...
class Activity < ApplicationRecord has_many :college_activities has_many :student_activities # has_many :students, through: student_activities # has_many :colleges, through: college_activities end
class HomeController < ApplicationController respond_to :html, :json def index @topics = Topic.last(2) @users = User.last(2) @posts = Post.last(2) respond_with @topics end end
class AssignmentsController < ApplicationController before_action :set_assignment, only: [:show, :edit, :update, :destroy] def new @assignment = Assignment.new end def create @assignment = Assignment.new(assignment_params) respond_to do |format| if @assignment.save format.html do ...
class FixBidderPeriodItemColName < ActiveRecord::Migration def self.up rename_column :bidder_period_items, :AmtBid, :amt_bid end def self.down end end
module Veda class BCAerror< XmlDataObject def error_type xml_obj.attributes['type'] end def error_type_code xml_obj.find_first('BCAerror-code').content end def description xml_obj.find_first('BCAerror-description').content end def to_s "error_type: #{error_type},...
require_relative 'ui_valet' module AppiumValet class ControlValet < UIValet def on(&block) begin wait(@after_wait) { target_element }.click rescue StandardError => e raise(e) if block.nil? on(&block) if block.call(self) end begin wait_true(timeout: @before...
FactoryGirl.define do factory :registration_form do name {Faker::Name.name} end end
class ConsentSerializer < ActiveModel::Serializer attributes :id, :name, :page_url, :description, :mandatory end
Gem::Specification.new do |spec| spec.name = 'openbel-api' spec.version = '0.2.0' spec.summary = %q{The OpenBEL API provided over RESTful HTTP endpoints.} spec.description = %q{The OpenBEL API provides a RESTful API over HTTP to manage BEL knowledge.} spe...
require 'rails_helper' RSpec.describe Image, type: :model do it 'shuold belongs to user' do user = User.new image = Image.new user.images << image expect(image).to respond_to :user expect(image.user).to be user end end
class Gallery < ActiveRecord::Base has_many :pictures, :dependent => :destroy has_many :videos, :dependent => :destroy validates :name, :presence => true validates :author, :presence => true validates :description, :presence => true attr_accessible :author, :description, :name end
# frozen_string_literal: true class Group < ApplicationRecord has_many :group_squads has_many :users, through: :group_squads end
module OAuth2 module Auth module Server module Models class AccessToken < ActiveRecord::Base cattr_accessor :default_lifetime self.default_lifetime = OAuth2::Auth::Server.default_lifetime belongs_to :client before_validation :setup, :on => :create ...
class CreateFormulas < ActiveRecord::Migration[5.1] def change create_table :formulas do |t| t.string :name, null: false t.string :slug, null: false t.string :short_name, null: false t.references :promotion, foreign_key: true t.string :abbreviation, null: false t.string :contac...
class ApplicationController < ActionController::Base protect_from_forgery before_filter :current_department, :current_role #redirect user based on sign in count and force user to change password if logged in first time def home if user_signed_in? current_user.update_attribute(:login_status, true) if ...
# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module MobileCenterApi module Models # # Model object. # # class DistributionGroupResponse # @return [String] The unique ...
class Fixnum # Fixnum#hash already implemented for you end class Array def hash hash_str = "" el_count = 7 # 7 is prime # hv = 0 self.each do |el| # hv = el.hash + i + hash_val hash_modulo = el.hash % (el + el_count) hash_str << hash_modulo.to_s el_count += 1 end ...
class AddUserIdToTracks < ActiveRecord::Migration[6.0] def change add_column :tracks, :user_id, :integer add_index :tracks, :user_id end end
class UserSerializer < ActiveModel::Serializer attributes :id, :email, :password, :name, :location, :bio has_many :trips end