text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe AuthorizeApiRequest do
let(:user) { create(:user) }
let(:header) { { Authorization: token_generator(user.email) } }
subject(:invalid_request_object) { described_class.new({}) }
subject(:valid_request_object) { described_class.new(header) }
describe '#call' do
contex... |
And(/^the user selects Canadian French as the language "([^"]*)"$/) do |locale_lang|
on (MoreServicePage) do |page|
DataMagic.load("moreservices.yml")
page.wait_for_page_to_load
page.french_language
end
end
And(/^the user click on the plus option from the service menu drop down$/) do
# on(Navigation... |
class MarkdownContent < ActiveRecord::Base
attr_accessor :component_parent, :component_parent_id
has_many :markdown_content_image
has_many :images, through: :markdown_content_image
before_validation :set_content_to_string
def content_blank?
content.to_s.strip.blank?
end
def parent
@parent ||... |
namespace :client do
desc "handle requests from active amqp accruers"
task fetch_client_messages: :environment do
AmqpAccrual::Config.clients.each do |client|
AmqpAccrual::Receiver.handle_responses(client)
end
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable,
:registerable,
:recoverable,
:rememberable,
:validatable
devise :omniauthable, ... |
class Review < ApplicationRecord
belongs_to :book
belongs_to :user
validates_presence_of :title
validates_presence_of :review_text
validates :rating, presence: true,
numericality: {only_integer: true,
greater_than_or_equal_to: 1,
less_than_or_equal_to: 5}
end
|
class Triangle
attr_accessor :a1, :a2, :a3
def initialize(a1, a2, a3)
@a1 = a1
@a2 = a2
@a3 = a3
end
def kind
validate_triangle
if a1 == a2 && a2 == a3
:equilateral
elsif a1 == a2 || a2 == a3 || a1 == a3
:isosceles
else
:scalene
end
end
def validate_trian... |
# frozen_string_literal: true
FactoryBot.define do
factory :account do
client_id { FactoryBot.create(:client).id }
balance { Faker::Number.number(4) }
a_type { 'Saving' }
number { Faker::Bank.account_number }
end
end
|
class AddFitnessGoalPaymentMethodSubscriptionPlanToMember < ActiveRecord::Migration[5.1]
def change
add_reference :members, :fitness_goal, index: true, foreign_key: true
add_reference :members, :payment_method, index: true, foreign_key: true
add_reference :members, :subscription_plan, index: true, foreign... |
class PublishedsController < ApplicationController
before_action :set_contact
before_action :set_contact_published, only: [:show, :update, :destroy]
def index
json_response(@contact.publisheds)
end
def show
json_response(@published)
end
def create
@contact.publisheds.create!(published_param... |
require "spec_helper"
describe Clockwork::Test do
let(:clock_file) { "spec/fixtures/clock.rb" }
let(:test_job_name) { "Run a job" }
let(:test_job_output) { "Here's a running job" }
it "has a version number" do
expect(Clockwork::Test::VERSION).not_to be nil
end
describe ".run" do
before { Clockwor... |
require "test_helper"
class FeedsControllerTest < ActionController::TestCase
include OrganisationFeedHelpers
test "routing handles paths with just format" do
assert_routing(
"/government/organisations/ministry-of-magic.atom",
controller: "feeds",
action: "organisation",
organisation_na... |
# coding: utf-8
require 'spec_helper'
feature 'Visitor signs up', js: true do
scenario 'with valid data' do
user = factory(:user)
sign_in_with user.email, '123456'
expect(page).to have_content('Выход')
end
end
|
doctype html
html
head
title Rails App
= csrf_meta_tags
= csp_meta_tag
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
//! Fonts and icons
// Font Awesome
link crossorigin="anonymous" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" inte... |
class FlowersController < ApplicationController
def index; end
def new
@flower = Flower.new
end
def create
@flower = Flower.new flower_params
if @flower.save
flash[:success] = t ".flash"
redirect_to @flower
else
render :new
end
end
def show
@flower = Flower.find_... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'home#index'
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
get 'posts/new' => 'posts... |
class AddSentOnColumnToAppointments < ActiveRecord::Migration
def change
add_column :appointments, :sent_on, :text
end
end
|
require 'hammerspace'
##
# Hammerspace-backed Store designed for BasicCache
module HammerStore
class << self
##
# Insert a helper .new() method for creating a new Store object
def new(*args)
self::Store.new(*args)
end
end
##
# Hammerspace-backed store object
class Store
attr_reade... |
# frozen_string_literal: true
module ParallelRunner
CONCURRENT_REQUESTS = 3
private
# TODO(uwe): Use concurrent-ruby instead?
def in_parallel(values)
queue = Queue.new
values.each { |value| queue << value }
threads = Array.new(CONCURRENT_REQUESTS) do
Thread.start { Rails.application.executo... |
Dado("que eu tenho {int} laranjas na bolsa.") do |valor|
@laranja = valor
end
Quando("eu coloco {int} laranjas na bolsa.") do |valor2|
@coloquei = valor2
@resultado = @laranja + @coloquei
end
Então("eu verifico se o total de laranjas é {int}.") do |total|
expect(@resultado).to eq total
end
... |
require 'spec_helper'
describe SPV::Fixtures::Modifiers::ShortcutPath do
describe '#modify' do
let(:path) { 'some home path' }
let(:shortcut_path) { 'some shortcut' }
let(:options) { instance_double('SPV::Options') }
let(:fixture) do
instance_double(
'SPV::Fixture',
... |
class Section < ApplicationRecord
acts_as_paranoid
has_paper_trail
belongs_to :status
belongs_to :visibility
belongs_to :document
belongs_to :created_by, :class_name => "User", :foreign_key => "created_by_id"
belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_id", optional: true
... |
# -*- encoding: utf-8 -*-
# stub: omniauth-moves 0.0.2 ruby lib
Gem::Specification.new do |s|
s.name = "omniauth-moves"
s.version = "0.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Nick Elser"]
s.date = ... |
class CartsController < ApplicationController
before_filter :current_cart
def add
CartItem.create(:product_id => params[:id], :cart_id => current_cart.id)
redirect_to cart_path(current_cart)
end
def show
@cart = Cart.find(params[:id])
@cart_items = CartItem.all.includes(:product)
total= 0... |
require 'spec_helper'
describe ProjectPolicy do
describe 'for a user' do
subject { ProjectPolicy.new(user, project) }
let(:user) { FactoryGirl.create(:user, :with_company) }
describe 'for valid project' do
let(:project) { FactoryGirl.create(:project, user: user) }
it { should permit_action(... |
require_relative 'spec_helper'
require_relative '../lib/Ebook'
describe Ebook do
before(:context) do
@ebook1 = Ebook.new("The Life-Changing Magic of Not Giving a F**k", 11.99, 125, "Sarah Knight")
end
describe "Initialization" do
it "is a kind of the Item class" do
expect(@ebook1).to be_a_kind_of(Ite... |
class Timetrap::Github
def login
octokit.user.login
end
def create_gist(display)
gist = octokit.create_gist(
description: 'Timetrap sheet',
files: { 'overview.txt' => { content: display }}
)
gist[:html_url]
end
# private
def octokit
token = config['access_token']
@octo... |
module XClarityClient
#
# Exposes NodeManagement features
#
module Mixins::NodeMixin
def discover_nodes(opts = {})
node_management.fetch_all(opts)
end
def fetch_nodes(uuids = nil,
include_attributes = nil,
exclude_attributes = nil)
node_management... |
#==============================================================================
# ** Theread Assist
#------------------------------------------------------------------------------
# This defined the method for assist thread
#==============================================================================
#tag: 3( Thread... |
class Round < ActiveRecord::Base
NUMBER_OF_TRICKS = 10
belongs_to :game, touch: true
has_many :cards, dependent: :destroy
has_many :tricks, dependent: :destroy
has_many :bids, dependent: :destroy
validates :game, presence: true
validates :order_in_game, presence: true, numericality: { greater_than_or... |
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [
:last_name,
:first_name,
:last_name_kana,
:first_name_kana,
:postal_code,
:pr... |
require './src/tokenizer/reader/file_reader'
require './src/tokenizer/errors'
require './spec/contexts/test_file'
RSpec.describe Tokenizer::Reader::FileReader, 'file reading in chunks' do
include_context 'test_file'
def init_reader_with_contents(contents)
write_test_file contents
@reader = Tokenizer::Rea... |
require 'test/unit'
require 'action_view'
require 'entitlement/view_helpers'
class View
include Entitlement::ViewHelpers
end
class ViewHelpersTest < Test::Unit::TestCase
def setup
@view = View.new
end
#
# tee
#
def test_tee_with_one_argument
out = @view.tee 'My page'
assert_equal 'My pa... |
class AddColumnProdIdToExpenseProduct < ActiveRecord::Migration
def change
add_column :expense_products, :prod_id, :string
end
end
|
class RemoveCatFromAccompaniments < ActiveRecord::Migration
def change
remove_column :accompaniments, :cat, :string
remove_column :accompaniments, :bearing_id, :integer
end
end
|
# frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'coverage/badge/version'
Gem::Specification.new do |spec|
spec.name = 'coverage-badge'
spec.version = Coverage::Badge::VERSION
spec.authors = ['Andrey Orsoev'... |
class UserMailer < ActionMailer::Base
default from: 'popr.mailer@gmail.com'
def activation_needed_email(user)
@user = user
@url = "http://popr.ca/users/#{@user.activation_token}/activate"
mail(to: @user.email, subject: 'Activate Your Popr Account')
end
def activation_success_email(user)
@user = user
@u... |
Deface::Override.new(
virtual_path: "spree/admin/orders/_line_items",
name: "add_additional_line_item_fields_partial_to_admin_order_view",
insert_bottom: ".line-item-name",
text: "<%= render partial: 'spree/shared/additional_line_item_fields', locals: {item: item} %>"
)
|
FactoryBot.define do
factory :team, class: Team do
name { Faker::Name.unique.name }
short_name { Faker::Name.unique.first_name }
code { Faker::Number.unique.number(5) }
end
end
|
require 'rspec'
require 'rack/test'
require 'byebug'
require_relative "../model/procesador_de_json"
require "json"
describe ProcesadorDeJson do
include Rack::Test::Methods
def app
Sinatra::Application
end
describe "covertir el json de entrada a un hash" do
it "debe devolver el json como un hash" do
... |
class Card < ActiveRecord::Base
has_one :list
has_many :members, class_name: "User"
has_many :activities
end
|
require_relative '../interface/iship'
##
# The ship class holds the crew and is the main component on which
# all the actions are invoked. It can't be directly accessed by the
# crew. They can only use an interface for the ship.
#
class Ship
attr_reader :interface, :data, :crew, :owner
attr_accessor :result, :id
... |
require 'rails_helper'
RSpec.describe BuyForm, type: :model do
describe '#create' do
before do
@user = FactoryBot.create(:user)
@item = FactoryBot.create(:item)
@buy_form = FactoryBot.build(:buy_form, user_id: @user.id, item_id: @item.id)
sleep 0.5
end
context '商品が購入できる時' do
... |
class User < ActiveRecord::Base
has_many :user_beers
has_many :beers, through: :user_beers
def add_beer_to_favorites(beer)
fav_beer = Beer.all.find_or_create_by(name: beer)
self.beers << fav_beer unless self.get_favorite_beer_names.include?(beer)
end
def get_favorite_beer_names
self.beers.map {|... |
class User < ActiveRecord::Base
belongs_to :rating
has_one :order
has_one :task
def as_json(options={})
super(:only => [:name,:phone,:rating],
:include => {
:rating => {:only => [:value]},
}
)
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
acts_as_token_authentication_handler_for User
private
def after_successful_token_authentication
# renew_authentication_token!
end
end
|
require 'aws-sdk-s3'
module OHOLFamilyTrees
class FilesystemS3
attr_reader :bucket
attr_reader :client
attr_reader :default_metadata
def initialize(bucket, metadata = {})
@bucket = bucket
@client = Aws::S3::Client.new
@default_metadata = metadata
end
def with_metadata(meta... |
# U2.W4: Cipher Challenge
# I worked on this challenge with: .
# 1. Solution
# Write your comments on what each thing is doing.
# If you have difficulty, go into IRB and play with the methods.
# Takes a string called coded_message then converts each character into a new element in an array
# Outputs decoded mess... |
require 'sinatra'
get '/' do
"Hello World #{params[:name]}".strip
end
# ENV['RACK_ENV'] = 'test'
#
# # require 'hello_world'
# # require 'test/unit'
# require 'rack/test'
#
# class HelloWorldTest < Test::Unit::TestCase
# include Rack::Test::Methods
#
# def app
# Sinatra::Application
# end
#
# def test_... |
class CompanyInformationController < ApplicationController
before_action :authenticate_user!
def index
@company_information = CompanyInformation.first()
end
end
|
# модель элемента меню
class MenuItem < ActiveRecord::Base
include MultilingualModel
include AutotitleableModel
default_scope { order('weight') }
translates :title
belongs_to :page
belongs_to :menu
has_many :menu_items
belongs_to :menu_item
validates :name, presence: true
# алиас: вложенные э... |
class AddDefaultRecords < ActiveRecord::Migration[6.0]
def change
User.create(:id => 1, :user_name => '--')
['New', 'In Progress', 'Finished'].each_with_index do |state, index|
State.create(:id => index + 1, :state_name => state)
end
end
end
|
class Httest < Formula
desc "Provides a large variety of HTTP-related test functionality."
homepage "https://htt.sourceforge.io/"
url "https://downloads.sourceforge.net/project/htt/htt2.4/httest-2.4.19/httest-2.4.19.tar.gz"
sha256 "0cf2454de50995c14c460040cdf29863dd49082805e2bc61fb6938a7042b2dbd"
bottle do
... |
Rails.application.routes.draw do
resources :news_items
root 'news_items#index'
end
|
#coding:utf-8
require 'selenium-webdriver'
require 'cucumber/rb_support/rb_dsl'
module Mgl
module Test
module Helper
# 启动Webdriver
# @return driver
def self.setup_selenium profile_name='',url = 'http://localhost:4444/wd/hub',timeouts = 5,&profile_settings
profile = Selenium... |
# Class Maglev::System is identically Smalltalk System
#
# == Persistent Shared Counters
#
# Maglev::System maintins a set of persistent shared counters.
#
# Persistent shared counters provide a means for multiple sessions to share
# common integer values. There are 128 persistent shared counters,
# numbered from 1 to... |
class Meme < ApplicationRecord
belongs_to :memer, class_name: "User"
has_many :captions
has_many :comments, as: :commentable
has_many :votes, as: :voteable
validates :photo, presence: true
validates :memer_id, presence: true
def total_votes
vote_total = 0
self.votes.each do |vote|
vote_tot... |
require 'forwardable'
# An object representing a Marketo Lead record.
class MarketoAPI::Lead
extend Forwardable
include Enumerable
NAMED_KEYS = { #:nodoc:
id: :IDNUM,
cookie: :COOKIE,
email: :EMAIL,
lead_owner_email: :LEA... |
class CargoWagon < Wagon
validate :total_volume, :max, 80
def to_s
"Грузовой вагон с доступным объемом: #{available_volume} м3 (#{occupied_volume} м3 занято)"
end
end
|
class Event < ActiveRecord::Base
has_many :event_dates, :order=>:event_date
has_many :roles, :dependent =>:destroy
has_many :users, :through => :roles
has_many :domains
def admin?(user)
user && roles.admin.where(:user_id=>user.id).size > 0
end
def creator?(user)
user && roles.creator.where(:user... |
class RegistrationsController < ApplicationController
before_filter :authenticate_user!
before_action :set_open_mat
def index
@registrations = @open_mat.registrations
end
def new
@registration = @open_mat.registrations.new
end
def create
@registration = @open_mat.registrations.new
@regi... |
module CapybaraSelenium
module AppServer
class BaseConfigurator < Server::Configurator
def apply
Capybara.server_host = host
Capybara.server_port = port
Capybara.app_host = url
end
end
# Class responsible for applying to Capybara the configuration of a Rack
# Web A... |
require_relative 'card'
require_relative 'view'
class Controller
attr_accessor :card_counter, :correct_answer_counter
def initialize
@deck = Deck.new
@view = View.new
@input = ""
@current_answer = nil
@correct_answer_counter = 0
@card_counter = 0
@total_cards = deck.size
end
def r... |
module Components
module Button
class ButtonComponent < Middleman::Extension
helpers do
def button(opts)
return link_to(opts[:text], opts[:href], build_button_html(opts)) if opts[:link]
content_tag(:button, opts[:text], build_button_html(opts))
end
def build_but... |
module LEDENET
module Functions
VALUES = [
SEVEN_COLOR_CROSS_FADE = 0x25,
RED_GRADUAL_CHANGE = 0x26,
GREEN_GRADUAL_CHANGE = 0x27,
BLUE_GRADUAL_CHANGE = 0x28,
YELLOW_GRADUAL_CHANGE = 0x29,
CYAN_GRADUAL_CHANGE = 0x2A,
PURPLE_GRADUAL_CHANGE = 0x2B,
WHITE_GRADUAL_CHANGE... |
class CreateOrganizations < ActiveRecord::Migration[5.2]
def change
create_table :organizations do |t|
t.string :name
t.string :email
t.string :phone
t.string :address
t.string :website
t.string :scales
t.text :description
t.attachment :avatar
t.string :websit... |
module EasyRakeTasksHelper
def task_period_caption(task)
l(:"easy_rake_tasks.periods.#{task.period}", :interval => task.interval)
end
def task_info_status(task_info)
case task_info.status
when EasyRakeTaskInfo::STATUS_RUNNING
l(:'easy_rake_task_infos.status.running')
when EasyRakeTaskInfo... |
class RemoveImageUrLfromCacheResources < ActiveRecord::Migration[5.2]
def change
remove_column :cache_resources, :image_url
end
end
|
class Plug::SockJS
def initialize
@handlers = {}
end
def on(message, &block)
(@handlers[message] ||= []) << block
end
def send(action, param)
hash = {
"a" => action,
"p" => param,
"t" => DateTime.now.strftime('%Q')
}
#puts ">> #{hash.to_json}"
@socket.send([hash.to_... |
RouteTranslator.config do |config|
config.generate_unnamed_unlocalized_routes = true
end |
require 'thor'
require 'rugged'
module Relsr
class Issue < Thor
desc 'checkout ISSUE_NO', 'Checkout an issue locally. Creates a new branch if required'
def checkout(issue)
local_branch_for(issue) || remote_branch_for(issue)
end
map co: :checkout
private
def local_branch_for(issue)
... |
require "rails_helper"
describe "add project" do
it "adds a new project to category" do
admin = FactoryGirl.create(:admin)
login_as(admin, :scope => :admin)
category = FactoryGirl.create(:category)
visit '/'
click_on 'Add a Category'
click_link('Rails', match: :first)
click_on 'Add a Proj... |
class SessionsController < ApplicationController
def new
redirect_to root_path if logged_in?
end
def create
@user = User.find_by(name: params[:name])
if @user && @user.authenticate(params[:password])
cookies.signed[:user_id] = @user.id
flash[:success] = "You are now logged in."
redi... |
require_relative "../require/macfuse"
class WdfsMac < Formula
desc "Webdav file system"
homepage "http://noedler.de/projekte/wdfs/"
url "http://noedler.de/projekte/wdfs/wdfs-1.4.2.tar.gz"
sha256 "fcf2e1584568b07c7f3683a983a9be26fae6534b8109e09167e5dff9114ba2e5"
license "GPL-2.0-or-later"
bottle do
roo... |
class ConsumersController < ApplicationController
load_and_authorize_resource
def update
@consumer.update!(update_params)
render json: {
consumer: ConsumerSerializer.new(@consumer)
}, status: :ok
end
private
def update_params
params.require(:consumer).permit(:first_name,
... |
card_number = "4024007136512380"
valid = false
card = card_number.reverse.split("")
double_card = card.map.with_index do |n, i|
if i.odd?
(n.to_i) * 2
else
n.to_i
end
end
def sum_digits(number)
number.map do |n|
n.to_i
end
.reduce(:+)
end
sum_products = double_c... |
require './lib/craft'
RSpec.describe Craft do
let(:craft) { Craft.new('knitting', {yarn: 20, scissors: 1, knitting_needles: 2}) }
describe '#initialize' do
it 'exists' do
expect(craft).to be_a(Craft)
end
it 'has a name' do
expect(craft.name).to eq('knitting')
end
it 'has required ... |
module Log::Filter
def write_level?(message_level)
if message_level.nil? && !logger_level?
return true
end
if message_level.nil? || !logger_level?
return false
end
precedent?(message_level)
end
def precedent?(message_level)
ordinal(message_level) <= logger_ordinal
end
d... |
#Override Jeweler's classes for properly configure a BioRuby Development Environment/Layout.
# This module should only include methods that are overridden in Jeweler (by
# breaking open the Jeweler::Generator class
require 'bio-gem/mod/jeweler/options'
require 'bio-gem/mod/jeweler/github_mixin'
require 'bio-gem/mod/bi... |
# frozen_string_literal: true
describe Facts::Macosx::Identity::Group do
describe '#call_the_resolver' do
subject(:fact) { Facts::Macosx::Identity::Group.new }
let(:value) { 'staff' }
let(:expected_resolved_fact) { double(Facter::ResolvedFact, name: 'identity.group', value: value) }
before do
... |
#Building Class
class Building
#attr_accessor :building_name, :building_address
attr_accessor :apartments
def initialize
@apartments = ["building_name", "building_address"]
end
def initialize(building_name, building_address)
@building_name = building_name
@building_address = building_address
end
def to... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :sanitize_params, :if => :has_unit_price?
def invoice
Invoice.find(params[:id])
end
def invoice_item
InvoiceItem.find(params[:id])
end
def merchant
Merchant.find(params[:id])
end
de... |
class BookshelfBook < ActiveRecord::Base
belongs_to :bookshelf
belongs_to :book
end
|
require 'test_helper'
class BrodosControllerTest < ActionController::TestCase
setup do
@brodo = brodos(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:brodos)
end
test "should get new" do
get :new
assert_response :success
end
tes... |
module RethinkAPI
class Template
attr_reader :name, :static_attrs, :dynamic_attrs, :has_many_relations
def initialize(name, host_name = nil)
@name = name
@host_name = host_name
@static_attrs = []
@dynamic_attrs = []
@has_many_relations = []
end
def attrib... |
class AuthenticationsController < ApplicationController
def sign_in
@user = User.new
end
def login
email = params[:user][:email]
password = params[:user][:password]
user = User.authenticate(email, password)
if user
session[:user_id] = user.id
redirect_to :root
else
flash.now[:error] = 'Pleas... |
class CreateVetProfiles < ActiveRecord::Migration[5.2]
def change
create_table :vet_profiles do |t|
t.text :clinic_name
t.text :address
t.string :postalcode
t.string :phone
t.string :hours
t.text :services
t.references :vet, foreign_key: true
t.text :image
t.... |
class Comment
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :post
belongs_to :user
field :text, type: String
validates :text, presence: true
end
|
class Task < ApplicationRecord
belongs_to :user
belongs_to :job
has_many :comments
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
private
def require_login
if @user
login(@user)
redirect_to @user
else
redirect_to login_path
end
end
end
|
class Comment < ActiveRecord::Migration[5.0]
def change
t.string :author
end
end
|
Gem.find_files("minitest/*_plugin.rb").each do |plugin_path|
name = File.basename plugin_path, "_plugin.rb"
next if seen[name]
seen[name] = true
require plugin_path
self.extensions << name
end
|
# Daily summary of notebook click actions
#
# Each day, we record the number of unique users ans executors of each notebook.
# We also compute a score reflecting the relative popularity of each notebook
# on this particular day. These daily stats are are used for the activity
# sparkline and are the main component of ... |
class AdminController < ApplicationController
before_filter :admin_lecturer_only!
before_filter :gchart_attendance_this_week, :if => Proc.new { current_user.admin? }
before_filter :gchart_attendance_last_week, :if => Proc.new { current_user.admin? }
def index
if current_user.admin?
render :index
... |
require 'nokogiri'
require 'open-uri'
require 'pry'
class Bestsellers::Category
attr_accessor :name, :titles, :category, :books
@@all = []
def initialize(name)
@name = name
@@all << self
@books = []
end
def self.all
@@all
end
def find_book_by_category_and_index(index)
self.books[i... |
require 'spec_helper'
describe "customer_services/index" do
before(:each) do
assign(:customer_services, [
stub_model(CustomerService,
:partner => nil,
:active_record => false
),
stub_model(CustomerService,
:partner => nil,
:active_record => false
)
])
... |
require "helpers/test_helper"
class UnitTestPubsubCollections < MiniTest::Test
def setup
Fog.mock!
@client = Fog::Google::Pubsub.new(google_project: "foo")
# Enumerate all descendants of Fog::Collection
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class)
@collections = descen... |
require "./lib/product.rb"
require "./lib/greengrocer.rb"
require "./lib/user.rb"
# 商品データ
product_params1 = [
{name: "トマト", price: 100},
{name: "きゅうり", price: 200},
{name: "玉ねぎ", price: 300},
{name: "なす", price: 400}
]
# product_params1 の商品を持つ八百屋の開店
greengrocer1 = Greengrocer.new(product_params1)
# 追加商品データ
a... |
class BillsController < ApplicationController
include BillFinder
before_action :authenticate_user!, only: [:follow, :unfollow]
def show
@bill = bill_details
end
def follow
find_or_create_alert
render json: @alert, status: 201
end
def unfollow
find_and_delete_alert
render json: @ale... |
class CommentSerializer < ActiveModel::Serializer
attributes :id,:body,:user_id
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.