text stringlengths 10 2.61M |
|---|
require 'deep_clone'
module SudokuHelpers
def self.log(str)
puts str if LOGS
end
def self.logln(str)
puts str if LOGS
end
def self.print_board(board)
return unless board.is_a?(Array)
puts "Board: "
0.upto(SIZE_MATRIX - 1).each do |row|
0.upto(SIZE_MATRIX - 1).each do |column|
... |
FactoryGirl.define do
factory :skill_group do
name { Faker::Lorem.word }
description { Faker::Lorem.word }
sequence(:sequence)
end
end
|
# frozen_string_literal: true
class Cell
attr_accessor :row, :column, :grid, :content, :visited
def initialize(row, column, content)
@row = row
@column = column
@content = content
@visited = false
end
def visited?
@visited
end
def get_neighbors(grid)
... |
#
# Cookbook Name:: cuckoo
# Spec:: default
#
require 'spec_helper'
describe 'cuckoo::_virtualbox' do
context 'When all attributes are default, on ubuntu platform' do
cached(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '14.04')
runner.converge(described_recipe)
... |
module V1
class SimulationInputsController < SecuredController
before_action :ensure_user_completed_questionnaire!
before_action :ensure_user_selected_portfolio!
before_action :ensure_user_selected_expenses!
def index
if params[:ids] && params[:ids].present?
# Purposefully getting an a... |
module Pompeu
class AndroidSource
def initialize textDB, languages, default_language, android_path, target
@textDB = textDB
@languages = languages
@android_path = android_path
@default_language = default_language
@target = target
end
#imports data form android xml files to ... |
$LOAD_PATH << 'lib'
require 'reviewr'
class MockGit < Reviewr::Git
attr_accessor :commands
def initialize
@responses = {}
@commands = []
end
def execute(cmd)
@commands << cmd
@responses[cmd] || ""
end
def register(cmd, response)
@responses[cmd] = response
end
end
class MockPony
... |
require 'dry/container'
module Containers
class NotifierContainer
extend Dry::Container::Mixin
register 'osx_notifier' do
OsxNotifier.new
end
register 'say_notifier' do
SayNotifier.new
end
end
end
|
require File.expand_path(File.dirname(__FILE__) + "/product_base_page")
class ReviewLandingPage < ProductBasePage
def initialize
@success_message = "Congratulations! Your review has been published"
@message_element = "infomsg"
end
def success_message?
selenium.wait_for_element_to_present ... |
require File.expand_path('../redmine_test_patch', __FILE__)
module EasyExtensions
module GroupsControllerTestPatch
extend RedmineTestPatch
repair_test :test_edit do
get :edit, :id => 10
assert_response :success
assert_template 'edit'
assert_select 'div#tab-content-general'
ass... |
class Admin::CourtsController < Admin::ApplicationController
# GET /courts
# GET /courts.json
def index
@courts = Court.by_name
respond_to do |format|
format.html # index.html.erb
format.json { render json: @courts }
end
end
# GET /courts/1
# GET /courts/1.json
def show
@cour... |
class TopController < ApplicationController
def index
all_stories = UchigawaKun::Application.config.stories
@stories = Hash[all_stories.to_a.reverse]
end
end
|
## Dash Insert
# Have the function DashInsert(str) insert dashes ('-') between each two
# odd numbers in str. For example if str is 454793 the output should be
# 7547-9-3. Dont Count Zero as an odd number.
def DashInsert(str)
dashed = ''
str.chars.each_with_index do |char, i|
dashed << char
dashed << '-' if... |
#===============================================================================
# * Sprite_Projectile
#-------------------------------------------------------------------------------
# Projectiles in the game, game cannot be saved if any projectile exist
#=============================================================... |
class Specinfra::Command::Base::User < Specinfra::Command::Base
class << self
def check_exists(user)
"id #{escape(user)}"
end
def check_belongs_to_group(user, group)
"id #{escape(user)} | awk '{print $3}' | grep -- #{escape(group)}"
end
def check_belongs_to_primary_group(user, group)... |
module Stinger
module Schemas
class ComparesNumberOfColumnsAction
extend LightService::Action
expects :compare_columns, :to_columns, :compare, :report, :table
executed do |ctx|
next ctx if ctx.compare_columns.length == ctx.to_columns.length
if ctx.compare_columns.length < ctx.t... |
# Your Names
# 1) Steve Jones
#
# We spent 1.5 hours on this challenge.
# Bakery Serving Size portion calculator.
# Two stages of refactoring.
# 1. Readability. aka renaming variables.
# 2. Logic and redudancy. aka keeping your code DRY.
# You ALWAYS do readability first.
# Because it is unlikely to break anything... |
module GoogleApiHelper
@@GOOGLE_API_KEY = 'AIzaSyAi-E59X3_vswQ9fwc5xhxoZhPTYe_kARs'
@@BASE_URI = 'https://maps.googleapis.com/maps/api'
@@chunk_size = 30
def build_url(api, format)
"#{@@BASE_URI}/#{api}/#{format}"
end
def call_api(api, format, params)
url = build_url(api, format)
params = para... |
require_relative './base'
# rubocop:disable Naming/UncommunicativeMethodParamName
class Pltt::Actions::List < Pltt::Actions::Base
def run(my: false, label: nil)
require 'terminal-table'
table = Terminal::Table.new
gitlab_api.issues(scope: my ? 'assigned-to-me' : 'all', label: label).each do |issue|
... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :message do
content { Faker::Lorem.paragraph(5) }
service
status
end
end
|
# frozen_string_literal: true
def template(src_file, dist_file)
if src_file_path = template_file(src_file)
src_file_string = StringIO.new(ERB.new(File.read(src_file_path)).result(binding))
random_string = SecureRandom.hex
upload! src_file_string, "/tmp/#{random_string}"
execute :sudo, "mv /tmp/#{ran... |
module Solid
class << self
def extend_liquid!
LiquidExtensions.load!
end
end
module LiquidExtensions
module ClassHighjacker
def load!
original_class = Liquid.send(:remove_const, demodulized_name)
original_classes[demodulized_name] = original_class unless original_clas... |
class FirestopSurveyJob < ActiveRecord::Base
class << self
def reporter_class
FirestopSurveyReporter
end
def projectcompletion_reporter_class
FirestopSurveyProjectCompletionReporter
end
end
end
|
module ActiveRecord
class LostConnection < WrappedDatabaseException
end
module ConnectionAdapters
module Sqlserver
module Errors
LOST_CONNECTION_EXCEPTIONS = {
:odbc => ['ODBC::Error','ODBC_UTF8::Error','ODBC_NONE::Error'],
:adonet => ['TypeError','System::D... |
require 'json_structure/type'
require 'json_structure/object'
require 'json_structure/array'
require 'json_structure/number'
require 'json_structure/string'
require 'json_structure/null'
require 'json_structure/any_of'
require 'json_structure/value'
require 'json_structure/any'
require 'json_structure/boolean'
require... |
class AddRestaurantContact < ActiveRecord::Migration
def change
add_column :restaurants, :contact, :string
end
end
|
class ListNode
attr_accessor :value, :next
def initialize(value = nil)
@value = value
@next = nil
end
end
class LinkedList
def initialize(value)
@head = ListNode.new(value)
end
def search(value)
p1 = @head
while p1
return p1 if p1.value == value
p1 = p1.next
end
... |
require 'httparty'
class NewYorkTimes
include HTTParty
base_uri 'http://api.nytimes.com/svc'
SECTIONS = %w(science sports)
def most_popular(options = {})
section = options[:section]
type = options[:type] || 'mostviewed'
page = options[:page] || 1
self.class.get("http://api.nytimes.com/svc/mos... |
class RegistrationForm < ActiveRecord::Base
belongs_to :camp
has_many :camp_registrations
end
|
require 'spec_helper'
RSpec.describe ActionComponent::Constraints do
class ConstraintsTest
include ActionComponent::Constraints
required :apple, :banana, carrot: String
optional durian: Hash
def check(opts)
check_constraints!(opts)
end
end
subject { ConstraintsTest.new }
it "passe... |
# == Schema Information
#
# Table name: subscriptions
#
# id :integer not null, primary key
# user_id :integer not null
# podcast_id :integer not null
# score :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Subscription <... |
template do
AWSTemplateFormatVersion "2010-09-09"
Description (<<-EOS).undent
Kumogata Sample Template
You can use Here document!
EOS
Parameters do
PolicyName do
Description "input your policyname"
Type "String"
end
end
Resources do
myRole do
Type "AWS::IAM::Role"
... |
require 'date'
# 指定年月の第〇番目の〇曜日の日付を返す。該当する日付が存在しないときはfalseを返す
# @param int year 年を指定
# @param int month 月を指定
# @param int week 週番号(第〇週目)を指定
# @param int weekday 曜日0(日曜)から6(土曜)の数値を指定
# @return int result_day | false
def get_nth_week_day(year, month, week, weekday)
# 週の指定が正しいか判定
if week < 1 || week > 5
retu... |
# frozen_string_literal: true
module SC::Billing::Stripe::Webhooks::Products
class CreateOperation < ::SC::Billing::Stripe::Webhooks::BaseOperation
set_event_type 'product.created'
def call(event)
product_data = fetch_data(event)
return if product_exists?(product_data)
::SC::Billing::Stri... |
require 'spec_helper'
describe Rectangle do
after(:each) do
Rectangle.count = 0
end
let(:rectangle) { Rectangle.new(4,5) }
it "returns a length and width upon initialization" do
expect(rectangle.length).to eq(4)
expect(rectangle.width).to eq(5)
end
describe "#area" do
it "returns the are... |
class Admissions::BlogPostsController < Admissions::AdmissionsController
before_filter :set_post, only: [:edit, :update, :confirm_destroy, :destroy]
load_resource find_by: :permalink
authorize_resource
def index
# authorize! :index, @posts
# @posts = BlogPost.roots.super_skinny.ordered
if params[:... |
MRuby::Gem::Specification.new("mruby-irb_like_debugger") do |spec|
spec.license = "MIT"
spec.authors = "Daniel Inkpen"
spec.add_dependency("mruby-sleep")
spec.add_dependency("mruby-eval")
spec.add_dependency("mruby-io")
spec.add_dependency("mruby-bin-mruby")
spec.add_dependency("mruby-kernel-ext")
spec.... |
#require_relative './config/environment.rb'
module Paramable
def to_param
name.downcase.gsub(' ', '-')
end
end
|
# frozen_string_literal: true
class ContactMailer < ApplicationMailer
def contact(options)
@name = options[:name]
@email = options[:email]
@message = options[:message]
mail to: "contact@dolentcaramel.co"
end
end
|
module NTFS
# The _ATTRIB_TYPE enumeration.
# Every entry in the MFT is made of a list of attributes. These are the attrib types.
AT_STANDARD_INFORMATION = 0x00000010 # Base data: MAC times, version, owner, security, quota, permissions
AT_ATTRIBUTE_LIST = 0x00000020 # Used for a list of attributes that ... |
#===============================================================================
# Personalizzazione controller di Holy87
# Difficoltà utente: ★
# Versione 1.1
# Licenza: CC. Chiunque può scaricare, modificare, distribuire e utilizzare
# lo script nei propri progetti, sia amatoriali che commerciali. Vietata
# l'attribu... |
require 'rubygems'
require 'bundler'
require 'fakeweb'
require File.dirname(__FILE__) + '/../lib/launchrock.rb'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'mini... |
module Api
module Endpoints
class Bookings < Grape::API
namespace :bookings do
desc 'Bookings by date range',
summary: 'Bookings by date range',
detail: 'Returns a list of bookings, given a date range.',
is_array: true,
success: Entities::Booking
... |
#!/usr/bin/env ruby
VERSION='1.0.0'
$:.unshift File.expand_path('../../lib', __FILE__)
require 'hashie'
require 'devops_api'
require 'pry'
require 'awesome_print'
require 'ruby-progressbar'
class Api
include DevopsApi
end
begin
opts = Slop.parse(strict: true, help: true) do
banner "Domain Cutover List Host... |
# frozen_string_literal: true
class CopyProductPriceIntoLineItem < ActiveRecord::Migration[6.0]
def change
add_column :line_items, :price, :integer, default: 1
end
end
|
class Medication < ApplicationRecord
has_many :prescriptions
has_many :users, :through => :prescriptions
end |
class Topic < ApplicationRecord
validates :user_id, presence: true
validates :description, presence: true
validates :image, presence: true
belongs_to :user
has_many :favorites
has_many :favorite_users,through: :favorites, source: 'user'
has_many :bookmarks
has_many :bookmark_users,through: :bookmarks... |
require 'date'
class Echo
def initialize
puts 'Say something'
end
def output
while @user_input = gets.chomp
case @user_input
when 'exit'
puts 'Goodbye'
break
else
puts "#{Date.today}" + ' | ' + "#{Time.now.strftime('%H:%M')}" + " | You said: '#... |
# <URL:http://code.google.com/apis/chart/#chtt>
module GoogleChart
module Title
def self.included(klass)
klass.register!(:title)
end
def title=(title)
@title = CGI::escape(title)
end
def title
"chtt=#{@title}" if @title
end
end
end
|
class FieldValuesController < ApplicationController
# GET /field_values
# GET /field_values.json
def index
@field_values = FieldValue.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @field_values }
end
end
# GET /field_values/1
# GET /field_values... |
class AddActivityYearToSelfEvaluation < ActiveRecord::Migration[5.0]
def change
add_column :self_evaluations, :activity_year, :string
end
end
|
describe ManageIQ::Providers::Amazon::InstanceTypes do
context "disable instance_types via Settings" do
it "contains t2.nano without it being disabled" do
allow(Settings.ems.ems_amazon).to receive(:disabled_instance_types).and_return([])
expect(described_class.names).to include("t2.nano")
end
... |
module ActiveRecordFiles::Persistence
attr_reader :id
def new_record?
!id
end
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'validations' do
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_uniqueness_of(:email) }
end
describe '#with_whitelist_domain_email' do
let(:response) { User.with_whitelist_domain_email(email) }
... |
require 'formula'
class Snappy < Formula
homepage 'http://snappy.googlecode.com'
url 'https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz'
sha1 '2988f1227622d79c1e520d4317e299b61d042852'
bottle do
cellar :any
revision 1
sha1 '3d55ae60e55bef5a27a96d7b1b27f671935288a9' => :mavericks
sha1 '7a... |
class RemoveBrokerIdFromRequest < ActiveRecord::Migration
def change
remove_column :requests, :broker_id, :integer
end
end
|
describe ROM::Redis::Relation do
include_context 'container'
subject { rom.relations[:users] }
before do
configuration.relation(:users)
end
it '#set' do
expect(subject.set(:a, 1).to_a).to eq(['OK'])
end
it '#hset' do
expect(subject.hset(:who, :is, :john).to_a).to eq([true])
end
it '#h... |
namespace :import_images do
desc "Imports placeholder images using the Faker gem"
task generate_profile_pictures: :environment do
# Grab half of all Authors, and set their profile images to Faker data;
Author.limit(Author.count/2).find_each do |author|
author.profile_image = Faker::Avatar.image
... |
module Cloudant
module QueryBuilder
# TODO: Add a check to determine if options value is valid for key.
# ex: {include_docs: true} is valid, {include_docs: 6} is not.
def build_query_string(opts,type)
query_str = ""
fields = get_fields(type)
fields.each do |field|
val = opts[... |
cask 'sip' do
version '0.9.5'
sha256 '3735b97790ba10f0a070105d5452ca503c3f84a1edcf63226bce7d23c85fe34a'
url 'http://sipapp.io/download/sip.dmg'
appcast 'http://sipapp.io/sparkle/sip.xml',
checkpoint: '985852e024717f0172fbef5107b83d8d855ff2a50a32ea21d042c73c3c28455e'
name 'Sip'
homepage 'http://si... |
# RELEASE 2: NESTED STRUCTURE GOLF
# Hole 1
# Target element: "FORE"
array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]]
# attempts:
# ============================================================
# p array[1][1][2][0]
# ============================================================
# Hole 2
... |
# == Schema Information
#
# Table name: friendships
#
# id :integer not null, primary key
# friend_fb_id :integer
# user_id :integer
# created_at :datetime
# updated_at :datetime
#
class Friendship < ActiveRecord::Base
belongs_to :friends, class_name: "User", foreign_key: "friend_f... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{roles_data_mapper}
s.version = "0.3.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
require 'rails_helper'
describe Importer::Cnab do
let(:cnab_input) { File.expand_path('spec/fixtures/cnab.txt') }
let(:importer) { described_class.new(cnab_input) }
context 'import file' do
it { expect{importer.import!}.to_not raise_error }
it { expect(importer.import!.size).to eq 21 }
end
context ... |
require 'json'
GLB_H_SIZE = 4
GLB_H_MAGIC = "glTF".b
GLB_H_VERSION = [2].pack("L*")
GLB_JSON_TYPE = "JSON".b
GLB_BUFF_TYPE = "BIN\x00".b
FF = "\x00".b
SLIDE_MATERIAL_NAME="Slide"
SLIDE_TEXTURE_NAME = "Slide-all"
class VCISlide
attr_accessor :template_vci_path, :vci_script_path, :image_path, :page_size, :output_p... |
class LandingController < ApplicationController
layout 'landing'
before_action :set_request, only: [:register]
def info
@user = User.new
end
def register
logger.info "Sending a register email #{params[:user][:email]}"
@user = User.new
@user.email = params[:user][:email]
UserNotifierMailer.send_info_em... |
class Painel::BaseController < ApplicationController
before_action :authenticate_user!, :funcionario?, :ativo?
layout 'painel'
private
def ativo?
unless current_user.status != false
sign_out @user
redirect_to previous_url(current_user)
end
end
def funcionario?
... |
require "tic_tac_toe_rz/core/mark"
module TicTacToeRZ
module Core
class Board
include Enumerable
WIN_PLACES = [[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0... |
module SimpleSpark
module Endpoints
# Provides access to the /recipient-lists endpoint
# @note See: https://developers.sparkpost.com/api/recipient-lists
class RecipientLists
attr_accessor :client
def initialize(client)
@client = client
end
# List all recipient lists
... |
# Tag some key information for Datadog so we can view it across all traces
# See https://docs.datadoghq.com/tracing/guide/add_span_md_and_graph_it/ for more info
module DatadogTagging
def self.included(base)
base.helper_method :current_enabled_features
end
def current_enabled_features
@current_enabled_fe... |
=begin
# Ruby Unless Modifier
SYNTAX:
code unless condition #Executes the code when condition is false
=end
x = false
puts "x is false. Hence, statment executed" unless x |
class AddOderItemIdToItemComments < ActiveRecord::Migration
def change
add_column :item_comments, :order_item_id, :integer
end
end
|
class Staffs::BaseController < ApplicationController
layout 'staffs_application'
protected
def after_sign_in_path_for(resource)
staffs_path
end
end
|
class Book
def initialize(title)
@title = title
end
attr_reader :title
attr_accessor :author, :page_count, :genre
def turn_page
puts "Flipping the page...wow, you read fast!"
end
end
|
class ContactMailer < ActionMailer::Base
default from: 'no-reply@dungeonmasters.com.br'
def contact_email(params)
@from_email = params[:email]
@message = params[:message]
mail(from: @from_email, to: ENV["mail_to"], subject: 'Email de contato - Dungeon Masters')
end
end
|
class AddTableIdToGuests < ActiveRecord::Migration[5.1]
def change
add_reference :guests, :table, foreign_key: true, index: true
end
end
|
# == Schema Information
#
# Table name: pcomb_detail_records
#
# id :integer not null, primary key
# representative_number :integer
# representative_type :integer
# record_type :integer
# requestor_number ... |
class Kill < ActiveRecord::Base
belongs_to :killer, class_name: 'Player'
belongs_to :target, class_name: 'Player'
belongs_to :game
validate :only_one_player_or_confirmed
# this probably breaks it
# attr_reader :killer_id
# attr_reader :target_id
# attr_reader :game_id
after_initialize :defaults
sc... |
# Puppet Type for editing text files
# (c)2011 Markus Strauss <Markus@ITstrauss.eu>
# License: see LICENSE file
Puppet.debug "Editfile::Yaml: Loading provider"
begin
require 'hashie'
rescue LoadError
Puppet.err('Editfile::Yaml needs hashie. Please run "gem install hashie".')
end
Puppet::Type.type(:editfile).pro... |
# == Schema Information
#
# Table name: images
#
# id :integer not null, primary key
# name :string default("")
# description :string default("")
# taken_at :datetime
# created_at :datetime
# updated_at :datetime
# gallery_id :integer
# image_file... |
class PlanetsController < ApplicationController
before_action :set_planet, only: %i(show destroy)
def index
planets = if planet_filter == 'giant'
Planet.giant
elsif planet_filter == 'terrestrial'
Planet.terrestrial
else
Planet.all
... |
#===============================================================================
# ** Window_Save_Details
#-------------------------------------------------------------------------------
# Mostra i dettagli del salvataggio e viene gestita all'interno di Scene_File.
#=====================================================... |
class Ship < ApplicationRecord
belongs_to :cruise_line
has_many :ship_images
has_many :reviews
has_many :voyages
end
|
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
#Users
can [:read, :follow, :unfollow], User
can :manage, User, id: user.id
#Posts
can :read, Post
can :manage, Post, user_id: user.id
#Comments
can :create, Comment
end
end
|
module GenText
class VM
# @param program Array of <code>[:method_id, *args]</code>.
# @return [Boolean] true if +program+ may result in calling
# {IO#pos=} and false otherwise.
def self.may_set_out_pos?(program)
program.any? do |instruction|
[:rescue_, :capture].include? instr... |
module Stride
class Client
def initialize(cloud_id, conversation_id, permanent_token = nil)
self.cloud_id = cloud_id
self.conversation_id = conversation_id
self.permanent_token = permanent_token
end
# `message_body` is a formatted message in JSON
# See: https://developer.atla... |
class CreateCars < ActiveRecord::Migration
def change
create_table :cars do |t|
t.string :god
t.string :marka
t.string :model
t.string :dvigatel
t.string :tip
t.string :moschnost
t.string :privod
t.string :tip_kuzova
t.string :kpp
t.string :kod_kuzova
... |
require 'test_helper'
class OrderTest < ActiveSupport::TestCase
# NB: we can't use transactional fixtures when testing code that manually manages a
# transaction, so we turn them off for this test, but that means we also need to
# clean up the database after each test manually, which we do using the
# Databas... |
require 'rails_helper'
RSpec.describe RequestBuilders::Runtastic::Response do
subject { described_class.new(raw_response: raw_response, request: dummy_request) }
let(:dummy_request) { RequestBuilders::Runtastic::Request.new(:get, 'http://some.url/') }
let(:raw_response) do
double('RawHttpResponse', code: c... |
require 'rails_helper'
RSpec.describe ProjectsController, type: :controller do
describe "projects#index action" do
it "loads when user is logged in" do
user = FactoryBot.create(:user)
sign_in user
get :index
expect(response).to have_http_status(:success)
end
it "should red... |
# 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: 'Emanuel... |
require_relative '../lib/dropbox_utility'
require 'test/unit'
class TestDropboxUtility < Test::Unit::TestCase
DropboxUtility::authenticate
def test_session
assert_not_nil DropboxUtility::session
end
def test_client
assert_not_nil DropboxUtility::client
end
def test_authentication_file
asser... |
RSpec.feature "Users can mark reports as QA completed" do
context "signed in as a BEIS user" do
let!(:beis_user) { create(:beis_user) }
before { authenticate!(user: beis_user) }
after { logout }
scenario "they can mark a report as QA completed" do
report = create(:report, state: :in_review)
... |
require 'rspec'
require './lib/merchant'
describe Merchant do
it 'exists' do
merchant = Merchant.new({id: "5",name: "Brian",created_at: "10-05-1988",updated_at: "06-03-2021"}, self)
expect(merchant).to be_a(Merchant)
end
it 'has attributes' do
merchant = Merchant.new({id: "5",name: "Brian",created_... |
class Api::V1::TeamsController < ApplicationController
before_action :get_team, only: [:show, :update, :destroy]
before_action :authenticate_token!, only: [:create, :update, :destroy]
def index
@teams = Team.all.order(:id)
render 'teams/index.json.jbuilder', team: @teams
end
def create
@team = Team.... |
class Income < ApplicationRecord
VALID_USR_REGEX = /USR-[a-zA-z0-9]{8}-[a-zA-z0-9]{4}-[a-zA-z0-9]{4}-[a-zA-z0-9]{4}-[a-zA-z0-9]{12}/
validates :user_guid, presence: true, format: { with: VALID_USR_REGEX }
validates :name, presence: true
validates :date, presence: true
validates :amount, presence: true, numer... |
class NodesController < ApplicationController
respond_to :json, :xml
after_filter :set_access_control_header
def set_access_control_header
headers['Access-Control-Allow-Origin'] = '*'
end
def index
respond_with(Node.all_public params[:since], params[:groups])
end
end
|
class AlterRestaurants < ActiveRecord::Migration[5.2]
def up
if column_exists? :restaurants, "cuisine"
remove_column(
:restaurants,
"cuisine"
)
end
end
def down
unless column_exists? :restaurants, "cuisine"
add_column(
:restaurants,
"cuisine",
... |
class Bikes < Netzke::Basepack::Grid
def configure(c)
super
c.model = "Bike"
c.force_fit = true
# columns with :id set, have :min_chars set in init_component
# See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering
c.columns = [
{ :name => :shop_id, :text => 'Shop ID', :... |
module Scmimport
class Git < Scmimport::Scm
def initialize(config)
super(config)
@fullpath = "#{config['basedirectory']}/#{config['name']}"
end
def updates
if not File.directory?(@fullpath)
@g = Git.clone(config.repourl, name: config.name, path: @fullpath, log: Logger.new(STDO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.