text stringlengths 10 2.61M |
|---|
def bubble_sort(array)
n = array.length # in computer science an array is referred to as 'n'.
loop do
is_swapped = false
(n-1).times do |i|
# if current element > next element
if array[i] > array[i +1]
# swap values
array[i], array[i + 1] = array[i + 1], array[i]
#... |
class ScreenshotsController < ApplicationController
before_action :set_screenshot, only: [:show, :edit, :update, :destroy]
before_action :correct_user, only: [:edit, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
def index
@screenshots = Screenshot.all.order("created_at DESC"... |
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
describe RipperRubyParser::Parser do
let(:parser) { RipperRubyParser::Parser.new }
describe '#parse' do
it 'returns an s-expression' do
result = parser.parse 'foo'
result.must_be_instance_of Sexp
end
describe 'for an emp... |
module Pacer
module Pipes
class WrappingPipe < RubyPipe
attr_reader :graph, :element_type, :extensions, :wrapper
def initialize(graph, element_type = nil, extensions = [])
super()
if graph.is_a? Array
@graph, @wrapper = graph
else
@graph = graph
@... |
module ROXML
unless const_defined? 'XML_PARSER'
begin
require 'libxml'
XML_PARSER = 'libxml'
rescue LoadError
XML_PARSER = 'rexml'
end
end
require File.join(File.dirname(__FILE__), 'xml', XML_PARSER)
#
# Internal base class that represents an XML - Class binding.
#
class XML... |
When("I try to delete my Lists") do
visit "https://www.ferguson.com/myAccount/myList"
60.times do
@mylist_page.Click_MoreActions
@mylist_page.Click_MoreActionsDelete
@mylist_page.Click_YesBtnDeleteList
end
end
Then("I should be able to delete my list successfully") do
... |
require_relative '../UI/character_ui.rb'
require_relative './character_modules/character_combat.rb'
# Base class for all characters that show up in the game.
class Character
attr_reader :name, :alive, :party, :party_number
attr_reader :initiative, :level, :hp, :max_hp, :mana, :max_mana, :ac
include CharacterUI
... |
get '/' do
erb :index
end
post '/login' do #find user, start session
@user = User.authenticate(params[:username], params[:password])
if @user
session[:user_id] = @user.id
redirect '/profile'
else
@errors = "Username and/or password not valid. Try again."
erb :index
end
end
get '/signup' do ... |
Card = Struct.new(:rank, :suit) do
def to_s
"#{rank.capitalize} of #{suit.capitalize}"
end
def ==(other_card)
self.rank == other_card.rank
end
end
|
require "fluent/plugin/filter"
module Fluent::Plugin
class SumologicK8sEventFilter < Fluent::Plugin::Filter
Fluent::Plugin.register_filter("sumologic_k8s_event", self)
helpers :record_accessor
def configure(conf)
super
@timestamp = record_accessor_create('$.@timestamp')
@kubernetes_ev... |
require 'json'
module SolidusMailchimpSync
# Line item for Cart or Order, mailchimp serializes the same
class LineItemSerializer
attr_reader :line_item
def initialize(line_item)
@line_item = line_item
end
def as_json
{
id: line_item.id.to_s,
product_id: line_item.produ... |
class AddGuestIdToVotes < ActiveRecord::Migration
def self.up
add_column :votes, :guest_id, :string, :limit => 36, :null => false, :default => 0
add_index :votes, [:option_id, :guest_id], :unique => true
end
def self.down
remove_column :votes, :guest_id
end
end
|
class Song
attr_accessor :artist
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def artist_name
artist ? self.artist.name : nil
end
end |
class Charge < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :customer_charge_id, :user_id
belongs_to :user
# attr_accessible :title, :body
end
|
require 'wlang'
require 'wlang/wlang_command_options'
require 'wlang/dialects/standard_dialects'
module WLang
#
# Provides the _wlang_ commandline tool. See 'wlang --help' for documentation.
#
class WLangCommand
# Creates a commandline instance.
def initialize()
end
# Run _wlang_ commandl... |
module ExchangeRateService extend self
CURRENCY_DATA = YAML.load_file(
Rails.root.join('config', 'currencies.yml')
).with_indifferent_access.freeze
CURRENCIES = CURRENCY_DATA.keys.freeze
CACHE_TIMEOUT = 15.minutes.freeze
def current_price(currency, formatted=false)
if formatted
MoneyService.fo... |
class AddOrderToFeNavigationItems < ActiveRecord::Migration[5.0]
def change
add_column :fe_navigation_items, :order, :integer, after: :parent_id, null: false, default: 0
end
end
|
class Admin::ChargesController < ApplicationController
before_action :admin_access
def index
@charges = Billing::Charge.order("created_at DESC")
end
def show
@charge = Billing::Charge.find(params[:id])
end
def new
@charge = Billing::Charge.new
end
def create
charge = Billing::Charge.... |
require 'test_helper'
module SurveyBuilder
class SurveyFormsControllerTest < ActionController::TestCase
setup do
@survey_form = survey_forms(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:survey_forms)
end
test "should ge... |
class LikeALittlesController < ApplicationController
before_action :signed_in_student, only: [:index, :create, :destroy]
def index
@lals = LikeALittle.where(:school => current_student.school ).includes(:student, :school)
@like_a_little = current_student.like_a_littles.new
end
def create
@lal = cur... |
require 'rails_helper'
RSpec.describe Item do
describe "visiting items pages" do
before(:each) do
@merchant = create(:merchant)
@item = create(:item, merchant_id: @merchant.id)
item_2 = create(:item, id: 2, merchant_id: @merchant.id)
end
it "can visit an item show page" do
get "/... |
class Api::V1::ShoppingListProductsController < ApplicationController
def index
@shoppinglistproducts = ShoppingListProduct.all
render json: @shoppinglistproducts
end
def create
@shoppinglistproduct = ShoppingListProduct.create(shopppinglistproduct_params)
if @shoppinglistproduct.save
... |
#
# for CentOS 6.x
#
execute "install remi repository" do
command "rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm"
not_if "rpm -qa | grep remi"
end
service "mysqld" do
action :stop
only_if "service mysql"
end
execute "remove installed mysql" do
command "yum remove -y mysql"
only_if ... |
class Attempt < ActiveRecord::Base
belongs_to :webhook
belongs_to :post_error
validate :success_not_nil
validate :success_without_error
attr_accessible :success, :error
def success_without_error
(@success and not @error) or (@error and not @success)
end
def success_not_nil
!@success.nil?
end... |
class TracksController < ApplicationController
def new
@track = Track.new
render :new
end
def create
@track = Track.new(track_params)
if @track.save
album = Album.find(@track.album_id)
redirect_to album_url(album)
else
render :new
end
end
private
def track_params
params.require(:track)... |
class RecycleController < ApplicationController
before_action :ensure_admin_in
before_action :set_menu_item, only: %i[ restore_menu_items delete_menu_item ]
before_action :set_menu_cetegory, only: %i[ restore_menu_category delete_menu_category ]
def menu_items_recycle
@pagy, @menuItems = pagy(MenuItem.wher... |
Rails.application.routes.draw do
resources :document_pages
resources :documents
root to: 'documents#new'
end
|
class Buda < ActiveRecord::Base
belongs_to :brecord, :foreign_key => 'bobjid'
end
# == Schema Information
#
# Table name: budas
#
# bobjid :integer(10)
# bname :string(16)
# bvalue :string(80)
# btimestamp :datetime
# bmdtid :integer(10)
# bsubclusterid :integer(5)
#
|
require 'spec_helper'
module Alchemy
describe EssencePicture do
it "should not store negative values for crop values" do
essence = EssencePicture.new(:crop_from => '-1x100', :crop_size => '-20x30')
essence.save!
essence.crop_from.should == "0x100"
essence.crop_size.should == "0x30"
e... |
class Notifications < ActionMailer::Base
default from: "admin@example.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notifications.new_pin.subject
#
def new_pin(conference)
@conference = conference
@pin = Hash.new()
if conference.co... |
class Api::Internal::TeamsController < ApplicationController
before_action :load_team, only: [:show, :update, :destroy]
def index
@teams = Team.where(tournament_id: params[:tournament_id])
render json: @teams
end
def create
head(:unauthorized) && return unless verified_user?
@team = Team.ne... |
class Tweet < ApplicationRecord
belongs_to :user
has_many :coments #commentsテーブルとのアソシエーション
end
|
# frozen_string_literal: true
# rubocop:todo all
require 'lite_spec_helper'
describe Mongo::Auth::Aws::Credentials do
describe '#expired?' do
context 'when expiration is nil' do
let(:credentials) do
described_class.new('access_key_id', 'secret_access_key', nil, nil)
end
it 'returns fa... |
require 'capybara/rspec'
require 'capybara/dsl'
feature 'Enter names and email' do
scenario 'submitting names and email' do
sign_in_and_play
expect(page).to have_content 'Thanks for signing in Dave. Will email you at Mittens@hotmail.com'
end
end
feature 'Submit takes to correct page' do
scenario 'submi... |
class Actions::NewPrivateKey
extend Extensions::Parameterizable
with :public_key
def call
api = Models::Api.find_by public_key: public_key
Models::PrivateKey.create api: api
end
end
|
class HistogramController < ApplicationController
def show
set_course
@bounds = []
render template: "histogram.html.erb",
:locals => { grades_counts: grades_counts}
end
def submitbounds
render json: {"submit": "grade bounds "}
end
def grades_counts
grades = @course.enrolls.collec... |
require "rails_helper"
describe "routes for tags" do
it "routes GET /repo/foo.bar/tag/latest to the tags controller" do
expect(get("/repo/foo.bar/tag/latest")).to route_to(
controller: "tags",
action: "show",
repo: "foo.bar",
tag: "latest"
)
end
it "routes GET /r... |
require "spec_helper"
describe Game do
let(:game) { Game.new("hello") }
describe "#new" do
it "sets game_word" do
display = game.game_word
expect(display).to be_an_instance_of(Array)
string = display.join
expect(string).to eql(game.word)
end
it "sets a display word" do
dis... |
# frozen_string_literal: true
require 'prawn/core'
require 'prawn/format'
require "prawn/measurement_extensions"
require 'gruff'
require 'pdf/format'
require 'pdf/data'
require 'pdf/styles/colored'
# REFACTOR: extract abstract Report class, and DRY functionality with InvoiceReporter
module Pdf
class Report
incl... |
FactoryGirl.define do
factory :audit_report do
data do
{
'name' => name,
'date' => Date.today,
'audit_structures' => []
}
end
sequence(:name) { |num| "report#{num}" }
user
initialize_with do
AuditReportCreator.new(
data: data,
user: user,
... |
Rails.application.routes.draw do
get 'cart' => 'cart#index', as: :cart
post 'cart/add/:id' => 'cart#add_item', as: :cart_add_item
post 'cart/checkout' => 'cart#checkout', as: :checkout
delete 'cart/empty' => 'cart#empty', as: :cart_empty
delete 'cart/remo... |
# frozen_string_literal: true
if defined? RSpec # otherwise fails on non-live environments
task(:spec).clear
desc 'Run all specs/features in spec directory'
RSpec::Core::RakeTask.new(spec: 'db:test:prepare') do |t|
t.pattern = './spec/**/*{_spec.rb,.feature}'
end
end
|
print 'Enter your car model: '
car_model = gets.strip
output = case car_model
when 'Focus', 'Fiesta' then 'Ford'
when 'Ibiza' then 'Seat'
when 'Civic' then 'Honda'
else 'Unknown model'
end
puts "The car company for #{car_model} is: " , output
puts "Please enter you role: Example 0 for Admin, \n1 for Manager, \n2 for ... |
require "miw/layout"
require "miw/size"
module MiW
module Layout
class Box
RESIZE_DEFAULT = [false, false].freeze
WEIGHT_DEFAULT = [100, 100].freeze
MIN_SIZE_DEFAULT = [0, 0].freeze
MAX_SIZE_DEFAULT = [Float::INFINITY, Float::INFINITY].freeze
def initialize(dir = 0, spacing = 0, co... |
describe "POST /signup" do
context "novo usuario" do
before(:all) do
payload = { name: "Alexandre Filho", email: "alexandrefilhor@gmail.com", password: "Teste@123" }
MongoDB.new.remove_user(payload[:email])
@result = Signup.new.create(payload)
end
it "Valida status code" do
... |
require 'rails_helper'
RSpec.describe "transactions/new", type: :view do
before(:each) do
assign(:transaction, Transaction.new(
:from_id => 1,
:to_id => 1,
:money => 1,
:reason => "MyText"
))
end
it "renders new transaction form" do
render
assert_select "form[action=?][m... |
# frozen_string_literal: true
# rubocop:todo all
require 'lite_spec_helper'
require 'support/shared/server_selector'
describe Mongo::ServerSelector::Primary do
let(:name) { :primary }
include_context 'server selector'
let(:default_address) { 'test.host' }
it_behaves_like 'a server selector mode' do
le... |
# encoding: utf-8
#
control "V-92255" do
title "The Red Hat Enterprise Linux operating system must have a host-based intrusion detection tool installed."
desc "Adding host-based intrusion detection tools can provide the capability to automatically take actions in response to malicious behavior, which can provide a... |
class Bstorage < ActiveRecord::Base
has_many :blocations, :foreign_key => 'bobjid'
has_many :bfiles, :foreign_key => 'bstorage', :primary_key => 'bname'
def open?
baccess == 'OPEN'
end
end
# == Schema Information
#
# Table name: bstorages
#
# bsubclusterid :integer(5)
# id :integer(10) ... |
class AddTenantIdToFaxAccount < ActiveRecord::Migration
def change
add_column :fax_accounts, :tenant_id, :integer
add_column :fax_accounts, :station_id, :string
end
end
|
module Faceter
module Nodes
# The node describes removing prefix from tuples' keys
#
# @api private
#
class RemovePrefix < ChangePrefix
private
def __operation__
:drop_prefix
end
end # class RemovePrefix
end # module Nodes
end # module Faceter
|
module Api
class BaseController < ApplicationController
before_filter :authenticate_user
private
def authenticate_user
auth_token = request.headers["Authorization"]
return render status: 401, json: { status: :failed, error: 'No access token passed' } if auth_token.blank?
@user = User.... |
# encoding: utf-8
class Cjdns
VERSION = '0.0.0'
end
|
# Virus Predictor
# I worked on this challenge with Stephen Fang.
# We spent 2 hours on this challenge.
# EXPLANATION OF require_relative
# require_relative takes the file from the local / relative folder and inputs the called file into the current file. Require may be useful if the file isn't relative and you need t... |
require 'addressable/uri'
module Rack
module WebSocket
class Connection
include Debugger
def initialize(app, socket, options = {})
@app = app
@socket = socket
@options = options
@debug = options[:debug] || false
socket.websocket = self
socket.comm_ina... |
class RemoveIndexSubscriptionToPlan < ActiveRecord::Migration
def change
remove_foreign_key :plans , :subscription
remove_index :plans , :subscription_id
remove_column :plans , :subscription_id
add_column :plans , :owner_id , :integer
end
end
|
class Task < ApplicationRecord
belongs_to :user, optional: true
belongs_to :category
belongs_to :assigned, class_name: "User", foreign_key: "assigned_id", optional: true
end
|
class DefaultChangeValidator < ActiveModel::EachValidator # :nodoc:
def validate_each(record, attribute, value)
return unless record.default_changes[attribute]
record.errors.add(attribute, 'changed by default')
end
end |
class GroupMembership < ActiveRecord::Base
attr_accessible :join_comment
validates_presence_of :group_id, :user_id
validates_length_of :join_comment, :maximum => 200
belongs_to :user
belongs_to :group
end
|
# encoding: utf-8
#
# Основной класс игры Game. Хранит состояние игры и предоставляет функции для
# развития игры (ввод новых букв, подсчет кол-ва ошибок и т. п.).
class Game
attr_reader :letters, :good_letters, :bad_letters
attr_accessor :status, :errors
MAX_ERRORS = 7
# принимает на вход загадное слово
def... |
class User < ApplicationRecord
has_many :events
has_many :event_followers, foreign_key: "follower_id", dependent: :destroy
has_many :joined_events, through: :event_followers, source: :event
has_many :posts
before_save { self.email = email.downcase }
validates :email, presence: true, length: { maximum: 255 },... |
class ApplicationController < ActionController::Base
protect_from_forgery :with => :exception
before_action :authorize
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
def authorize
redirect_to root_path unless current_user... |
require_relative "listings_menu"
require_relative "financial_menu"
require_relative "welcome_menu"
require_relative "../data/database_handler"
module SaveMenu
#Shows main menu for saving information to file
def SaveMenu.show
system "cls"
puts "============================================================"
... |
require_relative 'node'
class List < Node
attr_accessor :head, :tail, :name, :count
def initialize
self.head = nil
self.tail = nil
@count = 0
end
def head_value
return self.head.data
end
def tail_value
return self.tail.data
end
def count
@count
end
def pop
return nil... |
json.array!(@current_telematics_data) do |current_telematics_datum|
json.extract! current_telematics_datum, :id, :vehicle_id, :vin_number, :gps_date_time, :lat, :lon, :direction, :gps_speed, :soc, :dte, :odometer, :car_status, :hvac_status, :server_time
json.url current_telematics_datum_url(current_telematics_datum... |
require 'spec_helper'
describe Comment do
let(:user) { FactoryGirl.create(:user) }
let(:sticker) { FactoryGirl.create(:sticker) }
before do
@comment = Comment.new(comment: "A comment on a sticker by a user", user_id: user.id, sticker_id:sticker.id)
end
subject { @comment }
it { should respond_to(:comm... |
require "enex/version"
require "builder"
require "base64"
module Enex
class Note
ATTRIBUTE_NAMES = [:export_date, :title, :content, :created, :updated, :tags, :resources]
attr_accessor *ATTRIBUTE_NAMES
def initialize(attributes = {})
attributes.each do |k, v|
raise "Unknown attribute: #{k... |
class AddMessageUrl < ActiveRecord::Migration
def change
add_column :guests, :recording_url, :string
end
end
|
require 'securerandom'
require './token'
module Sapphire
class SEXP
attr_accessor :children, :token, :uuid, :parent_id
def initialize(tkn=nil)
@uuid = SecureRandom.uuid
@token = tkn
@children = []
end
def to_s
return "<SEXP id=#{@uuid} ... |
class CreateOferta < ActiveRecord::Migration[5.1]
def change
create_table :oferta do |t|
t.date :fecha
t.string :cargo
t.string :empresa
t.string :descripcion
t.timestamps
end
end
end
|
Given /^an answer "([^\"]*)"$/ do |answer|
@json_hash = { "text" => answer,
"id" => 46672912,
"user" => {"name" => "Angie",
"description" => "TV junkie...",
"location" => "NoVA",
"profile_image_url" =... |
require 'test_helper'
class BrowserReadersControllerTest < ActionController::TestCase
setup do
@browser_reader = browser_readers(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:browser_readers)
end
test "should get new" do
get :new
as... |
module Bothan
module Helpers
module App
def config
{
title: ENV['METRICS_API_TITLE'],
description: ENV['METRICS_API_DESCRIPTION'],
license: {
name: ENV['METRICS_API_LICENSE_NAME'],
url: ENV['METRICS_API_LICENSE_URL'],
image: license_... |
describe "OrderItemsRequests", :type => :request do
around do |example|
bypass_rbac do
example.call
end
end
let(:tenant) { create(:tenant) }
let!(:order_1) { create(:order, :tenant_id => tenant.id) }
let!(:order_2) { create(:order, :tenant_id => tenant.id) }
let!(:order_3) { create(:order, :t... |
class Action
attr_accessor :name, :callback
def initialize(name, &callback)
self.name = name
self.callback = callback
end
def do(player)
# Should return true if this action consumed the player's turn
# False if it did not.
unless self.callback.nil?
r... |
class PagesController < ApplicationController
def home
@date = Date.today
if current_user
@pair = current_user.pairs.find_by_day(Date.today)
end
end
end
|
class Category < ApplicationRecord
# Required fields:
validates :name, presence: true
# Other methods:
def total_hours_completed
time_records = TimeRecord.by_category(self.id)
hours_completed_sum = 0
time_records.each do |time_record|
hours_completed_sum += time_record.total_hours
end
... |
require_relative 'board.rb'
require_relative 'player.rb'
class Game
attr_reader :players, :player_one, :player_two, :board, :current_player
def initialize(player1, player2)
@player_one, @player_two = Player.new(player1), Player.new(player2)
player_one.color, player_two.color = "white", "black"
@board ... |
# encoding: utf-8
require 'spec_helper'
describe TTY::Table::Renderer, 'with style' do
let(:header) { ['h1', 'h2', 'h3'] }
let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
let(:table) { TTY::Table.new(header, rows) }
let(:color) { Pastel.new(enabled: true) }
subject(:renderer) { described_class... |
module Soulmate
module Helpers
def prefixes_for_phrase(phrase)
Soulmate.get_words(phrase).map do |w|
(MIN_COMPLETE-1..(w.length-1)).map{ |l| w[0..l] }
end.flatten.uniq
end
def normalize(str)
Soulmate.normalize(str)
end
end
end |
Given /^the content "([^\"]*)" for slot "([^\"]*)"$/ do |content, slot|
# def put(base_key, cobrand, preview, name, contents)
Cms.instance.put "home_#{slot}", Cobrand.root, false, slot, content
end
Given /^featured reviews? for (.*)$/ do |product_names|
@reviews = product_names.split(/,\s*/).map { |title|
... |
describe ::Treasury::Processors::HashOperations do
let(:dummy_class) do
Class.new do
include Treasury::Processors::HashOperations
end
end
let(:dummy) { dummy_class.new }
let(:raw_value) { '123:321,234:432' }
describe '#increment_raw_value' do
let(:result) { dummy.increment_raw_value(raw_val... |
class CreateSusuInvites < ActiveRecord::Migration[6.1]
def change
create_table :susu_invites do |t|
t.boolean :accepted, default: false
t.references :susu, null: false, foreign_key: true
t.references :sender, null: false, foreign_key: {to_table: :users} # Custom solution to addr... |
class Aws::SdbInterface
def put_attributes(domain_name, item_name, attributes, replace = false, expected_attributes = {})
params = params_with_attributes(domain_name, item_name, attributes, replace, expected_attributes)
link = generate_request("PutAttributes", params)
request_info( link, QSdbSimpleParser.... |
require 'oystercard'
describe Oystercard do
describe 'structure' do
it 'has a balance of zero when created' do
expect(subject.balance).to eq(0)
end
it 'starts with an empty journey history' do
expect(subject.journeys).to be_empty
end
end
describe 'top_up' do
it 'can add to t... |
require 'oystercard'
describe Oystercard do
let(:station) {double("Kings cross")}
let(:exit_station){double("Station")}
it "the balance should be 0 by default" do
expect(subject.balance).to eq 0
end
it "raises error when balance + top up amounts to a set limit" do
allow(subject).to receive(:balance)... |
require 'spec_helper'
describe WithingsSDK::Utils do
let (:startdateymd) { Hash['startdateymd', '2012-01-01'] }
let (:startdate) { Hash['startdate', 1325376000 ] }
let (:enddateymd) { Hash['enddateymd', '2015-05-12'] }
let (:enddate) { Hash['enddate', 1431388800 ] }
describe '.normalize... |
class Ticket < ActiveRecord::Base
belongs_to :user
def self.in_month(month, product)
where("opened >= ? AND opened <= ? AND product = ?", month.beginning_of_month, month.end_of_month, product)
end
end
|
## General options
set :step, 10
set :border_snap, 10
set :gravity, :ct66
set :tiling, false
set :honor_size_hints, false
set :urgent, false
set :urgent_dialogs, false
set :click_to_focus, false
set :skip_pointer_warp,... |
class CreateRaffles < ActiveRecord::Migration[6.1]
def change
create_table :raffles do |t|
t.references :user_id, null: false, foreign_key: true
t.references :type_id, null: false, foreign_key: true
t.string :title
t.text :description, null:true
t.datetime :probable_draw_date
t... |
require "rails_helper"
describe "Delete Template Mutation API", :graphql do
describe "deleteTemplate" do
let(:query) do
<<~'GRAPHQL'
mutation($input: DeleteTemplateInput!) {
deleteTemplate(input: $input) {
success
}
}
GRAPHQL
end
it "deletes th... |
module ActiveRecordSimpledbAdapter
module Defaults
def self.included(base)
base.send :alias_method_chain, :initialize, :defaults
end
def initialize_with_defaults(attrs = nil)
initialize_without_defaults(attrs) do
safe_attribute_names = []
if attrs
stringified_attrs =... |
class Site::CardsController < Site::DefaultController
def show
@card = Card.find(params[:id]) if params[:id]
end
end
|
class AdminsController < ApplicationController
before_action :authenticate_user!
def index
@chapters = Chapter.includes([:address])
@users = User.includes([:chapter])
authorize! :index, AdminsController
end
end
|
class WelcomeController < ApplicationController
before_action :set_raven_context
def index
Rails.logger.info("zomg division")
1 / 0
end
def view_error
end
def report_demo
@sentry_event_id = Raven.last_event_id
render(:status => 500)
end
private
def set_raven_context
Raven.user... |
require 'spec_helper'
describe GapIntelligence::CategoryVersion do
include_examples 'Record'
describe 'attributes' do
subject(:category_version) { described_class.new build(:category_version) }
it 'has name' do
expect(category_version).to respond_to(:name)
end
it 'has full_name' do
e... |
class LinksChannel < ApplicationCable::Channel
def subscribed
stream_from("links_channel", coder: ActiveSupport::JSON) do |data|
transmit data
end
end
end
|
require "executables/version"
require "executables/collector"
require "executables/web"
require "executables/executor"
module Executables
class << self
attr_accessor :root_directory, :executable_directories, :async_executor
def configure
yield self
end
end
end
|
class Team
attr_accessor :name, :win, :lose, :draw
def initialize(init_name,init_win,init_lose,init_draw)
self.name = init_name
self.win = init_win
self.lose = init_lose
self.draw = init_draw
end
def calc_win_rate
self.win.to_f / (self.win.to_f + self.lose.to_f)
end
def show_team_r... |
module Fog
module Storage
class GoogleJSON
module GetObjectHttpsUrl
def get_object_https_url(bucket_name, object_name, expires, options = {})
raise ArgumentError.new("bucket_name is required") unless bucket_name
raise ArgumentError.new("object_name is required") unless object_nam... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.