text stringlengths 10 2.61M |
|---|
require "rails_helper"
feature "Admin deletes comment" do
scenario "admin deletes comment succesfully" do
comment = FactoryGirl.create(:comment)
admin_user = FactoryGirl.create(:user)
admin_user.make_admin
sign_in_as(admin_user)
visit site_path(comment.review.site)
within('.comment-list') d... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#... |
require "elasticsearch/dsl"
class ProposalSearchDsl
include Elasticsearch::DSL
attr_reader :params, :current_user, :query_str, :client_data_type
def initialize(args)
@query_str = args[:query]
@client_data_type = args[:client_data_type] or fail ":client_data_type required"
@current_user = args[:curr... |
# Calculate the mode Pairing Challenge
# I worked on this challenge with Jack
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.
# 0. Pseudocode
# What is the input? array ... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
rescue_from StandardError, with: :render_unknown_error
rescue_from ActiveRecord::RecordNotFound, with: :render_missing
# handle finding invalidly formatted uuids; unnecessary with rails 4.2
rescue_from PG::InvalidT... |
class PasswordResetToken < ActiveRecord::Migration
def change
drop_table :password_reset_tokens
create_table :password_reset_tokens do |t|
t.string :token_digest, null: false
t.belongs_to :email_address, null: false
t.datetime :expires_at
t.timestamps
end
add_index :passwo... |
require 'spec_helper'
require 'kata-bank-ocr'
include KataBankOcr
describe OcrFile do
before :each do
@ocr_file = OcrFile.new("spec/files/many.txt")
end
it "can be instantiated" do
@ocr_file.should be_a OcrFile
end
describe :file_lines do
it "contains the text lines" do
@ocr_file.file_li... |
# frozen_string_literal: true
require 'sinatra/base'
require 'jiji/web/services/abstract_service'
module Jiji::Web
class IconImageService < Jiji::Web::AbstractService
options '/:icon_id' do
allow('GET,OPTIONS')
end
get '/:icon_id' do
content_type 'image/png'
[200, cacheable.merge({}),... |
class Brand < ApplicationRecord
has_many :favorites
has_many :reviews
has_many :brand_categories
has_many :categories, through: :brand_categories
has_many :nlps
has_many :news
include PgSearch::Model
pg_search_scope :search_by_name,
against: [ :name ],
using: {
tsearch: { prefix: true } #... |
# frozen_string_literal: true
require 'spec_helper'
describe 'resource_container_host_linux::docker' do
context 'configures docker' do
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
it 'installs docker' do
expect(chef_run).to create_docker_installation_package('default').... |
module ManagementConsultancy
class Supplier < ApplicationRecord
has_many :regional_availabilities,
foreign_key: :management_consultancy_supplier_id,
inverse_of: :supplier,
dependent: :destroy
has_many :service_offerings,
foreign_key: :management_consultancy... |
class MealServing
attr_accessor :times, :recipe
def initialize(hash)
@times = hash[:times]
@recipe = hash[:recipe]
end
end |
class CommentsController < ApplicationController
layout 'customer'
skip_before_action :ensure_authenticated_user
before_action :set_chat
def create
@comment = Comment.create! content: params[:comment][:content], chat: @chat
end
private
def set_chat
@chat = Chat.find(params[:chat_id])
end
e... |
require 'rails_helper'
RSpec.describe ApplicationHelper, type: :helper do
describe '#page_title' do
context '@titleが指定されていない場合' do
it 'デフォルトが返されること' do
stub_const('ApplicationHelper::APP_NAME', 'AnaLive')
expect(helper.page_title).to eq('AnaLive')
end
end
context '@titleが指定され... |
class Boulder < ActiveRecord::Base
validates :name, presence: true, length: { in: 2..45 }
belongs_to :block
belongs_to :sector
belongs_to :region
belongs_to :grade
end |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers => [:f... |
require 'narp/node_extensions.rb'
require 'narp/basic_extensions.rb'
module Narp
class JoinKeys < Treetop::Runtime::SyntaxNode
attributes FieldName
def sorted
text_value.strip.downcase =~ /(sorted)/
$1
end
def keys
myapp.fields.select{|s| field_names.detect{|d| d.value == s.name }}
end
... |
# frozen_string_literal: true
module LiteCable
INTERNAL = {
message_types: {
welcome: "welcome",
ping: "ping",
confirmation: "confirm_subscription",
rejection: "reject_subscription",
cancel: "cancel_subscription"
}.freeze,
protocols: ["actioncable-v1-json", "actioncable-unsu... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box_check_update = false
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
config.vm.synced_folder "./", "/vagrant"
config.vm.provision "shell", inline: <<-... |
class PagesController < ApplicationController
before_action :set_page, only: [:edit, :update, :destroy]
def show
@page = Page.find_by_path params[:id]
if @page.present?
render :show
else
raise ActiveRecord::RecordNotFound, 'Page not found.'
end
end
def new
@page = Page.new
en... |
# == Schema Information
#
# Table name: posts # 视频模型
#
# id :integer not null, primary key
# title :string # 视频标题
# url :string # 视频链接
# des :string # 视频描述
# published_at :dat... |
class Jobs::ExtractSequences < Jobs::AbstractJob
def do_perform
if params[:fasta_file_id].nil?
raise "Fasta File not provided"
return
end
fasta_file = FastaFile.find( params[:fasta_file_id] )
fasta_file.extract_sequences(params)
end
end
|
class IPTablesChain
attr_reader :name
attr_accessor :policy, :rules
def initialize name
@name = name
# the "undefined" policy for iptables
@policy = '-'
@rules = []
end
def add_rule rule
@rules << rule
end
end
class IPTablesTable
attr_reader :name... |
require 'game'
describe Game do
let(:game){Game.new(player)}
let(:player){double :player}
it 'should choose a weapon' do
game.pick_weapon
expect(["rock", "paper", "scissors"]).to include game.pick_weapon
end
it 'should choose rock and beat scissors' do
game.weapon = "rock"
... |
FactoryBot.define do
factory :category, class: "Category" do
category { "貝類" }
end
end
|
class RenameProductTypes < ActiveRecord::Migration
def change
rename_column :spree_products, :type, :product_type
end
end
|
require "minitest/autorun"
require "./lib/dice.rb"
class TestDice < Minitest::Test
def test_rolls_one_die
results = Dice::Roller.new("1d6").roll
assert_kind_of Array, results
assert_equal 1, results.length
results.each do |result|
assert_operator 1, :<=, result
assert_operator 6, :>=, res... |
class User < ApplicationRecord
has_many :votes
has_many :works, through: :votes
validates :username, presence: true
end
|
# frozen_string_literal: true
require 'bundler/setup'
require 'coveralls'
require 'orangetheses'
require 'pry-byebug'
require 'simplecov'
require 'webmock/rspec'
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
Coveralls.wear!
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start do
add_filt... |
require File.expand_path(File.dirname(__FILE__) + '/../acceptance_helper')
feature "Dashboard Comments" do
background do
log_in_as_administrator
@user_comment = FactoryGirl.create(:user_comment)
@anonymous_comment = FactoryGirl.create(:anonymous_comment)
end
scenario "show Comments" do
visit da... |
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.friendly.find(params[:id])
end
end |
class Api::DashboardsController < ApplicationController
before_action :require_logged_in
# GET /api/dashboard
def show
@dashboard = current_user.dashboard
@posts = @dashboard.followed_posts.page(params[:page])
render 'show'
end
def tags
@dashboard = current_user.dashboard
render json: @dashboard... |
class Listing < ActiveRecord::Base
include PgSearch
pg_search_scope :search_by_text, :against => {
:title => 'A',
:neighborhood => 'B',
:description => 'C'
}
validates :title, :description, :neighborhood, :start_date, :end_date, presence: true
belongs_to :user
has_many :favorites
has_many :u... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,:confirmable, :lockable,:timeoutable
#usernameを必須
validates :username, presence: true
... |
class Review < ApplicationRecord
#belongs_to :user
belongs_to :container
validates :content, :rating, presence: true
validates :rating, inclusion: {in: (1..5).to_a}
validates :container_id, presence: true
end
|
class Charactor
def self.classify(str)
str.gsub!('.',' .')
str.split(' ').map.with_index do |ele, idx|
raise ArgumentError if ele.size > 20
idx.odd? ? ele : ele.reverse
end.join(' ')
end
end
|
require 'spec_helper'
require_relative '../../models/errors/plan_inexistente_error'
require_relative '../../models/errors/edad_maxima_supera_limite_error'
require_relative '../../models/errors/edad_minima_no_alcanza_limite_error'
require_relative '../../models/errors/no_se_admite_conyuge_error'
require_relative '../..... |
require 'spec_helper'
describe User do
let(:user) { User.new }
subject { user }
it { should respond_to :locations }
describe "location association" do
let(:lat) { 43.086443 }
let(:lng) { -89.372817 }
let(:location) { Location.create(user: user,
latitude: lat,
... |
# A Nested Array to Model a Bingo Board SOLO CHALLENGE
# I spent [#] hours on this challenge.
# Release 0: Pseudocode
# Outline:
# Create a method to generate a letter ( b, i, n, g, o) and a number (1-100)
#fill in the outline here
=begin
create array containing B, I, N, G, and O
shuffle array and store 0th unit
... |
class Parcels
attr_accessor :height
attr_accessor :width
attr_accessor :depth
attr_accessor :weight
@@parcels = []
def initialize (height,width,depth,weight)
self.height = height
self.width = width
self.depth = depth
self.weight = weight
end
def volume
height * width * depth
end
def ... |
class FlowRecord < BinData::Record
endian :big
bit20 :smi_entity
bit12 :sflow_format
uint32 :flow_record_length
choice :flow_data, :selection => :sflow_format do
raw_packet 1
ether 2
ipv4_data 3
# ipv6_data 4
exten... |
require 'test/helper'
class ParserTest < Kss::Test
def setup
@scss_parsed = Kss::Parser.new('test/fixtures/scss')
@sass_parsed = Kss::Parser.new('test/fixtures/sass')
@css_parsed = Kss::Parser.new('test/fixtures/css')
@less_parsed = Kss::Parser.new('test/fixtures/less')
@multiple_parsed = Kss::P... |
class TwitterUser < ActiveRecord::Base
# Remember to create a migration!
has_many :tweets
validates :username, uniqueness: true
end
|
# frozen_string_literal: true
require "test_helper"
require "date"
module FuelSurcharge
class ColissimoTest < Minitest::Test
def test_time_period
nominal_case do
assert_equal "12-2018", @colissimo.time_period
end
failing_case do
assert_nil @colissimo.time_period
end
... |
#Transpose the matrix without extra matrix space
#for n*n
def transpose(a)
for i in 0..a.size-1
for j in 0..a[i].size-1
next if i==j
tmp = a[i]
a[i] = a[j]
a[j] = tmp
end
end
end
|
class Movie < ActiveRecord::Base
belongs_to :event
has_many :votes, dependent: :destroy
validates :event, presence: true
validates :url, presence: true
validates :title, presence: true,
uniqueness: {
scope: :event_id,
case_sensitive: false,
... |
class Setting < ActiveRecord::Base
belongs_to :blog
validates :blog_id, uniqueness: true
end
|
=begin
One's the old Ruby syntax while the other is the new one.
The first hash that was created used a symbol x as the key.
The second hash used the string value of the x variable as the key.
=end
|
class AdminMailer < ActionMailer::Base
default to: Proc.new { User.where("role = 'admin'").pluck(:email) },
from: "klinikmedifast@gmail.com"
def answer_admin_confirmation(answer)
@user = answer
mail(subject: "Новый ответ на вакансию")
end
def letter_admin_confirmation(letter)
@user = le... |
module ProductsHelper
def product_description(product)
if product.description == nil
return ("No description.").html_safe
else
return (product.description).html_safe
end
end
def product_photo(product)
if product.photo_url != "" && product.photo_url != nil
("<img src='" + product... |
describe 'Add maximum limited long text' do
before(:all) {
@too_long_text = 'Am%20banned%20cause%20fucked' * 74
@accepted_limit_text = 'Am%20banned%20cause%20fucked' * 73
}
let(:get_long_text){ get "?text=#{@too_long_text}" }
let(:get_limit_text){ get "?text=#{@accepted_limit_text}" }
it 'Returned ... |
class Question < ApplicationRecord
belongs_to :scenario
has_many :answers
validates :scenario_id, :question, :answer, :presence => true
end
|
module MotionBuild
class ObjectFileRule < FileRule
def destination
return nil unless output_extension
File.join(project.config.get(:build_dir_objects), relative_destination)
end
protected
def relative_source
if source.index(project.config.get(:build_dir_objects)) == 0
sourc... |
require('spec_helper')
describe('adding a new store', {:type => :feature}) do
it('allows a user to add new store') do
visit('/')
click_link('Add Store')
fill_in('name', :with =>'foot paradise')
click_button('Save')
expect(page).to have_content('Foot Paradise')
end
end
describe('adding a new br... |
# https://coderwall.com/p/u0x3nw
desc 'Pings PING_URL to keep a dyno alive'
task :wakeup do
require 'net/http'
if ENV['PING_URL']
message = "Pinging #{ENV['PING_URL']}..."
puts "\e[33m#{message}\e[0m"
uri = URI(ENV['PING_URL'])
response = Net::HTTP.get_response(uri)
puts "\e[32mDone!\e[0m"
p... |
Pod::Spec.new do |s|
s.name = 'test_podspec'
s.version = '1.0.0'
s.summary = "Payment kit extends the CNISDKCoreKit with payment functionality."
s.description = <<-DESC
Conichi SDK simplifies the use of Apple’s iBeacon technology with conichi's hardware. In only few step... |
class GuildInvitationValidator < ActiveModel::Validator
def validate(record)
@user = User.find_by_id(record.user_id)
@invited_user = User.find_by_id(record.invited_user_id)
@record = record
@record.errors.clear
validate_user
validate_invited_user
validate_duplication_of_guild_invitation un... |
class Ctools < Formula
desc "Software package for analysis of CTA data"
homepage "http://cta.irap.omp.eu/ctools/about.html"
url "http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.7.0.tar.gz"
# sha256 "7361351ef95be8f949815a0006df0867fda72c6a0ee6b9956b5340b3ae29764b"
depends_on "doxygen"
depends_on "g... |
class Ball
DEBUG_BALL_TRAJECTORY = true
BALL_RETURN_TIME = 1
RECT_DIRECTION_FACE = {
top: :bottom,
left: :right,
bottom: :top,
right: :left,
}
HALF_SIZE = BALL_SIZE / 2
# state
# ready, armed, launched, returning
attr_accessor :x, :y, :x_spd, :y_spd, :stat... |
require "geojson2image/version"
require "oj"
require "chunky_png"
module Geojson2image
class Convert
def initialize(json: nil, width: nil, height: nil, padding: nil,
background: nil, fill: nil, stroke: nil,
output: nil)
begin
@parsed_json = Oj.load(json)
@width = width || 500
... |
require 'rails_helper'
RSpec.describe Area, type: :model do
it "エリア名があれば有効な状態であること" do
expect(FactoryBot.build(:area)).to be_valid
end
it "エリア名がなければ不正な状態であること" do
expect(FactoryBot.build(:area, name:nil)).not_to be_valid
end
end
|
class Ability
include CanCan::Ability
def initialize(user)
if user.kind_of? Store
can :manage, Store, :id => user.id
can :manage, Ski, :store_id => user.id
can :manage, Snowboard, :store_id => user.id
elsif user.kind_of? Admin
can :manage, Admin
can :manage, Store
else
... |
require 'cassandra'
module CassandraObject
class Schemaless
class << self
DEFAULT_CREATE_KEYSPACE = {
'strategy_class' => 'SimpleStrategy',
'strategy_options' => 'replication_factor:1'
}
def create_keyspace(keyspace, options = nil)
stmt = "CREATE KEYSPACE #{keyspace} W... |
Rails.application.routes.draw do
resources :users, only: [:index, :show, :update, :create, :destroy] do
resources :contacts, :comments, only: [:index]
get 'authored_comments/' => 'comments#author_index'
end
# get 'users/' => 'users#index'
# get 'users/:id' => 'users#show'
# post 'users/' => 'users#cre... |
class AddDetailsToLessons < ActiveRecord::Migration
def change
add_column :lessons, :duration, :string
add_column :lessons, :minutes, :float
add_column :lessons, :days, :string
add_column :lessons, :frequency, :string
end
end
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe PokerHands::Hand::ThreeOfAKind do
it_behaves_like 'a hand'
it_behaves_like 'same type comparison' do
let(:left) { '7C 7D 2H 4D 7S' }
let(:right) { '6C 6D 2H 4D 6S' }
end
it_behaves_like 'same type comparison - equal ranking' do
le... |
## vim: set ft=rb:
module lexah.tools
class self
![public, static]
def create(errorType: String, error: String)
raise '{"type": $errorType, "error": $error}'
end
|
# portscan.rb
# Author: m-1-k-3 (Web: http://www.s3cur1ty.de / Twitter: @s3cur1ty_de)
# This Metasploit RC-File could be used to portscan the network via nmap or via the internal portscanner module
# it also uses the udp_sweep module and some more metasploit modules for getting more infos ans vulns
# RHOSTS is used fr... |
require 'csv'
module Uploader
class SentinelsParser < BaseParser
def parse
routes = []
files.each do |file|
routes << parse_routes(file.content)
end
routes.flatten
end
private
def parse_routes(raw_content)
routes = extract_data(raw_content)
routes.values... |
EvaluationSystem::Application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products... |
class AddDataSourceToTitle < ActiveRecord::Migration
def self.up
add_column :titles, :data_source, :text
end
def self.down
remove_column :titles, :data_source
end
end
|
class Manager::Edus::SchoolSerializer < ActiveModel::Serializer
root false
attributes :id, :name
has_many :items, serializer: Manager::Edus::UgroupSerializer
def items
gs = object.ugroups
if scope[:user].role_named? :manager
gs = gs.where("name != 'teacher'")
end
gs.paginate(scope[:pager]... |
#
# Cookbook Name:: omnibus
# Recipe:: ruby_windows
#
# Copyright 2013-2014, Chef Software, 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-... |
class OrderSummary < ActiveRecord::Base
has_and_belongs_to_many :products, :join_table => "order_summaries_products"
# search query
def self.search(query)
return where('FALSE') if query.blank?
conditions = []
search_columns = [ :account_name, :salesforce_url, :email, :... |
class User < ActiveRecord::Base
has_many :repositories
has_many :issues, through: :repositories
before_save :normalize_phone_number
# validates :url, uniqueness: true, presence: true, format: {with: /https:\/\/github.com/, message: "must be a valid github url"}
validates :phone_number, format: {with: /\d{3}-... |
class Book < ApplicationRecord
has_and_belongs_to_many :users, optional:true
has_many :pages
end
|
require 'csv'
require 'awesome_print'
#_______________ Grocery::Order _______________
module Grocery
class Order
attr_reader :id, :products
# Initialize class Order:
def initialize(id, products)
@id = id
@products = products
end
##################################################... |
require 'logging'
require 'shellwords'
module NvGpuControl
require_relative "nv_gpu_control/loggable"
require_relative "nv_gpu_control/util/stdout_logger"
require_relative "nv_gpu_control/nvidia_smi"
require_relative "nv_gpu_control/nvidia_settings"
require_relative "nv_gpu_control/nvidia_gpu"
@logger = ... |
# frozen_string_literal: true
require 'ruby-progressbar'
module Task
module Import
class << self
def title_basics(file)
require 'app/models/title_basics'
total_records = Task::Model::TitleBasics.total_records(file)
progressbar = init_progressbar(total_records)
Task::Model::... |
# frozen_string_literal: true
class UsersController < ApplicationController
load_and_authorize_resource
def index
@users = User.order(username: :asc)
set_start_end_dates
end
def show; end
def edit; end
def update
if User.find(current_user.id).has_role?(:admin) &&
@user.update(user_pa... |
ActiveAdmin.register Product do
config.per_page = 300
batch_action :add_to_category, form: -> {{
I18n.t("category") => Category.all.map{|t| [t.name, t.id]}
} } do |ids, inputs|
add_to_category(params["batch_action_inputs"],params["collection_selection"] )
#redirect_to collection_path
end
permit_params :... |
class CreateMimos < ActiveRecord::Migration
def change
create_table :mimos do |t|
t.references :user
t.string :title
t.integer :mimo_case
t.string :description
t.string :race
t.integer :size
t.string :address
t.string :coordinates
t.string :name
t.string... |
require 'rails_helper'
RSpec.describe StripeEventHandler do
let(:stripe_helper) { StripeMock.create_test_helper }
before { StripeMock.start }
after { StripeMock.stop }
it " sends an email on failed charge" do
set_up_stripe_event
StripeEventHandler.charge_failed_for_customer(@event.data.object.custom... |
class Race < ActiveRecord::Base
attr_accessible :name
has_many :dogs
end
|
# frozen_string_literal: true
require 'statistic_calcs/helpers/alias_attributes'
require 'statistic_calcs/helpers/array_validations'
require 'statistic_calcs/distributions/normal'
require 'statistic_calcs/distributions/t_student'
require 'statistic_calcs/data_sets/data_set'
require 'statistic_calcs/inference/errorable... |
def echo_with_yield(str)
yield
str
end
echo_with_yield {puts "world"} # => ArgumentError: wrong number of arguments
echo_with_yield("hello!") {puts "world"} # world
# "hello!"
echo_with_yield("hello", "world!") {puts "world"} # => Argument error
# Before we play around w... |
require '../util/infinite_grid.rb'
start = Time.now
input = File.read("input").chars
ROCKS = "-+L|O".chars
CAVE_WIDTH = 7
puts "Prep: #{Time.now - start}s"
def rock_info(r, x, y)
case r
when "-" then { area: [[x,y], [x+1,y], [x+2,y], [x+3,y]], width: 4 }
when "+" then { area: [[x+1,y], [x,y+1], [x+1,y+1], [x+2... |
module RelationshipMacros
def follow_show_different_stat(user)
click_button "Follow"
visit_profile_page
expect(user.following.count).to eq 1
end
def find_following_post_in_feed(micropost)
micropost
visit_home_page
expect(page).to have_content micropost.content
end
def find_one_to_follow(user)
user
... |
class Job < ActiveRecord::Base
has_many :candidates
belongs_to :user
validates :title, presence: true
validates :description, presence: true
scope :full_time, -> { where position_type: 'Full-time'}
scope :under_consideration, -> { where position_type: 'Part-time'}
scope :contract, -> { where position_type: '... |
# frozen_string_literal: true
module GeoPattern
class PatternPreset
private
attr_accessor :options
public
def initialize(options)
@options = options
end
%i[fill_color_dark fill_color_light stroke_color stroke_opacity opacity_min opacity_max].each do |m|
define_method m do
... |
class Page < ApplicationRecord
belongs_to :parent, :polymorphic => true
validates_presence_of :content, :parent_id
end
|
Then "I should be redirected" do
assert((300..399).include?(status), "Expected redirect, but was #{status}")
end
Then /^I should be redirected to (.+)$/ do |expected|
Then "I should be redirected"
if (md = /^\/(.+)\/$/.match(expected))
expected = Regexp.compile(md[1])
else
# try to translate to a path ... |
require 'rails_helper'
RSpec.describe SupplyTeachers::Journey, type: :model do
before do
Geocoder::Lookup::Test.add_stub(
'W1A 1AA', [{ 'coordinates' => [51.5149666, -0.119098] }]
)
end
after do
Geocoder::Lookup::Test.reset
end
context 'when following the school journey' do
subject(:j... |
require "./lib/too-soon-app"
require "test/unit"
class SequelTestCase < Test::Unit::TestCase
def run(*args, &block)
Sequel::Model.db.transaction(:rollback=>:always, :auto_savepoint=>true){super}
end
def test_password_confirmation
psyndl = User.new :username => 'psyndl', :email => 'jerry@kasigh.com', :pa... |
class MakeColumnsUnique < ActiveRecord::Migration
def change
# remove duplicates
#remove_dups('songs_users', Song.connection)
add_index :artists, :name, :unique => true, :name => 'by_name'
add_index :albums_artists, [ :artist_id, :album_id ], :unique => true, :name => 'by_album_and_artist'
add_i... |
# Pretentious - version
module Pretentious
VERSION = '0.2.4'
end
|
require "test_helper"
describe Work do
describe "name validations" do
it "upon creation or updating, it does not allow the title to be blank" do
test_work = Work.new(name: "")
refute(test_work.valid?)
end
it "upon creation or updating, it does not allow the title to be a dubplicate t... |
File.open(ARGV[0]).each_line do |line|
downcase, upcase, total = 0, 0, 0
line.gsub("\n", '').each_char do |char|
if char == char.downcase
downcase += 1
elsif char == char.upcase
upcase += 1
end
total += 1
end
puts "lowercase: #{ '%.2f' % ((downcase.to_f / total.to_f) * 100) } upperc... |
require 'csv'
class Registration < ApplicationRecord
# Extensions
searchable_columns %w[name email]
# Associations
belongs_to :event
# Validations
validates :name, presence: true
validates :email, presence: true #, format: { with: URI::MailTo::EMAIL_REGEXP }
validates :starting_at, presence: true
... |
class ChangeAddressToLocationStringInProviders < ActiveRecord::Migration
def change
rename_column :providers, :address, :location_string
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.