text stringlengths 10 2.61M |
|---|
module YACCL
module ObjectServices
def get_object(repository_id, object_id, filter, include_allowable_actions, include_relationships, rendition_filter, include_policy_ids, include_acl, succinct=false)
required = {succinct: succinct,
cmisselector: 'object',
repositoryId: r... |
class Users::SessionsController < Devise::SessionsController
# before_filter :configure_sign_in_params, only: [:create]
# This action will allow to redirect to different page as current_user's role after sign in
def sign_in_and_redirect(resource_or_scope, resource = nil)
scope = Devise::Mapping.find_scope!(r... |
class TagService
def initialize(params)
@input_tags = params
@validator = Tag
.validators
.find { |validator| validator.instance_of? ActiveModel::Validations::FormatValidator }
.options[:with]
end
def tags
input_tags
.split(" ")
.uniq
.select { |raw_tag| raw_tag =~... |
json.array!(@quotes) do |quote|
json.extract! quote, :id, :amount, :terms, :token, :expires_at, :request_id
json.url quote_url(quote, format: :json)
end
|
class Music < ApplicationRecord
mount_uploader :file, AudioFileUploader
mount_uploader :img_id, ImageUploader
acts_as_paranoid
belongs_to :band
validates :name, presence: true
validates :img_id, presence: true
validates :introduction, presence: true
validates :file, presence: true
def se... |
#! /usr/bin/env ruby
require 'yaml'
require 'colorize'
filename = ARGV[0]
pattern_text = ARGV[1]
unless filename && pattern_text
puts "Usage: grep_yaml.rb filename pattern"
exit(1)
end
pattern = Regexp.new(pattern_text, :nocase)
p pattern
hash = YAML.load_file(filename)
def recurse(obj, pattern, current_path ... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Failing retryable operations' do
# Requirement for fail point
min_server_fcv '4.0'
let(:subscriber) { Mrss::EventSubscriber.new }
let(:client_options) do
{}
end
let(:client) do
authorized_client.with(client_options... |
Given(/^two undrafted players with position QB$/) do
@player_1 = FactoryGirl.create(:player, name: "Bob", position: "QB")
@player_2 = FactoryGirl.create(:player, name: "Adam",position: "QB")
end
Given(/^two undrafted players with position TE$/) do
@player_3 = FactoryGirl.create(:player, name: "Al", position: "... |
class AddImageOwners < ActiveRecord::Migration
def up
change_table :images do |t|
t.rename :product_id, :owner_id
t.string :owner_type, null: false, default: 'Product'
end
end
def down
change_table :images do |t|
t.remove :owner_type
t.rename :owner_id, :product_id
end
e... |
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require "./lib/offsets.rb"
class OffsetCalculatorTest < Minitest::Test
def test_Offset_Calculator_exists
offset = OffsetCalculator.new
assert_equal OffsetCalculator, offset.class
end
def test_OffsetCalculator_has_key
offset = Offset... |
# Copyright 2013 OCLC
#
# 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/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# ... |
if yes?("Use NProgress.js for Turbolinks loading indicator?", :yellow)
inside "vendor/assets/" do
get 'https://raw.github.com/rstacruz/nprogress/master/nprogress.css', 'stylesheets/nprogress.css'
get 'https://raw.github.com/rstacruz/nprogress/master/nprogress.js', 'javascripts/nprogress.js'
end
inside "... |
class Exchange < ApplicationRecord
belongs_to :mittente, :class_name => 'User'
belongs_to :destinatario, :class_name => 'User'
validates :mittente, :destinatario, :libromittente, :librodestinatario, presence: true
validate :mittente_destinatario
private
def mittente_destinatario
if mittente == destin... |
## Copyright © 2018 Yokesh Thirumoorthi
## [This program is licensed under the "MIT License"]
## Please see the file LICENSE in the source
## distribution of this software for license terms.
## CREDITS
## Project: https://github.com/dsander/phoenix-connection-benchmark
require 'yaml'
class Config
class << self
... |
class QuestionFollow
# def self.find_by_id(id)
# results = QuestionsDatabase.instance.execute('SELECT * FROM question_follows WHERE id = ?')
# # results = QuestionsDatabase.instance.execute('SELECT * FROM users WHERE id = :id', id: id)
# QuestionFollows.new(results.first)
# end
def self.followers_fo... |
class ForumSentinel < Sentinel::Sentinel
def creatable?
current_user_admin?
end
def reorderable?
current_user_admin?
end
def viewable?
return true if self.forum.public? || current_user_admin?
(current_user? && self.forum.members.include?(self.current_user))
end
def editable?
return ... |
class LayoutSweeper < ActionController::Caching::Sweeper
observe Layout
def after_update(layout)
expire_cache_for layout
end
def after_destroy(layout)
expire_cache_for layout
end
private
def expire_cache_for(record)
record.pages.each do |page|
if page.home?
... |
class MyRegistrationsController < Devise::RegistrationsController
# def create
# super
# if @user.persisted?
# UserMailer.with(user: @user).welcome_email.deliver_later
# end
# end
def create
super
if @user.persisted?
UserMailer.registration_confirmation(@user).deliver_later
... |
class Enrollment < ActiveRecord::Base
include ShardedModel
db_magic :sharded => {
key: :classroom_id, sharded_connection: :enrollments
}
attr_accessible :classroom_id, :name, :user_id
belongs_to :classroom
belongs_to :user
has_many_in_shard :lessons
before_create :assign_shard_id
def full_n... |
require 'rails_helper'
RSpec.describe 'tutors/index', type: :view do
before(:each) do
@tutor1 = create(:tutor)
@tutor2 = create(:tutor)
assign(:tutors, [@tutor1, @tutor2])
end
it 'renders a list of tutors' do
render
expect(rendered).to match(@tutor1.first_name)
expect(rendered).to match(... |
#人员与活动关系实体,人员参与活动会有俩种身份,比如在部门审核中人员可以是信息提供者(参评人,信息需要被审核人审核)或者审核人
#role_type用来区分这个关系,而有很多活动配置&活动筛选中需要考虑人员在活动中充当的位置
#例如:
#1.在活动中维护配置人员,需要差分如果配置的是活动为info_register那么新建的关系role_type应该为info_register
#而其他模块role_type=review
#2.在人员进入user_zone中,可以看到人员能够进入的模块,而这个模块的筛选规则:
# (1)如果info_register模块,那么关系为role_type=info_register用户就可以看到
#... |
require 'json'
require 'rest-client'
class Capitals
attr_accessor :country
def initialize
@country = []
end
def get_input
gets.strip
end
def get_from_worldbank
#you're getting a list of ALL countries
response = RestClient.get("http://api.worldbank.org/countries/bm?format=json")
#Here you are pa... |
Rails.application.routes.draw do
root to: 'site#index'
namespace :api do
namespace :v1 do
resource :games, only: [:show, :update]
resources :quizzes
end
end
end
|
require 'rails_helper'
describe 'Ibans API', type: :request do
let!(:iban) { FactoryBot.create(:iban, name: 'albanian', iban_number: 'AL35202111090000000001234567') }
let!(:iban_two) { FactoryBot.create(:iban, name: 'greece', iban_number: 'GR35202111090000000001234567') }
describe 'GET /api/v1/ibans' do
it ... |
module Services
module Infra
module Logger
class << self
attr_accessor :adapter
end
def info(msg)
Logger.adapter.info(msg)
end
def warn(msg)
Logger.adapter.warn(msg)
end
def debug(msg)
Logger.adapter.debug(msg)
end
def error... |
class AddTagToQuestionInstances < ActiveRecord::Migration[5.1]
def change
add_column :question_instances, :tag, :string
end
end
|
require 'spec_helper'
describe Mailcheck do
before do
@domains = ['yahoo.com', 'yahoo.com.tw', 'google.com','hotmail.com', 'gmail.com', 'emaildomain.com', 'comcast.net', 'facebook.com', 'msn.com', 'gmx.com']
@top_level_domains = ['co.uk', 'com', 'org', 'info']
@mailcheck = Mailcheck.new
end
describ... |
class NotificationsMailer < ApplicationMailer
default :from => "noreply@gaiusgroup.org"
default :to => "jerry_lee92@hotmail.com,yikailee@gmail.com,yanzarchi@gmail.com"
def new_message(message)
@message = message
mail(:subject => "[Gaius Design Associates Contact Form] #{message.subject}")
end
end
|
class CreateRecommendedTopics < ActiveRecord::Migration
def self.up
create_table :recommended_topics do |t|
t.integer :topic_id
t.integer :referer_id
t.timestamps
end
end
def self.down
drop_table :recommended_topics
end
end
|
require 'spec_helper'
describe Urkel do
it 'has a version number' do
expect(Urkel::VERSION).not_to be nil
end
describe ".oops" do
let(:error) { StandardError.new("Ooops... did i do that?") }
it 'publishes a new error' do
stub_request(:post, "http://localhost:3000/api/v1/failures").to_return(s... |
#!/usr/bin/env ruby
# Ruby code for testing hidden markov model
reuire 'matrix'
class ForwardBackword
def initialize
@observations = ['homepage', 'signup', 'product', 'checkout']
@states = ['Prospect', 'User', 'Customer']
@emissions = ['homepage', 'signup', 'product page', 'checkout', 'contact us']
... |
# == Schema Information
#
# Table name: customers
#
# id :integer not null, primary key
# name :string(255)
# description :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
# phone :string(255)
# qq_number :string(255)
#
FactoryGirl.de... |
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::MimeTypes
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
process :save_size_in_model
# Choose what kind of storag... |
Pod::Spec.new do |s|
s.name = "Sible"
s.version = "0.1.1"
s.summary = "Sible iOS SDK"
s.homepage = "http://github.com/emberlight/sible"
s.platform = :ios, "7.0"
s.license = { :type => 'MIT' }
s.authors = { 'Emberlight' => 'kevinr@emberlight.co' }
s.source = { :g... |
Pod::Spec.new do |s|
s.name = 'FlowCore'
s.version = '0.2.1'
s.summary = 'The official Swift Flow.ai SDK '
s.description = <<-DESC
Access the Flow.ai platform from your iOS or macOS app.
Flow.ai is a AI powered interaction platform. FlowCore provides a websocket client that c... |
# -*- mode: ruby; -*-
# Simple scipt to run project in dev environment
# const
APP_HOST = "192.168.33.10"
APP_HOSTNAME = "family.local"
LOCAL_DIR = "."
MOUNT_DIR = "/media/rambler/family"
PIP_DIR = "/home/vagrant/env"
FAMILY_SETTINGS = "vagrant"
DB_USER = "family"
DB_PASS = "family"
DB_NAME = "family"
# Force Virtua... |
require "securerandom"
class ShortenedURL < ApplicationRecord
include SecureRandom
validates :short_url, uniqueness: true
validates :short_url, length: { minimum: 3}
# attr_accessor :short_url
# attr_accessor :long_url
#
# def short_url=(url)
# @short_url = url
# end
def self.random_code
while tru... |
def letter_case_count(string)
counts_hash = {}
char_array = string.chars
counts_hash[:lowercase] = char_array.count{|char| char =~ /[a-z]/}
counts_hash[:uppercase] = char_array.count{|char| char =~ /[A-Z]/}
counts_hash[:neither] = char_array.count{|char| char =~ /[^a-zA-Z]/}
p counts_hash
end
# def letter... |
class AddPublishedToBaseGoodsDescriptions < ActiveRecord::Migration[5.1]
def change
add_column :base_goods_descriptions, :published, :boolean, default: :true, null: :false
end
end
|
class Notification < ActiveRecord::Base
include Filterable
include Importable
include Exportable
self.per_page = 10
belongs_to :user
belongs_to :work_order
belongs_to :notification_type
# Validations
validates :user, :presence => true
validates :work_order, :presence => true
validates ... |
class TargetsController < ApplicationController
before_action :load_target, only: %i[edit show update]
before_action :load_project, only: %i[index create new edit_all update_all]
def index
@targets = @project.targets
end
def new
@target = Target.new
add_breadcrumb 'New Target', new_project_targe... |
class CreateStudents < ActiveRecord::Migration
def change
create_table :students do |t|
t.string :name
t.string :email
t.string :university
t.string :degree
t.string :major
t.text :interests
t.integer :graduation_month
t.integer :graduation_year
t.string :citi... |
require_relative '../pages/page'
module Pages
class GroveMonitorPage < Page
def visit_page
visit '/admin/grove-monitor'
self
end
end
end
|
# frozen_string_literal: true
module Articles
# Service to list all articles according to type
class GetTopStoriesService
def perform
Response::Success.new(stories)
end
private
def stories
headline = Article.where(kind: 0).last
hot_topics = Article.where(kind: 1).last(4)
... |
class Train
attr_reader :wagons_count, :speed, :current_station,
:number, :type, :route
def initialize(number, type, wagons_count)
@number = number
@type = type
@wagons_count = wagons_count
@speed = 0
end
def raise_speed(change_speed)
@speed += change_speed
end
def stop
@speed... |
require 'pathname'
module Calypso
BASE_DIR = Pathname(File.dirname(__FILE__)) + '../..'
SOURCES_DIR = BASE_DIR + 'Sources'
WORKSPACE = SOURCES_DIR + 'ZalandoCommerceSDK.xcworkspace'
SCHEME_UNIT_TESTS = 'UnitTests'.freeze
SCHEME_UI_UNIT_TESTS = 'UI+UnitTests'.freeze
# finds potentially the newest "norma... |
# frozen_string_literal: true
class Users::SessionsController < Devise::SessionsController
# Disable CSRF protection
skip_before_action :verify_authenticity_token
# Be sure to enable JSON.
respond_to :html, :json
# POST /resource/sign_in
def create
self.resource = warden.authenticate!(auth_options)
... |
class Zenity < Formula
desc "GTK+ dialog boxes for the command-line"
homepage "https://live.gnome.org/Zenity"
url "https://download.gnome.org/sources/zenity/3.24/zenity-3.24.0.tar.xz"
sha256 "6ff0a026ec94e5bc1b30f78df91e54f4f82fd982f4c29b52fe5dacc886a9f7f7"
bottle do
sha256 "9e4cafa7f463e97dc694293e45df1... |
##################################################
#
# This is the helper file for the /prime-payment page
#
###################################################
class UpdatePaymentMethod < VindiciaPrimePayment
def visit(baseurl)
@client.get "http://#{baseurl}/update-payment-method"
end
def is_displayed
put... |
task :hello_rake do
puts "Hello, from rake"
end
task :default do
puts "Hello, from default task!"
end
task :environment do
require_relative './config/environment'
end
task :upcoming_todos => [:environment] do
User.with_upcoming_todos.each do |user|
puts "Emailing #{user}"
end
end
task :overdue_tod... |
module Fog
module Compute
class ProfitBricks
class Real
# Retrieves the attributes of a given volume
#
# ==== Parameters
# * group_id<~String> - Required, The ID of the specific group to retrieve.
# * resource_id<~String> - Required, The ID of the specific resource... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
helper_method :addcomma, :erase_zero, :tax_rate_calculation
before_action :set_request_from... |
class VenuesController < ApplicationController
def index
@venues = Venue.where.not(latitude: nil, longitude: nil)
@markers = @venues.map do |venue|
{
lat: venue.latitude,
lng: venue.longitude#,
# infoWindow: { content: render_to_string(partial: "/venues/map_box", locals: { venue... |
require 'spec_helper'
describe Appilf::Listing do
include Appilf::TestData
describe '.new' do
let(:listing) { Appilf::Listing.new(load_test_json_data(mocked_response_file_path('listing/listing.json'))) }
it 'should respond to id' do
listing.id.should == "6046240"
end
it 'should respond to ... |
require 'fluent/test'
require 'fluent/plugin/filter_example'
class ExampleFilter < Test::Unit::TestCase
def setup
Fluent::Test.setup
end
def driver(conf = '', tag = 'test.example.tag', block = true)
Fluent::Test::FilterTestDriver.new(Fluent::ExampleFilter, tag).configure(conf, block)
end
def samp... |
class AddPhotothreeToIslands < ActiveRecord::Migration[5.2]
def change
add_column :islands, :photothree, :string
end
end
|
# input: two arrays
# output: new array that contains the product of each pair of number from arguments that have the same index
# same number of element for both arguments
# new array returned should have same number of elements as arguments
# data structure: array
# algo:
# set variable result as empty array
# use ea... |
require 'logger'
module Pompeu
module Logging
# This is the magical bit that gets mixed into your classes
def logger
Logging.logger
end
# Global, memoized, lazy initialized instance of a logger
def self.logger
@logger ||= Logger.new(STDOUT)
end
end
end |
class HomeController < ApplicationController
def sysadmin
# システム管理者メニュー
@link = {
'ユーザー管理' => [
{title: 'ログインユーザー一覧', controller: 'common_users', action: 'index'},
{title: 'ログインユーザー新規作成', controller: 'common_users', action: 'add'},
{title: "登録者情報作成・編集", controller:... |
# Copyright 2013 OCLC
#
# 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/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# ... |
# encoding: utf-8
class NotifierMailer < ActionMailer::Base
default :from => "\"DreamDay\" <cs@dreamday.com.hk>"
def welcome_email(user)
@user = user
mail(:to => @user.email, :subject => "Dreamday.com.hk 電郵地址驗證")
end
def reset_email(user, password)
@user = user
@password = password
mai... |
class ResultsController < ApplicationController
def show
@user_id = convert_to_id(params[:token])
@user = User.find_by(id: @user_id)
@user_answers = Answer.where(user_id: @user_id)
@group = Group.find_by(id: @user.group_id)
@user_results = Hash.new {0}
@group_results = Hash.new {0}
@quest... |
require 'pry'
dir = File.expand_path(__FILE__)
require dir.split("/")[0..-3].join("/")+"/test_helper.rb"
class TestAccountsTest < ContactImporterTestCase
def test_test_accounts_loads_data_from_example_accounts_file
accounts_yml_file = File.expand_path(__FILE__).split("/")[0..-3].join("/") + "/accounts.yml"
a... |
Rails.application.routes.draw do
get "students/:id/active", to: "students#activate", as: "activate_student"
resources :students, only: [:show, :index]
end
|
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB Inc.
#
# 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/LICENSE-2.0
#
# U... |
Rails.application.routes.draw do
devise_for :teachers
devise_for :users
devise_for :admins
mount RailsAdmin::Engine => '/admin/dashboard', as: 'rails_admin'
resources :courses do
resources :lessons
end
end
|
class Equipo < ActiveRecord::Base
belongs_to :division
has_many :partidolocal, :class_name => "Partido" , :foreign_key => "local"
has_many :partidovisitante, :class_name => "Partido", :foreign_key => "visitante"
validates_presence_of :nombre, :division_id
validates_uniqueness_of :nombre
def name
nomb... |
require 'test_helper'
class SeasonShareTest < ActiveSupport::TestCase
fixtures :seasons
test 'with_matches returns season shares for accounts that have matches in given season' do
account1 = create(:account)
create(:match, season: 1, account: account1, result: :win)
share1 = create(:season_share, acco... |
feature 'My Bookings' do
scenario 'If no bookings will have empty message' do
sign_up_owner
click_button 'My Bookings'
expect(page).to have_content('You have no bookings')
end
scenario 'If we make a booking it shows up in My Bookings' do
list_pad
sign_up_owner
click_button 'More Info'
... |
class CreateEquipment < ActiveRecord::Migration
def change
create_table :equipment do |t|
t.integer :num_id
t.string :name
t.string :manufacturer
t.string :model
t.string :serial
t.string :assigned_to
t.string :location
t.string :function
t.date :manuf_date
... |
class Student
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.find_student(student)
BoatingTest.all.select { |boatingTest| boatingTest.student == student }
end
def add_boatin... |
class CreateHatedGamesUsersJoinTable < ActiveRecord::Migration
def change
create_table :hated_games_users, :id => false do |t|
t.integer :game_id
t.integer :user_id
end
add_index :hated_games_users, :game_id
add_index :hated_games_users, :user_id
end
end
|
# frozen_string_literal: true
require "test_helper"
class ErrorResponseTest < ActiveSupport::TestCase
test "error response should return expected output" do
error = ErrorResponse.new(code: 401, message: "oops")
json = error.as_json
assert_equal 401, json[:code]
assert_equal "oops", json[:message]
... |
class CreateGames < ActiveRecord::Migration
def change
create_table :games do |t|
t.string :name, null: false
t.integer :white_player_id
t.integer :black_player_id
t.boolean :white_can_castle, default: false, null: false
t.boolean :black_can_castle, default: false, null: false
... |
require 'rails_helper'
describe Api::V1::UsersController, type: :controller do
context 'POST #create' do
before(:each) do
@user = {
email: 'tiein@tiein.com',
username: 'tiein',
password: 12341234,
password_confirmation: 12341234,
firstname: 'John',
lastname:... |
class AddUpdatedByIdToTaxonRelationships < ActiveRecord::Migration
def change
add_column :taxon_relationships, :updated_by_id, :integer
end
end
|
module CurrentAssetManageable
def current_asset_specified_in_session!
begin
raise RightRabbitErrors::InvalidSessionState if session[:current_lesson_id] && session[:current_worksheet_id]
if session[:current_lesson_id]
@current_asset = Lesson.find(session[:current_lesson_id])
elsif session... |
class CreateProperties < ActiveRecord::Migration
def change
create_table :properties do |t|
t.belongs_to :landlord
t.string :property_name
t.string :address
t.string :street_number
t.string :street_name
t.string :postal_code
t.string :locality
t.string :sublocality... |
# X) Methods: Creating
#
# We've used the puts method
# To create our own method we need to use the format:
# def: is the start of the method
# my_method: is the name of the method
# end: is the end of the method
def my_method
# your code here
end
# Once the method is defined we can call it by it's name
my_method
... |
require 'faraday_middleware/request_signing/version'
require 'faraday'
require 'http_signatures'
require 'forwardable'
module FaradayMiddleware
module RequestSigning
class Middleware < Faraday::Middleware
class HttpSignaturesFaradayAdapter
extend Forwardable
attr_accessor :signature
... |
# $Id$
require 'timeline_request_response'
require 'benchmark_helper'
class TimelinesController < ApplicationController
before_filter :login_required, :except => [:search, :tag_cloud]
require_role ['Guest', 'Member'], :for_all_except => [:search, :tag_cloud]
before_filter :ensure_subdomain
before_filter :set_... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session
helper_method :current_user
before_action :check_session, :except => [:current_user]
def current_user
begi... |
class BidPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.all
end
end
def create?
true
end
def order?
record.user == user
end
def accept?
true
end
private
def professional?
user.professional?
end
end
|
class ApplicationController < Sinatra::Base
register Sinatra::ActiveRecordExtension
set :views, Proc.new { File.join(root, "../views/") }
configure do
enable :sessions
set :session_secret, "secret"
end
get '/' do
erb :home
end
get '/registrations/signup' do
erb :'/registrations/signup'... |
require 'spec_helper'
describe Steam::History do
before do
stub_request(:get, 'https://api.steampowered.com/ISteam2Match_570/GetMatchHistory/V001/?key=A8229F479840DA66362A59443FF717CF').
to_return(status: 200, body: fixture(:history))
end
let(:history) { client.history }
it 'returns the n... |
module JwtToken
extend ActiveSupport::Concern
def decoded_jwt_token(req, secret = nil)
token = AuthToken.valid?(encoded_token(req), secret)
raise Exceptions::InvalidTokenError, "Unable to decode jwt token" if token.blank?
raise Exceptions::InvalidTokenError, "Invalid token payload" if token.empty?
... |
# lib/active_model/sleeping_king_studios/validations/relations/serializers/bracket_serializer.rb
require 'active_model/sleeping_king_studios/validations/relations/serializers'
module ActiveModel::SleepingKingStudios::Validations::Relations::Serializers
# Generates bracket-delineated compound keys.
#
# @example
... |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
scope :undeleted, -> {where.not(delete_at: nil)}
end
|
class AddKeyToMix < ActiveRecord::Migration[5.2]
def change
add_column :mixes, :key, :string
end
end
|
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
ActiveSupport::Inflector.inflections(:en) do |inflect|... |
require 'rails_helper'
feature 'user', type: :feature do
let(:user) { create(:user) }
scenario '非ログイン時の表示' do
visit root_path
expect(page).to have_no_content('Closet')
end
scenario '新規登録機能' do
expect {
visit root_path
fill_in 'user_email', with: 'goutfit_t_user@gmail.com'
fill_i... |
class Group < ApplicationRecord
mount_uploader :image, GroupImageUploader
belongs_to :owner, class_name: User.name, foreign_key: :user_id
has_many :user_groups, dependent: :destroy
has_many :users, through: :user_groups
validates :name, presence: true
validates :user_id, presence: true
scope :recent, ... |
class DeleteRecordingMutation < Types::BaseMutation
description "Delete a specified recording"
argument :id, ID, required: true
field :success, Boolean, null: false
field :errors, resolver: Resolvers::Error
policy CallPolicy, :manage?
def resolve
recording = Recording.find(input.id)
authorize re... |
# method that takes a year as input
# returns the century
# Return value is a string that begins with century number end with st,nd,rd,or th
# validate positive integer
# define correct_year?
# create ending hash with digit in string matching with correct ending
# calculate the correct century number
# case when year <... |
class Course < ActiveRecord::Base
attr_accessible :period, :teacher_id, :subject_id
validates :teacher_id, :presence => true
validates :period, :presence => true
validates :subject_id, :presence => true
validates :teacher_id, :uniqueness => { :scope => :period }
has_many :assignments
has_many :enrollments
ha... |
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
test "title must be present to save" do
comment = Comment.new
comment.content = nil
refute comment.save
assert comment.errors[:content].present?
end
test "link id must be present to save" do
comment = Comment.new
comment.... |
class CreateProductShippingMethods < ActiveRecord::Migration[5.0]
def change
create_table :product_shipping_methods do |t|
t.string :name, null:false, index: true
t.integer :shipping_fee_category, null:false
t.timestamps
end
end
end
|
module Raft
class Cluster
attr_reader :node_ids
def initialize(*node_ids)
@node_ids = node_ids
end
def quorum
@node_ids.count / 2 + 1 # integer division rounds down
end
end
end
|
class MethodsController < ApplicationController
def index
@therapies = Therapy.visible.order("position ASC")
end
def body_class
"post-template"
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.