text stringlengths 10 2.61M |
|---|
require 'rails_helper'
describe VoiceService do
describe '#generate_text_response' do
it 'takes a string and responds with twiml' do
response = subject.generate_text_response(message: 'Hello there')
expect(response).to eq '<?xml version="1.0" encoding="UTF-8"?><Response><Say voice="woman">Hello there... |
module Spree
class ReturnedProductsReport < Spree::Report
DEFAULT_SORTABLE_ATTRIBUTE = :product_name
HEADERS = { sku: :string, product_name: :string, return_count: :integer }
SEARCH_ATTRIBUTES = { start_date: :product_returned_from, end_date: :product_returned_till }
SORTABLE_ATTRIBUTES = [:product_na... |
class StudentsController < ApplicationController
before_action :set_student, only: [:show, :edit, :update, :destroy]
before_action :fix_date, only: [:update, :create]
def index
@students = Student.search params[:search], :page => params[:page], :per_page => 30, :include => :site
end
def new
@stude... |
# frozen_string_literal: true
class AdminUser < ActiveRecord::Base
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :async
validates :full_name, presence: true
end
|
# require 'faker' #if you want to test code with random-generated tasks
require 'sqlite3'
require 'date'
require_relative 'service/priority_algorithm'
require 'fileutils'
FileUtils::mkdir_p(Dir.home + '/.taskki')
DB = SQLite3::Database.new(Dir.home + '/.taskki/tasks.db')
class Task
attr_reader :title, :takes, :reo... |
class SessionsController < ApplicationController
skip_before_action :ensure_user_signed_in
def create
session[:auth_id] = auth_hash.uid
Auditor.new.user_signed_in(user_id: auth_hash.uid)
redirect_to '/tasks'
end
def destroy
Auditor.new.user_signed_out(user_id: session[:auth_id])
reset_s... |
class Flash < Fighter
def initialize color
@name = "Flash"
@opening_line = "Hey, what's that?!?!"
@moves = [
Move.new('looky here', hit_chance: 50, stun_chance: 40),
Move.new('over here', hit_chance: 40, stun_chance: 50),
Move.new('eye poke', hit_chance: 10, stun_chance: 80)
]
... |
# Class Warfare, Validate a Credit Card Number
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: the credit card number
# Output: true or false for whether it's a valid number
# Steps:
#1. initialize the credit card class
#check that it has 16 digits
... |
module DowlOptParse
class CoercionError < StandardError; end
module IntegerCoercer
def self.call(value)
Kernel.Integer(value)
rescue ArgumentError
raise CoercionError, 'is not an integer'
end
end
module FloatCoercer
def self.call(value)
Kernel.Float(value)
rescue Argument... |
class CreateCountries < ActiveRecord::Migration
def change
create_table :countries do |t|
t.string :name
t.string :h1
t.text :keywords
t.text :description
t.string :offname
t.string :stolica
t.string :language
t.string :valute
t.string :ploscha
t.string ... |
class ChangeBalanceAccountColumn < ActiveRecord::Migration[5.1]
def change
remove_column :balances, :account
add_reference :balances, :account, index: true, null: false, default: 0
end
end
|
class AddFieldsToMFInvestment < ActiveRecord::Migration
def change
add_column :monthly_f_investments, :invested_in, :string
end
end
|
# frozen_string_literal: true
require 'honeybadger'
module OkComputer
class DataciteConnectionCheck < OkComputer::Check
attr_accessor :connection, :datacite_doi
def check
@connection ||= Datacite::Connection.new
record = Datacite::Connection::ResponseRecord
.new(@datacite_doi || '... |
#! ruby -Ku
# Google App Engine上の単純ベイズ分類器に学習データを追加する
require "cgi"
require "uri"
require "net/http"
require "rubygems"
require "facets"
require "json"
Net::HTTP.version_1_2
# 追加済みの学習データを取得
added = File.foreach("added.txt").
map { |line| line.strip }.
map { |line| line.split(/\t/) }.
mash { |category, title| [... |
class AddProductToOrderItems < ActiveRecord::Migration[5.2]
def change
add_reference :order_items, :product, index: true
add_foreign_key :order_items, :products
end
end
|
require 'cxbrank/const'
require 'cxbrank/playdata/music_skill'
require 'cxbrank/user'
require 'cxbrank/adversary'
class Array
def rank
return self.map do |v| self.count do |a| a > v end + 1 end
end
end
module CxbRank
module PlayData
include Comparable
class AdversarySkill < PlayData::MusicSkill
... |
module API
module V1
class Items < Grape::API
include API::V1::Defaults
resources :todos do
params do
requires :todo_id, type: Integer
end
desc 'Return a Item'
route_param :todo_id do
resources :items do
get '', root: :items do
... |
class PasswordController < ApplicationController
def checker
@user_name = params[:user_name].to_s
@password = params[:password].to_s
# Tells user what the result is.
if (params.has_key?(:user_name) && !params[:user_name].strip.empty?) &&(params.has_key?(:password) && !params[:password].strip.empty?)... |
require 'test/unit'
require_relative '../models.rb'
class TestComments < Test::Unit::TestCase
def setup
@good = {
'HTTP_REFERER' => 'http://sivers.org/trust',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0',
'REMOTE_ADDR' => '5.9.59.61',
'rack.... |
class Person
attr_accessor :first_name, :last_name
def initialize(full_name)
parse_full_name(full_name)
end
def name
"#{first_name} #{last_name}".strip
end
def name=(full_name)
parse_full_name(full_name)
end
def to_s
name
end
private
def parse_full_name(full_name)
parts =... |
require 'test_helper'
class StudyTest < ActiveSupport::TestCase
fixtures :all
test "associations" do
study=studies(:metabolomics_study)
assert_equal "A Metabolomics Study",study.title
assert_not_nil study.assays
assert_equal 1,study.assays.size
assert !study.investigation.projects.empty?
... |
class CreateSpreeShipstations < ActiveRecord::Migration[5.1]
def change
add_column :spree_orders, :shipstation_exported_at, :datetime, default: nil
end
end
|
class V1::GamesController < V1::BaseController
def create
respond_with game
end
private
def game
GameCreator.call(user: current_user).game
end
end
|
name "single_node_hadoop_claster"
description "Installs and configures Hadoop 1.0.x on a Single Linux Node"
version "0.1.0"
maintainer "Pavel Mitin"
maintainer_email "mitin.pavel@gmail.com"
license "MIT"
|
class SupportController < ApplicationController
before_filter :setup_xbox_key, :only => [:remaining]
def remaining
client = XboxClient::client
@remaining = client.calls_remaining(params[:cached] == 'true')
end
end
|
# Cross Compiling configuration for the Sega Dreamcast
# This configuration requires KallistiOS (KOS)
# https://dreamcast.wiki
#
# Tested on GNU/Linux, MinGW-w64/MSYS2, Cygwin, macOS and MinGW/MSYS (see below)
#
MRuby::CrossBuild.new("dreamcast") do |conf|
toolchain :gcc
# Support for DreamSDK (based on MinGW/MSYS... |
module MDS
module Responses
class ShippingSKUAck
attr_accessor :body
def initialize(body)
@body = body.to_h
end
def success?
true
end
def message
"#{objects.size} shipments were received."
end
def objects
orders = body['Order'].is... |
class QueueManager
def initialize(queue_name, visibility_timeout = 60)
@queue_name = queue_name
@visibility_timeout = visibility_timeout
end
def send_message(message_data)
client.send_message({queue_url: queue_url, message_body: message_data })
end
def receive_message
client.receive_message(... |
require 'test_helper'
class AuthorPhotosControllerTest < ActionController::TestCase
def test_should_get_index
get :index
assert_response :success
assert_not_nil assigns(:author_photos)
end
def test_should_get_new
get :new
assert_response :success
end
def test_should_create_author_photo
... |
require 'byebug'
class KnightPathFinder
def initialize(pos)
@init_pos = pos
@visited_moves = [pos]
end
def self.valid_moves(pos)
ans = []
numbers = (-2..2).to_a - [0]
numbers.each do |i|
numbers.each do |j|
if i.abs + j.abs == 3
current = [pos[0] + i, pos[1] + j]
... |
class Address < ApplicationRecord
belongs_to :user
validates :postal_code, presence: true, format: { with: /\A\d{7}\z/ }
validates :address, presence: true
end
|
class PageCollection
include Her::JsonApi::Model
use_api PUB
collection_path "/api/page_collections"
# temporary while we are not yet sending jsonapi data back to core properly
include_root_in_json true
parse_root_in_json false
def self.new_with_defaults(attributes={})
page = Page.new({
title... |
require 'rails_helper'
RSpec.describe UserDecorator do
it 'returns a full address' do
user = create(:user, street_address: '1313 disneyland dr', city: 'anaheim', state: 'ca', zip: '92802').decorate
expect(user.full_address).to eq("1313 disneyland dr, anaheim, ca 92802")
end
end
|
require 'faraday'
require 'circuitbox/faraday_middleware'
class StudentsController < ApplicationController
include StudentsHelper
before_action :set_student_id, only: [:show, :edit, :update, :destroy]
before_action :set_conn
before_action :set_conn_with_department
def index
begin
... |
class Admin::StoresController < Admin::BaseController
def index
@stores = Store.admin_alpha
end
def edit
@store = Store.find(params[:id])
@store_items = @store.items
end
def update
@store = Store.find(params[:id])
if @store.skill_set.update(skill_set_params)
if @store.update(store_... |
FactoryBot.define do
factory :user, class: CamaManager.get_user_class_name do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
email { Faker::Internet.unique.email }
username { Faker::Internet.unique.user_name }
password { '12345678' }
password_confirmation { '12345678... |
class BookingSerializer < ActiveModel::Serializer
attributes :id, :confirmation_number, :rate, :tax, :total, :created_at, :hotel, :is_booked, :is_cancelled, :is_no_show
def hotel
HotelSerializer.new(object.hotel) if object.hotel.present?
end
end
|
require 'rails_helper'
RSpec.describe OrderAddress, type: :model do
before do
@order_address = FactoryBot.build(:order_address)
end
describe '購入登録' do
context '購入がうまくいくとき' do
it 'すべての値が正しく入力されていれば登録できる' do
expect(@order_address).to be_valid
end
it 'buildingが入力されていなくても登録できる' do
... |
FactoryGirl.define do
factory :address do
city nil
street "MyString"
addressable_id nil
addressable_type "MyString"
number 1
district "MyString"
complement "MyString"
zipcode "MyString"
end
end
|
class ChangeGamesPlayerNamesToPlayerIds < ActiveRecord::Migration[4.2]
def up
add_column :games, :winner_id, :integer
add_column :games, :loser_id, :integer
Game.all.each do |game|
game.winner_id = Player.find_by_name(game.winner_name).id
game.loser_id = Player.find_by_name(game.loser_name).i... |
class BooksController < ApplicationController
include SessionsHelper
before_action :set_book, only: [:show, :edit, :update, :destroy]
before_action :deny_access_for_non_authors, only: [:edit, :update, :destroy]
before_action :deny_access_for_non_admin, only: [:create, :new]
# This runs before every method call... |
class Question < ActiveRecord::Base
extend FriendlyId
friendly_id :title, use: :slugged
belongs_to :user
has_many :answers, dependent: :destroy
has_many :categorizations, dependent: :destroy
has_many :categories, through: :categorizations
has_many :likes, as: :likable
has_many :likers, through: :like... |
class Potentialclient < ActiveRecord::Base
validates :email, :presence => {:message => 'Email cannot be blank, Mail not sent'}
validates :fullname, :presence => {:message => 'Full Name cannot be blank, Mail not sent'}
validates :fullname, :length => {:in => 6..60}
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class UsersController < ApplicationController
def index
@users = User.all
end
def new
@user = User.new
end
def create
user = User.create(user_params)
sign_in user
redirect_to '/'
end
def activate
@user = User.find(params[:user_id])
@user.is_admin = 'true'
@user.save
... |
set :shared_paths, {'assets' => 'public/assets'}.merge(shared_paths)
namespace :vlad do
namespace :assets do
desc 'Remove compiled assets'
remote_task :clean do
run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake_cmd} assets:clean"
end
desc 'Compile all the configured assets'
remote_t... |
class NexmoAppController < ApplicationController
skip_before_action :set_nexmo_app, only: [:setup, :create, :reuse, :reset]
def regenerate_keys
key = OpenSSL::PKey::RSA.generate(2048)
if !@nexmo_app.update(public_key: key.public_key, private_key: key.to_s)
redirect_to app_url, alert: 'Could not rege... |
class ResourceHistory < ActiveRecord::Base
belongs_to :user
belongs_to :historable, polymorphic: true
ACTION_TYPES = {
create: 'create',
update: 'update',
delete: 'delete',
status_change: 'status_change'
}
validates :action_type, presence: true, inclusion: ACTION_TYPES.values
validates :... |
# frozen_string_literal: true
RSpec.describe Sandbox::Interactors::Articles::Publish do
let(:repo) { Sandbox::App.container['repositories.articles'] }
subject { Sandbox::App.container['interactors.articles.publish'] }
context 'when given article does not exist' do
it 'fails with not_found' do
res = su... |
class Message < ActiveRecord::Base
belongs_to :user
attr_accessible :body, :subject, :user_id
after_save :send_message_email
def send_message_email
MessageMailer.email_message(self).deliver
end
end
|
class PostsController < ApplicationController
before_action :logged_in_user, only: [:new, :create]
def new
@user = current_user
end
def create
@post = Post.new(post_params)
if @post.save
@post.update_attribute(:author, author_param)
flash[:success] = "You just created a new post"
redirect... |
class PatternExpander
def initialize(directories, file_pattern)
@directories = directories
@file_pattern = file_pattern
end
# Give the list of files that match the pattern in the given base directories
# Files are searched recursively
def expand
@directories.map do |directory|
files_to_inde... |
class Student < ActiveRecord::Base
def to_s
self.first_name + " " + self.last_name # to Print out the full name
end
end |
FactoryGirl.define do
factory :pricing_map, aliases: [:pricing_map_present] do
effective_date Time.current
full_rate 500.0
quantity_type "Each"
trait :future do
effective_date Time.current + 1.day
end
trait :past do
effective_date Time.current - 1.day
end
factory :prici... |
require 'spec_helper'
require 'lib/facter/jenkins'
describe Jenkins::Facts do
describe '.jenkins_home' do
subject(:home) { described_class.jenkins_home }
it 'should resolve to ~jenkins' do
expect(Facter::Util::Resolution).to \
receive(:exec).with('echo ~jenkins').and_return('/var/lib/jenki... |
class AddMoreFieldsToUser < ActiveRecord::Migration[5.1]
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
remove_column :users, :name, :string
add_column :users, :dob, :date
add_column :users, :gender, :string
add_column :users, :mobileno, :string
a... |
# ================================================================================
# Part:
# Desc:
# ================================================================================
class Testimonial
include Mongoid::Document
include Mongoid::Timestamps
# ... |
class AddApplicationIdToGlassaryTerms < ActiveRecord::Migration
def change
add_column :tr8n_glossary, :application_id, :integer
add_column :tr8n_glossary, :language_id, :integer
add_index :tr8n_glossary, [:application_id], :name => :tr8n_g_a
end
end
|
class DonationOrdersController < ApplicationController
before_filter :find_charity, :only => [:create]
before_filter :find_campaign, :only => [:create]
ssl_required :create
layout 'bootstrap/campaigns'
def create
@title = @campaign.name
@donation_order = DonationOrder.new(params[:donation_order])
... |
json.array!(@trials) do |trial|
json.extract! trial, :title, :description, :sponsor, :country, :focus
json.url trial_url(trial, format: :json)
end
|
require 'spec_helper'
describe UserController do
let :member do
FactoryBot.create(:member, username: 'bulkneets', password: 'mala', password_confirmation: 'mala')
end
let :rss_mime_type do
Mime::Type.lookup_by_extension(:rss).to_s
end
let :opml_mime_type do
Mime::Type.lookup_by_extension(:opml... |
require 'progressbar'
require 'clinical_tcga/ClinicalMetadata'
module ClinicalTCGA
#
# class to retrieve desired metadata properties given a list of samples, and the features to collect
#
class RetrieveSamples
def initialize(sampleLst, featureLst, are_uuids=false)
@h = Hash.new
@sampleLst = s... |
class User
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def recipe_card
RecipeCard.all.select do |list|
list.user == self
end
end
def recipes
recipe_card.map do |list|
list.recipe
end
end
def... |
class Chapter < ApplicationRecord
belongs_to :books
end
|
class Song
attr_accessor :name, :artist_name
@@all = []
def self.all
@@all
end
def self.create
song = Song.new
@@all << song
return song
end
def self.new_by_name(name)
song = Song.new
song.name = name
return song
end
def self.create_by_name(name)
song = self.new
... |
#! /usr/bin/env ruby
# goodfriday.rb: Written by Tadayoshi Funaba 1998, 2000, 2002
# $Id: goodfriday.rb,v 1.1 1998-03-08 18:44:44+09 tadf Exp $
require 'date'
def easter(y)
g = (y % 19) + 1
c = (y / 100) + 1
x = (3 * c / 4) - 12
z = ((8 * c + 5) / 25) - 5
d = (5 * y / 4) - x - 10
e = (11 * g + 20 + z - x... |
Rails.application.routes.draw do
resources :companies
resources :clients
resources :cars, path: :carros, path_names: { new: :cadastrar, edit: :editar }
resources :motorcycles, path: :motos, path_names: { new: :cadastrar, edit: :editar }
root to: 'pages#index'
# For details on the DSL available within this... |
FactoryGirl.define do
factory :plan_year do
start_date Date.new(2016,1,1)
end_date Date.new(2016,12,31)
fte_count 1
pte_count 1
employer
trait :overlapping_dates do
start_date Date.new(2016,2,1)
end_date Date.new(2017,1,31)
end
trait :renewal_plan_year_dates do
start... |
# encoding: utf-8
module Pakman
class Fetcher
include LogUtils::Logging
def fetch_pak( manifestsrc, pakpath )
start = Time.now
uri = URI.parse( manifestsrc )
logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
dirname = File.dirname( uri.path )
... |
class Product < ApplicationRecord
has_many :product_contents
has_many :pieces, through: :product_contents
has_many :restock_reports
end
|
module Merchant
class MerchantSubCategory < ActiveRecord::Base
attr_accessible :merchant_store, :sub_category
validates_presence_of :merchant_store, :sub_category
belongs_to :merchant_store
belongs_to :sub_category, :class_name => Merchant::Baseinfo::SubCategory
validates :sub_category_id, :uniqu... |
=begin
Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: Apache 2.0
http://www.apache.org... |
class Squadron < ActiveRecord::Base
has_many :authors
attr_accessible :name, :patch, :nickname
end
|
class InviteRequestAcceptor
def initialize(invite_request, acceptor)
@invite_request = invite_request
@acceptor = acceptor
@tournament = invite_request.tournament
@user = invite_request.user
end
def accept
@tournament.with_lock do
@invite_request.lock!
return if @invite_request.co... |
class CreateExchangeInfos < ActiveRecord::Migration[5.2]
def change
create_table :exchange_infos do |t|
t.integer :transfer_id
t.decimal :sending_amount
t.decimal :receiving_amount
t.string :currency_from
t.string :currency_to
t.decimal :exchange_rate
t.timestamps
en... |
# input: a number
# output: the sum of all the multiples of that number, not including the given number
# create an array holding all of the numbers from 2..n-1
# iterate over that array with map, to reveal a new array
# if x is not a multiple of n, delete from array
# once iteration is finished, add all of those numb... |
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
before_filter :allow_cross_domain_access
respond_to :html, :json
after_filter :set_xsrf_token_cookie
skip_befor... |
class FontMaterialIcons < Formula
version "3.0.1"
sha256 "722e3b09121b82a3746f3da2ecd3a2db8d7d24153b8433324315695a45f06a90"
url "https://github.com/google/material-design-icons/archive/#{version}.zip", verified: "github.com/google/material-design-icons/"
desc "Material Icons"
homepage "https://google.github.i... |
require 'site_prism'
require 'capybara/cucumber'
class QuestionsPage < SitePrism::Page
set_url 'http://rahul.domain4now.com/questions/new'
element :title, '[id = "question_title"]'
element :content,'[id = "question_content"]'
element :topic,'[id = "question_topic"]'
def new_question
question.click
... |
RSpec.describe Robot do
let(:robot) {Robot.new(1,1, "EAST")}
it 'report' do
expect(robot.report).to match('1, 1, EAST')
end
context 'move' do
let(:robot) {Robot.new(1,1, "SOUTH")}
subject { robot.move; robot.report}
it 'to south' do
should match('1, 0, SOUTH')
end
it 'to north... |
class Contact < CouchRest::ExtendedDocument
view_by :email,
:map =>
"
function(doc) {
if(doc['couchrest-type'] == 'Contact') {
emit(doc.email, null);
}
}
"
view_by :groups,
:map =>
"
function(doc) {
if(doc['couchrest-type'] == 'Contact') {
doc.groups.forEach(
... |
require 'spec_helper'
describe RootController do
before {
I18nStrategy.strategy = I18nStrategy::Strategy
I18nStrategy.available_locales = %w[en ja fr]
}
describe 'GET /' do
context 'with no preferred language' do
before { get :index }
it {
expect(response.body).to be == 'en'
... |
require 'rest-client'
require 'nokogiri'
require 'json'
module Correios
POST_URL = "http://websro.correios.com.br/sro_bin/txect01$.QueryList"
def self.get tracker_no
params = "P_ITEMCODE=&P_LINGUA=001&P_TESTE=&P_TIPO=001&P_COD_UNI=#{tracker_no}&Z_ACTION=Search"
response = RestClient.post POST_URL, para... |
# 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
class RepositoriesController < ApplicationController
def index
@repositories = current_user.repositories
end
def show
@repository = Repository.find(params[:id])
if @repository.user == current_user
render :show
else
redirect_to root_path, notice: "you can only view your own repos!"
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Feedback, type: :model do
it 'requires description' do
feedback = Feedback.new(target_page: '/somewhere')
expect(feedback).to be_invalid
expect(feedback.errors).to include(:description)
end
it 'requires target_page' do
feedback... |
require 'spec_helper'
describe PushBuilder::APS do
subject(:aps) { described_class.new }
describe '#badge=' do
it 'raises for non numeric values' do
expect { aps.badge = 'test' }.to raise_error(PushBuilder::TypeError)
end
it 'accepts numeric strings' do
aps.badge = '123'
aps.badge.s... |
module OAuth2
module Auth
module Server
module Controllers
module Helpers
extend ActiveSupport::Concern
included do
helper_method :current_token, :current_client
end
def current_token
@current_token
end
def curren... |
# Keep track of which agency ultimately created each series/record in the system
# by propagating the agency relationship from parents to children in the tree.
#
# Each record winds up with a 'creating_agency' ref.
#
module CreatingAgency
module ResourceCreation
def self.included(base)
base.extend(ClassMe... |
require 'rails_helper'
RSpec.describe LinksController, type: :controller do
describe "links#index action" do
it "should show the main page with a list of programming links submitted by users" do
get :index
expect(response).to have_http_status(:success)
end
end
describe "links#new action" do
... |
class EARMMS::UserSettingsGroupEditController < EARMMS::ApplicationController
helpers EARMMS::GroupHelpers
get '/:id' do |cid|
unless logged_in?
flash(:error, "You must be logged in to access this page.")
next redirect('/auth')
end
@user = current_user
@profile = EARMMS::Profile.for_us... |
require "spec_helper"
describe QingGroup do
it_behaves_like "has a uuid"
let(:form) { create(:form, question_types: [["text", "text", "text"]]) }
it "should return a list of groups" do
group = create(:qing_group, form: form, ancestry: form.root_group.id)
expect(form.child_groups.count).to eq(2)
end
... |
class SummaryController < ApplicationController
def create
@summary = ''
if params[:text] != ''
@summary = generate_summary(params[:text])
else
@summary = "Nothing is here."
end
end
def show
end
private
def generate_summary(text)
sentences = text.gsub(/\s+/, ' ').strip.spli... |
require 'spec_helper'
describe Puppet::Type.type(:postfix_master) do
it 'has :name, :service & :type as its keyattributes' do
expect(described_class.key_attributes).to eq([:name, :service, :type])
end
describe 'when validating attributes' do
[:name, :service, :type, :target].each do |param|
it "ha... |
# Backport of https://github.com/rails/rails/pull/18260.
#
# This allows job instances to customize their
# deserialization, which we use to implement
# job retries.
if ActiveJob::Base.method_defined?(:deserialize)
raise 'Rails 5 backport in lib/ext/active_job/base.rb no longer necessary.'
end
module ActiveJob
cl... |
class Contact < ApplicationRecord
belongs_to :user
belongs_to :company
# contact must be present
validates :name, :presence => true, :uniqueness => true
end
|
class RemoveQuestionMarkFromReturned < ActiveRecord::Migration[5.1]
def change
rename_column :injuries, :returned?, :returned
end
end
|
class CgColunmExtraCostToUser < ActiveRecord::Migration[5.1]
def change
change_column :users, :extra_cost, :integer
end
end
|
# == Schema Information
#
# Table name: goals
#
# id :integer not null, primary key
# title :string(255)
# notes :text
# due_date :date
# contact_id :integer
# created_at :datetime
# updated_at :datetime
#
class Goal < ActiveRecord::Base
belongs_to :contact
has_many :tasks, dep... |
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
setup do
@unique_seed = generate_test_seed
end
test "should authenticate users" do
existing_user = users(:one)
# Should reject requests with an unknown username.
credentials = {:username => 'unknownUser',
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.