text stringlengths 10 2.61M |
|---|
# For each letter in a string,
# Find what letter comes next in the alphabet
# Replace original letter with that next letter in the alphabet
# Move on to next letter in original string
def encrypt(word)
encrypt_word = ""
index = 0
while index < word.length
if word[index] == "z"
encrypt_word += "a"
index ... |
#!/usr/bin/env ruby
require 'httparty'
require 'dotenv'
require 'table_print'
require 'tty-prompt'
require_relative 'workspace'
Dotenv.load
BASE_URL = "https://slack.com/api/"
KEY = ENV["SLACK_TOKEN"]
def main
workspace = Slack::Workspace.new
prompt = TTY::Prompt.new
continue = true
# active_selection = nil... |
# frozen_string_literal: true
FactoryGirl.define do
factory :user do
name Faker::Name.name
sequence(:email) { |n| Faker::Internet.email(n) }
password '123456'
end
end
|
#! /usr/bin/env ruby -S rspec
require 'spec_helper'
describe "rspec_function_issue::os_uses_systemd" do
before :all do
@facter_facts = { }
end
let(:facts) { @facter_facts }
context "when on sles 12 with systemD" do
before :each do
facts['os'] = { 'name' => 'SLES',
'release... |
class PuppetLint
class Lexer
# Public: Stores a fragment of the manifest and the information about its
# location in the manifest.
class Token
# Public: Returns the Symbol type of the Token.
attr_accessor :type
# Public: Returns the String value of the Token.
attr_accessor :value
... |
class UserSerializer < ActiveModel::Serializer
attributes :id, :name, :dob, :is_deleted
end
|
require 'date'
Given /^there are no pending requests$/ do
@requests.should be_nil
end
Then /^the page displays "([^']*)"$/ do |arg1|
page.should have_selector("#msg", :content => arg1)
end
Given /^there are one or more pending requests$/ do
user = User.new_user_from_hash({
:provider => 'facebook',
:uid => ... |
class UsersHaveManyIosAndAndroidDevices < ActiveRecord::Migration
def change
remove_column :users, :device_id
add_column :apn_devices, :user_id, :integer
add_column :gcm_devices, :user_id, :integer
end
end
|
class CreateArticles < ActiveRecord::Migration[5.0]
def change
create_table :articles do |t|
t.string :name
t.string :kind
t.integer :number
t.string :color
t.string :sex
t.integer :hp
t.integer :attack
t.integer :defence
t.integer :sepAttack
t.integer :... |
class Auction < ApplicationRecord
has_many :sales, dependent: :destroy
validates_uniqueness_of :name
validates_presence_of :name
def upload(file)
CSV.foreach(file.path, headers: true) do |row|
if row.present?
@auction = Auction.find_or_create_by(name: row["auction name"])
# if the ad... |
class FeatureAccessSetting < ActiveRecord::Base
class<< self
def save_settings(settings)
errors= []
settings.each_pair do |key,value|
field = FeatureAccessSetting.find(key.to_i)
unless field.nil?
unless field.update_attributes(:parent_can_access => value == "1" ? true : fa... |
require 'spec_helper'
describe Subscriber do
it "should be able to subscribe! and unsubscribe!" do
brand = Factory(:brand)
subscriber = Factory(:subscriber)
subscriber.subscribe!(brand)
subscriber.brands.should include(brand)
subscriber.unsubscribe!(brand)
subscriber.reload
subscri... |
module TwilioHelper
def twilio_post_sms(tw_params = twilio_new_message_params, use_correct_signature = true)
post_path = '/incoming/sms'
post_sig = use_correct_signature ? correct_signature(tw_params, post_path) : nil
twilio_post tw_params, post_sig, post_path
end
def twilio_post_sms_status(tw_params... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :persona do
game_id ""
user_id ""
sequence(:name) { |n| "Character #{n}" }
server 1
end
end
|
# frozen_string_literal: true
require 'rails_helper'
describe 'フロント画面:アカウント検索', type: :system do
context 'ログインしているとき' do
let!(:user1) { FactoryBot.create(:user, :normal, company: login_user.company) }
let!(:user2) { FactoryBot.create(:user, :normal) }
before do
sign_in_as(login_user)
visit ... |
class Topic < ActiveRecord::Base
has_many :post_topics
has_many :posts, through: :post_topics
has_many :resource_topics
has_many :resources, through: :resource_topics
validates :name, presence: true
end
|
require 'rails_helper'
describe ScrapeTitleJob, type: :job do
let(:media_item) do
FactoryGirl.create(:media_item, url: 'https://youtube.com')
end
it "scrapes the title of a website" do
VCR.use_cassette('scrape_title_job') do
described_class.perform_now(media_item)
media_item.reload
ex... |
module Api
class Engine < ::Rails::Engine
config.api = Api
initializer "api.secret_key" do |app|
if app.respond_to?(:secrets)
Api.secret_key ||= app.secrets.secret_key_base
elsif app.config.respond_to?(:secret_key_base)
Api.secret_key ||= app.config.secret_key_base
end
... |
require 'test_helper'
class LoggedExceptionTest < ActiveSupport::TestCase
context "A logged exception" do
setup do
@logged_exception = Factory(:logged_exception)
end
should "respond to exception_class" do
assert_respond_to @logged_exception, :exception_class
end
should "respond to ... |
# frozen_string_literal: true
# This migration comes from alchemy (originally 20200505215518)
class AddLanguageIdForeignKeyToAlchemyPages < ActiveRecord::Migration[5.2]
def change
add_foreign_key :alchemy_pages, :alchemy_languages, column: :language_id
change_column_null :alchemy_pages, :language_id, false, ... |
uts "What is the name of the client?"
name=gets.chomp
puts "What is the client's age?"
age=gets.chomp
age=age.to_i
puts "How many children does the client have?"
children_Client = gets.chomp
children_Client = children.to_i
puts "What is the decor theme?"
theme = gets.chomp
puts "How many bedrooms would you li... |
control "V-72997" do
title "PostgreSQL must prohibit user installation of logic modules
(functions, trigger procedures, views, etc.) without explicit privileged
status."
desc "Allowing regular users to install software, without explicit
privileges, creates the risk that untested or potentially malicious soft... |
require 'csv'
require 'pp'
require 'fileutils'
# require 'strftime'
require 'rbconfig'
THIS_FILE = File.expand_path(__FILE__)
RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
dir_string = "F:/TEMP_D/"
def upload(item)
path = "F:/"
d = DateTime.now
folderName = d.strftime("%Y%m... |
class Song < ActiveRecord::Base
belongs_to :artist
has_many :favorites, dependent: :destroy
has_many :users, through: :favorites
validates :title, presence: true
end
|
require 'minitest/autorun'
require '6to5'
class Test6to5 < MiniTest::Test
NO_RUNTIME = %w( 3.0 3.1 3.2 ).any? { |v| ES6to5.version.start_with?(v) }
def setup
ExecJS.runtime = ExecJS::Runtimes.autodetect
end
def test_source_constants
assert ES6to5::Source::VERSION
assert ES6to5::Source::DATE
a... |
# frozen_string_literal: true
class Staff::LandingController < ApplicationController
layout 'staff'
before_action :authenticate_staff!
def index
respond_to do |format|
format.html { render :index }
format.json do
render json: { data: 'Hello Staff!' }
end
end
end
end
|
class FixTypeInUrlsAgain < ActiveRecord::Migration
def change
rename_column :urls, :urls_type, :url_type
end
end
|
#In order to speed up tests, it’s recommended to switch off processing
#If you need to test your processing, just enable it on your test file
#~ if Rails.env.test?
#~ CarrierWave.configure do |config|
#~ config.storage = :file
#~ config.enable_processing = false
#~ end
#~ end
CarrierWave.configure do... |
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# @param {ListNode} head
# @return {ListNode}
def odd_even_list(head)
dummy_l1 = ListNode.new(nil)
dummy_l2 = ListNode.new(nil)
cur = head... |
# frozen_string_literal: true
RSpec.shared_examples 'an IdentifierBuilder' do
subject(:builder) { described_class.new }
describe '#build' do
it 'returns an identifier string' do
expect(builder.build(hint: 'moomin'))
.to respond_to :to_str
end
end
end
|
class MapQuestService
def self.get_me_there(to, from)
response = faraday.get("/directions/v2/route?") do |f|
f.params['to'] = to
f.params['from'] = from
end
parsed = parse(response)
end
private
def self.parse(arg)
JSON.parse(arg.body, symbolize_names: true)
end
def self.farada... |
require 'redis'
require 'json'
require 'base64'
require 'erb'
require 'ostruct'
require 'mail'
require_relative 'drone-config'
require_relative 'creative'
class Drone
def send(creative_id, email)
creative = Creative.get creative_id
from_prefix = creative[:from_prefix]
from_name = creative[:from_name]... |
NkuProject::Application.routes.draw do
root "upload#index"
get "files/show"
get "files/download"
post "upload/import" => "upload#import"
get "upload/import" => "upload#index"
get "verify-email/:key" => "verifications#show", as: 'show_verifications'
get "sign-in" => "sessions#new", as: 'sign_in'
get "... |
gem 'minitest'
require 'minitest/autorun'
require './lib/messager'
class MessagerTest < Minitest::Test
include Messager
def test_it_can_receive_messages
assert_equal "test", Messager.output("test")
end
def test_it_can_say_goodbye
assert_equal "Thanks for playing.", Messager.goodbye
end
def test... |
module RIM
module Manifest
class Manifest
attr_reader :remote_url
attr_reader :modules
def initialize(remote_url, modules)
@remote_url = remote_url
@modules = modules
end
end
class Module
attr_reader :remote_path
attr_reader :local_path
attr_reader :target_revision
attr... |
class PermissionService
attr_reader :user,
:controller,
:action
def initialize(user)
@user = user
end
def allow?(controller, action)
@controller = controller
@action = action
if user && user.company_admin?
company_admin_permissions
elsif user && user.registered_user?
... |
# Write a method named include? that takes an Array and a search value as arguments. This method should return true if the search value is in the array, false if it is not. You may not use the Array#include? method in your solution.
=begin
approach:
- iterate over the array:
- for current elem of array:
- retu... |
require "matrix"
require "set"
class Valley
Blizzard = Struct.new(:position, :direction)
DIRECTIONS = {
"<" => Vector[-1, 0],
">" => Vector[1, 0],
"v" => Vector[0, 1],
"^" => Vector[0, -1]
}
attr_reader :height, :width
def initialize(diagram)
area = diagram.split("\n")
@height = a... |
class MethodCall < ActiveRecord::Base
belongs_to :scenario
has_many :params, inverse_of: :method_call
attr_accessible :method_name, :params_attributes
accepts_nested_attributes_for :params
validates :method_name, :scenario, presence: true
end
|
class OrganizationSerializer
include FastJsonapi::ObjectSerializer
attributes :id, :name, :form_of_ownership, :inn, :ogrn
end
|
class BookSerializer < ActiveModel::Serializer
attributes :id, :title, :image_url, :isbn, :description, :publisher, :price
has_many :authors
end
|
namespace :devise do
desc 'setup Devise example migrating db and creating a default customer'
task :setup => ['db:drop', 'db:create', 'db:migrate', 'db:fixtures:load', 'environment'] do
user = Customer.create! do |u|
u.first_name = 'Devise'
u.last_name = 'Customer'
u.email = 'devise@cus... |
# frozen_string_literal: true
require 'rails_helper'
describe 'Token authentication', type: :request do
describe 'POST /clients/sign_in' do
let(:client) { create(:client) }
context 'with valid credentials' do
let(:credentials) { token_credentials_for(client) }
it 'redirects to client#index' do... |
require "test_helper"
class UserTest < ActiveSupport::TestCase
# Matchers
should belong_to(:organization)
should have_many(:teams)
should have_secure_password
should validate_presence_of(:organization_id)
should validate_presence_of(:last_name)
should validate_presence_of(:first_name)
should allow_v... |
# frozen_string_literal: true
module IdentityCache
module Cached
module Recursive
class Association < Cached::Association # :nodoc:
def initialize(name, reflection:)
super
@dehydrated_variable_name = :"@dehydrated_#{name}"
end
attr_reader :dehydrated_variable_nam... |
require 'nokogiri'
require 'open-uri'
require 'chronic'
require 'geocoder'
require 'mechanize'
# Web Scraper for Silicon Prairie News
module SpnScraper
# TODO TomDoc Methods
# TODO Refactor
# TODO Clean up outdate events
# Scraper for Silicon Prairie News Events Calendar
#
# Scrape method loops over ... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_current_order
#adicionado seguindo o howto na wiki do deviser sobre username/email
before_action :configure_permitted_parameters, if: :devise_controller?
def set_current_order
session[:current_ord... |
FactoryGirl.define do
factory :group do
name "String Name"
description "String Description"
purpose "String Purpose"
limit "String Limit"
end
end
|
require_relative 'AiModel'
require_relative 'CasinoEngine'
require_relative 'PokerCard'
require_relative 'PokerDeck'
require_relative 'PokerHandEvaluator'
class AiSimulation
def totalPayout
@totalPayout
end
def winningHands
@winningHands
end
def doubleTries
@doubleTries
end
def doubleSuccesses
@doubl... |
class CreateAdmissionsDiagnoses < ActiveRecord::Migration[5.2]
def change
create_table :admissions_diagnoses, id: false do |t|
t.belongs_to :admission, index: true
t.belongs_to :diagnosis, index: true
end
end
end
|
feature 'users can be created' do
scenario 'user fills out fields correctly' do
sign_up
expect(User.first.full_name).to eq 'Donald J. Trump'
expect(User.first.user_name).to eq 'realDonaldTrump'
expect(User.first.email).to eq 'scumlord@potus.com'
expect(current_path).to eq '/'
expect(page... |
require 'machinist/active_record'
require 'sham'
require 'faker'
class Date
def self.rand(from = Date.new(1970, 1, 1), to = Date.today)
days = (to - from).to_i
from + Kernel.rand(days + 1)
end
end
Sham.define do
lastname(:unique => false) { Faker::Name.last_name }
firstname(:unique => false) { Faker:... |
require 'workling/remote/invokers/base'
#
# A basic polling invoker.
#
module Workling
module Remote
module Invokers
class BasicPoller < Workling::Remote::Invokers::Base
#
# set up client, sleep time
#
def initialize(routing, client_class)
super
... |
class CommentsController < ApplicationController
def create
@comment = parent.comments.build(params[:comment])
@comment.user = current_user
if @comment.save
respond_to do |format|
format.js
format.html { redirect_to parent }
end
else
respond_to do |format|
fo... |
class City < ActiveRecord::Base
has_many :tours
mount_uploader :image, CityImageUploader
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Datacite::XmlBuilder do
subject(:builder) { described_class.new }
describe '::ATTRIBUTES' do
it 'maps identifier' do
expect(described_class::ATTRIBUTES).to include :identifier
end
it 'has an accessor for each attribute' do
... |
class UsersController < ApplicationController
before_action :authenticate_user!, except: [:index]
before_action :set_user, only: [:show, :edit, :update]
before_action :format_params, only: [:update]
def show
end
def edit
end
def update
@user.slug = nil
if @user.update(@formatted_params)
... |
module Lee
# Draw a board and possibly solutions and expansions.
def self.draw(board, solutions, expansions=[], filename)
require 'victor'
if expansions.empty?
solution_colours = %w(2E5266 DB2B39 FE9920 566E3D)
else
solution_colours = %w(4A4A4A 828282 8F8F8F 575757)
end
expansion_... |
class StudentActivity < ApplicationRecord
belongs_to :activity
belongs_to :student
end
|
class Mailer < ActionMailer::Base
default from: "luigi.antonini84@gmail.com"
def contact(first_name, last_name , from , message)
@first_name = first_name
@last_name = last_name
@from = from
@message = message
mail(:to => "luigi.antonini84@gmail.com", :from => from ,
:subje... |
class User < ActiveRecord::Base
before_create :create_remember_token
before_save { self.email = email.downcase }
# for user.valid to be true, following must be executed and pass
# name is provided and less than 50 chars
validates :name, presence: true, length: { maximum: 50 }
# email address does n... |
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
desc "Default task running Tests"
task default: :test
desc "Run test suite"
task test: ["test:standard", "test:rspec"]
task "test:ci" => ["bootstrap:gem_requirements", :test]
namespace :test do
task :rspec do
sh "rspec"
end
... |
#!/usr/bin/env ruby
require 'Bundler'
require 'openssl'
Bundler.require(:default)
opts = Trollop::options do
opt :bucket, "Select the S3 bucket to archive to", :short => 'b', :type => String
opt :source, "Source directory to watch for archival", :short => 's', :type => String, :default => '.'
opt :targe... |
require 'enumerator'
require 'pathname'
require 'tins/module_group'
module Tins
module Find
EXPECTED_STANDARD_ERRORS = ModuleGroup[
Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP,
Errno::ENAMETOOLONG
]
class Finder
module PathExtension
attr_accessor :finder
... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Distributed
describe Subprocess do
let(:described) { Vedeu::Distributed::Subprocess }
let(:instance) { described.new(application) }
let(:application) {}
describe '#initialize' do
it { instance.must_b... |
module JobGroups
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def job_group(&block)
@lock_group_factory = block
end
def has_job_groups?
!!@lock_group_factory
end
def lock_group(payload)
@lock_group_factory.call(payload)
end
e... |
# Use this file to import data from the CSV and populate your database
require "pg"
require "csv"
require 'pry'
system "psql building-database < schema.sql"
def db_connection
begin
connection = PG.connect(dbname: "building-database")
yield(connection)
ensure
connection.close
end
end
def zoning(zon... |
module V1
# user apis
class UsersGrape < SignGrape
params do
requires :email, allow_blank: false, regexp: GRAPE_API::EMAIL_REGEX
requires :passwd, type: String
end
post '/sign_in' do
@user = User.find_by(email: params[:email])
auth_error!('The email not exists') if @user.nil?
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def require_signed_in
redirect_to root_path unless signed_in?
end
private
def current_user
@current_user ||= User.where(id: session[:user_id]).last
end
def signed_in?
!!current_user
end
helper_m... |
class ContributionPDF < Prawn::Document
CONSTANTS = {
table_head_color: 'dddddd',
notice_color: '3399cc',
notice_font_size: 12,
heading_color: 'f4733d',
table_row_color: 'ffffff',
table_font_size: 16,
head_font_size: 16
}.freeze
attr_reader :constants
def initialize(contribution, ... |
# frozen_string_literal: true
class CandleInformation
include ActiveModel::Model
attr_accessor :usd_jpy_m1_count, :eur_jpy_m1_count, :gbp_jpy_m1_count,
:usd_jpy_m1_latest, :eur_jpy_m1_latest, :gbp_jpy_m1_latest
def initialize(attributes = {})
attributes.each do |key, value|
send("#{ke... |
require 'rubygems'
require Dir.pwd+'/lib/serverconfig'
module Db
@connection = nil
def self.connect
# PG::Connection.new(host, port, options, tty, dbname, user, password) → conn
@connection = PG::Connection.new( HOST, PORT, nil, nil, DBNAME,USER,PASSWORD )
end
def self.query(msg)
begin
@connection.e... |
class Api::V1::UsersController < ApplicationController
def bookings
@bookings = User.joins(:bookings,:rooms).booking_info(params[:id])
render json: @bookings
end
end
|
module ContentManagement
module Helpers
VALID_VAR_NAME = /\A[_\p{letter}]+[\p{Alnum}_]*\z/
def load_attachments(attachments=all_attachments)
@attachments = attachments
@images = ImagesDrop.new(@attachments)
end
def all_attachments
get_subject.templates.includes(:attachments).inject... |
require "spec_helper"
describe User, type: :model do
subject { create(:user) }
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_uniqueness_of(:email).case_insensitive }
it { is_expected.to allow_value("pete@example.org").for(:email) }
it { is_expected.not_to allow_value("pete.... |
ENV['RAILS_ENV'] = 'test'
require_relative 'reporters/simple_spreadsheet_reporter'
RSpec.configure do |config|
if ENV['REPORT']
config.add_setting :report_filename
config.formatter = 'SimpleSpreadsheetReporter'
config.report_filename = 'spec-report.xlsx'
end
end
|
class LibrariesController < ApplicationController
before_action :set_library, only: [:show, :update, :destroy, :edit]
def index
@libraries = Library.all
end
def new
@library = Library.new
end
def create
@library = Library.create(library_params)
if @library.id == nil
flash[:error] = @libr... |
require 'spec_helper'
describe JsonTableSchema::Field do
before(:each) do
@descriptor_min = {'name' => 'id'}
@descriptor_max = {
'name' => 'amount',
'type' => 'number',
'format' => 'currency',
'constraints' => {'required' => true}
}
end
it 'returns the descriptor' do
exp... |
RSpec::Matchers.define :be_a_user_representation do |user|
match do |json|
response_attributes = user.sliced_attributes %w(
id
created_at
updated_at
email
name
)
expect(json).to be
expect(json).to include_attributes(response_attributes)
expect(json['session']).to in... |
require 'optparse'
require 'ostruct'
module OggEncode
class Parser
class << self
def make_path(folder)
folder =~ /\/$/ ? folder : folder + '/'
end
def parse(args)
script_name = File.basename( $0 )
options = OpenStruct.new
options.max_procs = 4
options.... |
class CreateTattooInformations < ActiveRecord::Migration[5.2]
def change
create_table :tattoo_informations do |t|
t.integer :interaction_id
t.string :subject
t.string :description
t.string :placement
t.boolean :consultation
t.boolean :coverUp
t.timestamps
end
end
en... |
namespace :s3 do
desc 'Create all configured S3 buckets'
task create_buckets: :environment do
Settings.aws.buckets.to_h.values.each do |bucket|
bucket = Aws::S3::Bucket.new(bucket)
bucket.create unless bucket.exists?
end
end
desc 'Populate S3 batch bucket with test data'
task populate_ba... |
TodoApplication.route_pot.prepare do
resources :fellows
get "/", to: "fellows#index"
end
|
class QuestionsController < ApplicationController
# GET /questions
# GET /questions.xml
layout "admin"
def index
@questions = Question.paginate :page => params[:page]||1,
:per_page=>10,:conditions=>["name like ?",params[:name]? "%#{params[:name]}%":"%"],
... |
class CreateMenulasts < ActiveRecord::Migration
def change
create_table :menulasts do |t|
t.string :name
t.integer :sortorder
t.text :hint
t.string :h1
t.text :keywords
t.text :description
t.text :page
t.timestamps null: false
end
end
end
|
require 'test_helper'
class FeedbackTest < ActiveSupport::TestCase
def test_feedback__ok
feedback = Feedback.new(name: 'Adam', comment: 'This is good!')
assert_predicate feedback, :valid?
assert_equal 'Adam', feedback.name
assert_equal 'This is good!', feedback.comment
end
def test_feedback__emp... |
require 'rails_helper'
RSpec.describe Course, type: :model do
describe "#create" do
before(:all) do
@active_course = create(:active_course)
@inactive_course = create(:inactive_course)
end
it "creates active user" do
expect(@active_course).to be_valid
expect(@active_course.status)... |
require 'net/http'
require 'securerandom'
require_relative '../spec_helper'
describe Talis::Hierarchy::Asset do
let(:namespace) { 'rubytest' }
before do
Talis::Authentication::Token.base_uri(persona_base_uri)
Talis::Authentication.client_id = client_id
Talis::Authentication.client_secret = client_secre... |
require 'rails_helper'
RSpec.describe "user_shipments/edit", type: :view do
before(:each) do
@user_shipment = assign(:user_shipment, UserShipment.create!(
:user => nil,
:shipment => nil,
:role => "MyString"
))
end
it "renders the edit user_shipment form" do
render
assert_selec... |
class Employee < ActiveRecord::Base
scope :has_title, -> (title){ where "title LIKE ?", "%#{title}%" }
# TODO make query more robust for edge cases e.g. a title coincidentally
# contained inside another title like man within manager. As it stands
# you could insert a blank string even and it would return everyt... |
class BarcodesController < ApplicationController
def new
@job = Job.find_by_id(params[:job_id])
@barcode = @job.barcodes.build
end
def create
@job = Job.find_by_id(params[:barcode][:job_id])
@barcode = @job.barcodes.build(barcode_params)
if @barcode.save
redirect_to @job
else
... |
# configures the Habitat Supervisor
hab_sup node['effortless']['hab-sup']['org'] do
license node['effortless']['hab-sup']['license']
auto_update node['effortless']['hab-sup']['auto_update']
event_stream_application node['effortless']['hab-sup']['event_stream_application']
event_stream_cert node['effortless']['... |
require "net/http"
require "net/https"
require "uri"
require "cgi"
require "hpricot"
require "#{File.dirname(__FILE__)}/cookies/cookie"
require "#{File.dirname(__FILE__)}/cookies/cookie_jar"
require "#{File.dirname(__FILE__)}/page/element"
class URI::Generic
def request_uri
self.to_s
end
end
# TODO: request... |
# frozen_string_literal: true
require 'spec_helper'
describe 'Authentication' do
before { @browser.goto 'www.saucedemo.com' }
it 'successful' do
@browser.text_field(data_test: 'username').set 'standard_user'
@browser.text_field(data_test: 'password').set 'secret_sauce'
@browser.button(type: 'submit'... |
class Source < ActiveRecord::Base
belongs_to :gift
belongs_to :user
validates_associated :donor
end
|
class ChangeOgrnColumnTypeOfClient < ActiveRecord::Migration
def change
change_column :clients, :ogrn, :string, limit: 15
end
end
|
require 'pry'
class String
def sentence?
self.end_with?(".")
end
#returns true if it ends in . and false if it doesnt
#you will need to use the self keyword to refer to the string on which the method is being called.
#use the end with method to determine what the final character in a string is.
def questio... |
class Brandsecondmenu < ActiveRecord::Base
belongs_to :brandmenu
#params的可提交的属性参数参数
def self.permit_data
data = [:menu_name, :desc,:brandmenu,:brandmenu_id,:created_at,:updated_at]
data
end
end
|
require 'rails_helper'
RSpec.describe 'Admin Dashboard Page' do
before :each do
@customer = create(:customer)
@invoice_1, @invoice_2, @invoice_3 = create_list(:invoice, 3, customer: @customer, status: 0)
@invoice_4 = create(:invoice, customer: @customer, status: 0, created_at: '2019-06-24 21:54:10 UTC')
... |
# frozen_string_literal: true
RSpec.describe Api::V1::User::UpdateSchema do
describe 'attributes' do
def schema(**options)
described_class.call(options)
end
describe 'first_name' do
it 'returns failure' do
result = schema(first_name: '')
expect(result).to be_failure
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.