text stringlengths 10 2.61M |
|---|
require 'net/http'
require 'json'
require 'uri'
require 'optparse'
require 'logger'
class UnlinkedSubjectDeleter
def initialize(opts, log)
@backend_url = URI.parse(opts[:backend_url])
@username = opts[:username]
@password = opts[:password]
@commit = opts[:commit] || false
@session = nil
@lo... |
class Ingredient < ActiveRecord::Base
has_and_belongs_to_many :recipes
validates :name, :presence => true, :uniqueness => true
end |
# Group 1
# my_proc = proc { |thing| puts "This is a #{thing}." }
# puts my_proc
# puts my_proc.class
# my_proc.call
# my_proc.call('cat')
=begin
Of note:
1) with Procs, arguments are optional
2) when called without an argument supplied (where one is expected), the return value of the argument will be nil.
3) ... |
class CreateDebitNotes < ActiveRecord::Migration[5.0]
def change
create_table :debit_notes do |t|
t.references :supplier, references: :company, foreign_key: true
t.references :purchase_order, foreign_key: true
t.references :delivery, foreign_key: true
t.decimal :total_value
t.decimal... |
#
# Cookbook Name:: cpe_ssh
# Libraries:: cpe_ssh
#
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
#
# Copyright (c) 2019-present, Uber Technologies, Inc.
# All rights reserved.
#
# This source code is licensed under the Apache 2.0 license found in the
# LICENSE file in the root directory of this sou... |
# in lib/ulamek2.rb
class Ulamek
def to_float
b.zero? && raise_error('Cannot divide by 0')
a / b.to_f
end
def to_s
a.to_s + '/' + b.to_s
end
end
|
require 'spec_helper'
describe LLT::Constants::RegExps do
def self.example_loop(regexp, negative = false)
yield.each do |example|
str = (negative ? "doesn't match" : "matches")
it "#{str} #{example}" do
if negative
regexp.should_not match(example)
else
regexp.shoul... |
# frozen_string_literal: true
module Darlingtonia
##
# A generic parser.
#
# `Parser` implementations provide a stream of `InputRecord`s, derived from an
# input object (`file`), through `Parser#records`. This method should be
# implemented efficiently for repeated access, generating records lazily if
# ... |
require 'spec_helper'
describe "static_pages/home" do
before do
mock_geocoding!
@social_info = stub_model(SocialInfo, hash_tags: "#goirish", not_tags:"")
@sport = stub_model(Sport, id:1)
@location = FactoryGirl.create(:location)
@team = stub_model(Team, id:1, name:"Seahawks", social_info:@so... |
#estructura que nos permite encapsular
#datos y acxciones - atributos y metodos
class Cliente
#datos-variables.atributos
@nombre
attr_accessor :correo
attr_accessor :celular
attr_accessor :direccion
attr_accessor :metodo_de_pago_favorito
attr_accessor :mascota
#acciones - metodos
... |
class PostsController < ApplicationController
before_action :authenticate_user!, only: %i[new create]
def index
@posts = Post.all
end
def create
@post = current_user.posts.build(post_params)
redirect_to root_path if @post.save
end
def new
@post = current_user.posts.build
end
end
|
# 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
#... |
# Write a method that takes a String as an argument, and returns a new String that contains the original value using a staggered capitalization scheme in which every other character is capitalized, and the remaining characters are lowercase. Characters that are not letters should not be changed, but count as characters... |
class AnswerTipMessage < UserTipMessage
def hash_name
"answer:tip:message:#{self.user.id}"
end
def path
"/questions?type=answered"
end
module UserMethods
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
def answer_tip_message
... |
require 'garage'
describe Garage do
let(:garage) {Garage.new}
let(:broken_bike) {double :broken_bike, broken?: true}
let(:working_bike) {double :working_bike, broken?: false}
it "should dock broken bikes from the van" do
allow(broken_bike).to receive(:fix!)
garage.accept(broken_bike)
expect(garag... |
class CreateEntryItems < ActiveRecord::Migration
def change
create_table :entry_items do |t|
t.date :entry_date
t.text :explanation
t.integer :credit_subject_id, null: false
t.integer :debit_subject_id, null: false
t.integer :amount
t.timestamps null: false
end
end
end
|
class Profile < ActiveRecord::Base
belongs_to :user
validate :first_or_last_name_nil
validates :gender, inclusion: { in: ["male", "female"] }
validate :male_has_name_sue
def first_or_last_name_nil
if first_name.nil? && last_name.nil?
errors.add(:last_name, "cannot both be nil!")
end
end
d... |
class MessagesController < ApplicationController
before_action :authenticate_user!
def new
@user = User.find(current_user.id)
end
def index
@user = User.find(current_user.id)
@messages = Message.where("user_id IN (?) OR user_id = ?", @user.friends.ids, @user.id).paginate(:page => params[:page], :per... |
class CartSerializer < ActiveModel::Serializer
attributes :id, :user_id, :history
has_many :add_products
end
|
#!/usr/bin/ruby
#coding=utf-8
# -*- coding: UTF-8 -*-
# 定义一个模块
module Restart
VAR_CONST = "60s"
def Restart.run
puts "开始重启中..."
end
end |
class Iteration
include Mongoid::Document
field :name, :type => String
field :start_date, :type => Date
field :end_date, :type => Date
has_many :user_stories
belongs_to :project
end
|
require './gameObject'
class Hiero < GameObject # Objeto objetivo do jogador, pode ser coletado pelo falcon, se move em direção ao canto inferior esquerdo
def initialize(name, x, y, zlist, width, length)
@movCoolDownTimer = 0 # Temporizador do movimento dos hieros
@name = name
@sprite = Sprite.new("./h... |
class Assessment < ActiveRecord::Base
has_many :indications
has_many :feelings, through: :indications
has_many :competencies
has_many :providers, through: :competencies
validates :word, uniqueness: true, presence: true
def self.determine_prevalent(feelings)
correlations = Hash.new(0)
feelings.each... |
# -*- encoding : utf-8 -*-
class Notify < ActiveRecord::Base
belongs_to :course
attr_accessible :content, :readed_times, :title
validates_presence_of :title, :content, :course_id
end
|
# app/models/spree/promotion/rules/order_quantity.rb
# A rule to apply to an order having quantity 'greater than', 'less than',
# 'greater than or equal to' or 'less than or equal to'
module Spree
class Promotion
module Rules
class OrderQuantity < Spree::PromotionRule
preference :quantity_min, :dec... |
require_relative '../supermarket.rb'
RSpec.describe Supermarket, type: :model do
let(:pricing_rule) { FactoryBot.create(:pricing_rule, :line_items) }
let(:item_a) { FactoryBot.create(:item, :a) }
let(:item_b) { FactoryBot.create(:item, :b) }
let(:supermarket) { Supermarket.new }
context "#init" do
it "s... |
class AddIndexToCardUsePage < ActiveRecord::Migration[5.2]
def change
add_index :card_use_pages, [:battle_page, :party, :result_no, :generate_no], :unique => false, :name => 'resultno_and_battle_page'
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'spec_helper'
describe TwitterCldr::Segmentation::BreakIterator do
describe "#each_sentence" do
let(:iterator) { described_class.new(:en, use_uli_exceptions: true) }
it "should return an enumerator if call... |
class RemoveEndTimeColumnFromTimeSlots < ActiveRecord::Migration[6.1]
def change
remove_column :time_slots, :end_time
end
end
|
class EventsController < ApplicationController
before_action :authenticate_user, :only => [:new, :create]
before_action :set_events, :only => [:show]
def new
@event = Event.new
@event.build_ticket
end
def index
@events = Event.recent_events
@categories = Category.all
end
def show
end
... |
module Byebug
#
# Reopens the +info+ command to define the +args+ subcommand
#
class InfoCommand < Command
#
# Information about arguments of the current method/block
#
class ArgsSubcommand < Command
def regexp
/^\s* a(?:rgs)? \s*$/x
end
def execute
locals = @s... |
class HoboMigration1 < ActiveRecord::Migration
def self.up
drop_table :list_items
end
def self.down
create_table "list_items", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.integer "list_id"
t.string "doc_id", :limit => 4
end
end
end
|
require 'rails_helper'
RSpec.describe Song, type: :model do
describe 'validations' do
let!(:artist) { create :artist, name: 'Weezer' }
let!(:album) { create :album, name: 'The Blue Album', artist: artist }
let!(:june) { create :song, name: 'June', album: album }
it 'is invalid without a name' do
... |
module Authentication
extend ActiveSupport::Concern
included do
before_action :ensure_authenticated_user
end
private
def ensure_authenticated_user
authenticate_session(cookies.signed[:user_id]) || redirect_to(new_team_session_url)
end
def authenticate_session(user_id)
if user = User.... |
class Order < ApplicationRecord
include Ownable
pg_search_scope(
:search,
against: [:number], associated_against: {
user: [:email],
person: [:first_name, :middle_name, :last_name, :employee_number, :job_title],
vendor: [:name]
}, using: {
tsearch: { prefix: true },
trigram... |
# 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... |
module Admin
class SiteMetaTagsController < BaseController
before_action :set_meta_tags, only: [:edit, :update, :destroy]
def index
@meta_tags = SiteMetaTags.order(:created_at)
end
def new
@meta_tags = SiteMetaTags.new
end
def create
@meta_tags = SiteMetaTags.new(params[:... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "posts/show", type: :view do
before(:each) do
post2 = Post.create(caption: 'I am the second', user_id: 1)
post2.picture.attach(io: File.open(Rails.root + 'app/assets/images/test2.jpg'), filename: 'test2.jpg')
@post = assign(:post, post2... |
class CreateStories < ActiveRecord::Migration
def change
create_table :stories do |t|
t.text :title
t.text :description
t.integer :owner_id
t.integer :requester_id
t.string :type
t.string_array :labels
t.integer_array :seen_by
t.timestamps
end
end
end
|
class JobsController < ApplicationController
def index
@jobs = LookingForService.recent_jobs
end
def show
@job = LookingForService.job(params[:id])
@job_data = @job.to_json
end
end
|
# frozen_string_literal: true
RSpec.describe ProcessVideoDataService do
let!(:video) { create(:video, duration: 0) }
let(:fixture) { file_fixture('video.mp4') }
describe '#call' do
before(:context) { start_web_server }
after(:context) { stop_web_server }
subject(:call) do
described_class.new.... |
class Planting < ActiveRecord::Base
belongs_to :parent_adoption_request, :class_name => "AdoptionRequest", :foreign_key => "adoption_request_id"
belongs_to :tree_species, :class_name => "Tree", :foreign_key => "tree_id"
belongs_to :created_by, :class_name => "User", :foreign_key => "user_id"
has_many :maintenan... |
require 'nokogiri'
require 'net/http'
class Anecdote < Botpop::Plugin
include Cinch::Plugin
match(/!a(necdote)? (.+)/, use_prefix: false, method: :exec_new)
HELP = ["!anecdote <...>"]
ENABLED = config['enable'].nil? ? false : config['enable']
CONFIG = config
def exec_new m, _, s
s.downcase!
f = ... |
class CookieBatchesController < ApplicationController
def index
@cookie_batches = CookieBatch.all
end
def new
@cookie_batch = CookieBatch.new
end
def create
@cookie_batch = CookieBatch.new(cookie_batch_params)
if @cookie_batch.save
redirect_to cookie_batches_path
else
render :ne... |
# This code is free software; you can redistribute it and/or modify it under the
# terms of the new BSD License.
#
# Copyright (c) 2008-2011, Sebastian Staudt
require 'exceptions/rcon_no_auth_exception'
require 'exceptions/rcon_no_connection_exception'
require 'steam/packets/rcon/rcon_auth_request'
require 'steam/pack... |
FactoryGirl.define do
factory :payment_profile do
user { |c| c.association(:user) }
address { |c| c.association(:address) }
payment_cim_id 123456789
default true
active true
cc_type 'visa'
month '05'
year '2013'
#las... |
class PagesController < ApplicationController
before_action :set_story
before_action :set_page, only: [:show, :edit, :update, :destroy]
before_action :authorize_admin, only: [:edit, :update, :destroy, :new, :create]
def index
@pages = @story.pages.all
end
def new
@page = Page.new
end
def create
@pag... |
class CreateTemplates < ActiveRecord::Migration
def self.up
create_table :templates do |t|
# The title of the HIT.
# --------------------------------------------------------------------------------
# A title should be short and descriptive about the kind of task the HIT contains.
# On the... |
# == Synopsis
#
# hello: greets user, demonstrates command line parsing
#
# == Usage
#
# hello [OPTION] ... DIR
#
# -h, --help:
# show help
#
# REQUIRED ARGUMENTS:
#
# --username, -u [lastfm username]:
# a valid last.fm username
#
# --password, -u [lastfm password]:
# a valid last.fm password
#
# OPTIONAL A... |
module Application
class User
def initialize username, name, job
@username = username
@name = name
@job = job
end
def update key, value
instance_variable_set("@#{key}".to_sym, value)
@observers.each { |o| o.updated self }
end
def subscribe observer
@observers... |
class GoalsController < ApplicationController
before_action :authenticate_user!
def new
@goal = Goal.new
end
def create
@goal = Goal.new(sanitized_params.merge(user_id: current_user.id))
@goal.save
redirect_to friends_path
end
def sanitized_params
params.require(:goal).permit(:name, ... |
# 1. What does the `each` method in the following
# program return after it is finished executing?
x = [1, 2, 3, 4, 5]
x.each do |a|
a + 1
end
# In exercise 1 of the Loops & Iterators chapter, the return value of
# `.each` is:
# => [1, 2, 3, 4, 5]
# "Each will always return the original array for which it is called... |
class User < ActiveRecord::Base
has_many :player_ones
has_many :player_twos
has_many :games, through: :player_ones
has_many :games, through: :player_twos
end
|
class User <ActiveRecord::Base
has_secure_password
validates_uniqueness_of :username
end
|
class Store < ActiveRecord::Base
has_many :employees
validates :name,length: { minimum: 3 }
validates :annual_revenue ,numericality: { only_integer: true, greater_than:0 }
end
|
require 'spec_helper'
module Boilerpipe::Labels
describe Default do
it 'has markup prefix' do
expect(Boilerpipe::Labels::Default::MARKUP_PREFIX).to eq '<'
end
end
end
|
class CreateRoomBillings < ActiveRecord::Migration
def self.up
create_table :room_billings do |t|
t.string :name #物业费
t.string :start_date #收取开始时间
t.string :end_date#收取结束时间
t.string :receipt_num# 收据或者发票号
t.integer :month_num #收取月份
t.integer :year_num #收取年份
t.float :unit_... |
module AriaApi
# Super class for all AriaApi exceptions.
class AriaApiError < ::StandardError; end
class ConfigurationError < AriaApiError
def initialize(setting, message) # :nodoc:
super "AriaApi::Configuration.#{setting} #{message}"
end
end
end
|
class RemoveNeedDailyScrapingFromCampaigns < ActiveRecord::Migration[5.0]
def change
remove_column :campaigns, :need_daily_scraping
end
end
|
#!/usr/bin/env ruby
# encoding: UTF-8
require "nokogiri"
require "open-uri"
require "set"
require "pp"
require "csv"
require "ld_slugger"
ECB_BASE = "http://sdw.ecb.europa.eu/"
ECB_START = "browse.do?node=1478"
# there are some filter values which we should exclude, because they are just
# multiple selections of ot... |
# Include this module to support ActiveRecord serialization
module Defaultable
module Serialization
# Called to deserialize data to ruby object.
extend ActiveSupport::Concern
module ClassMethods
def load(data)
overrides = {}
if data
obj = raw_load(data)
raise TypeError, "Deseria... |
class DealershipMessage < ActiveRecord::Base
belongs_to :dealership
has_many :cars
has_one :dealership_response_message
enum message_type: { Lead: 0, Problem: 1, Service: 2, Specials: 3 }
validates_presence_of :message_body, :message_type
before_save :create_bitly_links
private
def create_bitly_link... |
module PapersHelper
include ActsAsTaggableOn::TagsHelper
def is_in_library(paper)
current_user.favorite_papers.include?(paper)
end
def is_my_publish?(paper)
paper.user_id == current_user.id
end
end
|
class CrimeTagController < ApplicationController
@crime_tags ||= CrimeTag.all
# GET /crime_tags
# GET /crime_tags.json
def index
@crime_tags ||= CrimeTag.all
end
end
|
class CreateJoinTablePostSubcategory < ActiveRecord::Migration
def change
create_join_table :posts, :subcategories, column_options: {null: true} do |t|
t.index [:post_id, :subcategory_id]
t.index [:subcategory_id, :post_id]
end
end
end
|
FactoryGirl.define do
factory :company_contact do
name "MyString"
telephone_number "MyString"
mail "MyString"
association :company, factory: :company, strategy: :build
end
end
|
#--
# webricknio.rb
#
# Author: Pradeep Singh
# Copyright (c) 2012 Pradeep Singh
# All rights reserved.
General = {
:ServerName => ::WEBrick::Utils::getservername,
:BindAddress => nil, # "0.0.0.0" or "::" or nil
:Port => nil, # users MUST specify this!!
:MaxClients => 100, # ... |
# frozen_string_literal: true
module Tianguis
class Variant
attr_reader :name, :quantity, :unit
def initialize(name)
@name = name.strip.sub('.', '')
@quantity, @unit = parse(name)
end
def to_h
{ name: name, quantity: quantity, unit: unit }
end
private
def parse(value... |
require_relative "../../spec_helper"
module ViewExpensesByCategories
step 'I created the category :category_name' do |category_name|
Context::CategoriesCreator.create(category_name)
end
step 'I spent :expense in :category_name' do |expense, category_name|
Context::RegisterExpense.register(expense, categ... |
# frozen_string_literal: true
module Decidim
module Opinions
module Admin
# A form object to be used when admin users want to create a opinion.
class OpinionForm < Admin::OpinionBaseForm
validates :title, length: { in: 15..150 }
end
end
end
end
|
class CreateAbuseReport
def abuse_report_filed(payload)
request = payload[:request]
reporter = payload[:reporter]
reason = payload[:reason]
request.reload
abuse_report = AbuseReport.new
abuse_report.request = request
abuse_report.reason = reason
abuse... |
cars = 100 #cars is variable name and assigned 100 as it value.
space_in_a_car = 4.0 #floating point value 4.0 is assigned to a variable name of space_in_a_car
drivers = 30 #I have assigned value 30 to drivers
passengers = 90 #Simply assigned value 90 to passengers
cars_... |
require_relative '../lib/robot'
describe Robot do
let(:robot) { Robot.new }
describe '#place' do
context 'valid' do
before { robot.place 0, 0, :west }
it { expect(robot.placed?).to eq true }
end
context 'not valid' do
context 'more then max X' do
before { robot.place 5, 0, ... |
FactoryBot.define do
factory :user do
sequence(:name) { |n| "user#{n}" }
sequence(:email) { |n| "user#{n}@gmail.com" }
password { "12345678" }
intro { FFaker::Lorem.paragraph }
end
factory :category do
sequence(:name) { |n| "category#{n}" }
end
factory :restaurant do
sequence(:name) ... |
json.array!(@tailors) do |tailor|
json.extract! tailor, :id, :name, :capacity, :contact_number, :alt_contact_number
json.url tailor_url(tailor, format: :json)
end
|
require File.join(File.dirname(__FILE__), 'spec_helper')
describe Letterbox, 'initialisation' do
before :each do
@rumbster = mock('rumbster', :add_observer => nil)
Rumbster.stub!(:new).and_return(@rumbster)
@publishers = Array.new(3) {|i| mock("publisher #{i}") }
PublisherFactory.stub!(:create_pub... |
require 'chemistry/element'
Chemistry::Element.define "Rhenium" do
symbol "Re"
atomic_number 75
atomic_weight 186.207
melting_point '3453K'
end
|
require "spec_helper"
describe ContentMailer do
describe "email_content" do
let(:content) { create :news_story }
let(:message) { build :content_email,
content: content,
from_name: "Bryan Ricker!",
from_email: "bricker@scpr.org",
... |
#
# Be sure to run `pod spec lint LeoNet.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/... |
class AddIndexToPreTotalPartyNum < ActiveRecord::Migration[5.2]
def change
add_index :pre_total_party_nums, [:result_no, :count_type, :e_no], :unique => false, :name => 'resultno_counttype'
add_index :pre_total_party_nums, [:result_no, :e_no, :count_type], :unique => false, :name => 'resultno_eno'
add_ind... |
class RequestsController < ApplicationController
before_action :set_request, only: [:show, :edit, :update, :destroy]
respond_to :html, :csv
def index
@requests = Request.all
respond_to do |format|
format.html
format.csv { send_data @requests.to_csv }
end
end
def show
respond_wi... |
class Post < ApplicationRecord
has_many :comments
has_many :chars
validates :title, presence: true
validates :title, :length => {:minimum => 3, :maximum => 20}
validates :author, presence: true
validates :content, presence: true
validates :content, :length => {:minimum => 10, :maximum => 2000}
va... |
require 'test_helper'
context 'The Settings class' do
context 'reads settings' do
asserts('returns a list of search terms') { Settings['sections'] }.any?
end
context 'writes settings' do
setup { Settings['sections'] = %w(iphone windows7) }
asserts('expected sections') { Settings['sections'] }.equal... |
class RemoveReferenceColumnToProduct < ActiveRecord::Migration[5.2]
def up
remove_reference :products, :date_purchases, index:true
remove_foreign_key :products, :date_purchase
end
def down
add_reference :products, :date_purchases, index:true
add_foreign_key :products, :date_purchase
end
end
|
json.booking do
json.partial! 'booking', booking: @booking
end
json.spot do
json.extract! @booking.spot, :id, :host_id, :site, :location_name, :max_guests
json.photoUrls @booking.spot.photos.map {|file| url_for(file)}
end |
class SpecialPriceRule
attr_reader :code
def initialize(code, quantity, special_price)
@code = code
@quantity = quantity
@special_price = special_price
end
def apply(item)
item.total = @special_price if item.code == @code && item.quantity == @quantity
end
end
|
# Require psych under MRI to remove warning messages
if Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == "ruby"
require 'psych'
end
require 'minitest/pride'
require 'minitest/autorun'
require 'minitest/spec'
require 'vcr'
VCR.config do |c|
c.allow_http_connections_when_no_cassette = true
c.cassette_library... |
require 'rails_helper'
RSpec.describe CommentsController, type: :controller do
before(:each) do
user_authenticated = FactoryGirl.create(:user_authenticated)
@request.headers["Authorization"] = "Token token=#{user_authenticated.access_token}"
end
describe "GET #index" do
context "with unexist... |
# frozen_string_literal: true
class RemoteDatatable
include ActionView::RecordIdentifier
attr_accessor :node, :json, :header
def initialize(node, json_response)
@node = node
self.json = JSON.parse(json_response.body)
self.header = json_response.header
end
def url
@node['data-source']
end
... |
class Grid
def self.from(cave)
new(cave)
end
def initialize(cave)
@rows = cave.split(/\n/).map(&:strip)
end
def at(row, col)
@rows[row][col]
end
def water_at?(row, col)
at(row, col) == '~'
end
def fill(row, col)
@rows[row][col] = '~'
self
end
def to_s
@rows.join(... |
#
# This Rake Task is a striped down version of Buildr download task
# I took the code from http://rubyforge.org/projects/buildr
#
# I've striped down dependencies on Net::SSH and Facets to
# stay as simple as possible.
#
# Original code from Assaf Arkin, released under Apache License
# (http://buildr.rubyforge.org/lic... |
class Product < ApplicationRecord
belongs_to :supplier
has_many :images
has_many :carted_products
has_many :orders, through: :carted_products
has_many :categorized_products
has_many :categories, through: :categorized_products
validates :name, presence: true
validates :price, numericality: true
valid... |
class ApplicationHelper::Button::VmInstanceScan < ApplicationHelper::Button::Basic
needs_record
def skip?
return false if @display == "instances"
!(@record.is_available?(:smartstate_analysis) ||
@record.is_available_now_error_message(:smartstate_analysis)) ||
!@record.has_proxy?
end
def disa... |
###
# Bridges:
# name: Server names
# position: A1:C1
# type: in-external-multi-select
# external_resource: rlm_bridges
# required: yes
# Result:
# name: Result create bridges
# type: out-table
# position: A1:F1
#
###
begin
require 'lib/script_support/rlm_utilities'
require 'yaml'
require 'uri'
... |
require 'test_helper'
class CardTest < ActiveSupport::TestCase
test "new should create card instance" do
assert_not_nil Card.new(1, 2)
end
test "it returns number of instance" do
(0..15).each do |i|
m = rand(1..4)
n = rand(1..13)
c = Card.new(m, n)
assert_equal n, c.getNumber
... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in rakefile.rb, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{git-bro}
s.version = "0.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :require... |
class TransferDestroyService
def initialize(transfer_id:)
@transfer_id = transfer_id
end
def call
transfer.transaction do
revert_inventory_transfer!
transfer.destroy!
end
OpenStruct.new(success?: true)
rescue StandardError => e
OpenStruct.new(success?: false, error: e)
end
... |
module Api
class RegulationsController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
def getRegulations
room = Room.find_by_information_id(params[:information_id])
regulations = Regulation.where(house_id: room.house_id)
rende... |
require 'test_helper'
class FilePushControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
setup do
Settings.enable_logins = true
Settings.enable_file_pushes = true
Rails.application.reload_routes!
end
teardown do
@luca = users(:luca)
sign_out @luca
... |
class Review < ApplicationRecord
validates :rating, presence:true ,numericality: { less_than_or_equal_to: 5, only_integer: true }
belongs_to :user
belongs_to :product
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.