text stringlengths 10 2.61M |
|---|
class AddIndexToBugs < ActiveRecord::Migration
def change
add_index :bugs, :subscriber_id #this for forign key
add_index :bugs, [:subscriber_id,:number] #this for show action
end
end
|
class Post < ActiveRecord::Base
attr_accessible :content, :title
has_many :comments
validates_presence_of :title, :content
validates_uniqueness_of :title
validates_length_of :title, :minimum => 2
end
|
require 'rails_helper'
describe "authentication for post requests", type: :request do
let!(:user) {FactoryGirl.create(:user)}
let!(:business) {FactoryGirl.create(:business)}
it 'returns status code 422 if params passed do not meet validations' do
post "/businesses/", params: {token: user.token}
expect(r... |
class CategoriesController < ApplicationController
def index
@categories = Category.all
end
def show
@category = Category.find_by_dao(params[:category])
@items = @category.items.order(:name)
end
end
|
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
require 'fileutils'
class Api::StudentDocumentsController < ApiController
filter_access_to :all
def documents
begin
@xml = Build... |
require 'fileutils'
module Insanity
class FileWriter
def initialize(output_dir:)
return if output_dir.nil?
@write_path = check_or_create_output_dir(output_dir)
end
def save(iteration:, status:, output:)
return if no_path?
file_name = File.join(write_path, "i#{iteration}-exit#{s... |
require 'rails_helper'
RSpec.describe Job, type: :model do
context "validations" do
before(:each) do
@location = create(:location)
end
it "must have exp_min" do
job = Job.new()
expect(job.save).to eq(false)
end
it "can have blank location, technologies, base_id and exp_max" do... |
require 'find'
require 'omf_base/lobject'
require 'omf_web'
require 'omf-web/content/content_proxy'
require 'omf-web/content/repository'
require 'omf-web/content/gitolite'
module OMF::Web
# This class provides an interface to a GIT repository served via Gitolite.
#
# To enable this in LW, provide the following c... |
# frozen_string_literal: true
module Mishina
module Oanda
class ClientFactory
def self.client(token_path: nil, domain: :practice)
token_path ||= Mishina::Constants::OANDA_TOKEN_PATH
token_yml = YAML.load_file(token_path)
token = token_yml['oanda']['api_key']
OandaAPI::Client... |
class RenColumnStoragefile < ActiveRecord::Migration
def self.up
rename_column :storagefiles, :type, :files_type
end
def self.down
rename_column :storagefiles, :files_type, :type
end
end
|
class Item < ActiveRecord::Base
has_many :images, as: :imageable
belongs_to :artist
belongs_to :label
has_many :tracks
end
|
class VehicleType < ActiveRecord::Base
attr_accessible :name
has_many :makes
def sorted_makes
makes = self.makes.sort_by! {|make| make.name}
end
end
|
module CDI
module V1
class SimpleHomeSerializer < ActiveModel::Serializer
root false
attributes :latest_blog_post,
:categories_discussions,
:gamefication,
:ranking
has_one :latest_blog_post, serializer: SimpleBlogArticleSerializer
has_... |
class CartItemsController < ApplicationController
before_filter :is_in_store
respond_to :json, only: [:update]
skip_before_filter :sanitize_cart, only: [:update]
# POST /cart_items
def create
if cart_item = current_cart.items.where(product_id: create_cart_item_params[:product_id]).first
cart_ite... |
require 'rails_helper'
RSpec.describe Event, :type => :model do
it "responds to title" do
expect(Event.new).to respond_to(:title)
end
it "requires title" do
expect(Event.new(start: "2015-02-14")).to be_invalid
end
it "requires start" do
expect(Event.new(title: "Bowling")).to be_invalid
end
... |
class AddUniqueDownloadKeyToPurchases < ActiveRecord::Migration
def change
add_column :purchases, :unique_download_key, :string
end
end
|
#!/usr/bin/env ruby
# ytti@iki.fi
$VERBOSE = false # SSH is noisy
module Ring
require 'ring'
require 'thread'
require 'yaml'
# runs ssh to each node in parallel, returns hash with nodes as keys and array of output and end time
class All
Timeout = 10
NodeLimit = 50
StartTime = Time.now
TTY = $stdout.t... |
class CreateTasks < ActiveRecord::Migration[5.2]
def change
create_table :tasks do |t|
t.string :name, null: false
t.integer :creator_id, null: false
t.integer :assignee_id
t.string :assignee_status
t.boolean :completed, default: false
t.date :completed_at
t.date :due_on
... |
class Job < ActiveRecord::Base
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'helpers')
belongs_to :user
named_scope :published, :conditions => {:published => true}
named_scope :newest_first, :order => 'created_at DESC'
validates_presence_of :title, :description
def age
help.distance_o... |
class RenameIsAdminToIsSuper < ActiveRecord::Migration[5.0]
def change
rename_column :users, :is_admin, :is_super
end
end
|
require 'rails_helper'
RSpec.feature 'Home page', :js do
scenario 'visitor sees home page' do
visit root_path
expect(page).to have_content 'Alviss'
end
end
|
# frozen_string_literal: true
require 'encase'
require 'thread/pool'
module Jiji::Model::Trading
class BackTestRepository
include Encase
include Jiji::Errors
needs :backtest_thread_pool
attr_accessor :container
def initialize
@backtests = {}
end
def all
@backtests.values... |
class Artist < ActiveRecord::Base
has_many :songs
def song_count
self.songs.length
end
def artist_and_song_count
"#{self.name} - #{song_count} song(s)"
end
end
|
#
# Cookbook Name:: dadou-chef-recipes
# Definition:: addNginxService
#
# Copyright 2012 Damien DUPORTAL <damien.duportal@gmail.com>
# https://github.com/dduportal/dadou-chef-recipes
#
define :addNginxService do
clientId = params[:client_id]
serviceId = params[:service_id]
serviceUser = params[:service_user]
ser... |
class Api::GamesController < ApplicationController
def new
@game = Game.new(host_id: current_user.id)
render json: { game: @game.slice(:id, :host_id, :available_tokens) }
end
def index
@games = Game.all
render json: { games: @games.map { |game| GamePresenter.new(game) } }
end
def create
... |
class CreateSpreePostRelations < ActiveRecord::Migration
def change
create_table "spree_post_relations" do |t|
t.integer "post_id", null: false
t.integer "related_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "spree_... |
# frozen_string_literal: true
class User < ActiveRecord::Base
before_save { self.email = email.downcase }
before_save { self.profile_url = 'https://api.adorable.io/avatars/203/' + email.downcase }
has_secure_password
validates :name,
presence: true
validates :email,
presence: true,
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :machine
config.cache.enable :apt
end
datanyze_cluster = {
"nginx-1" => { :ipv4_address => "10.0.1.11"},
"nginx-2" => { :ipv4... |
class Project < ActiveRecord::Base
attr_accessible :name, :user_id
has_many :tasks, dependent: :destroy
belongs_to :user
def completed_tasks
completed_tasks = []
self.tasks.each do |task|
completed_task.push(task) if task.completed?;
end
end
end
|
class Admin::ClassRangesController < ApplicationController
before_filter :require_admin
layout "admin"
def index
@classes = ClassRange.order(:position)
end
def new
@class_range = ClassRange.new(params[:class_range])
end
def create
params[:class_range] = process_title(params[:class_range])
... |
class Sneaker < ApplicationRecord
#relationships
#validations
belongs_to :brand
has_many :favorites
has_many :users , through: :favorites
#accepts_nested_attributes_for :brand
def brand_attributes=(hash_of_attributes)
# hash_of_attributes = {"name"=>"Puma", "year_founded"=>"1971"}
... |
Rails.application.routes.draw do
get 'sessions/new'
#resources :users
get 'events/new'
get 'static_pages/home'
get '/list', to: 'static_pages#list'
get '/signup', to: 'users#new'
#get '/events', to: 'events#show_members'
# root 'events#new'
root 'static_pages#home'
get '/login', to: 'sessions#n... |
информация о плагинах бота
{command} (плагин)
*/{command}
бот покажет список плагинов
*/{command} help
бот покажет подробную информацию о плагине "help" |
require 'Gosu'
require_relative 'egg.rb'
require_relative 'red_bullet.rb'
class Weapon
def initialize bullet_type = nil
@bullet = (bullet_type == nil)? nil: bullet_types(bullet_type)
end
def bullet_types bullet_type
return RedBullet.new() if bullet_type == 0
return Egg.new() if bu... |
# frozen_string_literal: true
RSpec.describe SXS::Publishers::Memory, '#include?' do
let!(:publisher_1) { described_class.new 'queue_url_1' }
let!(:publisher_2) { described_class.new 'queue_url_2' }
before do
publisher_1.publish({ key: 'value.1' }.to_json)
publisher_1.publish({ key: 'value.2' }.to_json)... |
# frozen_string_literal: true
require "rails_helper"
describe NewsletterSubscriptionMailer do
describe "#update_available_email" do
subject { described_class.update_available_email(to: "subscription@example.com", trimesters: ["This Trimester"]) }
its(:body) { is_expected.to include("This Trimester") }
... |
class SessionsController < ApplicationController
before_action :load_user, only: :create
def new
return unless logged_in?
flash[:warning] = t ".login_alright"
redirect_to root_url
end
def create
if @user && @user.authenticate(params[:session][:password])
flash[:success] = t ".welcome"
... |
require('spec_helper')
describe(Stylist) do
describe('#name') do
it "returns the name of the stylist" do
test_stylist = Stylist.new({:id => nil, :name => 'Mary Marry',:station => '4'})
expect(test_stylist.name()).to(eq('Mary Marry'))
end
end
describe('#id') do
it "returns the id of the st... |
=begin
Problem 21
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, ... |
class RenameUserSmartProductJoinTable < ActiveRecord::Migration
def change
rename_table :user_smart_products, :smart_products_users
end
end
|
class Run < ActiveRecord::Base
attr_accessible :state
attr_accessible :started_at
attr_accessible :finished_at
has_one :notification
has_many :steps
has_one :trigger
belongs_to :workflow
def duration
finished_at - started_at
end
end
|
# Recipe.all should return all of the recipe instances
# Recipe.most_popular should return the recipe instance with the highest number of users (the recipe that has the most recipe cards)
# Recipe#users should return the user instances who have recipe cards with this recipe
# Recipe#ingredients should return all of the... |
Given /^I am on Login page$/ do
visit "/users/login"
end
Then /^I should be redirected to Home page$/ do
page.should have_css("body.pages-index.signed-in")
sleep 5
screen_shot_and_save_page
end
Given /^I logged in with "(.*?)" and "(.*?)"$/ do |email, password|
step "I am on Login page"
find('input#user-e... |
require 'spec_helper'
module RequirejsOptimizer
module Rake
describe Utils do
describe "#define_task_deeply" do
# Since #define_task_deeply recurses to do work, we can't test it with mocks
# so here we're creating a clean-room scenario with a class that responds
# to the part of... |
class CreateGabaritos < ActiveRecord::Migration
def self.up
create_table :gabaritos do |t|
t.string :descricao, :null => false
t.string :codgab, :null => false
t.integer :etapa, :null => false
t.boolean :ic_disponivel, :null => false, :default => false
t.integer :org... |
module Fog
module AWS
class S3
def buckets
Fog::AWS::S3::Buckets.new(:connection => self)
end
class Buckets < Fog::Collection
model Fog::AWS::S3::Bucket
def all
if @loaded
clear
end
@loaded = true
data = connection.g... |
class TwitterClone::Pages::Posts::Index < Matestack::Ui::Page
include Components::Registry
# def prepare
# @posts = Post.all
# end
def response
post_form_partial
post_list_partial
end
private
def posts
Post.all
end
def post_form_partial
div class: "mb-3 p-3 rounded shadow-sm"... |
class AddHarvestMetadataToProvider < ActiveRecord::Migration
def change
add_column :providers, :consumed_at, :datetime
add_column :providers, :interval, :integer
end
end
|
# frozen_string_literal: true
require 'rails_helper'
describe 'Accounts Show', type: :request do
describe 'GET /api/v1/accounts/:id' do
subject { get api_v1_account_path(id), headers: headers }
let!(:account) { create(:user).account }
before { subject }
context 'without jwt token' do
let(:h... |
require 'chemistry/element'
Chemistry::Element.define "Aluminium" do
symbol "Al"
atomic_number 13
atomic_weight 26.9815386
melting_point '933.4K'
end
|
class MealsController < ApplicationController
skip_before_action(:force_user_sign_in, {:only =>[:index, :show]})
def index
@q = Meal.ransack(params[:q])
@meals = @q.result(:distinct => true).includes(:restaurant, :dietary_guidances, :diets)
render({ :template => "meals/index.html.erb" })
end
... |
require 'i18n'
require 'logger'
require 'pathname'
require 'shanty/config_mixin'
require 'shanty/file_tree'
require 'shanty/plugin'
require 'shanty/plugins/shantyfile_plugin'
require 'shanty/task_set'
require 'shanty/task_sets/basic_task_set'
require 'yaml'
module Shanty
# RWS Monad pattern.
class Env
include ... |
#!/usr/bin/env ruby
require "colorize"
#Intcode.set_debug(ENV.has_key?("AOC_DEBUG") ? ENV["AOC_DEBUG"] == "true" : false)
INPUT = ARGV.size > 0 ? ARGV[0] : "day8/input.txt"
# WIDTH = 3
# HEIGHT = 2
# data = "123456789012"
WIDTH = 25
HEIGHT = 6
data = File.read(INPUT).strip
COLORS = {
0 => :black,
1 => :white,
... |
require_relative 'helpers'
class Light
attr_accessor :state, :brightness
def initialize
self.state = :off
self.brightness = 0
end
def toggle!
self.state = on? ? :off : :on
self.brightness += 2
end
def on!
self.state = :on
self.brightness += 1
end
def off!
self.state = :o... |
module Rink
module OutputMethod
class IO < Rink::OutputMethod::Base
attr_accessor :io
def initialize(io)
super()
@io = io
end
def output
@io
end
def print(*args)
return if silenced?
args = args.flatten.join
@i... |
require 'rails_helper'
describe Jobs::NotifySlack do
before do
SiteSetting.slack_outbound_webhook_url = "https://hooks.slack.com/services/abcde"
SiteSetting.slack_enabled = true
end
before do
FakeWeb.register_uri(:post, SiteSetting.slack_outbound_webhook_url, :body => "success")
end
let(:post) ... |
class AddingAuthorToTopic < ActiveRecord::Migration[5.0]
def change
add_column :topics, :author, :string, default: 0
end
end
|
# coding: utf-8
module Apress
module Images
module DanglingCleanable
extend ActiveSupport::Concern
included do
before_create -> { @enqueue_delete_dangling_image = true }, if: -> { subject_id.nil? }
before_update -> { @enqueue_delete_dangling_image = true }, if: -> { subject_id_change... |
require 'data_mapper' unless defined?DataMapper
require 'ysd_md_payment' unless defined?Payments::Charge
module BookingDataSystem
#
# It represents a booking charge
#
class BookingCharge
include DataMapper::Resource
storage_names[:default] = 'bookds_booking_charges'
belongs_to :booking, 'Booking'... |
module FacilitiesManagement
class SpreadsheetTestController < FacilitiesManagement::FrameworkController
def index; end
def dm_spreadsheet_download
assign_building_ids_and_service_codes
building_ids_with_service_codes = []
@building_ids.each_with_index do |bid, index|
building_ids_... |
class CreateDetails < ActiveRecord::Migration[4.2]
def change
create_table :details do |t|
t.integer :server_id
t.string :category
t.string :name
t.text :value
t.timestamps null: false
end
add_index :details, [:server_id, :category, :name], unique: true
end
end
|
require_relative "app_config"
class Fileserver
def self.get_upload_ticket(size)
size > 0 or raise ParameterError, "invalid size"
id = generate_id
IO::write(get_ticket_path(id), size)
id
end
def self.delete_upload_ticket(id)
ticket_path = get_ticket_path(id)
uploading_path = get_uploadi... |
################################################################################
require('minitest/autorun')
################################################################################
module CandyBarManualAccessors
##############################################################################
# <<: getter
... |
require 'spec_helper'
describe OrdersController do
render_views
describe "GET new" do
before { @movie = Factory :movie, :price => 30 }
context "with a valid zipcode" do
context "that taxes our product" do
before do
PriceCalculator.should_receive(:prices_for).with(@movie.price, '9811... |
require 'test_helper'
describe Match do
describe ".incomplete" do
it "must find a match with no game" do
match = create(:match, game: nil)
Match.incomplete.must_include match
end
it "wont find a match with a game" do
match = create(:match, game: create(:game))
Match.incomplete.wo... |
require "spec_helper"
describe HierarchyHelper do
let(:user) { create(:user) }
let(:children_niche) { create(:niche, user: user) }
let!(:niche) { create(:niche, user: user) }
describe "#hierarchy_output" do
it "returns the valid html" do
text = hierarchy_output(Niche.all.reject(&:parent))
expe... |
control "M-7.2" do
title "7.2 Ensure the minimum number of manager nodes have been created\nin a
swarm (Scored)"
desc "
Ensure that the minimum number of required manager nodes is created in a
swarm.
Manager nodes within a swarm have control over the swarm and change its
configuration
modifying securit... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :manage, Contact, user_id: user.id
can :manage, Document, user_id: user.id
can :manage, Invoice, contact: { user_id: user.id }
can :manage, Payment, invoice: { contact: { user_id: user.id } }
end
end
|
# frozen_string_literal: true
require 'jiji/model/securities/internal/utils/converter'
module Jiji::Model::Securities::Internal::Oanda
module RateRetriever
include Jiji::Errors
include Jiji::Model::Trading
include Jiji::Model::Securities::Internal::Utils
def retrieve_pairs
@client.account(@ac... |
#!/usr/bin/env ruby
# encoding: utf-8
### CONFIG [ THESE VALUES OVERRIDE weatherparser.rb ]
# "City, State" or "City, Country" or ZIP Code
$mycity = 'Amsterdam, Holland'
# f for fahrenheit, c for celsius
$f_or_c = 'c'
# folder where the weather icons are located, no trailing slash
$basedir = '~/Dropbox/WeatherIcons'
#... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :rubric, :class => 'Rubric' do
language "ru"
title { Faker::Name.name }
end
end
|
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
#original code
# def match(array)
# match_array = []
# array.each do |i|
# if i.split("").sort == @word.split("").sort
# match_array << i
# end
# end
# match_array
# end
def match(array)
a... |
class GasPreprocessor < Formula
homepage "https://github.com/yuvi/gas-preprocessor"
url "https://raw.github.com/yuvi/gas-preprocessor/master/gas-preprocessor.pl"
sha256 "554b8860ca85f90a6c268a709790ebfc37a16aa99ee235aca5cb95deed8275b3"
version "0.1"
test do
#
end
end
|
class CheckOutsController < ApplicationController
def index
@checkouts = CheckOut.all
end
def new
@borrow = CheckOut.new
end
def create
@borrow = CheckOut.create!(checkout_params)
if @borrow
redirect_to "/check-outs"
else
render :new
end
end
def delete
@borrowed... |
module V1
class LikeAPI < Base
resource :likes do
desc 'create a like on a content'
params do
requires 'content_id', type: Integer
requires 'content_type', type: String, values: Like::CONTENT_TYPES
end
post do
op = CreateLikeOp.new(current_user, params)
op.s... |
Rails.application.routes.draw do
resources :proyects do
resources :people, only: [] do
resources :works, only: %i[create new destroy]
end
end
resources :people
devise_for :admins
root 'proyects#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/rou... |
require 'spec_helper'
requrie 'kafkat/helpers/cluster_restart'
require 'kafkat/helpers/session'
describe Kafkat::Helpers::ClusterRestart do
let(:p1) { Partition.new('topic1', 'p1', ['1', '2', '3'], '1', 1) }
let(:p2) { Partition.new('topic1', 'p2', ['1', '2', '3'], '2', 1) }
let(:p3) { Partition.new('topic1', 'p... |
require 'rails_helper'
RSpec.describe TempToPermCalculator::Calculator do
subject(:calculator) do
described_class.new(
contract_start_date: contract_start_date,
days_per_week: days_per_week,
day_rate: day_rate,
markup_rate: markup_rate,
hire_date: hire_date,
notice_date: notic... |
class ModifyEvents2 < ActiveRecord::Migration
def change
add_column :events, :debit, :boolean,default:0
end
end
|
require 'spec_helper'
require_relative 'support/data_helper'
describe GroupBuzz::SubjectProcessor do
RSpec.configure do |c|
c.include DataHelper
end
context "format subject" do
it 'should format the subject as a Slack link with the link converted to https' do
gb_topic_link = "http://indyhall.g... |
require 'fileutils'
require 'file_mover/filter'
module FileMover
# moves path from #from to #to
# where the target_path is determined by calling gsub(from,to)
class Mv < Filter
attribute :from
attribute :to
def filter_file dir, path
assert :from, :to
return nil unless from.match(path)
... |
class UsersController < ApplicationController
before_action :authenticate_user!
def show
@user = current_user
end
def history
@purchase_histories = current_user.
carts.where(settled: true).
order(updated_at: "DESC").
paginate(page: params[:page], per_page: 10)
if @purchase_histor... |
# Represents a single relationship on a resource
#
# @!attribute [r] name
# @return [Symbol]
# @!attribute [r] cardinality
# @return [:singular,:collection]
# @!attribute [r] serializer_inferrer
# @return [SerializerInferrer]
# @!attribute [r] description
# @return [String]
# @!attribute [r] data_definition
# ... |
class ApplicationController < ActionController::Base
protect_from_forgery
def after_sign_in_path_for(resource)
stored_location_for(resource) ||
if resource.is_a?(User)
root_path
elsif resource.is_a?(Admin)
admin_path(resource)
else
super
end
end
def getCoordinatesFro... |
class MessagesController < ApplicationController
before_action :authorize, except: [:create, :new]
def index
@messages = current_user.messages.all.order(created_at: :desc)
end
def new
@user = User.find_by(username: params[:username])
@message = @user.messages.new
end
def create
@user = Us... |
class Answer < ActiveRecord::Base
attr_accessible :user_id, :content, :question_id
belongs_to :question
belongs_to :response, :inverse_of => :answers
validates_presence_of :content
validates_presence_of :question
validates_numericality_of :content, :if => :numeric_question?
validate :date_should_be_vali... |
class Guests
attr_accessor :guest_name, :available_cash, :song
def initialize(name, cash, fav_song)
@guest_name = name
@available_cash = cash
@song = fav_song
end
end
|
require 'jmeter'
require 'nokogiri'
require 'date'
module ReplayLoad
class Session
attr_reader :jsessionid, :index, :requests
def initialize(jsessionid:,index:)
@jsessionid = jsessionid
@index = index
@requests = []
end
def populate
response = ReplayLoad.es_client.search(
index: @index,
bo... |
class SectionsController < ApplicationController
before_action :find_section, only: [:show, :edit, :destroy, :update, :find_preschool]
def index
@sections = Section.all
end
def show
end
def new
@preschools = Preschool.all
@section = Section.new
end
def create
@preschools = Preschool.all
@section = ... |
class KbaUsage < Kb3
hobo_model # Don't put anything above this
set_primary_keys :docid, :kba
set_search_columns nil
set_table_name :kba_usage
belongs_to :from_doc,
:class_name => 'Doc',
:foreign_key => 'docid'
belongs_to :to_doc,
:class_name => 'Doc',
:foreign_key => 'kba'
def self.i... |
# Be sure to restart your server when you modify this file.
#
# +grant_on+ accepts:
# * Nothing (always grants)
# * A block which evaluates to boolean (recieves the object as parameter)
# * A block with a hash composed of methods to run on the target object with
# expected values (+votes: 5+ for instance).
#
# +grant... |
class DelayedMailerReportConfirmationJob < Struct.new(:user, :meeting)
def perform
@report = ReviewReport.find(meeting.id)
UserMailer.deliver_review_report_confirm(user, @report)
end
end |
class CreateSurveyInfos < ActiveRecord::Migration
def self.up
create_table :survey_infos do |t|
t.integer :contest_id
t.string :name
t.string :info
t.datetime :updated_at
t.datetime :created_at
end
add_index :survey_infos, :contest_id
end
def self.down
drop_ta... |
class User < ApplicationRecord
has_many :access_tokens
has_many :auth_tokens
end
|
class Materialcarga::AssistentAppointmentsController < ApplicationController
before_action :set_assistent_appointment, only: [:show, :edit, :update, :destroy]
before_action :set_tb_pessoas, only: [:new, :edit, :update, :create]
before_action :set_appointment, only: [:new, :create]
# GET /assistent_appointments... |
require 'rails_helper'
RSpec.describe Race do
describe "initialization" do
let(:race) {Race.new}
it "considers a race that has passed to be done" do
race.due_date = Date.tomorrow
expect(race.done?).to be_truthy
end
it "considers a race that has not passed to not be done" do
race.due... |
require 'spec_helper'
feature 'As an authenticated user,
I want to sign out
So that no one else can post items or reviews on my behalf' do
scenario 'user can sign out' do
User.create(username: 'johnmcg', email: 'johnmcg@gmail.com', password: 'password')
visit new_user_session_path
fill_in 'Email', wit... |
require_relative 'client'
class Bank
attr_accessor :name, :clients
def initialize(name)
@name = name
@clients = {}
end
def create_new_client(name, balance)
@clients[name] = Client.new(name, balance, {}) if @clients[name].nil?
end
def list_clients
clients_string = "Clients:"
@clients.... |
class Neighborhood < ActiveRecord::Base
attr_accessible :description, :name, :user_id, :city_id, :image_url, :link_url
belongs_to :city
belongs_to :user
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
has_many :followed_neighborhoods, through: :relationships, source: :followed
... |
require 'date'
class CAR
attr_reader :make, :model, :year, :msrp
attr_accessor :msrp_depr, :stereo, :manager_markup
#if you wanted to add stereo, just add it to the
# accessor
def initialize(make, model, year, msrp)
# instance variables have instance/object scope
@make = make
@model = model
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.