text stringlengths 10 2.61M |
|---|
#!/usr/bin/env ruby
#
# 10001st prime
# http://projecteuler.net/problem=7
#
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
# the 6th prime is 13.
#
# What is the 10,001st prime number?
#
class Numeric
def prime?
return true if self == 2
return false if self <= 1 or self % 2... |
class Gui < GuiElement
attr_accessor :menu, :shown
def initialize player
super()
@player = player
#we don't need all the space left and right
self.sx = 3/8
self.center
# add a vertical menu as a child to self
@menu = GuiMenuV.new
self << @menu
# some content
@menu << GuiBut... |
require_relative '../lib/strategy'
class Upczilla < Strategy
def scrape(code)
begin
description = image_url = ''
valid = false
url = "https://www.upczilla.com/item/#{code}/"
html = HTTParty.get(url, :verify => false)
doc = Nokogiri::HTML(html)
... |
# frozen_string_literal: true
module Auths
module Error
class Forbidden < AuthError
def http_status
:forbidden
end
end
end
end
|
Gem::Specification.new do |s|
s.name = %q{todo_api}
s.version = "0.0.1"
s.date = %q{2018-10-13}
s.summary = %q{CLI to interact with the todo app api}
s.files = [
"lib/todo_api.rb"
]
s.require_paths = ["lib"]
s.authors = ['Eduardo Poleo']
end |
module TruncateHtmlHelper
def truncate_html(html, options={})
return '' if html.nil?
html_string = TruncateHtml::HtmlString.new(html)
TruncateHtml::HtmlTruncator.new(html_string).truncate(options).html_safe
end
def count_html(html)
return 0 if html.nil?
html_string = TruncateHtml::HtmlString... |
class Shows < ActiveRecord::Migration
def self.up
create_table :shows do |t|
t.integer :theater_id
t.integer :movie_id
t.datetime :start
end
end
def self.down
drop_table :shows
end
end
|
# return any unique integer in an array that contains integers
# between 1 and n and has a length n + 1. The array cannot be
# copied or manipulated.
# run time O(n * log(n))
# memory O(n)
def find_duplicate(array, min=1, max=nil)
max = max || array.length - 1
# if the max and min have a difference of one... |
require 'rails_helper'
RSpec.describe "Api::Readers", type: :request do
describe "GET /api/readers" do
it "should list all readers" do
FactoryBot.create(:reader)
get api_readers_path
expect(response).to have_http_status(200)
json = JSON.parse(response.body)
expect(json.length).to ... |
module Bramipsum
class Paragraph < Sentence
def self.paragraph
self.sentences(5).join(" ")
end
def self.html_paragraph
"<p>" << self.paragraph << "</p>"
end
end
end
|
require 'spec_helper'
describe HomeController do
let(:user) { FactoryGirl.build(:user) }
context 'user is logged in' do
it 'forwards user to dashboard' do
pending 'to be added'
end
end
end
|
class SmsService
def initialize(delivery)
@delivery = delivery
end
def deliver_to(clients)
clients.each { |client| send_sms_to(client) }
end
private
def send_sms_to(client)
twilio_client = Twilio::REST::Client.new(TWILIO_CONFIG['sid'], TWILIO_CONFIG['token'])
twilio_client.account.sms.mes... |
class CreateApplicationsGroups < ActiveRecord::Migration
def change
create_table :applications_groups, :id => false do |t|
t.integer :application_id
t.integer :group_id
end
end
end
|
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Command monitoring' do
let(:subscriber) { Mrss::EventSubscriber.new }
let(:client) do
authorized_client.with(app_name: 'command monitoring spec').tap do |client|
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
... |
class MessageMailerWorker < BaseWorker
def self.category; :notification end
def self.metric; :email end
def perform(notification_type, user_id, message_id, data)
perform_with_tracking(notification_type, user_id, message_id, data) do
user = User.find(user_id)
message = Message.new(id: message_id)
... |
class Api::V1::NotificationsController < Api::V1::BaseController
before_action :set_notification, only: [:show, :update, :destroy]
def_param_group :notification1 do
param :notification1, Hash, required: true, action_aware: true do
param :offset, Integer, required: true, allow_nil: false
... |
class CreateAbsenceScheduleBlocks < ActiveRecord::Migration
def change
create_table :absence_schedule_blocks do |t|
t.integer :absence_id, :null => :false, :default => 0
t.integer :schedule_block_id, :null => false, :default => 0
t.timestamps
end
end
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
describe "#new" do
context 'can save' do
it "is valid with nickname, email, password, password_confirmation, last_name, first_name, last_name_kana, first_name_kana, birthday" do
expect(build(:user, avatar: nil, profile: nil, sex: nil)).t... |
class RouteOutgoingCall
def initialize(call:, status:, adapter: TwilioAdapter.new)
@outgoing_call = call
@status = status
@adapter = adapter
end
def call
if status.no_answer?
status.apply(outgoing_call)
adapter.end_call(outgoing_call.sid)
elsif status.answered?
connect_call_... |
module Media
module Command
class Progress
attr_reader :duration, :time
def initialize(duration = 0, time = 0)
@duration = duration
@time = time
end
def parse(str, &block)
str.split("\n").each do |line|
d = Parser.new(line, DURATION)
t = P... |
module ApplicationHelper
def display_base_errors resource
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block">
<button type="button" class="cl... |
require 'spec_helper'
describe "/questions/edit.html.erb" do
include QuestionsHelper
before(:each) do
assigns[:question] = @question = stub_model(Question,
:new_record? => false,
:prompt => "value for prompt",
:activity_id => 1
)
end
it "renders the edit question form" do
render... |
class User < ApplicationRecord
has_and_belongs_to_many :gradeworks
has_and_belongs_to_many :roles
accepts_nested_attributes_for :roles
validates :firstname, :lastname, :phone, presence: true
validates :email, :identification, presence: true, uniqueness: true
default_scope {order("users.firstname ASC")}... |
describe Rfm::Config do
subject {Rfm::Config}
let(:config) {subject.instance_variable_get :@config}
let(:klass) {Class.new{extend Rfm::Config}}
describe "#config" do
before(:each){klass.config :group1, :layout=>'lay1'}
it "sets @config with arguments & options" do
expect(klass.insta... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
# -*- encoding : utf-8 -*-
module Retailigence #:nodoc:
# A location result from the Retailigence API
#
# === Attributes
# * <tt>id</tt> - Unique identifier for the location
# * <tt>timezone</tt> - Timezone of the location
# * <tt>distance</tt> - Distance object calculated based off the <tt>userlocation</tt... |
describe PersonDecorator do
describe "#introduction" do
subject(:introduction) { person.decorate.introduction }
let!(:person) do
build(:person,
name: "Anakin",
height: "188",
mass: "84",
homeworld: build(:planet, name: "Tatooine"),
birth_year:... |
require "ostruct"
require "optparse"
require "fileutils"
require "tmpdir"
require "minitar"
module Gaudi
class GemError < RuntimeError
end
class Gem
MAIN_CONFIG = "system.cfg".freeze
REPO = "https://github.com/damphyr/gaudi".freeze
attr_reader :project_root, :gaudi_home
# :nodoc:
def self.... |
require 'spec_helper'
describe WorkfileVersionPresenter, :type => :view do
let(:workfile) { workfiles(:public) }
let(:owner) { workfile.owner }
let(:version) { workfile.latest_workfile_version }
let(:presenter) { WorkfileVersionPresenter.new(version, view, options) }
let(:options) { {} }
before(:each) do
... |
### Collections Basics ####
def palindrome?(word)
if word.size >=2
word == word.reverse
else
false
end
end
def change_me(sentence)
sentence_arr = sentence.split(" ")
pali_sentence = sentence_arr.map{|word| palindrome?(word) ? word.upcase : word}
pali_sentence.join(" ")
end
def palin... |
class AddIfPaidToUtilityCharges < ActiveRecord::Migration
def change
add_column :utility_charges, :is_paid, :boolean, null: false, default: false
end
end
|
require "test_helper"
describe UsersController do
describe "index" do
it "responds with success when there is at least one user saved" do
user = users(:ada)
get users_path
expect(User.count > 0).must_equal true
must_respond_with :success
end
end
descri... |
class DevisesessionController < Devise::SessionsController
def create
Rails.logger.debug(params[:user][:email])
user = User.find_by_email(params[:user][:email])
if(!user.nil?)
Rails.logger.debug(user.is_approved)
Rails.logger.debug(user.is_approved == 1)
if(user.is_approved == 1)
... |
class Address < ActiveRecord::Base
attr_accessible :street1, :street2, :city, :state, :zip, :household_id
validates_presence_of :street1, :city, :state, :zip
validates_numericality_of :zip
#validates_length_of :zip, :is => 5, :message => "must be 5 digits long."
belongs_to :household
end
|
require 'OptimizerService.rb'
require 'OptimizerServiceMappingRegistry.rb'
require 'soap/rpc/driver'
module AdCenterWrapper
class IOptimizerService < ::SOAP::RPC::Driver
DefaultEndpointUrl = "https://adcenterapi.microsoft.com/Api/Advertiser/V8/Optimizer/OptimizerService.svc"
Methods = [
[ "GetBudgetOpportuni... |
class Weapon < Item
attr_reader :damage, :range
def initialize(name, weight, damage)
@name = name
@weight = weight
@damage = damage
end
def hit(recipient)
recipient.wound(@damage)
end
end
|
require('minitest/autorun')
require('minitest/rg')
require_relative('../river.rb')
require_relative('../fish.rb')
require_relative('../bear.rb')
class RiverTest < MiniTest::Test
def setup()
@amazon = River.new("Amazon", @fish)
@george = Bear.new("George", "Black Bear")
@tuna = Fish.new("Tuna")
@salm... |
class CreatePurchaseOrderDetails < ActiveRecord::Migration
def change
create_table :purchase_order_details do |t|
t.integer :delivery_order_detail_id
t.float :unit_price
t.boolean :igv
t.float :unit_price_igv
t.text :description
t.timestamps
end
end
end
|
class WorkgroupRegionSelection < ActiveRecord::Base
belongs_to :workgroup
belongs_to :region
end
|
shared_examples_for GroupDocs::Signature::DocumentMethods do
describe '#documents!' do
before(:each) do
mock_api_server(load_json('template_get_documents'))
end
it 'accepts access credentials hash' do
lambda do
subject.documents!(:client_id => 'client_id', :private_key => 'private_ke... |
class ClickScoresController < ApplicationController
before_action :set_click_score, only: [:show, :edit, :update, :destroy]
# GET /click_scores
# GET /click_scores.json
def index
@click_scores = ClickScore.all
end
# GET /top-five-rapid-clicks.json
def top_five
@top_five = ClickScore.top_five
... |
# Build a program that asks a user for the length and width of a room in meters and then displays
# the area of the room in both square meters and square feet.
# Note: 1 square meter == 10.7639 square feet
# Do not worry about validating the input at this time.
# Example outputs:
=begin
Enter the length of the r... |
# cross the desert the smart way
# keep only directions that aren't cancelled out
# [NORTH, SOUTH, EAST] = [EAST] as north and south cancel each other
PAIRS = {
'NORTH' => 'SOUTH', 'SOUTH' => 'NORTH',
'EAST' => 'WEST', 'WEST' => 'EAST'
}
def reduce_directions(arr)
stack = []
arr.each do |cardinal|
PAIRS[c... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :email, null: false
t.string :password_digest, null: false
t.string :first_name, null: false
t.string :last_name, null: false
t.string :plaid_id
t.string :stripe_account
t.decimal :... |
require 'digest'
class Block
attr_reader :content, :previous_hash
def initialize(content:, previous_hash: 'Vazio')
@content = content
@previous_hash = previous_hash
end
def hash
Digest::SHA256.hexdigest content
end
def print
<<~HEREDOC
#{content}
Hash: #{hash}
Hash Anterior:... |
require 'rails_helper'
describe 'CRUD for reviews' do
before(:each) do
Product.destroy_all
Review.destroy_all
@user = FactoryGirl.create(:user)
@product = FactoryGirl.create(:product)
@review = FactoryGirl.create(:review, :user_id => @user.id, :product_id => @product.id)
login_as(@user, :sco... |
require 'echoe'
Echoe.new('sshkeyproof') do |p|
p.author = "Andrew Snow"
p.email = 'andrew@modulus.org'
p.summary = 'Ruby gem to prove client has the other half of a keypair'
p.url = 'https://github.com/andys/sshkeyproof'
p.runtime_dependencies = ['sshkey']
end
|
require 'rails_helper'
RSpec.describe Product, type: :model do
describe "商品(product)的規格" do
let(:product) { Product.create!( :name => "book", :is_alive => true, :count => 1) }
it "新建一個商品時,有name,預設數量==1,商品狀態為在庫中" do
expect(product.name).to eq("book")
expect(product.count) == (1)
expect(pro... |
class LanguageUsersController < ApplicationController
before_action :set_language_user, only: [:show, :edit, :update, :destroy]
before_action :check_language, only: [:update, :create]
before_action :authenticate_user!, only: [:update, :create, :destroy]
before_action :check_user, only: [:create]
before_action... |
class AddAverageWordCountToProductStat < ActiveRecord::Migration
def self.up
ProductStat.reset_column_information
unless ProductStat.columns.map(&:name).include?('average_word_count')
add_column :product_stats, :average_word_count, :integer, :default => 0
end
end
def self.down
Prod... |
# Mostrar 1-255
# Escriba un programa que muestre todos los números del 1 al 255.
def printRange
(1..255).each { |n| puts n }
end
printRange()
# Mostrar números impares entre 1 y 255
# Escriba un programa que muestre todos los números impares del 1 al 255.
def printEven
(1..255).each { |n| puts n if n % 2 != 0 }
e... |
module DataMapper
module Model
class DescendantSet
include Enumerable
# Append a model as a descendant
#
# @param [Model] model
# the descendant model
#
# @return [DescendantSet]
# self
#
# @api private
def <<(model)
@descendants << mo... |
class RenameLatLongToFlat < ActiveRecord::Migration[5.2]
def change
rename_column :flats, :lat, :latitude
rename_column :flats, :long, :longitude
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class ApplicationController < ActionController::Base
layout :layout_method
private
def layout_method
if login_user_signed_in?
"layout1"
else
"layout2"
end
end
end |
class Calculator::WeightRate < Calculator
preference :base_weight, :decimal, :default => 0
preference :base_cost, :decimal, :default => 0
preference :rate_per_unit, :decimal, :default => 0
def self.description
"Weigh based"
#I18n.t("weight_based")
end
def self.unit
"Weight Unit"
#I18n.t(... |
class Vote < ApplicationRecord
belongs_to :post
belongs_to :user
enum direction: {down: 0, up: 1}
validates:user_id, uniqueness: {scrope: :post_id}
end
|
# Create a person class with at least 2 attributes and 2 behaviors.
# Call all person methods below the class and print results
# to the terminal that show the methods in action.
class Person
attr_accessor :name, :hair_color, :eye_color
def initialize(n, h, e)
@name = n
@hair_color = h
@eye_color = e
... |
Given(/^I am on an article page$/) do
step 'I view an article in English'
end
When(/^I scroll to the bottom of the page$/) do
page.execute_script "window.scrollBy(0,10000)"
end
When(/^I dismiss the newsletter$/) do
home_page.sticky_newsletter.close_button.trigger('click')
page.driver.set_cookie('_cookie_dismi... |
require 'spec_helper'
module Oauth2Provider
describe Client do
before { @client = FactoryGirl.create(:client) }
subject { @client }
it { should validate_presence_of(:name) }
it { should validate_presence_of(:uri) }
it { VALID_URIS.each{|uri| should allow_value(uri).for(:uri) } }
it { should validate_prese... |
class AddModerationStatusToEducations < ActiveRecord::Migration
def change
add_column :educations, :moderation_status, :integer, default: 1
end
end
|
class RemoveMeritFieldsFrom<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def self.up
remove_column :<%= table_name %>, :sash_id
remove_column :<%= table_name %>, :level
end
end
|
# frozen_string_literal: true
require "rails_helper"
RSpec.describe RideCreator do
shared_examples_for "creates valid ride" do
it "calls #create_ride" do
expect_any_instance_of(described_class).to receive(:create_ride)
subject
end
it "creates a ride" do
expect { subject }.to change { ... |
class AddOnestopIdToStops < ActiveRecord::Migration[5.0]
def change
add_column :stops, :onestop_id, :string
add_index :stops, :onestop_id
end
end
|
class AddArchivalFieldsToItems < ActiveRecord::Migration
def change
add_column :items, :creator, :string
add_column :items, :date, :date
add_column :items, :rights_information, :text
end
end
|
# == Schema Information
#
# Table name: evaluations
#
# id :integer not null, primary key
# thought_morals :text
# upright_incorruptiable :text
# duties :text
# created_at :datetime not null
# updated_at :datetime not nul... |
class UsersController < ApplicationController
before_filter :signed_in_user, only: [:edit, :update]
before_filter :correct_user, only: [:edit, :update]
# GET /users
# GET /users.json
def index
@exercise_types = ExerciseType.all
@users = User.all
@goals = Goal.order("progress DESC").where(compl... |
FactoryGirl.define do
factory :experience do
location_id 1
name 'Barbecue at Mom\'s'
description 'It\'s not very far away, so you won\'t need the Airstream.'
location
user
distance 30.00
end
end
|
class CreateSwProjectCustomerQnaxUserRoles < ActiveRecord::Migration
def change
create_table :sw_project_customer_qnax_user_roles do |t|
t.integer :project_info_id
t.string :name
t.text :brief_note
t.integer :last_updated_by_id
t.string :for_department
t.timestamps
end
... |
# ActsAsLoggable
module Acts #:nodoc:
module Loggable #:nodoc:
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_loggable
has_many :logs, :as => :loggable, :dependent => :destroy, :order => 'created_at DESC, id DESC'
include Acts::Loggable... |
class WorkspaceChannel < ApplicationCable::Channel
def subscribed
stream_for "workspace_channel"
end
def speak(data)
new_message = data["message"]
@socket_message = Message.create(new_message)
WorkspaceChannel.broadcast_to("workspace_channel", @socket_message)
end
def unsubscribed
# Any ... |
class JoinCartItemsController < ApplicationController
before_action :set_cart, only: [:create, :destroy]
before_action :authenticate_user!, only: [:create, :destroy]
def create
chosen_item = Item.find(params[:item_id])
current_cart = @current_cart
if !current_cart.items.include?(ch... |
class JobPostsController < ApplicationController
skip_before_filter :authorize
# GET /job_posts
def index
@job_posts = JobPost.all
end
# GET /job_posts/1
def show
@job_post = JobPost.find(params[:id])
end
# GET /job_posts/new
def new
@job_post = JobPost.new
end
# GET /job_post... |
module ManageIQ
module Providers
module Kubernetes
module ContainerManager::RefresherMixin
KUBERNETES_ENTITIES = [
{:name => 'pods'}, {:name => 'services'}, {:name => 'replication_controllers'}, {:name => 'nodes'},
{:name => 'endpoints'}, {:name => 'namespaces'}, {:name => 'resou... |
require 'http'
class Api::V1::ChaptersController < Api::V1::ApiBasicsController
include DeviseTokenAuth::Concerns::SetUserByToken
include NoCaching
include ChaptersApi
skip_before_action :authenticate_api_v1_user!, only: :show
def index
chapter_ids =
AreaChapterConfig.active.by_area(current_api_... |
describe "GenreSelect" do
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormOptionsHelper
class Album
attr_accessor :genre
end
let(:album) { Album.new }
let!(:template) { ActionView::Base.new }
let(:builder) do
if defined?(ActionView::Helpers::Tags::Base)
ActionView:... |
class Contact < ActiveRecord::Base
attr_accessible :email, :name, :message
validates_presence_of :email, :message
end
|
module SchoolfinderApi
module Models
# GBD data
class Gbd < Base
# @return [String] The education.com logo image linking to www.education.com/schoolfinder.
attr_accessor :logosrc
# @return [String] Disclaimer text.
attr_accessor :disclaimer
# @return [String]... |
class Car
attr_accessor :speed
def initialize
@speed = 0
end
def accelerate(speed)
@speed += speed
end
#write Car class code here
end
|
class Session < ActiveRecord::Base
attr_accessible :date, :number
has_many :votes, dependent: :destroy
has_many :assistances, dependent: :destroy
def name
I18n.t("sessions.name", number: self.number)
end
def generate_assistances!
Party.official_ids.each do |official_id|
scraper = Scraper:... |
class Room
def initialize(name, desc)
@name = name
@desc = desc
@exits = {}
@verbs = {}
@objects = {}
end
def update_exits(exitlist)
@exits.update(exitlist)
end
def update_verbs(verblist)
@verbs.update(verblist)
end
def update_object... |
class Plug::Nowplaying
include Virtus.model
attribute :dj, Plug::User
attribute :history_id, String
attribute :media, Plug::Media
attribute :playlist_id, Integer
attribute :timestamp, DateTime
attribute :votes, Hash[Integer => Integer]
attribute :grabs, Set[Integer]
def woot_count
votes.values.... |
class Customer < ActiveRecord::Base
has_many :bills
has_many :review_books
has_many :orders
has_one :users
validates :lastname, presence: true
end
|
class AddReadersToCheckouts < ActiveRecord::Migration
def up
add_column :checkouts, :reader_id, :integer
Checkout.all.each do |checkout|
name = checkout.borrower
reader = Reader.find_by(full_name: name)
checkout.reader = reader
checkout.save!
end
change_column :checkouts, :re... |
require "singleton"
module Collmex
#
# Represents the configuration as an singleton object
# for your Collmex environment.
#
class Configuration
include Singleton
DEFAULTS = {
user: ENV["COLLMEX_USER"],
password: ENV["COLLMEX_PASSWORD"],
customer_id: ENV["COLLMEX_CUSTOMER... |
require 'rails_helper'
RSpec.describe Rating, type: :model do
context "#validation" do
it "rate is from 1 to 5" do
rating = build(:rating)
rating.rate = 6
expect{rating.save!}.to raise_error(ActiveRecord::RecordInvalid)
end
it "user and movie combination is unique" do
existing_r... |
include_recipe "php-fpm::prepare"
php_installed_version = `which php >> /dev/null && php -v|grep #{node["php-fpm"][:version]}|awk '{ print substr($2,1,5) }'`
php_prefix = node["php-fpm"][:prefix]
php_already_installed = lambda do
php_installed_version == node["php-fpm"][:version]
end
remote_file "/tmp/php-#{node[... |
require "rails_helper"
RSpec.describe Webview::DrugStocksController, type: :controller do
before do
Flipper.enable(:drug_stocks)
end
after do
Flipper.disable(:drug_stocks)
end
describe "GET #new" do
let(:facility) { create(:facility) }
it "renders 404 for anonymous users" do
expect {... |
require 'set'
class SpiralMovers
attr_reader :t
def initialize(initial_coordinates)
@movers = initial_coordinates.map { |x, y| Mover.new(Point.new(x, y)) }
@points_occupied = Set.new
record_positions
@t = 0
end
def move
loop do
@movers.each { |mover| mover.move }
remove_move... |
require 'test_helper'
class ShortUrlsShowTest < ActionDispatch::IntegrationTest
def setup
@admin = users(:cthulhu)
@short_url = short_urls(:hits_test)
log_in_as(@admin)
end
test 'shows slug as heading' do
get short_url_path(@short_url)
assert_select 'h2', @short_url.slug
end
test 'shows... |
Rails.application.routes.draw do
resources :orders
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
devise_for :users, skip: [:show], controllers: {
sessions: 'users/sessions',
passwords: 'users/passwords',
registrations: 'users/registrations'
}
root :to => 'products#index'
resource... |
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
class JSRegularExpressionLiteralTest < Test::Unit::TestCase
include TestHelper
def setup
@parser = JSRegularExpressionLiteralParser.new
end
def test_basic_regexp
assert_parsed '/foo/'
end
def test_basic_regexp_with_... |
FactoryGirl.define do
factory :hyperlink do
url "http://guides.rubyonrails.org/"
body "*the* best rails resource"
end
end
|
class RemoteUsdtStandardOrder
attr_reader :id, :user_id, :order_price_type, :contract_code, :lever_rate, :volume, :direction
def initialize(id:, user_id:, contract_code:, lever_rate:, volume:, direction:)
@id = id
@user_id = user_id
@order_price_type = order_price_type
@contract_code = contract_c... |
#!/usr/bin/env ruby
# Script from Brandon to prefix a commit message with first part of the branch name you are on which should be the JIRA card ID
`git rev-parse --abbrev-ref HEAD`.strip =~ /^\S+\/(\w+?\-\w+)\-?.*/
system "commit -m '#{$1} #{ARGV[0]}'"
|
# frozen_string_literal: true
# rubocop:todo all
require 'lite_spec_helper'
describe Mongo::Srv::Result do
let(:result) do
described_class.new('bar.com')
end
describe '#add_record' do
context 'when incoming hostname is in mixed case' do
let(:record) do
double('record').tap do |record|
... |
FactoryGirl.define do
factory :destination do
name do
raise "don't call 'destination' factory directly, use one of the "\
"sub-factories"
end
end
trait :two_letter_code do
sequence(:code) do |n|
str = "AA"
(n - 1).times { str.next! }
str
end
end
trait :thr... |
class Store::Manager::Products::ReviewsController < ApplicationController
# GET /store/manager/products/reviews
# GET /store/manager/products/reviews.json
def index
@store_manager_products_reviews = Store::Manager::Products::Review.all
respond_to do |format|
format.html # index.html.erb
forma... |
require 'spec_helper'
require 'net/http'
describe AmberbitConfig do
describe "GET '/'" do
it 'environments from HTML content and settings should be equal' do
port = '5555'
envs = %w(test development production)
envs.each do |x|
ENV['RAILS_ENV'] = ENV['RACK_ENV'] = x
`rails s -d... |
class Spree::Page < ActiveRecord::Base
#Note: Attempted as decorator but default scope sorting messed up Page.rebuild!
#so had to override model completely
#Added the following
acts_as_nested_set
#Changed this for proper order
default_scope :order => "spree_pages.position ASC"
validates_presence_o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.