text stringlengths 10 2.61M |
|---|
FactoryBot.define do
factory :pricing_rule do
trait :line_items do
name { "2 items A for £90" }
end
trait :line_items_2 do
name { "3 items B for £75" }
end
trait :basket do
name { "10% off total basket cost for baskets worth over £200" }
apply_last { true }
end
end
... |
class FontInconsolataNerdFont < Formula
version "2.3.3"
sha256 "d8450da53f7cbe9f8e9247d3db0e9d16e4baafa90c5c3a93ef34f3d8e4565bed"
url "https://github.com/ryanoasis/nerd-fonts/releases/download/v#{version}/Inconsolata.zip"
desc "Inconsolata Nerd Font (Inconsolata)"
desc "Developer targeted fonts with a high nu... |
json.array! @messages do |message|
json.content message.content
json.image message.image
json.created_at message.created_at
json.user_name message.user_name
json.id message.id
end |
#!/usr/local/bin/ruby
require "pp"
require "cgi"
require "rubygems"
require "xmlsimple"
require 'yaml'
##
# Serves up kml..
class KMLHandler < RackWelder
#set stuff up, log=logger, cfg=shiv kml config.
def initialize ( log,http_conf, set)
@logger = log
#the ip of the requesting host..
@REMOTE... |
#encoding:utf-8
#收货地址
class Address < ActiveRecord::Base
belongs_to :user
validates :user, :presence => true
validates :region_code, :presence=> true
validates :note, :presence=> true
#params的可提交的属性参数参数
def self.permit_data
data = [:user_id, :region_code,:note, :is_default,:created_at,:updated_at]
... |
class Expense
include Lotus::Entity
attributes :amount, :category_id
end
|
# https://central.github.com/mac/latest
default[:chimpstation_pkg][:github_for_mac][:release_url] = "https://github-central.s3.amazonaws.com/mac%2FGitHub%20for%20Mac%20:version:.zip"
default[:chimpstation_pkg][:github_for_mac][:app_path] = "/Applications/Github.app"
default[:chimpstation_pkg][:github_for_mac][:ver... |
class StepsController < ApplicationController
before_action :login_again_if_different_shop
before_action :validate_payment_type
before_action :set_step, only: [:show, :edit, :update, :destroy]
around_filter :shopify_session
layout 'embedded_app'
# GET /steps
# GET /steps.json
def index
@steps = Ste... |
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "Binchan's Toy App"
xml.description ""
xml.link root_url + "users/1"
for post in @posts
xml.item do
if post.content.index("\n") != nil
xml.title post.content[0,post.content.index("\n")]... |
FactoryGirl.define do
factory :search do
input { |n| "search#{n}" }
phrase
session_key SessionKeyService.get
end
end
|
class Piece < ActiveRecord::Base
belongs_to :artist
belongs_to :collection
belongs_to :customer
validates_presence_of :artist_id, :name
validates :price_in_cents, numericality: { greater_than_or_equal_to: 0, allow_blank: true }
def buy_piece(customer)
self.customer_id = customer.id
self.available ... |
class SearchController < ApplicationController
before_action :require_login
def index
search_term = {}
if params[:Cities].nil? || params[:Category].nil?
params[:Cities] = ""
params[:Category] = ""
end
search_term[:city] = params[:Cities] unless params[:Cities].empty?
search_term[:produce_category] = p... |
module QuestionsHelper
TOPICS = ["JS", "HTML", "Ruby", "Functions", "Rails", "Testing"]
DIFFICULTY = ["Easy", "Medium", "Hard"]
def show_topic(num)
TOPICS[num]
end
def show_difficulty(num)
DIFFICULTY[num]
end
end
|
# == Schema Information
#
# Table name: case_studies
#
# id :integer(4) not null, primary key
# title :string(255)
# description :text
# permalink :string(255)
# keywords :string(255)
# service_id :integer(4)
# crea... |
require "application_system_test_case"
class MotorcyclesTest < ApplicationSystemTestCase
setup do
@motorcycle = motorcycles(:one)
end
test "visiting the index" do
visit motorcycles_url
assert_selector "h1", text: "Motorcycles"
end
test "creating a Motorcycle" do
visit motorcycles_url
cl... |
# frozen_string_literal: true
RSpec.describe Hanamimastery::CLI::Transformations::Unshot do
let(:subject) { described_class.new }
describe '#call' do
let(:expected) { "before after at the end" }
it 'removes shot marks with normal space from content' do
content = "before [🎬 02] after [🎬 02] at the... |
class Hotels::GetService < Hotels::Base
PERSONAL_ROUTE = 'hotels'
def initialize(params={})
@id = params[:id]
end
def perform!
@api_call = get_hotel
if @api_call.include?('errors')
error_result
else
ResultObjects::Success.new(@api_call)
end
end
private
def get_hotel
... |
# frozen_string_literal: true
module GraphQL
module Tracing
# Each platform provides:
# - `.platform_keys`
# - `#platform_trace`
# - `#platform_field_key(type, field)`
# @api private
class PlatformTracing
class << self
attr_accessor :platform_keys
def inherited(child_cl... |
class PickupHistory < ActiveRecord::Base
validates :condition, presence: true,
length: {minimum: 5};
validates :pickupid, presence: true
validates :employeeid, presence: true
end
|
class CreateWorkoutGroupSpecifiedDays < ActiveRecord::Migration[5.1]
def change
create_table :workout_group_specified_days do |t|
t.integer :workout_group_id, null: false
t.integer :workout_day_num, null: false
t.timestamps
end
end
end
|
FactoryBot.define do
factory :account do
account_number { Faker::Bank.account_number }
bank_number { Faker::Bank.routing_number }
balance { Faker::Number.decimal(l_digits: 2) }
user
end
end
|
# Example 3
# Let's mix it up a little bit and have you try taking apart an example on your own.
[[1, 2], [3, 4]].map do |arr|
puts arr.first
arr.first
end
# Map out a detailed breakdown for the above example using the same approach as the previous two examples. What do you think will be returned and what will be ... |
require 'rails_helper'
describe 'Help requests', type: :request do
context 'unauthenticated' do
let(:help_link) { 'help me omg' }
before do
@help_link = ENV['HELP_LINK']
ENV['HELP_LINK'] = help_link
end
after { ENV['HELP_LINK'] = @help_link }
subject { get help_index_path }
it... |
class CagesController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource :group
load_and_authorize_resource :cage, :find_by => :cage_id, :through => :group, :shallow => true
skip_authorize_resource :cage, :only => [:show, :edit, :update]
def index
#@group = Group.fin... |
class Plane
attr_reader :flying
def initialize
@flying = false
end
def fly
@flying = true
end
def grounded
@flying = false
end
end |
class User < ApplicationRecord
attr_reader :password
validates :username, presence: true
validates :session_token, presence: true
validates_presence_of :password_digest, message: "Password can't be blank"
validates :password, length: {minimum: 6, allow_nil: true}
before_validation :ensure_session_token
... |
require 'rails_helper'
RSpec.describe Liability do
describe "initialization" do
let(:liability) { Liability.new }
it "should have a valid factory for a loan with interest" do
expect(FactoryGirl.build_stubbed(:loan_with_interest)).to be_valid
end
it "should have a valid factory for a loan wit... |
Redmine::Plugin.register :budget_plugin do
name 'Budget plugin'
author 'Author name'
description 'This is a plugin for Redmine'
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
settings :default => {
'budget_nonbillable_overhead' => '',
'budget_materi... |
class ApplicationController < ActionController::Base
include Pundit
rescue_from Pundit::NotAuthorizedError do |exception|
redirect_to root_url, alert: exception.message
end
protect_from_forgery with: :exception
end
|
class MembersController < ApplicationController
before_action :set_member, only: [:show, :edit, :update, :destroy]
def index
@members = Member.all
end
def new
@member = Member.new
end
def create
@member = Member.new(member_params)
respond_to do |format|
if @member.save
fo... |
# Copyright 2014 Square 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
#
# Unless required by applicable law or agreed ... |
module MaterializedViews
class TrackReviewReport < BaseMaterializedView
belongs_to :learning_track
belongs_to :student_class
alias :track :learning_track
self.table_name = 'track_review_reports_matview'
end
end
|
# hello rake task
namespace :hello do
desc 'Just a task to greet'
task process: :environment do
puts "hello, my first rake task"
end
end
# create a rake task to enroll given number of subjects to a study
# add 100 participants to a given study
# rake --tasks to check all rake tasks available
namesp... |
class Item < ActiveRecord::Base
attr_accessible :description, :price
has_many :purchases
end
|
class AddGroupDateToTimeFrameGroups < ActiveRecord::Migration
def change
add_column :time_frame_groups, :group_date, :date, null: false
end
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :tournament do
start_date { Faker::Date.between(from: DateTime.now + 1, to: DateTime.now + 2) }
time_to_answer { 60 }
factory :tournament_with_participants do
transient do
count { 3 }
end
after(:create) do |trnmt, evalua... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::StaticValidation::FragmentsAreFinite do
include StaticValidationHelpers
let(:query_string) {%|
query getCheese {
cheese(id: 1) {
... idField
... sourceField
similarCheese(source: SHEEP) {
... flavorFi... |
require 'rails_helper'
RSpec.describe Notebook, type: :model do
it_behaves_like 'a presentable'
describe 'associations' do
it { is_expected.to belong_to :user }
it { is_expected.to have_many(:notes).dependent(:destroy) }
end
describe 'validations' do
it { is_expected.to validate_presence_of :name... |
class Web::Admin::AppConfigsController < Web::Admin::ProtectedApplicationController
authorize_actions_for ::AppConfig
def show
@app_config = AppConfig.last
end
def edit
@app_config = AppConfigType.last
end
def update
@app_config = AppConfigType.last
if @app_config.update(params[:app_confi... |
class RenameColumnsInCutoffAndQuota < ActiveRecord::Migration
def change
remove_foreign_key "cutoffs", name: "cutoff_fk"
remove_foreign_key "quota", name: "quota_fk"
remove_column :cutoffs, :subject_id
remove_column :quota, :subject_id
add_column :cutoffs, :stream_id, :integer, null: false
add_colum... |
class Bears
attr_reader :name, :type, :stomach
attr_writer :name, :type, :stomach
def initialize(name, type, stomach)
@name = name
@type = type
@stomach = []
end
def stomach_contents
return @stomach.size
end
def add_fish(fish)
@stomach.push(fish)
end
end
|
#!/usr/bin/ruby
# Dropzone Destination Info
# Name: Create DMG file
# Description: Creates a DMG file from the dropped files, pressing the cmd key creates an encrypted DMG.
# Handles: NSFilenamesPboardType
# Events: Clicked, Dragged
# KeyModifiers: Command
# Creator: Megan Cooke
# URL: http://www.insanekitty.co.uk
# I... |
#
# @author Kristian Mandrup
#
# Storage that stores role as a single String
#
module Trole::Storage
class StringOne < BaseOne
# constructor
# @param [Symbol] the role subject
def initialize role_subject
super
end
# display the role as a list of one symbol
# see Troles:... |
# coding: utf-8
# frozen_string_literal: true
require "test_helper"
class RubemeCharTest < Minitest::Test
include Rubeme
def setup
@ch_a = "a"
@ch_b = "b"
@ch_a_ja = "あ" # UTF-8
@ch_i_ja = "い" # UTF-8
end
def test_it_can_generate_from_string_with_a_character
char =... |
class CreatePostAndAuthor < ActiveRecord::Migration[5.0]
def change
create_table :posts do |t|
t.belongs_to :author, index: true
t.string :content_type, null: false
t.string :content, null: false
t.timestamps
end
create_table :authors do |t|
t.string :first_name, null: fals... |
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/fixtures/cassettes'
c.hook_into :webmock
c.configure_rspec_metadata!
c.default_cassette_options = {
:record => :once,
:match_requests_on => [:method, :uri_with_unordered_params]
}
# In recorded cassettes, replace these environment v... |
# noinspection RubyUnusedLocalVariable
class FizzBuzz
def fizz_buzz(number)
@number = number
@return = ""
@return += 'fizz ' if output_fizz?
@return += 'buzz ' if output_buzz?
return @return += 'fake deluxe' if output_fake_deluxe?
@return += 'deluxe' if output_deluxe?
@return = @number.to... |
class Message < ApplicationRecord
validates_presence_of :body
validates_presence_of :recipient
validates_presence_of :sender
end
|
require 'rails_helper'
RSpec.describe OrganizationCampaignsController, type: :controller do
before(:each) { login_user }
describe 'show > ' do
let(:oc) { FactoryGirl.create(:organization_campaign) }
it 'stores organizaton campaign particulars in session' do
get :show, id: oc.id
expect(session... |
class AddServiceGoalToReviewReport < ActiveRecord::Migration
def self.up
add_column :review_reports, :service_goal, :text
end
def self.down
remove_column :review_reports, :service_goal
end
end
|
module Oshpark
class Token
attr_accessor :expires_at
def initialize json={}
super
@expires_at = Time.now + (@ttl || 0)
end
def self.attrs
%w| token ttl user_id |
end
include Model
def ttl
expires_at - Time.now
end
def user
User.from_json 'id' => ... |
event_id = read_and_clear_event_id
json.event_url event_source_path(projection: 'MessageProjection', event: event_id) if event_id
json.messages(@messages) do |message|
json.extract! message, :id, :head, :body, :author, :email
json.url message_url(message, format: :json)
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
############################################################
# NYU: CSCI-GA.2820-001 DevOps and Agile Methodologies
# Instructor: John Rofrano
############################################################
Vagrant.configure(2) do |config|
# config.vm.box = "ubuntu/focal64"
c... |
class Ability
include CanCan::Ability
def initialize(user)
alias_action :index, :show, to: :read
alias_action :create, :read, :update, :destroy, to: :crud
if user.has_role? :admin
can :manage, :all
elsif user.has_role? :normal
can :read, :all
else
can :read, Home
end
en... |
# coding: utf-8
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "t/version"
Gem::Specification.new do |spec|
spec.add_dependency "geokit", "~> 1.9"
spec.add_dependency "htmlentities", "~> 4.3"
spec.add_dependency "launchy", "~> 2.4"
spec.add_dependency "o... |
FactoryGirl.define do
factory :user do
full_name { Faker::Name.name }
email { Faker::Internet.email }
password "password"
api_token { SecureRandom.hex(40) }
trait :facebook do
facebook_uid { 20.times.map{ rand(9) }.join }
facebook_token { SecureRandom.hex }
facebook_token_expire... |
# Project-specific configuration for CruiseControl.rb
Project.configure do |project|
# Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody)
project.email_notifier.emails = ['t@gmail.com', 'sadsfgjana@bajratechnologies.com', 'bishasdfnu@bajratechnol... |
RSpec.describe 'Item Dashboard Page' do
before(:each) do
@item_1 = Item.create(name: "Zanti Red", description: "Red Wine", unit_price: 7, image: '../../public/images/capy-photo.jpg')
@item_2 = Item.create(name: "Espinosa White", description: "White Wine", unit_price: 11, image: '../../public/images/capy-photo... |
require 'chemistry/element'
Chemistry::Element.define "Chromium" do
symbol "Cr"
atomic_number 24
atomic_weight 51.9961
melting_point '2130K'
end
|
class Parking < ApplicationRecord
#In the future the client may want new kinds of status, example: overnight
enum status: {
in_progress: 0,
finished: 1
}, _prefix: :status
validates :plate, presence: true
validates_format_of :plate, with: /\A\w{3}\-\d{4}\z/
def self.create_default(plate)
park... |
class Level < ApplicationRecord
has_many :items
has_many :platforms
has_many :users
has_many :appearances
has_many :characters, through: :appearances
has_many :npc_dialogs, through: :appearances
def get_item_types
items = self.items
item_types = []
items.each do |item|
item_types << item.item_type
en... |
require 'minitest/autorun'
require 'ruby-hl7'
class Pv1Segment < MiniTest::Test
def setup
@base = "PV1||I|3ST^P001^A|3|||1234567890^LastName^FirstName^^^^MD|9876543210^LastName^FirstName^M^^^MD||RAD||||6||""|2345678901^LastName^FirstName^^^^MD|RT|1112100001|SP|||||||||||||||||||A|||||02/06/2012||||||ADM"
end
... |
#!/usr/bin/env ruby
def checksum(input)
array = input.split("\n").map{ |row| row.split("\t").map(&:to_i)} # Returns an array of integer arrays.
values = []
array.each do |row|
values << row.minmax.reverse.reduce(:-)
end
sum = values.reduce(:+)
puts sum
end
checksum("5\t1\t9\t5
7\t5\t3
2\t4\t6\t8")
... |
module Dashboard
class ParseCardsController < Dashboard::BaseController
def new; end
def create
AddCardsFromUrlJob.perform_later(parse_cards_params)
redirect_to cards_path, notice: "Cards adding task from #{parse_cards_params[:url]} was added in queue."
end
private
def parse_cards_p... |
module Lolita
module Extensions
module Authentication
class DeviseAdapter
def initialize context, options={}
raise Lolita::NoAuthenticationDefinedError, "Lolita.authentication is not defined" unless Lolita.authentication
@context = context
end
def current_... |
class UserSweeper < ActionController::Caching::Sweeper
observe User
def before_update(record)
expire_cache_for(User.find(record.id), record)
end
def before_destroy(record)
expire_cache_for(record, nil)
end
private
def expire_cache_for(old_record, new_record)
if old_record and
(new_re... |
require 'nokogiri'
require 'pry'
require 'json'
require 'objspace'
require_relative 'external_service.rb'
class Assignment
def run
# Reading and parsing the feed.xml file
doc = File.open("data/feed.xml") { |f| Nokogiri::XML(f) }
# Getting the batches of parsed items
parsed_items = get_parsed_items_... |
class My::AsksController < ApplicationController
before_action :find_ask, only: [ :show, :edit, :update, :destroy ]
def index
@asks = current_user.asks
end
def show
end
def new
@ask = Ask.new
@nft = Nft.find(params[:nft_id])
@collectible = Collectible.find(@nft.collectible_id)
end
def cr... |
Given /^There are many snippets$/ do
100.times do |i|
Snippet.create(:name => "snippet_#{i}", :content => "This is snippet #{i}")
end
end
Given /^There are few snippets$/ do
#
end
Then /^I should see all the snippets$/ do
Snippet.all.each do |snippet|
response.body.should have_tag('tr.snippet') do
... |
require 'rubygems'
require 'gruff'
context "Method chart_loc_per_commit" do
chart_spec :method => :chart_loc_per_commit
specify "should use at most 20 labels" do
@repo.revisions_append_with_loc((1..50).to_a)
@gruff_line_object.should_receive(:labels=) do |labels|
labels.size.should <= 20
end
... |
require 'rails_helper'
require 'support/user_attributes'
describe Media do
let(:user) { User.create!(user_attributes) }
it "should respond to attributes" do
media = Media.new
expect(media).to respond_to(:user)
expect(media).to respond_to(:title)
expect(media).to respond_to(:subtitle)
expect(... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :warehouse do
branch_id 1
category "MyString"
tujuan_project "MyText"
time "2014-07-04 00:42:56"
spesifikasi_id 1
no_ticket "MyString"
remarks "MyText"
end
end
|
require_relative('guest')
class Room
def initialize(name)
@name = name
@songs = []
@guests = []
end
def name
return @name
end
# ------------------------------------music methods ----------------------------
def playlist
return @songs
end
def currently_playing
current = @songs.s... |
# This is a Chef attributes file. It can be used to specify default and override
# attributes to be applied to nodes that run this cookbook.
# Set a default name
default["starter_name"] = "Rihards"
default['fail2ban']['services'] = {
'ssh' => {
"enabled" => "true",
"port" => "ssh",
"filter" ... |
# frozen_string_literal: true
class AddSubscribersCountToJets < ActiveRecord::Migration[5.2]
def change
add_column :jets, :subscribers_count, :integer, default: 0
end
end
|
class Api::V1::CommentsController < ApplicationController
before_action :set_comment, only: %i[ show update destroy ]
def index
@comments = Comment.all
render json: @comments
end
def show
render json: @comment, status: 200
end
def create
@comment = Comment.cre... |
class Task < ActiveRecord::Base
include DateTimeConverter
include IndexCheck
belongs_to :project
has_many :comments
has_many :user_tasks, foreign_key: "assigned_task_id"
has_many :assigned_users, through: :user_tasks
belongs_to :owner, class_name: "User"
enum status: [:active, :complete, :inactive, :... |
class RacesController < ApplicationController
before_filter :authenticate_user!
def index
@races = Race.all
end
def show
@race = Race.find(params[:id]) # TODO: Refactoring
end
def new
@race = Race.new
end
def create
@race = Race.new(race_params)
if @race.save
redirec... |
class Admin::ForumsController < ApplicationController
# GET /admin/forums
def index
@forums = Forum.all
respond_to do |format|
format.html
end
end
# GET /admin/forums/:id
def show
@menu = Forum.all
@forum = Forum.get(params[:id])
respond_to do |format|
format.html
en... |
require 'spec_helper'
require 'prct07'
describe Referencia do
before :each do
@r1 = Referencia.new(["Dave Thomas", "Andy Hunt", "Chad Fowler"], "Programming Ruby 1.9 & 2.0: The Pragmatic Programmers’ Guide",
nil, "Pragmatic Bookshelf", "4 edition", "July 7, 2013", ["ISBN-13: 978-1937785499","ISBN-... |
FactoryBot.define do
factory :post do
sequence(:body) { |n| "Secret #{n}" }
factory :public_post do
privacy {:public_access}
end
factory :private_post do
privacy { :private_access }
end
end
end
|
namespace :mamashai do
desc "自动设置热点话题"
task :set_hot_topic => [:environment] do
if Time.now.yday % 2 == 1 #单数日子,要换话题
hot = WeekTag.first(:conditions=>"current = 1", :order=>"id desc")
candidates = WeekTag.all(:conditions=>"id > #{hot.id}", :order=>"id")
candidates.first.current ... |
class Api::StandingsController < ApplicationController
before_action :require_logged_in
def index
@standings = Score.where(author_id: current_user).or(Score.all.where(player_two: current_user.username)).head_to_head_player_standings
render :index
end
# def show
# @standings = Score.all.where
# end
privat... |
#
# Be sure to run `pod lib lint HLNetworking.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'HLNet... |
require 'rails_helper'
RSpec.describe Api::V1::ToysController, type: :controller do
describe 'Get #idenx' do
before :each do
@toy_1 = create :toy
@toy_2 = create :toy
@toy_3 = create :toy
get :index
end
it { should respond_with 200 }
it 'returns a toy response' do
expe... |
# 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... |
class AddWebLinkToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :web_link, :string
end
end
|
=begin
#Scubawhere API Documentation
#This is the documentation for scubawhere's RMS API. This API is only to be used by authorized parties with valid auth tokens. [Learn about scubawhere](http://www.scubawhere.com) to become an authorized consumer of our API
OpenAPI spec version: 1.0.0
Contact: bryan@scubawhere.co... |
class Message
attr_reader :text, :user, :timestamp
def initialize text:, user:, timestamp: Time.now
@text, @user, @timestamp = text, user, timestamp
end
def to_s
"#{user}: #{text}"
end
end
|
class WelcomeController < ApplicationController
def index
return unless logged_in?
end
end
|
# 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... |
require 'test_helper'
class EventTest < ActiveSupport::TestCase
test "should create event with title" do
event = Event.create( title: 'ECE 458 Lecture', description:
'description text')
assert event.save, "saved event with a title and description"
end
test "should not create event without title" do
eve... |
HAS_MANY_OPTIONS = {
allow_destroy: true
}
ActiveAdmin::FormBuilder.class_eval do
def has_rules(options = {})
inputs('Rules', { class: 'inputs rules' }) do
semantic_fields_for(:rule_set) do |rules_rule_set_form|
rules_rule_set_form.has_many(:rules, HAS_MANY_OPTIONS) do |rules_rule_form|
... |
class Personalcharge < ActiveRecord::Base
acts_as_commentable
validates_presence_of :person_id
validates_presence_of :charge_date
validates_numericality_of :hours
validates_numericality_of :ot_hours
belongs_to :project
belongs_to :period
belongs_to :person
state_machine :initial => :pending do
e... |
class AddCompter < ActiveRecord::Migration[5.0]
def change
create_table :computers do |t|
t.string :user_name
t.string :computer_name
t.string :windows_install
t.string :product_key
t.string :office_install
t.string :office_key
t.string :second_office
t.string :seco... |
class Book < ApplicationRecord
# Associations
has_many :authors, inverse_of: :book
belongs_to :author, inverse_of: :books, dependent: :destroy, foreign_key: "author_id"
belongs_to :publisher_house, foreign_key: "publisher_house_id"
# Validations
validates :title, length: { maximum: 150, too_long: "%{count}... |
class PackingListItem < ApplicationRecord
acts_as_paranoid
validates :quantity, numericality: { greater_than_or_equal_to: 0}
belongs_to :packing_list
end
|
require 'test_helper'
class ActiveCacheStoreTest < ActiveSupport::TestCase
test "abstract store defines read" do
assert ActiveCache::Store::AbstractStore.respond_to?(:read)
end
test "abstract store defines write" do
assert ActiveCache::Store::AbstractStore.respond_to?(:write)
end
test "abstract st... |
# frozen_string_literal: true
module Kafka
# Holds a list of interceptors that implement `call`
# and wraps calls to a chain of custom interceptors.
class Interceptors
def initialize(interceptors:, logger:)
@interceptors = interceptors || []
@logger = TaggedLogger.new(logger)
end
# This ... |
class RenameColumnsInMovieNight < ActiveRecord::Migration
def self.up
rename_column :movie_nights, :users, :user_ids
rename_column :movie_nights, :movies_towatch, :towatch_movie_ids
rename_column :movie_nights, :movies_seen, :seen_movie_ids
end
def self.down
rename_column :movie_nights, :user_ids... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.