text stringlengths 10 2.61M |
|---|
# U2.W5: Virus Predictor
# I worked on this challenge [by myself.]
# ----- Release 0: Run the code
# Look at the output. Look at the input (it's in the other file). Explain what the program is doing.
# The program uses population density and population to determine how many predicted deaths will result in a given... |
class AddCorrectFlagToStudentDeliveries < ActiveRecord::Migration
def change
add_column :student_deliveries, :correct, :boolean
add_index :student_deliveries, :correct
end
end
|
require 'rails_helper'
describe Exchange do
it { should validate_presence_of(:amount) }
it do
should validate_numericality_of(:period)
.only_integer.is_less_than_or_equal_to(250)
.is_greater_than_or_equal_to(1)
end
it { should validate_presence_of(:request_date) }
it { should belong_to(:user)... |
module Veda
module Enquiry
module Types
class Base
def fetch
raise 'Abstract method call'
end
def skeleton_request_object(update_params = {})
details_hash = {
:role => 'principal',
:business_name => "",
:business_abn => ... |
module ESModel
extend ActiveSupport::Concern
ES_NAMESPACE = ENV['ES_NAMESPACE'] || Settings.elasticsearch.namespace
included do
names = [table_name, Settings.elasticsearch.environment || Rails.env]
names.unshift(ES_NAMESPACE) unless ES_NAMESPACE.blank?
index_name names.join('_')
end
end
|
require "spec_helper"
require "jekyll"
require "jekyll-github-metadata/site_github_munger"
RSpec.describe(Jekyll::GitHubMetadata::SiteGitHubMunger) do
let(:source) { File.expand_path("test-site", __dir__) }
let(:dest) { File.expand_path("../tmp/test-site-build", __dir__) }
let(:github_namespace) { nil }
let(:u... |
# typed: strict
class Banal::Brainstorm < ApplicationRecord
acts_as_paranoid
has_many :comments, foreign_key: 'banal_brainstorm_id'
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ProjectsController, type: :controller do
context 'with logged in user' do
login_user
describe 'GET #index' do
let(:projects) { create_list(:project, 2, creator: @current_user) }
before { get :index }
it { expect(respons... |
class Admin::CategoriesController < ApplicationController
layout 'admin.html.erb'
before_action :require_login
def new
@project = Project.find_by(id: params['project_id'])
@projects = Project.all.order(:rank)
end
def create
Category.create(name: params['name'], project_id: params['project_id'])
redirect_... |
class User < ActiveRecord::Base
has_many :choices
has_many :places, through: :choices
end
# def find_through_hash(some_hash)
# where(user).first_or_create # or something
# end
#
# def self.parse_hash(some_hash)
# user = {}
# some_hash.each do |k,v|
# if k == 'id'
# user['user_number'] = v
# ... |
# frozen_string_literal: true
class UniformNotifier
class TerminalNotifier < Base
class << self
def active?
!!UniformNotifier.terminal_notifier
end
protected
def _out_of_channel_notify(data)
unless defined?(::TerminalNotifier)
begin
require 'termina... |
class DeliverablesController < ApplicationController
unloadable
layout 'base'
before_action :find_project, :authorize, :get_settings
helper :sort
include SortHelper
# Main deliverable list
def index
sort_init "#{Deliverable.table_name}.id", "desc"
sort_update 'id' => "#{Deliverable.table_name}.i... |
Rails.application.routes.draw do
root 'home#index'
resources :jobs
resources :users
resources :sessions, only: [:new, :create, :destroy]
end
|
{
:schema => {
"$schema" => "http://www.archivesspace.org/archivesspace.json",
"version" => 1,
"type" => "object",
"uri" => "/repositories/:repo_id/accessions",
"properties" => {
"uri" => {"type" => "string", "required" => false},
"external_ids" => {"type" => "array", "items" => {"typ... |
# 使い方が良くわからなかったのでとにかく使ってみる
# 指定したものを返す
def func
yield 1, 2, 3
end
class Test
def initialize(arr)
@arr = arr
end
# 実際に each を実装
def each
cnt = @arr.size
cnt.times{|i|
# 内容を列挙して1つずつ yield で返す
yield @arr[i]
}
end
end
func{|i,j,k| p i,j,k}
arr = Array.new
arr << 'yield'
arr << 'の使い方を'
arr << '使って'... |
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
first_name "Steve"
last_name "Rogers"
email
password "password"
role "stockholder"
factory :ironman do
first_name "Tony"
last_name "Stark"
end
end
factory :admin, class: User... |
class EventsController < ApplicationController
before_action :authenticate_user!
def index
if params[:login] == "success"
@login_success = "Successfully logged in!"
end
# show the current users's upcoming pending and accepted events and sort by time; create hash for each event with 3 keys - de... |
Rails.application.routes.draw do
#Superuser routes
mount RailsAdmin::Engine => '/superuser', as: 'rails_admin'
#Session Routes
devise_for :users, controllers: {registrations: 'user/registrations', sessions: 'user/sessions'}
#Public Routes
root to: "home#index"
get "portfolios/:portfolio_id", to: "portf... |
class Card
attr_accessor :suit, :face_value
def initialize(s, fv)
@suit = s
@face_value = fv
end
def pretty_output
"The #{face_value} of #{suit}. "
end
def to_s
pretty_output
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
['Hearts', 'Diamonds', 'Spades'... |
class VowelFinder
include Enumerable
def initialize(string)
# Di fatto la stringa è come se fosse un array di caratteri.
@string = string
end
def each
# Itera sulla stringa e tutte le volte che trova una vocale la torna.
@string.scan(/[aeiou]/) { |vowel| yield vowel }
end
end |
# frozen_string_literal: true
module Common
module Client
module MHVSessionBasedClient
extend ActiveSupport::Concern
def initialize(session:)
@session = self.class.client_session.find_or_build(session)
end
attr_reader :session
def authenticate
if session.expired?
... |
class ReporteSerializer < ActiveModel::Serializer
attributes :id, :zone, :location
def id
object.id.to_s
end
def location
[ object.location[0].to_f, object.location[1].to_f]
end
end
|
namespace :db do
namespace :calendars do
desc 'Permanently remove calendars deleted more than one day ago'
task :delete_old => :environment do
Calendar::Archive.delete_all(["deleted_at < ?", 1.day.ago]).tap do |num_rows|
Rails.logger.info("Permanently removed #{num_rows} deleted calendars.")
... |
require File.dirname( File.expand_path( __FILE__) ) + "/../lib/fractran.rb"
def first_hundred_seq
[2, 15, 825, 725, 1925, 2275,
425, 390, 330, 290, 770, 910,
170, 156, 132, 116, 308, 364,
68, 4, 30, 225, 12375, 10875,
28875, 25375, 67375, 79625, 14875, 13650,
2550, 2340, 1980, 1740, 4620, 4060,
10780, 12... |
module Scriptum
class UserSessionApp < Base
set :views, ["views/user_session"]
get '/new' do
@page_title = "Sign In"
erb :login
end
post '/create' do
if user = User.authenticate(params[:username], params[:password])
session[:user] = user.id
flash[:succe... |
# frozen_string_literal: true
require 'capybara/rspec'
# check if you have chromedriver installed
# chromedriver --version
# and install it like this if needed
# npm install chromedriver -g
Capybara.javascript_driver = :headless_chrome
Capybara.server = :puma, { Silent: true }
Capybara.server_port = 3001
# Do not f... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.define "mysql" do |mysql|
mysql.vm.network "private_network", ip: "192.168.100.8"
mysql.vm.provision "file", source: "sakila-schema.sql", destination: "sakila-schema.sql"
mysql.vm.pro... |
PROVIDERS.fetch(:quizlet).register_metric :answers do |metric|
metric.title = "Answer count"
metric.description = "Number of answered questions"
metric.block = proc do |adapter|
Datapoint.new(value: adapter.answer_count)
end
end
|
require SamfundetAuth::Engine.root.join('app', 'models', 'member')
class Member < ActiveRecord::Base
has_many :blogs, foreign_key: 'author_id'
has_one :membership_card, class_name: "BilligTicketCard", foreign_key: :owner_member_id
has_many :billig_purchase, foreign_key: :owner_member_id
def my_groups
if A... |
class ChangeColumnName < ActiveRecord::Migration[5.0]
def change
rename_column(:wishes, :price, :price_cents)
end
end
|
class Drink
attr_accessor :name
def initialize(name)
@name = name
end
def make
get_cup
get_water
prepare
end
def get_cup
puts "Getting cup for a #{name}"
end
def get_water
puts "Boiling water for #{name}"
end
def prepare
raise 'Abstract method called'
end
end
clas... |
module Radriar
module Roar::Representers
include Roar::Links
mattr_accessor :hypermedia
def represent(obj, *args, with: nil, represent: nil, context: nil)
representer = find_representer(obj, with)
options = {}
if params[:fields].present?
options[:include] = params[:fields].spli... |
# frozen_string_literal: true
module FileReaderTest
module Readline
def test_readline_with_custom_separator
file = file_containing("tahi+rua-toru*whā/")
assert_equal "tahi+", file.readline("+")
assert_equal "rua-", file.readline("-")
assert_equal "toru*", file.readline("*")
assert_... |
class Dock
attr_accessor :name,
:max_rental_time,
:revenue,
:active_boat_hours_rented,
:in_the_water,
:charges
def initialize(name, max_rental_time)
@name = name
@max_rental_time = max_rental_time
@revenue = 0
@active_... |
class WessStandings::Results
include Memorable::InstanceMethods
@@all = []
def call
greeting
full_rotation
end
def generate_list
self.races
end
def results_list
@race_list = WessStandings::Results.all
@race_list
end
def full_rotation_after_load
display_list
user_input_after_results_load
... |
module Issues
class QueryTaskIssues
prepend SimpleCommand
attr_reader :task_id, :filter_status
def initialize(task_id, filter_status = %w(open resolved))
@task_id = task_id
@filter_status = filter_status
end
def call
Issues::Issue.where(task_id: task_id, is_archived: false).
... |
require 'yaml'
module RapidRack
class Engine < ::Rails::Engine
isolate_namespace RapidRack
configure do
config.rapid_rack = OpenStruct.new
end
initializer 'rapid_rack.build_rack_application' do
config.rapid_rack = OpenStruct.new(configuration)
config.rapid_rack.authenticator = aut... |
require_relative './spec_helper'
require_relative '../lib/notification_pipe.rb'
describe NotificationPipe do
before(:each) do
Celluloid.shutdown
Celluloid.boot
end
let(:clear_msg) { double(text: 'something cleared', type: :clear)}
let(:problem_msg) { double(text: 'something broke', type: :problem)}
... |
class CreateSharespaces < ActiveRecord::Migration[5.1]
def change
create_table :sharespaces do |t|
t.string :space_type
t.text :description
t.float :cost
t.integer :overall_rating
t.integer :profile_photo
t.references :sharespace_venue, foreign_key: true
t.timestamps
... |
class Blog < ApplicationRecord
enum status: {draft: 0, published: 1}
# This is mixing in the FriendlyId class so that this model has access to its methods
# (as class methods - they would be instance methods if 'include' was used
# instead of 'extend')
extend FriendlyId
# friendly_id takes Blog's title... |
module FishTank
class Taxon::Fish < FishTank::Taxon
# Ugh
def description
return {
'UBERON_0001703' => [0, 10, 10, 10], # 'neurocranium'
'UBERON_0000970' => [3, 12, 3, 3], # 'eye'
'UBERON_0001708' => [1, 17, 5, 2], # 'jaw skeleton'
'UBERON_0002090' => [10, 10... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :event do
title "MyString"
description "MyText"
booking_information "MyText"
start_at { 1.hour.ago }
end_at { start_at + 6.hours }
location
end
end
|
# encoding: utf-8
# 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 applic... |
require("MiniTest/autorun")
require("minitest/rg")
require_relative("../class_b.rb")
class TestSportsTeam_B < MiniTest::Test
def setup()
@team = Team.new("win-less", ["Snoopy", "Lucy", "Linus", "Woodstock"], "Charlie Brown")
end
def test_team_name()
result = @team.team_name()
assert_equal("win-le... |
class MovieSerializer < ActiveModel::Serializer
attributes :title, :locationname, :address
has_many :movies
#this translates to json
end |
# -*- mode: ruby -*-
Vagrant.configure("2") do |config|
config.vm.box = "boxcutter/ol72"
# synced_folder is disabled. it requires a kernel module that is specific to a kernel.
# this module will not be there once the kernel is upgraded.
config.vm.synced_folder ".", "/vagrant", disabled: true
# ssh settings
... |
require './lib/shiftable'
require 'date'
class Decryptor
include Shiftable
attr_reader :current_date
def initialize
@current_date = (DateTime.now.strftime "%d%m%y").to_i
end
def find_cipher_index(cipher, key, date)
cipher_letters = cipher.chars
shift_arr = calculate_shift_based_on_character_ind... |
require 'cgi'
require 'nokogiri'
require 'open-uri'
require 'net/http'
require 'json'
module PdfExtract::Resolve
class Sigg
def self.find ref
resolved = {:doi => nil, :score => nil}
url = "http://search.crossref.org/dois?q=#{CGI.escape(ref)}&rows=1"
query = JSON.parse(open(url).read())
... |
class StockService
require 'net/http'
# has it changed between ruby 1.9 and 2.1 ?
# define stock symbol list, keep in cache (local variable) or db?
# keep in class variable in StockService, get with an action?
# public
# full public method for getting stock values
def self.request(*stocks)
res = self.req... |
require "uri"
# Solution to problem from page 37 (p73 in PDF) of Web application hacker
# handbook
# scrub method as specified by the problem
def scrub(str)
p im = str.gsub(/<script>/, "") # 1. remove <script>
p im = im[0...50] # 2. truncate to first 50 chars
p im = im.gsub(/("|')/, "") # 3. r... |
class Department < ActiveRecord::Base
has_many :groups
has_many :students
end
|
# ResultExt
# Provides a helpful method wrapper around Dry::Monad::Result objects
module ResultExt
include Dry::Monads[:result]
# ResultExt#fmap_left
# Takes two arguments:
# a result, Success(T) | Failure(U)
# a map function, Fn(U) -> V
# and returns:
# a result, Success(T) | Failure(V)
# Works ... |
require 'formula'
class Tmux19a1 < Formula
homepage 'https://github.com/markeissler/tmux-19a1'
url 'http://dl.bintray.com/markeissler/homebrew/tmux-19a1/tmux-19a1.tar.gz'
sha256 '2e187f02411ce6c3247f75223e62db24ae03215d8da452b4448d3fdc0d6f0d03'
bottle do
root_url 'http://dl.bintray.com/markeissler/homebre... |
#
# project.rb
# macistrano
#
# Created by Pom on 25.04.08.
# Copyright (c) 2008 __MyCompanyName__. All rights reserved.
#
require 'osx/cocoa'
require 'hpricot'
require 'notification_hub'
require 'host'
class Project < OSX::NSObject
include NotificationHub
notify :stage_loaded, :when => :stage_tasks_loaded
... |
require "rails_helper"
describe SubscriptionPlan do
describe "#hours_amount" do
context "with hours specified" do
let(:plan) { described_class.new(units: :hours, amount: 5) }
it "calculates correct amount of hours" do
expect(plan.hours_amount).to eq 5
end
end
context "with day... |
class AddWishesCountOnProposal < ActiveRecord::Migration[5.0]
def change
add_column :proposals, :wishes_count, :integer, default: 0
end
end
|
# frozen_string_literal: true
class ImportV2 < BaseCommand
def self.perform_task
new.call_with_transaction
end
COMBO_ZONES = {
"in/mh/greater-mumbai": {
name: "Mumbai",
category: "district",
maintainer: "bot@covid19zones.com",
unit_code_changes: %w... |
require 'spec_helper'
describe "teams/show" do
before(:each) do
mock_geocoding!
@sport = FactoryGirl.build(:sport)
@location = FactoryGirl.build(:location)
@league = FactoryGirl.build(:league)
@conference = FactoryGirl.build(:conference)
@division = FactoryGirl.build(:division)
@affiliati... |
#!/usr/bin/ruby
=begin
Finds the sum of digits of 100!.
=end
# Computes factorial function.
#
def factorial(n)
base = 1
n.downto(1) { |val| base *= val }
return base
end
# Here we extend the Array class so that [...].sum works!
# Once this is added, it is possible to run this statement: [1,2,3].sum => 6.
#
cl... |
class Brewery < ApplicationRecord
include RatingAverage
validates :name, presence: true, allow_blank: false
validates :year, numericality: { greater_than_or_equal_to: 1042,
less_than_or_equal_to: lambda { Time.current.year }.call ,
only_intege... |
require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
self.split(/[.?!]+/).count
# + in regex just means "one or more" of something, though it binds to the immediate set, ... |
class Show < ActiveRecord::Base
has_many :characters
has_many :actors, through: :characters
belongs_to :network
def actors_list
actorNames = []
self.characters.each do |i|
actorNames << i.actor.full_name unless actorNames.include?(i.actor.full_name)
end
actorNames
end
end |
class CreatePlanTags < ActiveRecord::Migration[5.1]
def change
create_table :plan_tags do |t|
t.integer :plan_id, null: false
t.integer :tag_id, null: false
t.timestamps
end
add_index :plan_tags, [ :plan_id, :tag_id ], name: "ui_plan_tags_01", unique: true
end
end
|
class Electricalexpense < ActiveRecord::Base
validates :amount , presence: true
validates :month , presence: true
end
|
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Multiple Equip Types
# Author: Kread-EX
# Version 1.01
# Release date: 20/03/2012
#
# Made for Hesufo.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#--------------------------------------------... |
require 'rails_helper'
RSpec.describe User do
describe 'properties' do
it { should validate_presence_of(:name) }
it { should_not allow_value('test@test').for(:email) }
it { should_not allow_value('ruby').for(:email) }
it { should allow_value('mai@gmail.com').for(:email) }
it { should have_secure_... |
class Player
attr_accessor :name, :life_points
# L'utilisateur créé le personnage robot en indiquant son nom
def initialize(player_name)
@name = player_name
@life_points = 10
end
# Méthode qui affiche les points de vie du joueur
def show_state
print "#{name} a #{life_points} points de vie."
if @life_po... |
require "test_helper"
require "nokogiri"
class CvFormatTest < VitaeServerTestCase
test "a CV has a well formatted vcard" do
with_project :default do
get '/arthur_gunn'
assert last_response.ok?
assert_select ".vcard" do
assert_select "h1#title.fn", "Arthur Gunn"
assert_se... |
class AddVisitEntryTypeToVisits < ActiveRecord::Migration[5.2]
def change
add_column :visits, :visit_entry_type, :integer
add_column :visits, :event_id, :string
add_column :visits, :qrcode_id, :string
end
end
|
class SessionsController < ApplicationController
skip_before_action :verify_authenticity_token, :only => [:callback]
def new
@authhash = session['authhash']
redirect_to session_path unless @authhash
end
def show
end
def create
@authhash = session['authhash']
if params[:commit] =~ /cancel/... |
#!/usr/bin/ruby
require 'set'
require './microtest'
def completion_time(edges, num_workers, overhead)
pending_steps = edges.flat_map(&:itself).uniq
total_secs = 0
in_progress = []
done = []
until pending_steps.empty?
# Make sure each worker has something to do, if possible
(num_workers - in_progress.length... |
class AddSynonymsToPlants < ActiveRecord::Migration
def change
add_column :plants, :synonyms, :string
add_column :plants, :lat_synonyms, :string
end
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
subject(:user) do
FactoryBot.build(:user, username: "Koy", password: "hotsauce")
end
it { should validate_presence_of(:username) }
it { should validate_presence_of(:password_digest) }
it { should validate_length_of(:password).is_at_least(6) ... |
name 'effortless_migration'
maintainer 'Matt Ray'
maintainer_email 'matt@chef.io'
license 'Apache-2.0'
description 'Manages converting to Effortless Audit and Infra patterns.'
version '0.1.0'
chef_version '>= 12.0' # oof
# Linux & Windows only
depends 'habitat', '~> 2.2'
source_url 'https://github.com/mattray/effortl... |
class AddNameToJobqueues < ActiveRecord::Migration[5.0]
def change
add_column :jobqueues, :name, :string, null: true
add_index :jobqueues, :name
# Populate queue name with queue arn logical name
Jobqueue.find_each do |jq|
jobqueue_name = jq.arn.split(':').last
jq.name = jobqueue_name
... |
require_relative "./shared/assembunny"
def sequence(&generator)
Enumerator.new do |yielder|
n = 0
loop do
yielder.yield generator.call(n)
n += 1
end
end
end
# There are a handful of false positives if you set this too low.
SIGNAL_CUTOFF = 8
CLOCK_SIGNAL = sequence { |i| i.even? ? 0 : 1 }.f... |
require 'uri'
class HttpRequest
def initialize(method, uri, headers)
@method = method
@uri = uri
@headers = headers
end
def self.build(stream)
first_line = stream.gets
method, uri = first_line.split(' ')
headers = {}
while ((line = stream.gets))
break if line.strip.empty?
... |
When(/^I start the timer countdown$/) do
click_button 'TIMER'
click_button 'ENTER'
end
When(/^I set the timer to "(.*?)"$/) do |timer|
click_button 'SET'
click_button 'TIMER'
timer.split('').each { |i| click_button i unless i == ':' }
click_button 'ENTER'
# Hit Timer to get the time to display
clic... |
# frozen_string_literal: true
require 'rails_helper'
describe '管理画面:アカウント検索', type: :system do
context 'ログインしているとき' do
let!(:user) { FactoryBot.create(:user, :normal) }
before do
sign_in_as(login_user)
visit admin_users_path
end
context '権限が not_administrator のとき' do
let(:login_u... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "benoki" do |node|
config.vm.box = "bento/ubuntu-18.04"
config.vm.network "public_network", ip: "192.168.11.31"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--nictype1",... |
module Ruhax
# Parse function's args
class ArgsParser < MasterParser
attr_reader :variables
# constructor
def initialize(node)
@node = node
@content = ""
@variables = []
end
def parse
if @node.children.length == 0
return
end
@node.children.each_... |
class Employee<BaseClass
attr_reader :id
attr_accessor :name,:salary
end |
class Team < ActiveRecord::Base
attr_accessible :name, :competition_id, :members_attributes
belongs_to :competition
has_many :members, :order => "id ASC"
accepts_nested_attributes_for :members
validates_presence_of :name
end
|
class Region < ActiveRecord::Base
has_many :fund_regions, dependent: :destroy
end
|
require 'spec_helper'
describe Restfulie::Client::Formatter::Xml do
before :all do
full_json = IO.read(File.dirname(__FILE__) + '/full_xml.xml')
@xml = Restfulie::Client::Formatter::Xml::Driver.new.unmarshal(full_json)
end
describe "XML read" do
it "should be able to read a XML object in many ways... |
class Product < ActiveRecord::Base
validates :name, :presence => true
validates :description, :presence => true
validates :month, :presence => true
has_attached_file :image, :styles => { :medium => "450x450#", :thumb => "250x250#" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_ty... |
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
feature "Legacy Node URLs" do
scenario "loading the page with no query params" do
visit "/legacy_nodes"
current_path.should == root_path
end
scenario "loading the page with bogus query params" do
visit "/legacy_nodes?q=bogus... |
# frozen_string_literal: true
RSpec.describe StringCheese::Engine do
let(:engine) { described_class.new(vars, options) }
let(:vars) do
{
var_1: 1,
var_2: 2
}
end
let(:options) { {} }
describe 'data_repository.attr_data' do
context 'when accesses incorrectly' do
it 'is handled g... |
require 'spec_helper'
describe MeshKeyword do
describe '.find_all_by_pmid' do
fixtures :pmids_mesh_keywords, :mesh_keywords
it "should load mesh keywords for a single pmid" do
keywords = MeshKeyword.find_all_by_pmid(15253354)
keywords.length.should == 6
keywords.should be_include me... |
class KakeibosController < ApplicationController
def new
@kakeibo = Kakeibo.new
end
def create
@kakeibo = Kakeibo.new(kakeibo_params)
@kakeibo.user_id = current_user.id
if @kakeibo.save
if @kakeibo.is_kakeibo_status == true
redirect_to new_gacha_kakeibo_path
else
redir... |
class SearchesController < ApplicationController
def show
@query = params[:query]
@artists = Artist.text_search(@query)
@venues = Venue.text_search(@query)
end
end
|
XNova::Application.routes.draw do
devise_for :players
root "static_pages#index"
get "overview/index"
end
|
#!/usr/bin/env ruby
require "bundler/setup"
require "klue_lancer"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
require "pry"
# require "irb"
# IRB.... |
Given(/^vault "([^"]*)" is in the list of vaults$/) do |vaultname|
vaultid = C_Support.get_vault_id(vaultname)
assert Page_vaults .isVaultInList(vaultid),"#{vaultname} with id #{vaultid} was expected to be in the list of vaults: it was not"
end
When(/^I open vault "([^"]*)"$/) do |vaultname|
Page_vaults.openVaul... |
class CreateJobPostings < ActiveRecord::Migration[5.2]
def change
create_table :job_postings do |t|
t.integer :job_type_id
t.text :main_text
t.string :address
t.string :zip
t.string :phone
t.string :email
t.string :application_deadline
t.timestamps
end
end
en... |
json.progressions do
json.partial! 'api/v1/progressions/show', collection: @progressions, as: :progression
end
|
require 'socket'
require 'net/http'
require 'json'
require 'uri'
require "logman_rails/version"
require 'action_dispatch'
require 'logman_rails/log'
class Logman
def self.options
@@options
end
def self.options=(val)
@@options = val
end
class Rails
def self.default_ignore_exceptions
[].tap do |exc... |
class HomePage < SitePrism::Page
set_url '/'
elements :products, "[data-hook='products_list_item']"
elements :product_links, "[data-hook='products_list_item'] a"
element :search_field, "input#keywords"
element :search_dropdown, "select#taxon"
def search_for(query, scope='All departments')
... |
module HasMagickTitle
module ViewHelper
# Creates and HTML image tag with the options provided
def magick_title_for(record, options={})
opts = record.magick_title_options[:to_html].merge(options)
record.refresh_magick_title unless record.has_image_title?
return "[magick_title error]" unl... |
class ProductsController < ApplicationController
before_action :set_product, only: %i[ :create, :show, :edit, :update, :destroy ]
helper_method :profile
# GET /products or /products.json
def index
@products = Product.all
end
# GET /products/1 or /products/1.json
def show
@pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.