text stringlengths 10 2.61M |
|---|
require 'sinatra/base'
require 'sinatra/activerecord'
require 'date'
require './models/event.rb' # your models
# require 'json' #json support
require './models/score.rb' # your models
# require 'json' #json support
require './models/user.rb' # your models
# require 'json' #json support
class MyApplication < Sinatra::... |
require_relative 'property_utilities'
module AnimalQuiz
class Animal
include PropertyUtilities
attr_reader :name, :properties
def initialize(name, props = [])
@name = name
@properties = props
end
end
end
|
#
# Copyright 2011 National Institute of Informatics.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required ... |
module ProductHelper
def cart_count
count = current_user.products.count
count > 0 ? pluralize(count, 'item') : 'Empty'
end
def cart_link_for(product)
if product.in_cart?
link_to 'Remove From Cart',
product_remove_path(product),
method: :delete,
class: 'btn btn-danger',
... |
Given(/^I login to the "([^"]*)" application$/) do |application|
begin
visit env
sleep 8
arg = getCredentialInfo
fill_in "Username",:with => arg["Username"]
fill_in "Password",:with => arg["Password"]
sleep 5
find("#Login").click
sleep 10
puts "Successfully entered the #{applicati... |
require 'rails_helper'
RSpec.describe DoctorSpecialty, type: :model do
it "Doctor cant have equal specialties" do
specialties = Specialty.create([{name: "Test Specialty 1"}])
doctor = Doctor.new(name: "Doctor Test", crm:"crm test", phone: "phone_test", specialty_ids:[specialties[0].id,specialties[0].id])
... |
RSpec.describe "Announcements" do
it "lists the announcements" do
visit announcements_path
expect(page).to have_current_path(announcements_path)
end
it "lists items on the page" do
announcement = create :announcement
visit announcements_path
expect(page).to have_text announcement.title
en... |
require 'cucumber/formatter/html'
module VagrantPlugins
module Cucumber
module Formatter
class Html < ::Cucumber::Formatter::Html
def puts(message)
# TODO Strip ansi escape codes
@delayed_messages << message
end
... |
class Topic < ApplicationRecord
extend FriendlyId
friendly_id :title, use: :slugged
belongs_to :user
has_many :questions
belongs_to :parent_topic, class_name: 'Topic', foreign_key: :parent_topic_id
has_many :subtopics, class_name: 'Topic', foreign_key: :parent_topic_id
has_many :followings
scope 'par... |
require 'rails_helper'
describe "Beer" do
let!(:brewery) { FactoryGirl.create :brewery, name:"Koff" }
let!(:style) { FactoryGirl.create :style, name:"Lager" }
let!(:user) { FactoryGirl.create :user }
before :each do
visit signin_path
fill_in('username', with:'Pekka')
fill_in('password', ... |
json.array! @images.each do |image|
json.partial! "image.json.jbuilder", images: image
end |
# app/models/post.rb
class Post < ApplicationRecord
# friendly url
extend FriendlyId
friendly_id :title, use: :slugged
# validations
validates_presence_of :title
# callbacks
before_save :anti_spam
def to_s
return "#{self.title}"
end
def anti_spam
doc = Nokogiri::HTML::DocumentFragment.... |
class ControllerAircraft
include Mongoid::Document
field :original_id, type: Integer
field :created_at, type: Time
field :content, type: Hash
after_create :store_standardized_version
def self.parse_zipfile
`unzip -o controller.zip`
`ls controller`.split("\n").each do |file|
listings = JSON.pa... |
require 'spec_helper'
describe command('ufw status verbose') do
its(:stdout) { should match /^Status: active$/ }
its(:stdout) { should match /^Default: deny \(incoming\), allow \(outgoing\), deny \(routed\)$/ }
its(:exit_status) { should eq 0 }
end
|
# The rules of tic-tac-toe are as follows
# There are two players in the game (X and O)
# Players take turns until the game is over
# A player can claim a field if it is not already taken
# A turn ends when a player claims a field
# A player wins if they claim all the fields in a row, column or diagonal
# A game is ov... |
class AddInitialAmountToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :initial_amount, :decimal, precision: 8, scale: 2, default: 0
end
end
|
# Write your code here.
katz_deli = []
def line(deli_line)
if deli_line.length == 0
puts "The line is currently empty."
else
beginning_sentence = "The line is currently:"
list_of_names = []
deli_line.each_with_index do |item, index|
list_of_names.push("#{index+1}. #{item}")
end
puts... |
require 'rubygems'
require 'oauth'
require 'json'
class Twitter
def initialize(user, count)
baseurl = "https://api.twitter.com"
path = "/1.1/statuses/user_timeline.json"
query = URI.encode_www_form(
"screen_name" => "#{user}",
"count" => count,
)
... |
class Contact < ActiveRecord::Base
attr_accessible :contact_us
acts_as_gmappable :check_process => false
def gmaps4rails_address
#describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
"#{self.contact_us}"
end
end
|
module Account
class UsersController < ApplicationController
def show
@user = current_user
end
def edit
@user = current_user
end
def update
@user = current_user
# authorize @user
@user.update(user_params)
redirect_to account_dashboard_path
end
pri... |
#
# 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... |
require 'spec_helper'
describe TagsController do
describe 'GET #index' do
it "populates an array of tags"
it "renders the :index view"
end
describe 'GET #show' do
context "when the tag exists by name" do
it "assigns the requested tag to @tag"
it "renders the :show view"
end
con... |
# encoding: utf-8
pages_names = {
home: 'ГЛАВНАЯ',
concept: 'КОНЦЕПЦИЯ',
place: 'РАСПОЛОЖЕНИЕ',
floor_plans: 'ПЛАНИРОВКА',
service: 'СЕРВИС',
gallery: 'ГАЛЕРЕЯ',
contacts: 'КОНТАКТЫ',
main: 'ГЛАВНАЯ',
}
Page.reset_column_information
pages_names.each do |page_slug, page_name|
parent_page = Page.create... |
require 'spec_helper'
require 'email_spec'
describe PayslipNotifier do
before(:each) do
period = FactoryGirl.build(:periodJan2013)
payroll_tags = PayTagGateway.new
payroll_concepts = PayConceptGateway.new
@payroll_process = PayrollProcess.new(payroll_tags, payroll_concepts, period)
end
it 'Shou... |
Rails.application.routes.draw do
#post "cart_products/update_quantity" => "cart_products#update_quantity"
resources :products do
collection do
get :choose_new_type
get :new_books
get :new_cloth
get :new_snacks
get :category_products
post :create_books
post :create_snac... |
module Closeio
class Client
module OpportunityStatus
def list_opportunity_statuses
get(opportunity_status_path)
end
def create_opportunity_status(options = {})
post(opportunity_status_path, options)
end
def update_opportunity_status(id, options = {})
put(opp... |
# == Schema Information
#
# Table name: gifts
#
# id :integer not null, primary key
# name :string
# description :text
# event_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# photo :string
#
# Indexes
#
# index_gifts_on_event_id ... |
class UserSession < Authlogic::Session::Base
generalize_credentials_error_messages true
single_access_allowed_request_types :all
params_key "api_key"
end |
require File.expand_path '../../spec_helper.rb', __FILE__
require './src/services/location_counts_by_date_importer.rb'
describe "Services::LocationCountsByDateImporter" do
klass = Services::LocationCountsByDateImporter
it "should be defined" do
expect(klass).not_to be nil
end
it "should have an API for pulli... |
module OSMLib
module Element
# OpenStreetMap Way.
#
# To create a new OSMLib::Element::Way object:
# way = OSMLib::Element::Way.new(1743, 'user', '2007-10-31T23:51:17Z')
#
# To get a way from the API:
# way = OSMLib::Element::Way.from_api(17)
#
class Way < OSMLib::Element::Obj... |
class DevicesController < ApplicationController
before_action :set_device, only: [:show, :edit, :update, :destroy] #, :new_point, :new_point1]
before_filter :authenticate_user!, :except => [:new_point, :new_point1]
# GET /devices
# GET /devices.json
def index
#@devices = Device.all
@devices = Devi... |
require 'spree_core'
require "spree_reports/engine"
require "chartkick"
require "groupdate"
module SpreeReports
# list of visible reports
mattr_accessor :reports
# time zone
mattr_accessor :time_zone
# start of week
mattr_accessor :week_start
# export
mattr_accessor :csv_export
# avail... |
require ('minitest/autorun')
require ('minitest/rg')
require_relative ('../models/members')
class TestMember < MiniTest::Test
def setup
@member1 = Member.new({
'first_name' => 'Ricky',
'last_name' => 'Corrigan',
'membership_type' => 'Basic'
})
end
def test_member_first_name
assert_e... |
require 'pry'
class Person
attr_accessor :hair_color, :top_color, :height
attr_reader :height
# Instance Variables
def initialize(height = 0.0)
@height = height
@top_color = 'Black'
@hair_color = 'Blue'
end
def to_s
"Your hair color is #{@hair_color}. Your height is #{@height.to_s... |
class Mytodo < ActiveRecord::Base
attr_accessible :description, :done, :due, :priority
validates :description, presence: true
belongs_to :user
end
|
module TransferAccountService
def self.call(source_account_id, destination_account_id, amount)
account = Account.find_by_account_id(source_account_id)
raise StandardError, 'Source Account not found' unless account
recipient = Account.find_by_account_id(destination_account_id)
raise StandardError, 'D... |
class Public::ArticlesController < PublicController
def index
@page = params.has_key?(:page) ? params[:page] : 1
@limit = limit = APP_CONFIG[:articles_per_page]
@offset = offset = (@page.to_i - 1) * limit;
@articles = Article.all_public(nil, offset, limit)
@page_count = (Article.count_all_public... |
# 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 'spec_helper'
class MoonPresenterSpec < TarotSpec
let(:options) do
{
:phase => phase,
:illumination => illumination,
:is_waxing => is_waxing,
:is_waning => is_waning
}
end
let(:moon) { OpenStruct.new(options) }
let(:phase) { :new }
let(:illumination) { 0 }
let(:is_wa... |
# frozen_string_literal: true
class Api::ServicePlansController < Api::PlansBaseController
before_action :authorize_service_plans!
before_action :activate_sidebar_menu
activate_menu :serviceadmin, :subscriptions, :service_plans
sublayout 'api/service'
def index
@new_plan = ServicePlan
end
def new... |
#Blackjack
#Tealeaf Academy
SUITS = ["Hearts", "Diamonds", "Spades", "Clubs"]
CARDS = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "ACE", "KING", "QUEEN", "JESTER"]
BLACKJACK = 21
DEALER_HIT_LIMIT = 17
#calculates score for respective hand
def calculate_score(hand_of_cards)
card_values = hand_of_cards.map{|car... |
FactoryGirl.define do
factory :user do
name "username"
password "password"
email "sample@example.com"
factory :admin_user do
admin true
end
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 League
class Roster
class CommentEdit < ApplicationRecord
default_scope { order(created_at: :desc) }
belongs_to :created_by, class_name: 'User'
belongs_to :comment, class_name: 'Comment'
validates :content, presence: true
end
end
end
|
class Price
include Comparable
attr_accessor :money
attr_accessor :tax
def initialize(cents, currency, &block)
@currency = currency
@money = Money.new(cents, @currency)
@tax = Money.new(0, @currency)
yield self if block_given?
end
def tax_cents=(cents)
@tax = Money.ne... |
module Byebug
class Breakpoint
def inspect
values = %w{id pos source expr hit_condition hit_count hit_value enabled?}.map do |field|
"#{field}: #{send(field)}"
end.join(", ")
"#<Byebug::Breakpoint #{values}>"
end
end
end
|
json.array! @organization_types do |org_type|
json.id org_type.id
json.title org_type.title
end
|
# == Schema Information
#
# Table name: comunicado_archivos
#
# id :integer not null, primary key
# comunicado_id :integer
# nombre :string
# ruta :string
# created_at :datetime not null
# updated_at :datetime not null
#
class ComunicadoArchivo < Applicat... |
require 'spec_helper'
describe Season do
it { should allow_mass_assignment_of(:name) }
it { should allow_mass_assignment_of(:rounds_attributes) }
it { should validate_presence_of(:name).with_message("Name can't be blank") }
it { should have_many(:rounds).dependent(:destroy) }
it { should accept_nested_attrib... |
# -*- coding: utf-8 -*-
class TopPage < ActiveRecord::Base
# Relation
belongs_to :person
# Validations
validates :planed_value, :numericality => true
validates :erned_value, :numericality => true
def rate
self.erned_value / planed_value
end
end
|
class Review < ActiveRecord::Base
belongs_to :user
has_attached_file :photo, styles: { thumbnail: "50x50>" }
validates_attachment_content_type :photo, :content_type => /\Aimage\/.*\Z/
end
|
#!/usr/bin/env ruby
# frozen_string_literal: true
class Score
attr_reader :frame_score
def initialize
score = ARGV[0]
# @resultscore = score.split(',').map{|s| s == 'X'? 10, 0 : s.to_i} 折りたたみ演算で記述したかったのですができず。
@frame_score = score.split(',').each_with_object([]) do |s, result|
if s == 'X' # str... |
class InfoQuery < ApplicationQuery
def initialize(options = {})
@current_user = options[:current_user]
@query = SqlQuery.new(:info_query)
end
private
attr_accessor :current_user, :query
end
|
require "UnitTest"
class Board_Manual_Key < UnitTest
private
#####################################
# DEFAULT PARAMETERS #
#####################################
@@DEFAULT_EXECUTION_TIMEOUT = 30;
#####################################
# TEST DESCRIPTION #
################... |
require File.dirname(__FILE__) + '/../spec_helper'
###
# CONVIENENCE METHODS
###
def build_valid_endeca_dimension_value(opts=nil, create=false)
opts ||= {}
unless opts.key?(:endeca_dimension)
opts[:endeca_dimension] = mock_model(EndecaDimension)
end
unless opts.key?(:name)
opts[:name] = ... |
module VCAP::CloudController
module AnnotationsUpdate
class TooManyAnnotations < StandardError; end
class << self
def update(resource, annotations, annotation_klass)
annotations ||= {}
starting_size = annotation_klass.where(resource_guid: resource.guid).count
annotations.each do... |
class Sqlite3BTree
attr_accessor :header, :cells, :file
@@types = {2 => 'Interior Index', 5 => 'Interior Table', 10 => 'Leaf Index', 13 => 'Leaf Table'}
def initialize(f)
@file = f
old = @file.pos
self.header = parse_header
self.cells = parse_cells(self.header[:cells])
@file.pos = old
end... |
RSpec.describe ContactsController, type: :controller do
describe 'GET #index' do
it_behaves_like 'Unauthorized'
context 'When user logged in' do
sign_in_user
it 'renders main contacts page' do
get :index
expect(response).to render_template :... |
require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test_helper')
class EditCollectionsTest < ActionDispatch::IntegrationTest
setup do
@collection = Collection::SKOS::Unordered.new.publish.tap { |c| c.save }
end
test 'create a new collection version' do
login('administrator')
... |
# == Schema Information
#
# Table name: documents
#
# id :integer not null, primary key
# title :text not null
# filename :text not null
# date :date not null
# type :string(255) not null
# is_public :boolean ... |
class Company < ActiveRecord::Base
attr_accessible :company_url, :image_url, :name, :featured
validates :company_url, presence: true
validates :image_url, presence: true
validates :name, presence: true
has_many :sponsorships
has_many :events, through: :sponsorships
scope :featured, where(featured: true... |
class CreateArenas < ActiveRecord::Migration[6.0]
def change
create_table :arenas do |t|
t.string :arena_name
t.text :arena_description
t.timestamps
end
end
end
|
class ClassChangesController < ApplicationController
before_action :user_signed_in
before_action :user_has_profile
before_action :find_clazz
before_action :owns_clazz
before_action :not_in_the_past
before_action :not_canceled, only: :cancel
before_action :canceled, only: :uncancel
before_action :not_sub... |
# encoding: utf-8
class Omniauth
def initialize(omniauth)
@omniauth = omniauth
end
def provider
@omniauth[:provider].to_s.downcase
end
def uid
@omniauth[:uid]
end
def email
@omniauth[:info][:email].to_s.downcase
end
def avatar
@omniauth[:info][:image]
end
def name
@o... |
class AbstractTaskWrapper
def call
catch(:done) do
loop do
ActiveSupport::Notifications.instrument('pipeline.task_wrapper.loop', name: name) do
do_work
rescue ApplicationError => e
Rails.logger.error "#{e.message}\n#{e.backtrace}"
next
end
end
... |
class Label < ApplicationRecord
has_many :task_labels, dependent: :destroy
has_many :tasks, through: :task_labels, source: :task
validates :name,
presence: true,
length: { maximum: 20 },
uniqueness: true
end
|
class TripSeparator
include GeocodeUtil
STOP_TIME_THRESHOLD_S = 15 * 60
attr_accessor :visited_regions, :region, :locs
def initialize(user)
@user = user
@visited_regions = []
end
def calc_and_save_trips
until (locs = unprocessed_locations).empty?
Rails.logger.debug "Separating trips ba... |
require 'rails_helper'
describe User do
it { expect(subject).to have_many(:users_groups) }
it { expect(subject).to have_many(:groups).through(:users_groups) }
it { expect(subject).to have_many(:expenses) }
it { expect(subject).to have_many(:users_expenses) }
it { expect(subject).to have_many(:owned_expenses)... |
# == Schema Information
#
# Table name: lists
#
# id :integer not null, primary key
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# description :string(255)
# user_id :integer default(0), not null
#
require 'spec_helper... |
class NoteItem
include Listable
attr_reader :description
@@note_items = []
def initialize(description)
@description = description
@@note_items << self
end
def self.note_items
unless @@note_items == 0
@@note_items
else
puts "There are no notes in this list"
end
end
def details
"Note ... |
class Question < ActiveRecord::Base
ANSWER_KEYS = { 0 => 'no',
1 => 'yes',
2 => 'partially'}
belongs_to :control
def answer
ANSWER_KEYS[self.answer_id]
end
end
|
class Api::FollowingsController < ApplicationController
def create
new_follow = Following.new
new_follow.followee_id = params[:user_id]
new_follow.follower_id = current_user.id
if new_follow.save
@user = current_user
render 'api/users/show'
else
render json: new_follow.errors.fu... |
class Product < ActiveRecord::Base
belongs_to :merchant
has_many :orders
has_many :sales, through: :orders, source: :merchant
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
it { should have_many :questions }
it { should have_many :badges }
it { should have_many :likes }
it { should have_many(:authorizations).dependent(:destroy) }
it { should have_many(:subscriptions).dependent(:destroy) }
it { should validate_presen... |
#This is assignment 23
#
load 'a23_InvoiceItemClass.rb'
load 'a23_Invoiceclass.rb'
require 'active_support'
require 'active_support/all'
b = Invoice.new
loop do
puts ' '
puts "Enter a product name:"
product_name = gets.chomp
break if product_name == '\q'.downcase
puts ' '
puts "Enter a sales price:"
... |
require 'rails_helper'
describe User do
it "can be a shopper" do
user = create :user, :shopper
expect( user.shopper? ).to eq true
end
it "can be a seller" do
user = create :user, :seller
expect( user.seller? ).to eq true
end
it "is a shopper by default" do
user = create :user, role=ni... |
class ProjectUpdatesController < ApplicationController
breadcrumb "Project Updates", :project_updates_path, match: :exact
before_action :get_project_update, except: [:index, :new, :create]
def index
@project_updates = ProjectUpdate.paginate(page: params[:page], per_page: 15)
end
def show
breadcrumb ... |
# frozen_string_literal: true
class AddDefaultImageToReviews < ActiveRecord::Migration[5.1]
def change
change_column :reviews, :image, :string, default: 'https://www.eaglenewsonline.com/wp-content/uploads/2018/12/paws-tongue.jpg'
end
end
|
require "test_helper"
require "minitest/spec"
module ActiveRecord::Snapshot
class ImportTest < ActiveSupport::TestCase
extend MiniTest::Spec::DSL
let(:rake_task) { stub("Rake Task", invoke: true) }
before do
Object.any_instance.stubs(:puts)
end
describe "::call" do
describe "given n... |
# frozen_string_literal: true
require "cbor"
require "uri"
require "openssl"
require "webauthn/authenticator_data"
require "webauthn/authenticator_response"
require "webauthn/attestation_statement"
require "webauthn/client_data"
require "webauthn/encoder"
module WebAuthn
class AttestationStatementVerificationError... |
module Httpotemkin
class Client
attr_reader :out, :err, :exit_code
def initialize(containers)
@containers = containers
end
def execute(cmd, working_directory: nil)
@out, @err, @exit_code = @containers.exec_client(cmd, working_directory: working_directory)
end
def inject_tarball(... |
#------------------------------------------------------------------------------
# Copyright (c) 2013 The University of Manchester, UK.
#
# BSD Licenced. See LICENCE.rdoc for details.
#
# Taverna Player was developed in the BioVeL project, funded by the European
# Commission 7th Framework Programme (FP7), through grant ... |
Rails.application.routes.draw do
resources :ai_books
# Home
root to: 'landing#index'
# Oauth2
use_doorkeeper do
skip_controllers :authorizations, :applications,
:authorized_applications
end
# RESTful API
scope '/api' do
scope '/v1' do
post '/register' => 'auth#regist... |
require_relative '../../../../test_helper'
require 'ehonda/middleware/server/active_record/transaction'
middleware_class = Ehonda::Middleware::Server::ActiveRecord::Transaction
retrier_class = Ehonda::Middleware::Server::ActiveRecord::Retrier
describe middleware_class do
let(:error) { nil }
let(:worker) { Object.... |
# frozen_string_literal: true
class CreateTransactions < ActiveRecord::Migration[6.0]
def change
create_table :transactions do |t|
t.references :store, null: false, foreign_key: true
t.datetime :transacted_at, null: false
t.references :transaction_type, null: false, foreign_key: true
t.in... |
require 'test_helper'
class PostsControllerTest < ActionController::TestCase
def setup
login_as(users(:admin))
end
test 'index' do
get :index
assert_redirected_to posts(:base)
end
test 'new' do
get :new
assert_response :success
end
test 'create invalid' do
Post.stub_any_instan... |
require_relative 'gratter_class.rb'
require_relative 'prepare.rb'
base_url = "http://www.tinymixtapes.com/music-reviews?page=0"
base_xpath = { :links => "//section[@class='tile-panel tile-panel--archive view view-TMT7-Music-Reviews view-id-TMT7_Music_Reviews view-display-id-page_1 view--musicreview view-dom-id-1']//a[... |
class GrumblersController < ApplicationController
def index
@grumblers = GrumblerModel.all
render json: @grumblers.to_json
end
def show
@grumbler = GrumblerModel.find(params[:id])
render json: @grumbler.to_json
end
def new
@grumbler = Grumbler.new
end
def create
@grumbler = GrumblerModel.new(grumb... |
# frozen_string_literal: true
module ActiveStorage
class InvariableError < StandardError; end
class UnpreviewableError < StandardError; end
class UnrepresentableError < StandardError; end
end
|
require 'rails_helper'
describe 'Routing' do
example 'Staff page top' do
expect(get: 'http://baukis.example.com').to route_to(
host: 'baukis.example.com',
controller: 'staff/top',
... |
class LinksController < ApplicationController
before_filter :require_user, except: [:index, :show]
expose(:reference) { Reference.find params[:reference_id] }
expose(:links) { reference.links }
expose(:link)
def index
index!(link)
end
def new
new!(link)
end
def show
redirect_to referenc... |
class JudgingController < ApplicationController
before_filter :authenticate_user!
def outstanding_reviews
@scorecards = Judging.outstanding_reviews(current_user.username)
end
def scorecard
@participant = Participant.find(params[:participant_id])
@submissions = @participant.current_submissions(@participant.c... |
module Sluggable
extend ActiveSupport::Concern
included do
before_save :call_slug
end
def to_param
self.slug
end
def generate_slug(column)
the_slug = to_slug(column)
obj = self.class.find_by(slug: the_slug)
count = 2
while obj && obj != self
the_slug = append_suffix(the_slu... |
# Write a method reverse_array to reverse the order of elements in an array. You will take in an array as a parameter, and will return the reversed array. You may not use the .reverse method
def reverse_array(n)
newArr=[]
n.each do |i|
newArr.push(n[-i])
end
return newArr
end
p reverse_array([... |
feature 'testing a user can sign up' do
scenario 'a user signs up with a username, email and password' do
visit '/users/new'
expect(page).to have_css("input[type=text][name='username']")
expect(page).to have_css("input[type=email][name='email']")
expect(page).to have_css("input[type=password][name='pa... |
class Fluentd
module Setting
class InMonitorAgent
include Fluentd::Setting::Plugin
register_plugin("input", "monitor_agent")
def self.initial_params
{
bind: "0.0.0.0",
port: 24220,
emit_interval: 60,
include_config: true,
include_retry:... |
# frozen_string_literal: true
# Used for creating exceptions with the Ldap connections and configuration
module LdapQuery
class Error < StandardError; end
class AttributeError < Error; end
class ConnectionError < Error; end
class CredentialsError < Error; end
class ConfigError < Error; end
end
|
# frozen_string_literal: true
module Sentry
class DummyTransport < Transport
attr_accessor :events, :envelopes
def initialize(*)
super
@events = []
@envelopes = []
end
def send_event(event)
@events << event
end
def send_envelope(envelope)
@envelopes << envelop... |
class ItemOutputsController < ApplicationController
before_action :set_item_output, only: [:show, :edit, :update, :destroy]
# GET /item_outputs
# GET /item_outputs.json
def index
@item_outputs = ItemOutput.order(departure_date: :desc).page(params[:page])
end
# GET /item_outputs/1
# GET /item_outputs... |
# frozen_string_literal: true
module IndieLand
module Response
# List of future events
RangeEvents = Struct.new(:range_events)
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.