text stringlengths 10 2.61M |
|---|
class FixSalasName < ActiveRecord::Migration
def change
rename_column :salas, :name, :nombre
end
end
|
class ChangeUsersAdminColumn < ActiveRecord::Migration[5.0]
def change
remove_column :users, :admin
add_column :users, :admin, :boolean, default: :false
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :event do
sequence(:name) { |n| "event_#{n}" }
sequence(:memo) { |n| "event_memo_#{n}" }
date '2014/01/01'
end
end
|
class MetadataController < ApplicationController
include Metadatable
prepend_before_action :authenticate_user_with_basic_auth!
before_action :set_doi, only: [:destroy]
before_action :set_raven_context, only: [:create_metadata]
def index
@doi = validate_doi(params[:doi_id])
fail AbstractController::A... |
Before do
@login_page = LoginPage.new
@home_page = HomePage.new
@cadastro_page = CadastroPage.new
@editar_page = EditarPage.new
end
After('@evidencia') do |scenario|
if scenario.failed?
nome_cenario = scenario.name.gsub(/[^A-Za-z0-9 ]/, '')
nome_cenario = nome_cenario.gsub(' ', '-')... |
require File.expand_path('../../../spec_helper', __FILE__)
describe Admin::BusterController do
dataset :users
before :each do
ActionController::Routing::Routes.reload
login_as :designer
end
it "should be a ResourceController" do
controller.should be_kind_of(Admin::ResourceController)
end
i... |
class Category < ActiveRecord::Base
extend FriendlyId
friendly_id :name_en, use: :slugged
validates :name_en, :name_gr, presence: true, uniqueness: true
has_many :menuitems
acts_as_tree name_column: :name_en
end
|
def roll_call_dwarves(array)
array.each_with_index { |name, index| puts "#{index + 1} #{name}"}
end
def summon_captain_planet(array)
array.collect { |name| "#{name.capitalize}!" }
end
def long_planeteer_calls(array)
array.any? { |element| element.size > 4}
end
def find_the_cheese(array)
# the array below is ... |
#!/usr/bin/env ruby
require 'fileutils'
require 'yaml'
require 'optparse'
require_relative 'lib/project'
require_relative 'lib/list_methods'
require_relative 'lib/options'
include ListMethods
projects = load_list
options = Options.parse
case options[:command]
when nil
if projects.size > 0
puts "Your projects:... |
require 'watir'
require 'selenium-cucumber'
# require 'Login'
Given(/^it navigates to gmail\.com$/) do
navigate_to("http://www.gmail.com")
end
When(/^user logs in using Username as "([^"]*)"$/) do |arg1|
enter_text('name', arg1, 'Email')
click('name', 'signIn')
end
When(/^Password "([^"]*)"$/) do |arg1|
ente... |
class RemoveCategoryFromMedia < ActiveRecord::Migration[5.2]
def change
remove_column :media, :category
end
end
|
# frozen_string_literal: true
require 'jiji/configurations/mongoid_configuration'
require 'jiji/utils/value_object'
require 'jiji/errors/errors'
require 'jiji/web/transport/transportable'
module Jiji::Model::Agents
class AgentSource
include Mongoid::Document
include Jiji::Utils::ValueObject
include Jij... |
module CarrierWave
module MiniMagick
def gaussian_blur(radius)
manipulate! do |img|
img.gaussian_blur(radius.to_s)
img = (yield) if block_given?
img
end
end
# def vignette(path_to_file)
# manipulate! do |img|
# cols, rows = img[:dimensions]
# vig... |
# frozen_string_literal: true
module Atacama
# The type namespace to interact with DRY::Types
# @see https://dry-rb.org/gems/dry-types/built-in-types/ dry-types Documentation
module Types
include Dry.Types()
Boolean = Types::True | Types::False
# Defines a type which checks that the Option value con... |
require 'test/unit'
require 'de'
require 'de/boolean'
class DeBooleanOperatorTest < Test::Unit::TestCase
class SomeOperator < De::Boolean::BooleanOperator; end
class SomeOperator < De::Boolean::BooleanOperator; end
class NotSuitableOperand < De::Operand; end
def test_constructor
assert_raise(De::Error::A... |
module ActiveRecord
module NestedErrorIndexer
module Associations
module Builder
module HasMany
def valid_options
super + [:index_errors]
end
end
end
end
end
end
|
class Appointment < ApplicationRecord
belongs_to :availability
validates :client_id, presence: true
delegate :from, to: :availability
delegate :fp_id, to: :availability
end
|
class ProfilesController < ApplicationController
def show
@user = User.find_by(profile_name: params[:id])
if @user
@statuses = @user.statuses
render :show
else
render file: "public/404", status: :not_found
end
end
end
|
require 'digest/sha1'
class ObjectStore
def initialize
@branch_manager = BranchManager.new
end
def self.init(&block)
instance = self.new
if block_given?
instance.instance_eval(&block)
end
instance
end
def add(name, object)
@branch = @branch_manager.branch
new_file = File.... |
require 'formula'
class PgpoolIi <Formula
url 'http://pgfoundry.org/frs/download.php/2664/pgpool-II-2.3.3.tar.gz'
homepage 'http://pgpool.projects.postgresql.org/'
md5 'fae5a3b50eab995d15a18f80fee2e92b'
depends_on 'postgresql'
def install
system "./configure", "--prefix=#{prefix}"
system "make insta... |
# frozen_string_literal: true
require "spec_helper"
describe "GraphQL::Execution::Interpreter::Arguments" do
class InterpreterArgsTestSchema < GraphQL::Schema
class SearchParams < GraphQL::Schema::InputObject
argument :query, String, required: false
end
class Query < GraphQL::Schema::Object
... |
# encoding: UTF-8
class VoterValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :author) if record.session.try(:is_author?, record.user)
record.errors.add(attribute, :voter) unless record.user.try(:voter?)
end
end |
class TreeNode
attr_accessor :value, :children, :parent
def initialize(value)
@value = value
@parent = nil
@children = []
end
def add_child(child)
self.children << child
child.parent = self
end
def dfs(target)
return self if value == target
return nil if children.empty?
found_node = nil
child... |
require 'rails_helper'
RSpec.describe Product, type: :model do
describe "Validations" do
it "should be valid with valid attributes" do
@test_category = Category.new(name: "Test Things")
@test_product = Product.new(name: "Test Product", price: 29.99, quantity: 4, category: @test_category)
expect(@t... |
require 'test_helper'
require 'rackstash/buffered_logger'
require 'stringio'
require 'json'
describe Rackstash::BufferedLogger do
let(:log_output){ StringIO.new }
let(:base_logger){ Logger.new(log_output) }
def log_line
log_output.string.lines.to_a.last
end
def json
JSON.parse(log_line)
end
su... |
def encryption(s)
word = s.split(' ').join
count = word.chars.count
cols = Math.sqrt(count).ceil
str = ''
word.chars.each_with_index do |el, ind|
str += ' ' if (ind % cols).zero? && (ind != 0)
str += el
end
p str
arr = str.split(' ')
temp =''
cols.times do |t|
arr.each do |item|
... |
require "rails_helper"
describe Strategies::Fail do
it "fails when given a message" do
s = Strategies::Fail.new
message = Message.new(
text: "hello",
user: "someone",
timestamp: Time.now
)
expect { s.call message }.to raise_error(Strategies::Fail::Failure)
end
end
|
module TaskMapper::Provider
module Jira
# Ticket class for taskmapper-jira
#
class Ticket < TaskMapper::Provider::Base::Ticket
#API = Jira::Ticket # The class to access the api's tickets
# declare needed overloaded methods here
def initialize(*object)
if object.first
... |
#types = [:P_VOID, :P_CHAR, :P_INT, :P_LONG, :P_VOIDPTR, :P_CHARPTR, :PINTPTR, :P_LONGPTR]
$psize = {:P_VOID => 0, :P_CHAR => 1, :P_INT => 4, :P_LONG => 8, :P_VOIDPTR => 8, :P_CHARPTR => 8, :P_INTPTR => 8, :P_LONGPTR => 8}
class Types
def self.compatibleTypes(t1, t2, onlyright=false)
if t1 == ... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'selectize/ajax/version'
Gem::Specification.new do |spec|
spec.name = 'selectize-ajax'
spec.version = Selectize::Ajax::VERSION
spec.authors = ['Ryabov Ruslan']
spec.em... |
class Item < ApplicationRecord
include ImageUploader::Attachment.new(:image)
include Filterable
has_many :reviews, as: :reviewcontainer, dependent: :destroy
belongs_to :user
belongs_to :category
has_many :books, dependent: :destroy
# extend ItemSpliter
# split(name)
validates :name, :description,... |
class Movie < ActiveRecord::Base
def self.get_all_ratings
return Movie.distinct.pluck("rating")
end
end
|
namespace :realogy do
def active_job_configured?
return Rails.application.config.active_job.queue_adapter.eql?(:async) ? false : true
end
desc "Sync all active entities"
task :sync_active_entities => [:sync_active_agents, :sync_active_companies, :sync_active_listings, :sync_active_offices, :sync_active_te... |
class CourseInstance < ActiveRecord::Base
belongs_to :course
has_many :exercise_groups, :order => "name ASC", :dependent => :destroy
end
|
class Doctor < ApplicationRecord
# We can add email for keep it for later. -> email user != email pro
belongs_to :user
has_many :doctor_specialities
has_many :schedules
validates :phone, presence: true, length: { minimum: 10, maximum: 10 }
validates :city, presence: true, length: { minimum: 2, maximum: 50 ... |
require "pry"
class Scrabble
attr_reader :point_values, :scored_letters
def initialize
@point_values =
{
"A"=>1, "B"=>3, "C"=>3, "D"=>2,
"E"=>1, "F"=>4, "G"=>2, "H"=>4,
"I"=>1, "J"=>8, "K"=>5, "L"=>1,
"M"=>3, "N"=>1, "O"=>1, "P"=>3,
"Q"=>10, "R"=>1, "S"=>1, "T"=>1,
"U"=... |
require 'ffi'
module FFI
class Struct
class << self
alias :layout_base :layout
private :layout_base
puts method_defined? :layout_base
end
def self.layout(*args)
layout_base(*args)
members.each do |name|
unless method_defined?(name)
define_method name, ->{ ... |
class Label < ActiveRecord::Base
has_many :albums
has_and_belongs_to_many :artists
validates(:name, :presence => true)
validates(:name, :uniqueness => true)
end
|
class HomePage < SitePrism::Page
#set_url Rails.application.routes.url_helpers.root_path
set_url '/'
element :brand_link, 'a.navbar-brand'
element :search_field, 'input#q'
element :search_button, 'button#search-button'
NO_RESULTS = I18n.t('will_paginate.page_entries_info.single_page_html.zero')
O... |
module Mirren
module Rigs
class Status < BaseStruct
attribute :status, Types::String
attribute :hours, Types::IntString
attribute :rented, Types::Bool
attribute :online, Types::Bool
end
end
end
|
require "test_helper"
class InvoiceTest < ActiveSupport::TestCase
test "must be valid" do
invoice = Invoice.new({
price: 10,
currency_uid: "USD",
quotation: quotations(:one)
})
assert(invoice.valid?)
end
test "must be invalid" do
invoice = Invoice.new({
currency_uid: "USD... |
class Sudoku
attr_reader :board
def initialize(board)
@board = board.split('').map { |n| n.to_i }
end
def clone
Sudoku.new @board.join('')
end
def check_row(i)
row_index = i / 9
cell_start = row_index * 9
cell_end = cell_start + 9
@board[cell_start...cell_end]
end
def check_c... |
# frozen_string_literal: true
require 'English'
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'paginate-responder/version'
Gem::Specification.new do |gem|
gem.name = 'paginate-responder'
gem.version = PaginateResponder::VERSION
gem.authors ... |
class MyScript < ::Process::Naf::Application
opt :thing, default: "world"
def work
logger.info("Hello #{@thing}!")
end
end
|
class RegistriesController < ApplicationController
layout 'application'
before_filter :require_user
before_filter :find_user
def index
if session[:current_friend].nil?
redirect_to user_registry_path(@user, @user.registries )
else
redirect_to :controller => 'gifts', :action => 'select_f... |
class EverythingClosedPeriod < ActiveRecord::Base
attr_accessible :message_no, :message_en, :closed_from, :closed_to
validates :message_no, presence: true
validates :message_en, presence: true
validates :closed_from, presence: true
validates :closed_to, presence: true
validate :times_in_valid_order
scop... |
module Timeable
module ClassMethods
end
module InstanceMethods
def during_the_day?(datetime)
day_time_hours_include?(datetime.hour)
end
def day_time_hours_include?(hour)
day_time_hours.include?(hour % 24)
end
def night_time_hours_include?(hour)
night_time_hours.incl... |
FactoryBot.modify do
factory :json_resource, class: JSONModel::JSONModel(:resource) do
self.series_system_agent_relationships {
[
{
'jsonmodel_type' => 'series_system_agent_record_ownership_relationship',
'relator' => 'is_controlled_by',
'start_date' => generate(:yyyy_mm_dd... |
class Player
attr_accessor :cards, :bank, :name
TOTAL_SCORE = 21
MAX_CARDS = 3
ACE = 1
def initialize(name)
@name = name
@bank = 100
@cards = []
end
def full_hand?
@cards.size == MAX_CARDS
end
def add_cards(card)
@cards << card
end
def minus_cash(sum)
@bank -= sum
e... |
class TodoList < ActiveRecord::Base
has_many :todo_items, dependent: :destroy
validates :title, presence: true
validates :description, presence: true
end
|
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox"
config.vm.box = "egavm"
config.vm.define "egavm" do |v|
end
config.vm.network "forwarded_port", guest: 3000, host: 30080
config.vm.synced_folder ".", "/vagrant", disabled: true
# VirtualBox
config.vm.provider "virtualbox" do |v|
v... |
class TechnologiesController < ApplicationController
def index
@technologies = Technology.where("name like ?", "%#{params[:q]}%")
respond_to do |format|
format.html
format.json {render json: @technologies.map(&:attributes)}
end
end
end
|
require_relative 'dice'
class Player
MOVE = 1
WIN = 2
attr_reader :name, :dice, :die_rolls
attr_accessor :position, :color, :piece
def initialize(name:)
@name = name
@position = 0
@die_rolls = []
@dice = Dice
@color = ""
@piece = piece
end
# View
def rolls_array
@die_rol... |
module SupplyTeachers
class SuppliersController < SupplyTeachers::FrameworkController
before_action :set_end_of_journey, only: %i[master_vendors neutral_vendors]
helper :telephone_number
def master_vendors
@back_path = source_journey.current_step_path
@suppliers = Supplier.with_master_vendor... |
task :default do
File.open('README.md', 'w') do |out|
out.puts "# My Pagists"
out.puts
out.puts "This is a collection of my [Pagists](http://www.pagist.info/)."
out.puts
File.read('.gitmodules').scan(/path = (\S+)\s+url = (\S+)/).sort_by(&:first).reverse.each do |path, url|
out.puts "*... |
require 'rails_helper'
RSpec.feature 'Links', type: :feature do
let!(:existing_link) { create :link, title: 'My Wonderful Page' }
context 'with authentication' do
before { do_login }
scenario 'can be created' do
visit new_link_path
fill_in 'Title', with: 'Great Link'
fill_in 'Path', w... |
require 'rubygems'
require 'pathname'
require 'sinatra'
require 'yaml'
require 'ostruct'
def root_dir
@root_dir ||= Pathname(__FILE__).dirname
end
# Load vendorered slidedown.
if (path = root_dir.join("vendor", "slidedown", "lib")).directory?
$:.unshift(path.to_s) unless $:.include?(path.to_s)
end
require 'slide... |
# -*- encoding: utf-8 -*-
# stub: custom_error_message 1.1.1 ruby lib
Gem::Specification.new do |s|
s.name = "custom_error_message".freeze
s.version = "1.1.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.aut... |
require 'spec_helper'
describe "batches/new" do
before(:each) do
assign(:batch, stub_model(Batch,
:batch_name => "MyString",
:sales => 1.5
).as_new_record)
end
it "renders new batch form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
... |
class Admin::UsersController < ApplicationController
before_action :set_user, only: %i[show edit update destroy]
helper_method :sort_column, :sort_direction
after_action :verify_authorized
def index
@users = User.all.order(sort_column + " " + sort_direction)
authorize @users
end
def new
@us... |
require 'cf_spec_helper'
describe LanguagePack::NodeInstaller do
describe '#install' do
context 'with different stacks' do
let(:installer) { LanguagePack::NodeInstaller.new('stack') }
before do
allow(FileUtils).to receive(:mv)
allow(FileUtils).to receive(:rm_rf)
allow_any_ins... |
class UserAnswersController < ApplicationController
before_action :ensure_logged_in
def create
@user_answer = current_user.user_answers.new(user_answer_params)
if @user_answer.save
redirect_to user_questions_url(user_answer_params[:user_id])
else
flash.now[:errors] = @user_answer.errors.ful... |
# @Author: Ismael Hadj
# @Date: 2018-05-21T10:46:10+02:00
# @Email: Ismael.hadj13@yahoo.com
# @Last modified by: Ismael Hadj
# @Last modified time: 2018-05-21T15:18:12+02:00
class Travel < ApplicationRecord
has_many :topic
mount_uploader :photo, PictureUploader
validates :title, :story, :duration, :destin... |
require 'zlib'
require 'ox'
module Dabooks
class CLI::GnucashCommand
DETAILS = {
description: 'Converts GnuCash files into dabooks format.',
usage: 'dabooks gnucash <filename>',
schema: {},
}
def initialize(clargs)
@argv = clargs.free_args
end
def run
@argv.map{ |file| convert(file) }
... |
class HashSet
def initialize(init_size)
@curr_size = init_size
@buckets = Array.new(init_size) {[]}
@element_num = 0
end
def insert(el)
if @element_num >= @curr_size
resize
end
if !self.include?(el)
@buckets[el.hash % @curr_size] << e... |
require 'spec_helper'
describe Occupant do
let (:meder) {Occupant.new("Meder", "Tok")}
describe '.new' do
it "gives a name of a new occupant" do
expect(meder.class).to eq(Occupant)
end
end
end
|
# Copyright (c) 2016 Novell, Inc.
# Licensed under the terms of the MIT license.
$space = "spacecmd -u admin -p admin "
And(/I check status "([^"]*)" with spacecmd on "([^"]*)"$/) do |status, target|
host = $ssh_minion_fullhostname if target == "ssh-minion"
host = $ceos_minion_fullhostname if target == "ceos-minio... |
require 'test_helper'
require 'fakefs/safe'
class RailsLogtruncateTest < ActiveSupport::TestCase
def setup
FakeFS.activate!
File.write('test_file', "1" * 900)
@logtruncate = RailsLogtruncate
@logtruncate.truncator = RailsLogtruncate::Truncator.new
end
def teardown
FakeFS.deactivate!
end
... |
class Question < ApplicationRecord
belongs_to :user
has_many :answers, dependent: :destroy
validates :title, :description, presence: true
end |
#!/usr/bin/env ruby
#
# author: scott w olesen <swo@mit.edu>
require 'arginine'
class String
def fix_doi
m = self.match(/dx\.doi\.org\/([^\}]+)/)
if m.nil?
self
else
"doi={#{m.captures[0]}#{m.captures[1]}}"
end
end
end
par = Arginine::parse do
desc ""
arg :bibtex
end
# get raw in... |
Copycopter::Application.routes.draw do
namespace :api do
namespace :v2 do
resources :projects, :only => [] do
resources :deploys, :only => [:create]
resources :draft_blurbs, :only => [:create, :index]
resources :published_blurbs, :only => [:index]
end
end
end
resources... |
# Call Ruby's OpenURI module which gives us a method to 'open' a specified webpage
require 'open-uri'
require 'uri'
# This is the basic address of Pfizer's all-inclusive list. Adding on the iPageNo parameter will get us from page to page.
FIRST_PAGE = 'https://www.unglobalcompact.org/what-is-gc/participants/s... |
module Noodle
class MinValidator < ActiveModel::Validator
def validate(record)
if record.node_class_property.properties.key?('validators') && record.node_class_property.properties['validators'].key?('min')
record.errors.add(:empty_value, 'Valu is to small', strict: true) if record.value.to_i < r... |
require 'spec_helper'
require "cancan/matchers"
RSpec.describe Ability do
context "a director should" do
let(:user){ FactoryGirl.create(:confirmed_director) }
subject(:ability){ Ability.new(user) }
context "be able to manage Faq" do
%i[create read update destroy].each do |role|
it{ is_expe... |
# Using the following code, create a class named Cat that prints a greeting
# when #greet is invoked. The greeting should include the name and color of
# the cat. Use a constant to define the color.
class Cat
COLOR = 'pastel'
attr_accessor :name
def initialize(name)
self.name = name
end
def greet
... |
require 'fileutils'
module HasModerated
module CarrierWave
def self.included(base)
# lazy require so it doesn't require carrierwave until
# it's actually used by the user
require File.expand_path('../carrier_wave_patches', __FILE__)
base.send :extend, ClassMethods
end
def self.p... |
class Instrument < ActiveRecord::Base
attr_accessible :name, :photo
has_many :users, :through => :skills
has_many :skills
end
|
class OutboundList<ActiveRecord::Base
has_many :outbound_logs
has_many :contact_lists, through: :link_outbound_contacts
has_many :link_outbound_contacts
def self.find_controller(id)
outbound=self.find_by(:id => id)
if outbound == 0
required_id =Project.find_by(:id => outbound.vboard_survey_id).user_call_cod... |
# encoding: UTF-8
require 'test_helper'
class CertificateTest < ActiveSupport::TestCase
# should validate_acceptance_of :tax_deductible
setup do
@merchant = FactoryGirl.create(:merchant)
@charity = FactoryGirl.create(:charity)
@customer = FactoryGirl.create(:customer)
end
should "have amount" do... |
require 'lol_api/types/dtos/image'
module LolApi
class Mastery
attr_reader :raw_mastery
def initialize(raw_mastery)
@raw_mastery = raw_mastery
end
def id
raw_mastery['id']
end
def name
raw_mastery['name']
end
def description
raw_mastery['description']
end
... |
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'sms_spec'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support... |
class CreateOreNodes < ActiveRecord::Migration
def change
create_table :ore_nodes do |t|
t.string :name
t.integer :map_id
t.integer :server_id
t.integer :reset_date_id
t.integer :x
t.integer :y
t.timestamps
end
end
end
|
require 'bike'
describe Bike do
it { is_expected.to respond_to(:working?)}
it { is_expected.to respond_to(:report_broken) }
it 'is reported broken' do
bike = Bike.new
bike.report_broken
expect(bike.broken?).to eq true
end
end |
# frozen_string_literal: true
require 'optparse'
require 'optimist'
namespace :caststone do
namespace :images do
desc 'Ensure all images have height and width specified'
task image_sizes: :environment do
Refinery::Image.where(image_width: [nil, '']).each do |image|
original_image = image.image
... |
# frozen_string_literal: true
module Api::V1::Videos::Featured
class IndexAction < ::Api::V1::BaseAction
map :find_videos
map :build_response
private
def find_videos
::VideosFinder
.new(initial_scope: Video.dataset)
.call(
filter: {featured: {eq: true}},
ex... |
require "pry"
require "./db/setup"
require "./lib/all"
require "colorize"
require "thor"
class Todo < Thor
desc "add TASK LIST", "Adds [TASK] to [LIST]"
def add task, list
addition task, list
end
desc "due TASK DUE_DATE", "Marks task with [TASK] ID with a [DUE DATE]"
def due task_id, due_date
Task.f... |
# frozen_string_literal: true
module Api
class TournamentsController < ApiController
before_action :set_tournament, except: %i[index create]
before_action :tournament_running?, only: %i[update join]
after_action :verify_authorized, except: %i[index create join leave games participants]
def index
... |
class MyApp
@@routes_conllection = []
def self.match(route)
@@routes_conllection << Route.new(route)
end
def map_routes(path)
@@routes_conllection.each do |route|
if route.match(path)
return route.controller, route.action
end
end
end
def call env
path = env['PATH_INFO']
... |
require_relative './../../spec_helper.rb'
describe MessageModule::CreateService do
before do
@description = "teste"
@language = "en"
end
describe "#call" do
context "Without description params" do
it "Will receive a error" do
@createService = MessageModule::CreateService.new({"langu... |
class TopicsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :set_topic, only: [:edit, :update, :destroy]
def index
# If the parameter :user_topics is passed, display only the user's posted topics
# otherwise, display all topics (default)
@to... |
class Game_Player < Game_Character
def move_straight(d, turn_ok = true)
forefront = passable?(@x, @y, d)
super
return unless forefront
@followers.move(d, nil, self.direction, :str)
end
def move_diagonal(horz, vert)
forefront = diagonal_passable?(@x, @y, horz, vert)
super
return unle... |
class AddDetailedReportFlagToIcseExamCategory < ActiveRecord::Migration
def self.up
add_column :icse_exam_categories, :is_detailed_report, :boolean,:default=>true
end
def self.down
remove_column :icse_exam_categories
end
end
|
require 'spec_helper'
# See: https://github.com/rails3book/ticketee/blob/master/spec/api/v1/tickets_spec.rb
describe '/members', :type => :api do
# Lazy, not suitable for API test. Use before(:each|:all) instead.
# The object is not initialized until its first method is accessed.
# let (:member) { create(:membe... |
class TaskListsController < ApplicationController
before_action :authenticate_user!
def index
@task_lists = current_user.task_lists
end
def new
@task_list = TaskList.new
end
def create
@task_list = current_user.task_lists.new(task_list_params)
if @task_list.save
@task_list.tasks.map... |
# frozen_string_literal: false
require_relative "rss-testcase"
require "rss/maker"
module RSS
class TestMakerTaxonomy < TestCase
def setup
@uri = "http://purl.org/rss/1.0/modules/taxonomy/"
@resources = [
"http://meerkat.oreillynet.com/?c=cat23",
"http://meerkat.oreillynet.com/?c=4... |
require 'generators/ng/generator_helpers'
module Ng
module Generators
class BootstrapGenerator < ::Rails::Generators::Base
include Ng::Generators::GeneratorHelpers
source_root File.expand_path("../../templates", __FILE__)
desc "Creates the AngularJS application skeleton in app/assets/javascri... |
# 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: 'Ema... |
require 'spec_helper'
describe 'ssh::user', :type => :define do
on_os_under_test.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
let(:title) { 'foo' }
let :params do
{
:key => 'foobarblabbq'
}
... |
# def find_element_index(array, value_to_find)
# if array.include?(value_to_find)
# array.index(value_to_find)
# else
# return nil
# end
# end
# def find_max_value(array)
# new_array = array.sort
# new_array.last
# end
# def find_min_value(array)
# new_array = array.sort
# new_array.first
# en... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :ensure_logged_in
def login(user)
@user.reset_session_token
@user.session_token = session[:session_token]
end
def logged_in?()
@false
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.