text stringlengths 10 2.61M |
|---|
class BookingStatusJob < ApplicationJob
queue_as 'b2b-api-booking-status'
def perform(status, customer_id, booking_id)
BookingStatusMailer.send(status, customer_id, booking_id).deliver
end
end
|
class Restaurant
include MongoMapper::Document
key :name, String
key :rating, Integer
key :location, String
key :avgPrice, Float
key :cuisine, String
validates :name, :presence => true
end
|
class Admins::AttachmentsController < ApplicationController
layout "admins"
def show
@attachment = Attachment.where(admin_id: current_admin.id).last
if !@attachment
redirect_to new_admins_attachments_path
end
end
def new
@attachment = Attachment.new(admin_id: current_admin.id)
end
... |
class Admins::SystemVariablesController < Admins::ApplicationController
helper :sort
include SortHelper
before_filter :find_master_scenario, :add_crumbs
before_filter :find_system_variable, :only => [:show, :edit, :update]
before_filter :initialize_variables_sort, :only => [:index]
cache_sweeper :syst... |
Pod::Spec.new do |s|
s.name = "SKYKit"
s.version = "0.10.1"
s.summary = "iOS SDK for Skygear"
s.description = <<-DESC
This is the client library for Skygear backend.
DESC
s.homepage = "https://github.com/SkygearIO/skygear... |
require 'test_helper'
require 'exceptions'
class CartTest < ActiveSupport::TestCase
setup do
@cart = Cart.new
@u = users(:client)
end
test 'initialize cart' do
assert_empty(@cart.items)
end
test 'initialize with items' do
@cart = Cart.new([products(:fishoil)])
assert_equal(1, @cart.size... |
module Prophet
module Holidays
def get_holiday_names(country)
years = (1995..2045).to_a
make_holidays_df(years, country)["holiday"].uniq
end
def make_holidays_df(year_list, country)
holidays_df[(holidays_df["country"] == country) & (holidays_df["year"].in?(year_list))][["ds", "holiday"]... |
class MDirectorsController < ApplicationController
before_filter :authenticate_user!
#load_and_authorize_resource
# GET /m_directors
# GET /m_directors.json
def index
@m_directors = MDirector.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @m_directors ... |
class AddIndexes < ActiveRecord::Migration
def change
add_index :follows, :follower_id
add_index :follows, :followee_id
end
end
|
# frozen_string_literal: true
module Vedeu
module Logging
# Provides the ability to log anything to the Vedeu log file.
#
# @!macro [new] vedeu_logging_log_param_message
# @param message [String] The message you wish to emit, useful
# for debugging.
#
# @api public
#
cla... |
class UsersController < ApplicationController
skip_before_action :ensure_signed_in, only: [:create, :login]
def gen_token(user_id)
payload = {id: user_id}
JWT.encode(payload, Rails.application.credentials.secret_key_base)
end
def create
email = params[:email]
password = params[:password]
n... |
describe BaseDecorator do
def escape(str)
# equivalent to what's used in templates
ERB::Util.html_escape(str)
end
describe '.combine_html' do
it "escapes content" do
output = BaseDecorator.combine_html(["<script>alert()</script>"])
expect(escape(output)).to eq("<script>alert()</s... |
class ApplicationController < ActionController::Base
def index
@books = Book.all
end
def current_user
User.find_by(id: session[:user_id]) if session[:user_id]
end
def logged_in?
!!current_user
end
end
|
require "spec_helper"
describe Cfp::Proposal do
let (:user) do
user = User.new
user.roles = []
user
end
describe "#can_be_edited_by?" do
context "CFP is open" do
before { allow(Cfp::Config).to receive(:call_for_papers_state).and_return "open" }
context "can be seen by user" do
... |
module ActivityMonitorable
extend ActiveSupport::Concern
included do
before_save :update_activity_timestamps
scope :active_since, ->(since) { where("#{table_name}.last_activity_on >= ?", since) }
scope :inactive_since, ->(since) { where("#{table_name}.last_activity_on IS null OR #{table_name}.last_act... |
class CreateConfirmations < ActiveRecord::Migration
def change
create_table :confirmations do |t|
t.string :unconfirmed_email
t.string :confirmation_token
t.datetime :confirmation_sent_at
t.references :account
t.timestamps
end
add_index :confirmations, :account_id, :unique =... |
require 'features/features_spec_helper'
feature "User check status his orders" do
let(:user){FactoryGirl.create :user, :as_customer}
let!(:book){FactoryGirl.create :book}
before do
visit root_path
visit new_user_session_path
within '#new_user' do
fill_in 'Email', with: user.email
... |
class FontSilkscreen < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/silkscreen"
desc "Silkscreen"
desc "Typeface for your web graphics"
homepage "https://fonts.google.com/specimen/Silkscreen"
def install
(share/"fonts").install "S... |
class DailyForecast
attr_reader :high, :low, :today, :tonight
def initialize(weather)
@high = weather['daily']['data'].first['temperatureHigh'].round
@low = weather['daily']['data'].first['temperatureLow'].round
@today = weather['daily']['data'].first['summary']
@tonight = night_summary(weather)
... |
require 'digest'
require 'thin'
require "dry-validation"
require "dry-transaction"
require "google/cloud/datastore"
require "sinatra/base"
require "omada/version"
require "omada/api"
module Omada
ProjectID = "kumo-ctf-framework"
def self.start_server!
server = API::Server.new
server.settings.run!
ensure... |
require 'puppet_x/nexus/scheduled_tasks'
require 'spec_helper'
describe Nexus::ScheduledTasks do
describe :find_type_by_id do
specify { expect(described_class.find_type_by_id('EmptyTrashTask').name).to eq('Empty Trash') }
specify { expect(described_class.find_type_by_id(:EmptyTrashTask).name).to eq('Empty T... |
require 'rails_helper'
describe Store::V1 do
let!(:cart) { FactoryGirl.create(:cart) }
describe 'GET api/v1/stores' do
end
end
|
class User < ApplicationRecord
validates :username, presence: true, uniqueness: true
validates :email, presence: true, uniqueness: true
validates :password_digest, presence: true
validates :password, length: { minimum: 6 }, allow_nil: true
attr_reader :password
after_initialize :ensure_session_token
# S... |
# 1 Given the below usage of the Person class, code the class definition.
# class Person
# attr_accessor :name
# def initialize(n)
# @name = n
# end
# end
# bob = Person.new('bob')
# p bob.name # => 'bob'
# bob.name = 'Robert'
# p bob.name # => 'Robert'
# 2. Modify the c... |
require 'rails_helper'
RSpec.describe Category do
describe 'validations' do
let(:category) { FactoryBot.create(:category) }
it 'validates name' do
category.name = ''
expect(category).to_not be_valid
expect(category.errors[:name]).to eq ["can't be blank"]
end
end
end
|
class Willgit < Formula
desc "William's miscellaneous git tools"
homepage "http://git-wt-commit.rubyforge.org"
head "https://gitorious.org/willgit/mainline.git"
def install
prefix.install "bin"
end
end
|
# frozen_string_literal: true
# Copyright (c) 2019 Danil Pismenny <danil@brandymint.ru>
class SorceryCore < ActiveRecord::Migration[6.0]
def change
enable_extension 'uuid-ossp'
create_table :users, id: :uuid, default: -> { 'uuid_generate_v4()' } do |t|
t.string :email, null: false
t.string :cry... |
class User < ApplicationRecord
has_secure_password #needed for bcrypt gem to hide/encrypt passwords
validates :name, presence: true
validates :name, uniqueness: {scope: :user_id}
validates :email, uniqueness: true
validates :password, length: {in: 8...12}
has_many :fave_drinks
has... |
class AdressType < ActiveRecord::Base
has_many :address
BILLING = "Billing"
SHIPPING = "Shipping"
NAMES = [BILLING,SHIPPING]
BILLING_ID = 1
SHIPPING_ID = 2
validates :name , :presence => true,:length => { :maximum => 55}
end
|
require_relative "Pieces/pieces.rb"
class Board
def initialize
@sentinel = NullPiece.instance
@board = Array.new(8) {Array.new(8, @sentinel)}
end
def [](pos)
row, col = pos
@board[row][col]
end
def []=(pos, val)
row, col = pos
@board[row][col] = val
end
def add_piece(piece, po... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :embed
def embed(url)
youtube_id = url.split("=").last
pre = "http://youtube.com/embed/"
... |
class EmployerIdentificationNumberFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
# This regex should match all rules of
# http://en.wikipedia.org/wiki/Employer_Identification_Number#EIN_format
#---------------------------------------------------------------
i... |
# == Schema Information
#
# Table name: account_requests
#
# id :bigint not null, primary key
# confirmed_at :datetime
# email :string not null
# name :string not null
# organization_name :string not null
# organiz... |
class RemoveCityTable < ActiveRecord::Migration[5.0]
def change
drop_table :cities
end
end
|
#!/usr/bin/env ruby
require 'yaml'
require 'nexpose_ticketing'
# Path to ServiceNow configuration file
SERVICENOW_CONFIG_PATH = File.join(File.dirname(__FILE__),
'../lib/nexpose_ticketing/config/servicenow.config')
# Read in ServiceNow options from servicenow.config
servicenow_optio... |
require "spec_helper"
RSpec.describe "Day 11: Monkey in the Middle" do
let(:runner) { Runner.new("2022/11") }
let(:input) do
<<~TXT
Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to mo... |
class Picture < ActiveRecord::Base
has_attached_file :image, :styles => { :medium => "300x300!", :show => "270x200!", :thumb => "100x100!", :large => "570x500!" }
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
validates :image, presence: true
validates :caption, presence: true, lengt... |
require_relative 'helper'
require_relative '../lib/cal_day'
class TestDay < Minitest::Test
def test_initializing_a_day_saves_values
m = Day.new(05,25,2015)
assert_equal 25,m.day
end
def test_day_to_s_for_beginning_of_month_may_01_2014
m = Day.new(05,01,2014)
expected = 5
... |
class Exercise < ActiveRecord::Base
validates :title, :calories_burned, presence: true
end
|
describe Importer::EmployeeListing do
let(:record) {{
:empl_id=>"008511",
:name=>"Evans,William B",
:rank=>"Comiss",
:badge=>"PC",
:doa=>"11/1/82",
:title=>"Commissioner (Bpd)",
:orgname=>"OFFICE OF POLICE COMMISSIONER",
:status=>"A"
}}
let(:records) { [record] }
let(:attribution... |
class PageFollow < ActiveRecord::Base
belongs_to :page
belongs_to :user
# attr_accessible :title, :body
validates_presence_of :page, :user
end
|
class Specialty
attr_reader(:id, :type)
def initialize(attributes)
@id = attributes[:id]
@type = attributes[:type]
end
def self.all
returned_specialties = DB.exec("SELECT * FROM specialties;")
specialties = []
returned_specialties.each do |specialty|
id = specialty["id"]
type... |
class CreateEventPrompts < ActiveRecord::Migration
def change
create_table :event_prompts do |t|
t.references :event
t.references :prompt
t.references :player
t.boolean :completed, default: false
t.boolean :passed, default: false
t.timestamps
end
end
end
|
class AddActiveToLists < ActiveRecord::Migration[6.0]
def change
add_column :idea_lists, :active, :boolean
end
end |
require_relative '../../automated_init'
context "CLI" do
context "Parse Arguments" do
context "Extra Path Arguments" do
path_1 = Controls::Path.example
path_2 = Controls::Path.alternate
argv = ['-a', path_1, path_2]
return_value = CLI::ParseArguments.(argv)
test "Returns the unpa... |
ActiveAdmin::Dashboards.build do
# Define your dashboard sections here. Each block will be
# rendered on the dashboard in the context of the view. So just
# return the content which you would like to display.
# == Simple Dashboard Section
section "Recent Posts" do
ul do
BlogPost.all[0..4].collec... |
require 'rails_helper'
RSpec.describe 'Albums API', type: :request do
let!(:artist) { create(:artist) }
let!(:album) { create(:album, artist_id: artist.id) }
let!(:artist_id) { artist.id }
let(:album_id) { album.id }
describe 'GET /artists/:artist_id/albums' do
before { get "/artists/#{artist_id}/albums... |
# frozen_string_literal: true
module Decidim
module Opinions
module Metrics
class AcceptedOpinionsMetricManage < Decidim::Opinions::Metrics::OpinionsMetricManage
def metric_name
"accepted_opinions"
end
private
def query
return @query if @query
... |
class Bird < Animal
def talk
puts "Chirp! Chirp!"
end
def move(destination)
puts "Flying to the #{destination}."
end
end |
module RailsMaps
class Event
attr_reader :type
TYPES = [:single_mark, :empty]
def initialize(type = :empty)
raise "Unknown type" unless TYPES.include? type
@type = type
end
end
end
|
require 'spec_helper'
AfterConfigurationChangeReceived = Class.new(StandardError)
describe GemConfig::Configuration do
let(:parent) {
Module.new do
include GemConfig::Base
end
}
subject do
GemConfig::Configuration.new(parent).tap do |configuration|
configuration.rules.has :all_allowed
... |
require 'spec_helper'
module CourseAssets::Jobs
describe ContentDepositorChangeEventJob do
before do
@depositor = FactoryGirl.create(:user)
@receiver = FactoryGirl.create(:user)
@file = GenericFile.new.tap do |gf|
gf.apply_depositor_metadata(@depositor.user_key)
gf.save!
end
CourseAs... |
class Api::UsersController < ApplicationController
before_action :signed_in_user
before_action :correct_user
def show
@user = User.find(params[:id])
render json: @user
end
def signed_in_user
redirect_to signin_url, notice: "Please sign in." unless signed_in?
end
def correct_user
@user =... |
require "report_builder"
require "date"
Before do
@login_page = LoginPage.new
@filme_page = FilmePage.new
@sidebar = SideBarView.new
# Maximizar a página do browser na execução do teste
# page.driver.browser.manage.window.maximize
# Settar o tamanho da tela para o valor passado
page.current_window.resi... |
class FacebookFriend < Struct.new(:linx_user, :facebook_user_id, :name)
alias_method :read_attribute_for_serialization, :send
def thumbnail_url
"https://graph.facebook.com/#{ facebook_user_id }/picture?type=large"
end
def first_name
name_parts.first
end
def name_parts
@name_parts ||= name.spl... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/../rspec_methods.rb')
describe Comment do
before(:each) do
@comment = Comment.new
@valid_comment = Comment.new :user_id => 1
end
it "should not be valid without user" do
@comment... |
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
require "daisy/version"
Gem::Specification.new do |s|
s.name = "daisy"
s.version = Daisy::VERSION
s.platform = Gem::Platform::RUBY
s.date = File.new("lib/daisy/version.rb").ctime
s.authors = ["Drewry Morris"]
s.email = %q{dhmorris@gma... |
class User < ApplicationRecord
has_secure_password
# associations *****************************
has_many :ideas, dependent: :nullify
has_many :likes, dependent: :destroy
has_many :liked_ideas, through: :likes, source: :idea
has_many :members, dependent: :destroy
has_many :memberships, through: :member... |
require 'cancan/matchers'
require 'rails_helper'
RSpec.describe S3ManifestAbility, type: :model do
let(:solr_document) { SolrDocument.new(attributes) }
let(:presenter) { Hyrax::FileSetPresenter.new(solr_document, ability) }
let(:attributes) { file.to_solr }
let(:file) do
create(:file_set,
id: '1... |
require 'carrierwave/orm/activerecord'
class Participant < ApplicationRecord
attr_accessor :remember_token
before_save { email.downcase! }
has_secure_password
mount_uploader :picture, ParticipantPictureUploader
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :first_name, ... |
require "application_system_test_case"
class PalletsTest < ApplicationSystemTestCase
setup do
@pallet = pallets(:one)
end
test "visiting the index" do
visit pallets_url
assert_selector "h1", text: "Pallets"
end
test "creating a Pallet" do
visit pallets_url
click_on "New Pallet"
cli... |
class Memo < ActiveRecord::Base
include Readable
belongs_to :person
belongs_to :template
validates_color_format_of :color
before_save :fix_time
before_save :fix_read
private
def fix_time
now = Time.now
if !self.ctime
self.ctime = now
end
self.mtime = now
end
def fix_read... |
require 'faraday'
require 'multi_json'
require_relative 'configurable'
require_relative 'api/mails'
require_relative 'api/sms'
require_relative 'error/client_error'
require_relative 'error/decode_error'
module Nipap
class Client
include Nipap::API::Mails
include Nipap::API::Sms
include Nipap::Configurab... |
module Resolver
class EntityMapper
include Resolver
def initialize(store, mapping)
@store = store
@mapping = mapping
end
def resolve_entity_mapper(obj)
@mapping[
if obj.kind_of? Store::Ref
extract_entity_class_name_from_ref(obj)
elsif obj.kind_of? Stor... |
chruby_zsh_path = ::File.expand_path(::File.join(ENV['HOME'],
'.oh-my-zsh/custom/chruby.zsh'))
template chruby_zsh_path do
source 'chruby.zsh.erb'
owner ENV['SUDO_USER'] || node['current_user']
action :create_if_missing
only_if { FueledZsh.installed? }
end
|
class CreateSwatches < ActiveRecord::Migration
def change
create_table :swatches do |t|
t.string :color_name
t.string :hex_code
t.string :rgb_code
t.string :hsl_code
t.integer :user_id
end
end
end
|
# frozen_string_literal: true
module Holders
class PaymentsController < ApplicationController
def index
render json: payments, status: :ok
end
private
def payments
::Payment.joins(invoice: :student)
.where(invoice: { students: { holder_id: params[:holder_id] } })
end
... |
# frozen_string_literal: true
require "test_prof/ext/string_strip_heredoc"
module TestProf::FactoryProf
module Printers
module Simple # :nodoc: all
class << self
include TestProf::Logging
using TestProf::StringStripHeredoc
def dump(result)
return log(:info, "No factories... |
class Department < ApplicationRecord
#学部
has_many :students #学部に複数の学生が所属している
end
|
class Item < ActiveRecord::Base
has_many :user_items
def self.to_hash(model_data, key)
"""
ActiveRecordのオブジェクトを指定のkeyでhashに変換
:param string : key
:param Item::ActiveRecord_Relation : model_data
"""
hash_data = {}
# オブジェクトの照合
if model_data.kind_of?(Item::ActiveRecord_Relation) then... |
require 'rails_helper'
RSpec.describe Post, type: :model do
before { @post = FactoryGirl.create(:post) }
subject { @post }
it { should respond_to(:position) }
it { should respond_to(:content) }
it { should respond_to(:photo) }
it "should belongs_to a location" do
@location = FactoryGirl.create(:locat... |
# frozen_string_literal: true
require_relative '../../assets/lib/filters/mergeable'
require_relative '../../assets/lib/pull_request'
require_relative '../../assets/lib/input'
require 'webmock/rspec'
describe Filters::Mergeable do
let(:ignore_pr) do
PullRequest.new(pr: { 'number' => 1, 'head' => { 'sha' => 'abc'... |
# 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 ... |
# Activate and configure extensions
# https://middlemanapp.com/advanced/configuration/#configuring-extensions
# Reload the browser automatically whenever files change
activate :livereload
# pretty URLs with no *.html ending
activate :directory_indexes
page "/test.php", :directory_index => false
page "/mail.php", :di... |
class CreateTransacts < ActiveRecord::Migration[5.2]
def change
create_table :transacts do |t|
t.decimal :incoming_transactions, default: 0
t.decimal :outgoing_transactions, default: 0
t.references :user, foreign_key: true
t.timestamps
end
end
end
|
require 'test_helper'
class PrescriptionDetailsControllerTest < ActionDispatch::IntegrationTest
setup do
@prescription_detail = prescription_details(:one)
end
test "should get index" do
get prescription_details_url
assert_response :success
end
test "should get new" do
get new_prescription_d... |
class FixTimesColumnName < ActiveRecord::Migration
def change
rename_column :activities, :times, :time
end
end
|
class TasksController < ApplicationController
# before_action :auth_user!
def new
@task = Task.new
end
def create
@task = current_user.tasks.create!(params[:task].permit(:title, :deadline, :difficulty, :importance, :description, :category))
@task.save!
respond_to do |format|
format.html{redirect_to '... |
require 'rails_helper'
RSpec.describe CSXML do
def doc(xml)
Nokogiri::XML(xml.to_xml)
end
let(:xml) { Nokogiri::XML::Builder.new(:encoding => 'UTF-8') }
let(:source_data_date) { '1971' }
let(:structured_date) { CSDTP.parse(source_data_date) }
it "can 'add' correctly" do
CSXML.add(xml, 'foo', 'bar... |
class UserAnswer < ApplicationRecord
validates_presence_of :message, :response
belongs_to :chatbot_statement
end
|
WINNING_NUM = 21
DEALER_STAYS = 17
WAIT_TIME = 3
def prompt(msg)
puts "=> #{msg}"
end
def initialize_deck
deck = []
%w(Spade Diamond Heart Clubs).each do |suit|
%w(2 3 4 5 6 7 8 9 10 Jack Queen King Ace).each do |value|
deck << [suit, value]
end
end
deck
end
def total(cards)
sum = 0
valu... |
# frozen_string_literal: true
require 'excon'
class Akismet
class Error < StandardError; end
class Client
PLUGIN_NAME = 'discourse-akismet'.freeze
VALID_COMMENT_CHECK_RESPONSE = %w{true false}.each(&:freeze)
VALID_SUBMIT_RESPONSE = 'Thanks for making the web a better place.'.freeze
UNKNOWN_ERROR_... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :task do
user_id 1
dispatcher_id 1
driver_id 1
company_id 1
name "MyString"
delivery_time "2014-03-04 11:41:33"
address "MyString"
comment "MyString"
end
end
|
require File.expand_path('../../test_helper', __FILE__)
require 'config_parser/utils'
class ConfigParser::UtilsTest < Test::Unit::TestCase
include ConfigParser::Utils
attr_reader :config
def setup
@config = {}
end
#
# LONG_FLAG test
#
def test_LONG_FLAG
r = LONG_FLAG
assert '--long' =~... |
#!/usr/bin/env ruby
require 'nkf'
# OS 判定
def is_win?
return RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/
end
# 文字列変換
def conv(msg)
if is_win?
encoding = 'cp932'
else
encoding = 'utf8'
end
return NKF.nkf("--oc=#{encoding}", msg)
end
# usage
def usage
puts conv("Usage: #{File.basen... |
# coding: utf-8
require File.expand_path('spec/spec_helper')
include SimilarityEngineSimilarity
describe CommonAlgorithm do
include CommonAlgorithm
context 'initialized' do
describe '#sum' do
context 'vec input' do
it 'should be expected value' do
list = []
#[ vec, expect]
... |
class Exam < ActiveRecord::Base
belongs_to :user
has_many :questions
end
|
class UserMailer < ApplicationMailer
default from: "mail@benwoodall.com"
def welcome_email(user)
@user = user
mail(to: user.email, subject: "Welcome to Shortener!")
end
def weekly_stats(user)
@user = user
@links = user.links.created_in_last_week
mail(to: user.email, subject: "Shrtnr Weekly... |
class AddApplicationIdToStatuses < ActiveRecord::Migration
def change
add_column :statuses, :application_id, :integer
add_index :statuses, :application_id
end
end
|
module Authorable
extend ActiveSupport::Concern
included do
belongs_to :author, class_name: 'Exposition::User'
validates_presence_of :author
end
end
|
class Gamey::AABB
attr_accessor :center, :size, :extents
def initialize(center, size)
@center = center
@size = size
@extents = @size / 2
end
def center=(new_center)
@center = new_center
end
def min
Gamey::Vector2.new(center.x - extents.x, ... |
class CommentAtRemind < ActiveRecord::Base
#attr_accessible :author
belongs_to :comment
#belongs_to :author, :class_name=>"User", :foreign_key=>"author_id"
belongs_to :clap, :foreign_key=>"comment_id"
belongs_to :post, :foreign_key=>"comment_id"
belongs_to :gift_get, :foreign_key=>"comment_id"
before_create :g... |
# Test if the array contains all elements. Order doesn't matter
# Check presenence of all the elements
RSpec.describe 'contain_exactly matcher' do
subject { [1, 2, 3] }
context 'long form syntax' do
it 'should check for the presence of all elements' do
expect(subject).to contain_exactly(1, 2, 3)
ex... |
class PostsController < ApplicationController
def new
@subs = Sub.all
@sub = Sub.find(params[:sub_id])
@post = Post.new
render :new
end
def create
@post = Post.new(post_params)
@post.user_id = current_user.id
# post_subs = []
# params[:post[subs]].each do |topic|
# post_sub... |
class AddRepeatCountToBusinessCardOrders < ActiveRecord::Migration
def self.up
add_column :business_card_orders, :repeat_count, :integer
end
def self.down
remove_column :business_card_orders, :repeat_count
end
end
|
# Copyright (c) 2009-2011 VMware, Inc.
$:.unshift(File.dirname(__FILE__))
require 'spec_helper'
require 'logger'
require 'yajl'
require 'mysql_service/util'
require 'timeout'
module VCAP
module Services
module Mysql
module Util
class ConnectionPool
attr_reader :connections, :shutting_down... |
require 'rails_helper'
RSpec.describe Song, type: :model do
let(:song) { Song.new }
describe "stuff of songs" do
it "has zero songs to begin with" do
expect(Song.count).to eq 0
end
it "has one song after adding one" do
Song.create
expect(Song.count).to eq 1
end
it "has none... |
class FavoritesController < ApplicationController
before_action :authenticate_user!, only: [:create, :destroy]
def create
@fovorite = current_user.favorites.create(post_id: params[:post_id])
@post = Post.find(params[:post_id])
@post.create_notification_favorite!(current_user)
respond_to do |format|
for... |
class TypegroupsController < ApplicationController
before_action :set_typegroup, only: [:show, :edit, :update, :destroy]
# GET /typegroups
# GET /typegroups.json
def index
@typegroups = Typegroup.all
respond_to do |format|
format.html
format.json { render json: @typegroups }
end
end
... |
feature 'Game start' do
# As a user
# So that I can see my name in lights
# I would like to register my name before playing the game
scenario 'On game start, user can submit his name' do
sign_in
expect(page).to have_content('John')
end
# As a user
# So that I know how to start the game
# I ne... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.