text stringlengths 10 2.61M |
|---|
require "rails_helper"
RSpec.describe CashRegister, type: :model do
before :each do
CashRegister.initiate!(insecure: true)
end
it 'should add a amount to the cash register' do
CashRegister.add(100)
expect(CashRegister.amount).to eq(100)
end
it 'should remove a amount from the cash register' do
... |
ActiveAdmin.register GroupMember do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes... |
class AddPriceToMovies < ActiveRecord::Migration
def change
add_column :movies, :gold, :decimal
add_column :movies, :silver, :decimal
add_column :movies, :platinum, :decimal
end
end
|
require 'rails_helper'
RSpec.describe FulfillmentsController do
before :each do
sign_in
@line_item = create(:line_item, protocol: create(:protocol_imported_from_sparc), service: create(:service))
@fulfillment = create(:fulfillment, line_item: @line_item)
end
describe "GET #index" do
context 'c... |
class AddColumnsToRentals < ActiveRecord::Migration[5.1]
def change
add_column :rentals, :start_date, :date
add_column :rentals, :end_date, :date
add_column :rentals, :photo, :string
add_column :rentals, :price, :integer
add_column :rentals, :status, :string
end
end
|
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '2.5.1'
gem 'bcrypt'
gem 'bootsnap', '>= 1.4.2', require: false
gem 'bootstrap'
gem 'image_processing'
gem 'jbuilder', '~> 2.7'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'rails', '~> 6.0.0'
gem 'sass-rails', '~> 5'
gem 'turbolinks', '~> 5'
g... |
class AddDateRangeToVariants < ActiveRecord::Migration
def change
add_column :spree_variants, :available_from, :date
add_column :spree_variants, :available_to, :date
end
end
|
=begin
Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers.
Return your answer as a number.
=end
#Solution
def sum_mix(x)
x.map{|item| item.to_i}.reduce(:+)
end
#other solution
def sum_mix(x)
x.sum(&:to_i)
end
|
class ToniNovels::AllNovels
attr_accessor :name, :price, :availability, :url
def self.today
self.scrape_novels
end
# puts <<~DOC
# 1. The Bluest Eye by Toni Morrison - $19.43
# 2. Sula by Toni Morrison - $19.84
# 3. Beloved by Toni Morrison - $32.00
# DOC
def price
@amazon_d... |
class Book < ApplicationRecord
belongs_to :categories, required: false
belongs_to :library_location, required: false
end
|
# encoding: utf-8
#
# This file is part of the mamertes gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#
require "spec_helper"
describe Mamertes::Parser do
let(:application) {
::Mamertes::A... |
class CreateNoteRecipients < ActiveRecord::Migration
def self.up
create_table :note_recipients, :id => false do |t|
t.column :faculty_id, :integer, :null => false
t.column :note_id, :integer, :null => false
t.column :created_at, :datetime
t.column :hidden, :boolean
end
end
def self.down
drop_tabl... |
class TagsController < ApplicationController
def index
@tags = ActsAsTaggableOn::Tag.all
end
def show
@tag = ActsAsTaggableOn::Tag.find(params[:id])
@question = Question.tagged_with(@tag.name)
end
def search_suggestions
if params[:search]
@tags = ActsAsTaggableOn::Tag.where("name IL... |
# frozen_string_litaral: true
require 'rails_helper'
describe Api::V1::UsersController, type: :controller do
let(:user) { create(:user) }
describe 'GET #token' do
context 'user valid' do
subject! do
get :token,
format: :json,
params: {
email: user.email,
... |
# This controller is used to process and render home page
# History: June 06, 2013
# By NamTV
class OrganizationsController < ApplicationController
authorize_resource
SORT_MAP = {
1 => "name"
}
##
#Get user list except an user with specify ID
#Parameters::
# * (Integer) *iDisplayLength*: number of ro... |
# Found this number conversion on Stack Overflow
# Link: https://stackoverflow.com/questions/19445003/using-ruby-convert-numbers-to-words
def in_words(int)
numbers_to_name = {
1000000000 => "Billion",
1000000 => "Million",
1000 => "Thousand",
100 => "Hundred",
90 => "Ninety",
80 =... |
# frozen_string_literal: true
module Tikkie
module Notifications
# Payment notification.
class PaymentNotification
NOTIFICATION_TYPE = 'PAYMENT'
attr_reader :body
def initialize(body)
@body = body
end
def subscription_id
body[:subscriptionId]
end
... |
module Refinery
module Caststone
module ProductGroups
include ActiveSupport::Configurable
config_accessor :active_storage_service
self.active_storage_service = :s3
end
end
end
|
# == Schema Information
#
# Table name: usage_types
#
# type_id_usg :integer primary key
# guide_to :integer
# point_category :integer
# origin_country_dial_code_req :integer
# tax_code_origin_req :integer
# tax_code_target_req :integer... |
class CampaignsController < ApplicationController
before_action :set_campaign, only: [:show, :edit, :update, :destroy]
before_action :authorize, except: [:index, :show]
def index
if params[:search]
edition = params[:edition] == '' ? '%' : params[:edition]
@campaigns = Campaign.join... |
#fixing to use Binet's Formula, as it's faster than recursion
#combining all the code in 1 function, instead of 4
#removing extra lines
#using local variables instead of global constants
def series(sequence, n)
alpha = (1 + Math.sqrt(5)) / 2
beta = 1 - alpha
return ((alpha**n - beta**n) / Math.sqrt(5)).to_i if s... |
# config/intializers/jquery_query_builder_operators.rb
module JqueryQueryBuilder
module Operators
class IsDivisibleBy
def evaluate(input, value)
input % value == 0
end
end
class EqualsFive
def evaluate(input, ignored_value)
input == 5
end
end
end
end |
module Firmament
class Plane
attr_reader :id
attr_reader :plane
attr_reader :dead_tile
@@planes = ThreadSafe::Cache.new
@@admins = ThreadSafe::Array.new
@@servers = ThreadSafe::Cache.new
def self.admins
@@admins
end
def self.add_admin(admin)
@@admins << admin
end
def self.remove_admin(... |
class Subtask < ApplicationRecord
# include ActiveModel::Validations
scope :incomplete, -> { where(complete: false) }
# scope :unassigned, -> { joins(:user_tasks).where.not(user_tasks: { subtask_id: nil }) }
# scope :unassigned, -> { joins("LEFT OUTER JOIN user_tasks as usertasks ON subtasks.id = usertasks.sub... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe CountryCodesController do
def mock_country_code(stubs={})
@mock_country_code ||= mock_model(CountryCode, stubs)
end
describe "responding to GET index" do
it "should expose all country_codes as @country_codes" do
Coun... |
class Transaction < ActiveRecord::Base
attr_accessible :booking_date, :value_date, :type, :details, :originator,
:receiver, :amount, :balance
scope :daily_min, select("value_date AS value_date, sum(amount) AS amount, MIN(balance) AS balance")
.group("value_date")
.order("value_date")
scope :monthly_... |
require 'test_helper'
class UserStoriesTest < ActionController::IntegrationTest
fixtures :products
# A user goes to the store index page.
# They select a product, adding it to their cart.
# They then check out, filling in their details on the checkout form.
# When they submit,
# an order is created ... |
#coding: utf-8
class TicketsController < ApplicationController
before_filter :all_projects
before_filter :find_selected, :tickets_count, :progress
def find_selected
if params[:selected].nil?
@sel_project = @projects.first
else
@sel_project = Project.find(params[:selected])
end
end
... |
class ProjectsController < ApplicationController
def create
params.require(:project)
params.permit({ :project => [ :url, :title, :description ] })
project = params[:project]
@project = Project.new(
user_id: project[:user_id],
title: project[:title],
url: project[:url],
descrip... |
class RolesController < ApplicationController
allow_access :authenticated
before_filter :find_role, only: [:show, :edit, :update]
def index
@roles = Role.all
end
def new
@role = Role.new
end
def create
@role = Role.new(role_params)
if @role.save
redirect_to roles_url
else
... |
require "spec_helper"
module Alchemy
describe Admin::EssenceFilesController do
before do
authorize_user(:as_admin)
end
let(:essence_file) { mock_model('EssenceFile', :attachment= => nil, content: content) }
let(:content) { mock_model('Content') }
let(:attachment) { mock_model('Attac... |
class CrimeThiefsController < ApplicationController
before_action :set_crime_thief, only: [:show, :edit, :update, :destroy]
# GET /crime_thiefs
# GET /crime_thiefs.json
def index
@crime_thiefs = CrimeThief.all
end
# GET /crime_thiefs/1
# GET /crime_thiefs/1.json
def show
end
# GET /crime_thie... |
require 'test_helper'
class CreateShopperReportTest < ActionDispatch::IntegrationTest
def setup
@json = {shopper_name: 'bob', orders_count: 22, shop_collections: [{aisle_count: 1, name: 'Costco', line_items: [{product_id: 4294967296, title: 'My Product'}]}]}
end
test 'create new shopper report' do
ass... |
require 'rails_helper'
RSpec.describe 'Cars', type: :request do
# initialize test data
let!(:cars) { create_list(:car, 10) }
let(:car_id) { cars.first.id }
# Test suite for GET /api/v1/cars
describe 'GET /api/v1/cars' do
# make HTTP get request before each example
before { get '/api/v1/cars' }
... |
# A Liquid tag for Jekyll sites that allows embedding files from GitHub.
# by: Ian Davis
# based on work by Brandon Tilly for the CodeBlock and Gist plugins.
#
# Usage: {% github user repo sha [title/filename [link linkText]]] [/lang:value] %}
#
# You can get the sha hash for a file by:
# git rev-parse HEAD:filenameg... |
require 'test_helper'
class FlailExceptionTest < ActiveSupport::TestCase
def exception_params
{
:class_name => "NoMethodError",
:target_url => "https://mysterymachine.com/gggghosts",
:environment => "production",
:parameters => {
'controller' => "gggghosts",
'action' => "i... |
class TeamGroupStatistic < ActiveRecord::Base
belongs_to :team
validates :team, presence: true
synchronisable
end
|
require 'socket'
require 'thread'
require_relative 'retriever'
if ARGV.length != 1
$stderr.puts("Usage: #{$0} <port>")
end
port = ARGV[0].to_i
mutex = Mutex.new
server = TCPServer.new('localhost', port)
pending_data = []
reader_thread = Thread.new do
loop do
latest = Retriever.get_latest
mutex.synchroniz... |
class Admin::StaticPagesController < ApplicationController
layout "admin_application"
before_action :authenticate_user!
before_action :verify_admin
def index
@courses = Course.all
@subjects = Subject.all
@users = User.all
end
end
|
Rails.application.routes.draw do
resources :shopping_lists, only: [:index]
get 'items/create'
root to: 'pages#home'
devise_for :users, path: 'users', controllers: {
sessions: "users/sessions"
}
devise_for :drivers, path: 'drivers', controllers: {
sessions: "drivers/sessions"
}
r... |
FactoryBot.define do
factory :message_group do
subject { Faker::TvShows::NewGirl.character }
end
end
|
module Seek
class ActivityStats
#the time periods to be tested
PERIODS={"daily"=>1.day.ago,"weekly"=>1.week.ago,"monthly"=>1.month.ago,"six_monthly"=>6.month.ago,"yearly"=>1.year.ago}
#the item types to include
INCLUDED_TYPES=["Sop","Model","Publication","DataFile","Assay","Study","Invest... |
module Inesita
module Config
SOURCE_MAP_PREFIX = '/__OPAL_MAPS__'
ASSETS_PREFIX = '/__ASSETS__'
APP_DIR = 'app'
STATIC_DIR = '/static'
end
end
|
class AddOldIdToCourseClasses < ActiveRecord::Migration
def change
add_column :course_classes, :old_id, :string
add_index :course_classes, :old_id, :unique => true
end
end
|
class UsersController < ApplicationController
include ApiResponseConcern
before_action :require_admin, only: [:create]
def create
new_user = User.new(user_params)
render_resource_response(new_user)
end
private
def user_params
params.require(:user).permit(:name, :email, :password, :account_ty... |
class CreateTraitsValues < ActiveRecord::Migration[4.2]
def change
create_table :traitvalues do |t|
t.string :value_name
t.references :trait, index: true
t.text :value_description
t.timestamps
end
end
end |
require 'open-uri'
a279688 = open("https://oeis.org/A279688/b279688.txt").read.split(/\s/).each_slice(2).map(&:last).map(&:to_i)
class Integer
def to_base(b)
return [0] if self == 0
(0..Float::INFINITY).
lazy.
map { |i| b**i }.
reduce([]) { |a, d| break a if d > self; a.unshift(self/d % b)... |
require_relative 'load_helper'
require_relative 'test_helper'
require 'tempfile'
require 'open3'
require 'clinical_tcga'
class TestConvertUUID < MiniTest::Test
#
# test single UUID to sample conversion
#
def test_uuid1()
retval = ClinicalTCGA::ConvertUUIDToBarcode.getBarcode("7c6a70e0-7fde-4b96-ab1c-fdca9... |
# frozen_string_literal: true
module GraphQL
class Dataloader
# @see Source#request_all which returns an instance of this.
class RequestAll < Request
def initialize(source, keys)
@source = source
@keys = keys
end
# Call this method to cause the current Fiber to wait for the ... |
require 'spec_helper'
describe "searches videos" do
before { user = create(:user)
video = create(:video, user: user)
}
it "fills in the search form and searches" do
visit root_url
select 'Director', from: 'query'
click_button "Search"
page.should have_content "kevin"
end
... |
require 'rails_helper'
RSpec.describe Item, type: :model do
describe 'validations' do
it {should validate_presence_of(:name)}
it {should validate_presence_of(:description)}
it {should validate_presence_of(:unit_price)}
it {should belong_to(:merchant)}
it {should have_many(:invoices).through(:invo... |
# 150. Evaluate Reverse Polish Notation
# Author: David Lin
# @param {String[]} tokens
# @return {Integer}
def eval_rpn(tokens)
operators = ["+","-","*","/"]
stack = []
for char in tokens
if operators.include? char
a = stack.pop.to_i
b = stack.pop.to_i
stack.push(b.to_f.send(char, a)) # o... |
module Sequel
class Error
class CacheNotFound < Error; end
end
end
module Sequel
class Model
def self.set_cache(store, opts = {})
@cache_store = store
if (ttl = opts[:ttl])
set_cache_ttl(ttl)
end
meta_def(:[]) do |*args|
if (args.size == 1) && (Hash === (h =... |
Rails.application.routes.draw do
devise_for :users
root 'items#index'
namespace :admin do
resources :users, except: [:new, :edit, :update]
end
resources :items do
resources :reviews
end
resources :scores, only: [:create, :update, :destroy]
end
|
FactoryGirl.define do
factory :question do
title "Just a question"
text "As I said, just a question."
end
factory :user do
username "Milo"
email "gmail@gmail.com"
password "password"
end
end
|
FactoryGirl.define do
factory :empty_create_check_in_location_form,
class: CreateCheckInForm::LocationForm do
end
factory :valid_create_check_in_location_form,
parent: :empty_create_check_in_location_form do
latitude 50
longitude 19
end
end
|
class ProjectsController < ApplicationController
def index
if logged_in?
@projects = Project.all
else
flash[:access] = "Unauthorized access, please contact your administrator if you believe this error is incorrect."
if request.env["HTTP_REFERER"].present?
redirect_to :back
... |
require 'rails_helper'
RSpec.describe RequestsController do
before(:each) do
@user = FactoryGirl.create(:user)
sign_in @user
end
let(:request) { FactoryGirl.create(:request, user: @user) }
describe 'GET index' do
it 'populates an array with requests' do
request
get :index
expect(... |
require_relative '../spec_helper'
require_relative '../../app/controllers/failures_controller'
# rubocop: disable Metrics/BlockLength
describe FailuresController, type: :controller do
fixtures :users
before do
@controller = FailuresController.new
@request = ActionDispatch::TestRequest.create
@response... |
# create a machine that develops robot names
class Robot
attr_reader :name
@@used_names = []
def initialize
@name = create_name
@@used_names << @name
end
def reset
@@used_names.delete(@name)
@name = create_name
end
private
def create_name
name = ''
loop do
name = [*'... |
require 'securerandom'
require 'base64'
require 'digest'
require 'redcarpet'
module Itpkg
module StringHelper
MARKDOWN = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(link_attributes:{target:'_blank'}), tables: true)
module_function
def rand_s(n)
SecureRandom.hex n
end
def uuid
... |
CarrierWave.configure do |config|
config.root = Rails.root.join('tmp')
config.cache_dir = 'carrierwave'
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV["S3_ACCESS_KEY"],
aws_secret_access_key: ENV["S3_SECRET_KEY"],
region: 'us-east-2'
}
config.stor... |
require_relative './lib/gqli'
class ContentfulClient
extend GQLi::DSL # Makes DSL available at a class level
include GQLi::DSL # Makes DSL available at an object level
SPACE_ID = 'cfexampleapi'
ACCESS_TOKEN = 'b4c0n73n7fu1'
CONTENTFUL_GQL = GQLi::Client.new(
"https://graphql.contentful.com/content/v1/sp... |
class CommandType < ApplicationRecord
has_many :command, dependent: :destroy
end
|
class CreateProgramDetails < ActiveRecord::Migration
def change
create_table :program_details do |t|
t.integer :student_id
t.string :academic_plan
t.string :application_domain
t.datetime :application_domain_submitted_date
t.string :minor
t.datetime :minor_submitted_date
... |
module GemBench
class StrictVersionRequirement
attr_reader :gemfile_path
attr_reader :gems
attr_reader :starters
attr_reader :benchers
attr_reader :verbose
def initialize(options = {})
@gemfile_path = "#{Dir.pwd}/Gemfile"
file = File.open(gemfile_path)
# Get all lines as an ... |
require_relative 'spec_helper'
describe 'App' do
let(:realm) { ENV['quickbooks_realm'] }
let(:secret) { ENV['quickbooks_access_secret'] }
let(:token) { ENV['quickbooks_access_token'] }
let(:headers) {
{
"Content-Type": "application/json"
}
}
include Rack::Test::Methods
def app
Quickbo... |
class User < ApplicationRecord
has_secure_password
has_many :movies
has_many :comments
has_many :favorites, class_name: 'Movie', foreign_key: 'user_id'
end
|
# This is where we define the version number for the gem
module Groundskeeper
VERSION = "1.0.0"
end
|
# create_table "books", force: :cascade do |t|
# t.string "title"
# t.integer "author_id"
# t.integer "category_id"
# t.decimal "isbn", precision: 13
# t.text "description"
# t.datetime "created_at", null: false
# t.datetime "updated_at", nul... |
#encoding: utf-8
require "model-base"
class Package
include DataMapper::Resource
include Utils::DataMapper::Model
extend Utils::DataMapper::Model
include Utils::ActionLogger
# 坑:
# 1. creator_id/editor_id不可以设置为必填项,因为它们不是同一阶段设置
# 2. created_at/updated_at/created_on/updated_on系统自动设置[dm-time... |
require 'spec_helper'
describe 'Client returns ' do
describe 'champions' do
champions = LolApi.champions
subject { champions }
it { should_not be_empty }
describe 'by id' do
champion = LolApi.champion_by_id(35, champData: "all")
subject { champion }
it { should be_kind_of(LolApi::Champion... |
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'pages#home'
devise_for :instructors, path: "instructors", controllers: {
sessions: 'instructors/sessi... |
module CardDeck::TrumpCardDeck
class Base < CardDeck::Base
attr_reader :trump_suit, :lead_suit, :current_hand
def trump_suit=(suit)
if self.class.valid_suit? suit
@trump_suit = suit
else
raise "Invalid Trump Suit"
end
end
def lead_suit=(suit)
if self.clas... |
class ChangeDatatypeInSprintPlannings < ActiveRecord::Migration
def change
change_column :sprint_plannings, :sprint_desc, :text
end
end
|
# 计算机设备 computer
#
#cpu cpu
#cpu数量 cpu_qty
#内存 mem
#硬盘 disk
#硬盘数量 disk_qty
#网卡 nic
#网卡数量 nic_qty
#显示器 display
class ComputerDetail < ActiveRecord::Migration
def self.up
create_table "computer_details", :force => true do |t|
t.string "cpu"
t.integer "cpu_qty"
t.integer "disk"
t.integ... |
class QuestionsController < ApplicationController
def new
@question = Question.new
end
def create
@question = current_user.questions.new(question_params)
if @question.save
redirect_to :root
else
render 'new'
end
end
def show
@question = Question.find(params[:id])
@... |
class PostComment < ApplicationModel
belongs_to :user
belongs_to :post, :counter_cache => :comment_count
validates_inclusion_of :from_where, :in => %w(WEB ANDROID IPHONE NONE)
validates_length_of :comment, :within => 1..200
validates_presence_of :user_id, :post_id, :comment, :from_where
end
|
require 'rspec'
require_relative '../config/environment.rb'
describe "Player" do
let (:bri) {Player.new(name: "Bri", gender: "female", race: "Khajiit", money: 0, location: 64)}
it "Player.name returns player name" do
expect(bri.name).to eq "Bri"
end
it "Player.gender returns player gender" d... |
class Resume < ApplicationRecord
enum employment_eligibility: { authorized: 0, sponsorship: 1 }
enum status: { private_resume: 0, public_resume: 1 }
RESUMES_PER_PAGE = 15
paginates_per RESUMES_PER_PAGE
include ResumeSearch
validates_presence_of :first_name, :last_name
#validates :firs... |
# -*- coding: utf-8 -*-
class PublicResourcesController < ApplicationController
# 公共资源列表
def index
if params[:category_id].blank?
@sub_categories = Category.roots
@public_resources = PublicResource.no_category
@navigation_categories = []
else
@category = Category.find(params[:categor... |
require File.dirname(__FILE__) + '/../test_helper'
class DraftsControllerTest < ActionController::TestCase
fixtures :drafts, :issues, :users
def setup
@controller = DraftsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.sessio... |
Rails.application.routes.draw do
root 'home#index'
resources :users do
resources :notifications, param: :notification_id
resources :bets, param: :bet_id
resources :significant_others, param: :significant_other_id
end
get '/sessions/new', to: 'sessions#new'
post '/sessions', to: 'sessions#create'... |
require 'spec_helper'
describe "the event listing page" do
it "listing should show blank Location if no location_id exists" do
create(:location, :name => 'locname')
event = create(:event, :location_id => nil, :title => 'mytitle')
create(:event_session, event: event, starts_at: 1.day.from_now, ends_at: 2.... |
class AddIndexToMeddlingTarget < ActiveRecord::Migration[5.2]
def change
add_index :meddling_targets, [:e_no, :card_id, :chain, :result_no, :generate_no], :unique => false, :name => 'resultno_eno_cardid_chain'
add_index :meddling_targets, :target_id
add_index :meddling_targets, :count
end
end
|
# Completed step definitions for basic features: AddMovie, ViewDetails, EditMovie
Given /^I am on the RottenPotatoes home page$/ do
visit movies_path
end
When /^I have added a movie with title "(.*?)" and rating "(.*?)"$/ do |title, rating|
visit new_movie_path
fill_in 'Title', :with => title
select ratin... |
require 'rails_helper'
RSpec.describe Api::V1::Notebooks::NotesController, type: :controller do
let(:user) { create(:user) }
include Devise::Test::ControllerHelpers
before { sign_in user }
describe 'GET /api/v1/notebooks/{notebook_id}/notes.json' do
it 'responds with status 200 OK' do
notebook = c... |
# require 'faker'
#
MAIN_PICS = [
"https://s3.amazonaws.com/BLUE-PRINTS-DEV/main_pics/how_to_make_bottle_building.jpg",
"https://s3.amazonaws.com/BLUE-PRINTS-DEV/main_pics/building_2_dollar_treehouse.jpg",
"https://s3.amazonaws.com/BLUE-PRINTS-DEV/main_pics/build_a_cedar_canoe.jpg",
"https://s3.amazonaws.com/BL... |
# frozen_string_literal: true
RSpec.describe 'Video Categories' do
resource 'video_categories' do
let!(:video_category1) { create(:video_category, name: FFaker::Name.name) }
let!(:video_category2) { create(:video_category, name: FFaker::Name.name) }
let!(:video_category3) { create(:video_category, name: ... |
class Document < ActiveRecord::Base
validates_presence_of :name, :source
mount_uploader :source, DocumentUploader
end
|
#!/usr/bin/env ruby
require 'rubygems'
require 'multi_json'
require 'httparty'
require 'socket'
config_file_path = "./config.yml"
@config = YAML.load(File.new(config_file_path).read)
def data_points_url
@config['base_url'] + @config['paths']['data_points']
end
def production?
@config["environment"] == "product... |
require 'test_helper'
class CampusCrimesControllerTest < ActionDispatch::IntegrationTest
setup do
@campus_crime = campus_crimes(:one)
end
test "should get index" do
get campus_crimes_url
assert_response :success
end
test "should get new" do
get new_campus_crime_url
assert_response :succ... |
if defined?(Sidekiq)
redis_proc = lambda {
config = YAML.safe_load(ERB.new(IO.read(Rails.root.join('config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
Redis.new(config.merge(thread_safe: true))
}
Sidekiq.configure_client do |config|
config.redis = ConnectionPool.new(size: 15, &redis_p... |
class Users::EditSerializer < ApplicationSerializer
object_as :user
attributes(
:id,
:email,
:active_company_id,
:active,
)
has_many :people, serializer: PersonSerializer
has_one :person, serializer: PersonSerializer
has_many :companies, serializer: CompanySerializer
end
|
module BootstrapHelper
def bootstrap_flash
flash_class = {
'notice' => 'success',
'alert' => 'warning',
'error' => 'danger'
}
flash.map do |k, title|
if title.is_a? Hash
@title = title["msg"]
@url = title["url"]
@prompt = title["prompt"]
else
... |
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :project_name
t.datetime :due_date
t.string :components
t.string :notes
t.string :client_name
t.string :project_manager_assigned
t.string :account_manager_assigned
t.s... |
require 'rodent'
class Customer
attr_accessor :name, :email
def initialize(options)
@name = options['name']
@email = options['email']
end
def as_json
{name: name, email: email}
end
end
class CustomersAPI < Rodent::Base
listen 'customers.create' do
self.status = 201
self.headers['API-... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
module CDI
module V1
module ServiceConcerns
module LearningDeliveriesParams
extend ActiveSupport::Concern
WHITELIST_ATTRIBUTES = [
:format_type,
:delivery_date,
:delivery_kind,
:description,
:group_size
]
included do
... |
module Inventory
class ConvertProductPlan
include Mongoid::Document
include Mongoid::Timestamps::Short
field :product_type, type: String
field :package_type, type: String
field :quantity, type: Float, default: -> { 0 }
field :uom, type: String
field :conversion, type: Float, default: -> {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.