text stringlengths 10 2.61M |
|---|
class RenameIntelligenceFromMyAvatars < ActiveRecord::Migration
def up
rename_column :my_avatars, :intelligence, :intelligence_xp
end
def down
rename_column :my_avatars, :intelligence_xp, :intelligence
end
end
|
module StatusOptions
def self.defined
"defined"
end
def self.in_progress
"in_progress"
end
def self.completed
"completed"
end
def self.all
[self.defined, self.in_progress, self.completed]
end
end
|
require 'bundler'
module Bundler
module Whatsup
# Works with dependencies and specs described in Gemfile
class Gemfile
attr_accessor :specs, :dependencies
def initialize
b = Bundler.load
@specs = b.specs.sort_by(&:name)
@dependencies = b.dependencies.sort_by(&:name)
... |
class EventsTableController < DialTestController
attr_accessor :callbacks
def initWithNibName(name, bundle: bundle)
super
self.tabBarItem = UITabBarItem.alloc.initWithTitle("My Account",
image: UIImage.imageNamed("event_calendar.png"),
tag: 2
... |
#
# Author:: Alessio Rocchi (<alessio.rocchi@staff.aruba.it>)
# © Copyright ArubaCloud.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
require 'fog/arubacloud/service'
module Fog
module Compute
class ArubaCloud < Fog::Service
recognizes :url
requires :arubacloud_username, :arubacloud_passwo... |
require_dependency 'principal'
require_dependency 'person'
module PlanningPlugin
module PersonPatch
def self.included(base)
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
has_many :planning_confirmations, foreign_key: ... |
class Comment < ActiveRecord::Base
has_paper_trail class_name: "C2Version"
belongs_to :proposal, touch: true
belongs_to :user
delegate :full_name, :email_address, :to => :user, :prefix => true
validates :comment_text, presence: true
validates :user, presence: true
validates :proposal, presence: true
... |
module Sensors
class Dth < Base
attributes :temperature, :humidity, :battery_voltage
display_as :line_chart, group_by: :minute, attributes: [:temperature, :humidity]
def payloadHexa
message.payloadHex.gsub(/../) { |pair| pair.hex.chr }
end
def temperature
@temperature ||= "#{values.t... |
class ZoosController < ApplicationController
before_action :find_zoo, only: [:show, :edit, :update, :destroy]
def index
@zoos = Zoo.all
end
def new
@zoo = Zoo.new
end
def create
@zoo = Zoo.new(zoo_params)
if @zoo.save
redirect_to zoos_path, flash: {success: "Successfully Added Zoo"}
el... |
class Item < ApplicationRecord
ALLOWED_TYPES_OF_ITEMS = %w(ARMOR CRAFTABLE FOOD WEAPON MEDICINE RAW_MATERIAL PROCESSED_MATERIAL DROPPED_ITEM FURNITURE TOOLS USER_DEFINED)
before_validation :infer_default_values_from_item_type
validates_presence_of :item_type
validates_inclusion_of :item_type, :in => ALLOWED_TY... |
# transferring files to/from cloud storage
# 01/27/19
require 'net/http'
def print_help()
# script usage message
puts "Transfer files securely to/from local and Dropbox!"
puts "Usage: ruby dropbox_transfer.rb <direction flag> <src> <dst>"
puts "\t<direction flag> must be either -u (upload to dropbox) or -d (downl... |
require 'rails_helper'
RSpec.describe PointsConverter, type: :lib do
describe 'Constants' do
it 'has RATES constant' do
rates = {
'AUD' => 1,
'CAD' => 1,
'CHF' => 1,
'CZK' => 20,
'DKK' => 0.1,
'EUR' => 1,
'GBP' => 1,
'JPY' => 1,
'MXN' ... |
require 'spec_helper'
describe Paperclip::DynamicExtentProcessor do
let(:mock_file) { double('mock file', path: 'mock_file.png') }
let(:processor) { described_class.new(mock_file, options) }
let(:base_options) { { geometry: '15x15', file_geometry_parser: MockGeometryParser } }
describe '#transformation_comma... |
class CreateEmailTemplates < ActiveRecord::Migration
def change
create_table :email_templates do |t|
t.string :language
t.text :description
t.string :type
t.integer :version
t.integer :group_id
t.boolean :status
t.timestamps
end
end
end
|
require_relative '../lib/ranked_vote'
RSpec.describe RankedVote do
it 'has a voter and candidates' do
vote = RankedVote.new('Miyoshi', %w(Alice Bob))
expect(vote.voter).to eq 'Miyoshi'
expect(vote.candidates).to eq %w(Alice Bob)
end
end
|
# require 'movie'
require 'rails_helper'
describe MoviesController, :type => :controller do
it "test s" do
expect true ==true
end
describe "GET similar_movies" do
it "director value is not empty" do
fake_movie = object_double(Movie.new, :director => "hello", :title => "fakemovie")
... |
class Company < ApplicationRecord
has_many :locations
geocoded_by :address
after_validation :geocode
end
|
# frozen_string_literal: true
require 'bank_deposits/import'
module BankDeposits
class CalculateLongTermDepositSum
include Import['calculate_annual_deposit_sum']
def call(interest_rate, annual_addition, years, annual_compounds_count)
years.times.reduce(0) do |period_start_sum, _year|
calculat... |
require 'spec_helper'
describe "Teams" do
before do
mock_geocoding!
@team = FactoryGirl.create(:team)
end
describe "without admin or user logged in" do
it "should redirect edit team to admin login" do
get edit_team_path(@team)
response.should redirect_to(new_admin_session_path... |
require 'spec_helper'
describe 'routing to api/pin' do
%w(all add remove clear).each do|name|
it "routes #{name}" do
expect(post("/api/pin/#{name}")).to route_to("api/pin\##{name}")
end
end
end
|
class PassengerMonit
def self.init
if defined?(PhusionPassenger)
require 'passenger_monit/pidfile_manager'
PhusionPassenger.on_event(:starting_worker_process) do |forked|
PidfileManager.write_pid_file if forked
end
PhusionPassenger.on_event(:stopping_worker_process) do
Pid... |
# 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... |
Rails.application.routes.draw do
scope :admin do
devise_for :admins, controllers: { sessions: 'admin/admins/sessions' }
end
namespace :admin do
root to: 'main#index'
resources :teachers, except: :show
resources :disciplines, except: :show
resources :admins, except: :show
resources :c... |
shared_examples "fieldable" do
it { is_expected.to have_many(:fieldset_associations) }
end
|
require 'rails_helper'
require 'shoulda/matchers'
RSpec.describe Story, :type => :model do
describe "Validation" do
it { validate_presence_of(:content) }
end
describe "Associations" do
it { belong_to(:user) }
it { have_many(:comments) }
it { have_many(:likes) }
end
end
|
require 'rails_helper'
RSpec.describe PlayerCardChemistry, type: :model do
it { is_expected.to belong_to :player_card }
it { is_expected.to belong_to :chemistry }
it { is_expected.to validate_presence_of :tier }
end
|
class UserToken < ApplicationRecord
belongs_to :user
before_create :generate_access_token
private
def generate_access_token
self.access_token = SecureRandom.uuid.gsub(/\-/,'')
end
end
|
describe Link do
it "validates the link" do
data = ["link_id", "quality", "source", "target", "type"]
Link.new(*data).valid?.should.eql true
end
it "has valid links" do
json = BW::JSON.parse(LINKS)
link = Link.from_json(json).first
link.link_id.should.eql "66:70:02:5e:a9:1a-de:ad:be:ef:22:22... |
# frozen_string_literal: true
require 'jiji/test/test_configuration'
describe Jiji::Db::RegisterBuiltinIcons do
include_context 'use container'
let(:script) { container.lookup(:v0to1_register_builtin_icons) }
let(:icon_repository) { container.lookup(:icon_repository) }
it '#id' do
expect(script.id).to e... |
class TagsController < ApplicationController
def show
@tag = Tag.where(:name => params[:tag]).first
if @tag.nil?
raise not_found_404
end
@resources = Resource.tagged_with(@tag.name)
@tips = Tip.tagged_with(@tag.name)
end
end |
require 'test_helper'
class GraduationsControllerTest < ActionController::TestCase
setup do
@graduation = graduations(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:graduations)
end
test "should get new" do
get :new
assert_response :... |
class Registration < ActiveRecord::Base
attr_accessible :token, :email
validates :token, :email,
presence: true
end
|
# -*- coding: utf-8 -*-
=begin
Escreva um programa que leia um número e verifique se é
ou não um número primo. Para fazer essa verificação, calcule
o resto da divsão do número por 2 e depois por todos os números
impares até o número lido. Se o resto de uma dessas divisões for
igual a zero, o número não é primo. Obser... |
# frozen_string_literal: true
require "spec_helper"
RSpec.describe GeoPattern do
subject(:pattern) { GeoPattern.generate(input) }
let(:input) { "Mastering Markdown" }
let(:color) { "#ffcc00" }
let(:rgb_base_color) { PatternHelpers.html_to_rgb_for_string(seed, color) }
let(:seed) { instance_double("GeoPatter... |
class RenameReceiptsToAcknowledgements < ActiveRecord::Migration
def change
rename_table :receipts, :acknowledgements
end
end
|
# frozen_string_literal: true
module GraphQL
module Analysis
# Calculate the complexity of a query, using {Field#complexity} values.
module AST
class QueryComplexity < Analyzer
# State for the query complexity calculation:
# - `complexities_on_type` holds complexity scores for each type
... |
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Search do
before(:each) do
@search_content = File.open(File.join(File.dirname(__FILE__), 'fixtures', 'diomedes_search.htm'), 'r:ISO-8859-1').read
@letra_content = File.open(File.join(File.dirname(__FILE__), 'fixtures', 'siete_palabras... |
=begin
#===============================================================================
Title: Troop Escape Ratio
Author: Hime
Date: Mar 30, 2013
--------------------------------------------------------------------------------
** Change log
Mar 30, 2013
- Initial release
----------------------------------------... |
require 'context-io/error/client_error'
module ContextIO
# Raised when Context.IO returns the HTTP status code 401
#
# This means that the OAuth signature can't be validated.
#
# @api public
class Error::Unauthorized < ContextIO::Error::ClientError
end
end
|
class CreateCoupons < ActiveRecord::Migration
def change
create_table :coupons do |t|
t.string :coupon_value
t.string :status
t.references :user
t.timestamps
end
end
end
|
class AddCodeToOrderMaps < ActiveRecord::Migration[5.0]
def change
add_column :order_maps, :code, :string
end
end
|
class CreateTurnActionsTable < ActiveRecord::Migration[5.1]
def change
create_table :turn_actions do |t|
t.integer :turn_id, null: false
t.integer :action_id, null: false
t.boolean :completed, null: false, default: false
t.timestamps
end
add_index :turn_actions, [:turn_id, :action_... |
require 'test_helper'
class MealsControllerTest < ActionController::TestCase
setup do
@meal = meals(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:meals)
end
test "should get new" do
get :new
assert_response :success
end
test "s... |
class Concert < ActiveRecord::Base
belongs_to(:venue)
belongs_to(:band)
end
|
module Inventory
class ConvertPackageFromScan
prepend SimpleCommand
attr_reader :user,
:id,
:product_type,
:package_type,
:source_package_id,
:source_package,
:tag,
:product, # Deduce from product_type, package type & strain from batch
:name, ... |
class Concert < ApplicationRecord
belongs_to :artiste
validates :salle, presence: true
validates :date, presence: true
validates :photo, presence: true
has_attachment :photo, accept: [:jpg, :png, :jpeg]
end |
require 'polymorphic_plugin'
require 'rails'
module PolymorphicPlugin
class Railtie < Rails::Railtie
initializer "polymorphic_plugin.active_record" do |app|
ActiveSupport.on_load :active_record do
include PolymorphicPlugin::PolymorphicHolder
end
end
end
end
|
require 'test_helper'
class ChloesControllerTest < ActionController::TestCase
setup do
@chlo = chloes(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:chloes)
end
test "should get new" do
get :new
assert_response :success
end
test... |
class WarChannel < ApplicationCable::Channel
def subscribed
stream_from "war_channel_#{params[:war_id].to_s}"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
# 한 길드의 유저가 전투 버튼을 눌렀을 때에만 호출
def request_battle(data)
ActionCable.server.broadcast(
"war_channel_#{dat... |
# frozen_string_literal: true
module UMA
class Exception < StandardError; end
class ValidationFailed < Exception
attr_reader :object
def initialize(object)
super object.errors.full_messages.to_sentence
@object = object
end
end
end
|
Fabricator :hood do
city
name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" } }
# geom { [rand(30) - 50, rand(40) - 30] }
end
|
class UserGroupsUser < ActiveRecord::Base
belongs_to :user
belongs_to :user_group
belongs_to :member, :polymorphic => true
named_scope :is_student,:conditions => {:target_type => "student"}
named_scope :is_employee,:conditions => {:target_type => "employee"}
named_scope :is_parent,:conditions => {:tar... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
BLOG_PATH = "../solita.github.com/"
Vagrant.configure("2") do |config|
nodes = {
'dev-blog' => { :ip => '10.30.30.10', :memory => 512, :cpu => 1 }
}
nodes.each do |node_name, node_opts|
config.vm.define node_name do |node_config|
nod... |
Fabricator(:post) do
title "dummy post"
content "dummy content"
publish_time Time.now
user { Fabricate(:user) }
end
|
class Loan < ActiveRecord::Base
has_many :payments
# Current Balance = Funded Amount - SUM(Payments)
def balance
self.payments.map(&:amount).reduce(self.funded_amount, :-)
end
def as_json(options={})
# Uncomment if you want to expose payments on the index/show endpoints for loans
# super(include... |
unless ARGV.length == 3
puts "Usage: ruby css_intelligent_compressor.rb
<input_html_file> <input_css_file> <output_minimized_css_file>
Input can be any resource, e.g. http://"
exit 1
end
require 'lib/css_eliminator'
require 'open-uri'
puts "Loading HTML..."
html_doc = open(ARGV[0]).read
puts... |
require 'rails_helper'
describe FantasyTeam do
it { should have_many(:fantasy_players).through(:roster_positions) }
it { should have_many(:roster_positions).dependent(:destroy) }
it { should have_many(:roster_transactions).through(:transaction_line_items) }
it { should have_many(:transaction_line_items) }
it... |
require 'httparty'
module Algorithmia
class Http
include HTTParty
base_uri "https://api.algorithmia.com/v1"
def initialize(client)
@client = client
@default_headers = {
'Authorization' => @client.api_key || '',
'Content-Type' => 'application/json',
'User-Agent' => 'Al... |
require 'spec_helper'
describe "Interaction pages" do
subject { page }
let(:booking) { FactoryGirl.create(:booking) }
let(:slot) { booking.slot }
let(:user) { booking.user }
let(:activity) { slot.activity }
let(:merchant) { activity.merchant }
before do
visit new_user_session_path
fill_in "u... |
# frozen_string_literal: true
require 'stripe_mock'
require 'timecop'
require 'pundit/rspec'
require 'aasm/rspec'
require './spec/support/simplecov_env'
SimpleCovEnv.start!
RSpec.configure do |config|
config.define_derived_metadata do |meta|
meta[:aggregate_failures] = true
end
config.expect_with :rspec d... |
Gretel::Crumbs.layout do
crumb :oauth_clients_index do
link I18n.t('oauth_clients.client_apps'), {:controller=>"oauth_clients", :action=>"index"}
end
crumb :oauth_clients_new do
link I18n.t('new_text'), {:controller=>"oauth_clients", :action=>"new"}
parent :oauth_clients_index
end
crumb :oauth_cli... |
class MemosController < ApplicationController
protect_from_forgery except: :create
before_action :auth
include Auth
def index
# renderは、画面に文字列を出力する。
render text: 'memo index'
end
def list
@memos = Memo.all
# render(jsonオプション)は、画面にJSON形式のデータを出力する。
rend... |
class AddSalePeriodToTakeoff < ActiveRecord::Migration
def change
add_column :takeoffs, :sale_period, :integer
Takeoff.update_all ["sale_period = 3"]
end
end
|
Rails.application.routes.draw do
root 'chores#index'
resources :chores
end
|
class DynamicRecord::Entity < DynamicRecord::Base
self.table_name = :dynamic_records
belongs_to :record_class,
:readonly => true,
:foreign_key => :record_class,
:class_name => 'DynamicRecord::Class'
default_scope :include => [{:fields => :value_field}, {:record_class => :field_descriptions}]
del... |
require 'active_support/json/decoding'
module Bonobo
module Middleware
class ParseJSONResponse < Faraday::Response::Middleware
def on_complete(env)
if env[:status] == 200
env[:body] = ActiveSupport::JSON.decode("[#{env[:body]}]").first
end
end
end
end
end |
# app/controllers/api/v1/events_controller.rb
class Api::V1::EventsController < EventsController
before_filter :authenticate_user_from_token!
before_filter :authenticate_user!
respond_to :json
def user_index
@events = Event.where(host: current_user.id)
end
def user_invited_index
notifications... |
class Movie::ActorsController < Movie::BaseController
before_action :set_movie_actor, only: [:show, :edit, :update, :destroy]
def index
@actors = Actor.all
end
# GET /movie/actors/1
# GET /movie/actors/1.json
def show
end
# GET /movie/actors/new
def new
@movie_actor = Movie::Actor.new
end... |
require File.dirname(__FILE__) + '/../spec_helper'
describe "Archive Children Tags" do
dataset :home_page, :archive
it '<r:archive_children:children:each><r:title /> </r:archive_children:children:each> should iterate over all children of ArchivePages' do
pages(:home).should render("<r:archive_children:child... |
module CvHelper
def pos label, &block
render layout: 'pos', locals: {label: label}, &block
end
def small_pos label, &block
render layout: 'small_pos', locals: {label: label}, &block
end
def li label, &block
render layout: 'li', locals: {label: label}, &block
end
def range time_range
beg... |
FactoryBot.define do
factory :place do
name { 'TestPlace' }
latitude { 1.5333 }
longitude { 42.425 }
location { 'test location' }
rating { 4 }
end
end
|
class HomeController < ApplicationController
skip_before_action :authenticate_user!, only: [:index]
def index
@q = MediaItem.shared.ransack(params[:q])
@items = @q.result(distinct: true).order(created_at: :desc).page(params[:page]).per(10)
end
end
|
class Sponsor < ActiveRecord::Base
validates :name, :phone, :email, :state, :city, :organization, presence: {message: 'Uno o más campos están vacíos.'}
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
after_create :send_mail
def send_mail
ContactMailer.sponsor(s... |
require 'rails_helper'
RSpec.describe System, type: :model do
it { is_expected.to belong_to :category }
it { is_expected.to validate_presence_of :name }
it { is_expected.to validate_presence_of :category }
end
|
class EmployeesController < ApplicationController
before_filter :authorize_admin, only: [:index, :destroy, :toggle]
before_filter :authorize, only: [:show, :edit, :update]
# GET /employees
# GET /employees.json
def index
@employees = Employee.order('is_active desc', 'first_name')
respond_to do |form... |
require 'test/unit'
require_relative 'show'
class GroupingTest < Test::Unit::TestCase
def setup
@show = Show.new
end
def test_1
@show.regex('banana', /an+/)
@show.regex('banana', /a(n)+/)
@show.regex('banana', /(an)+/)
end
def test_2
value = 'red ball blue sky'
@show.regex(value, ... |
# frozen_string_literal: true
require 'cld3'
module Search
class Query
attr_reader :query # rubocop:disable
include QuranUtils::StrongMemoize
LANG_DETECTOR_CLD3 = CLD3::NNetLanguageIdentifier.new(0, 2000)
def initialize(query)
@query = query.to_s.strip
end
def arabic?
detect_la... |
require 'rails_helper'
include Helpers
describe "Beer" do
let!(:user) { FactoryBot.create :user }
let!(:brewery) { FactoryBot.create :brewery, name: "Koff" }
let!(:style) { FactoryBot.create :style }
before :each do
sign_in(username: "Pekka", password: "Foobar1")
end
describe "when creating Beer" do... |
require 'rails_helper'
RSpec.describe Player, type: :model do
describe "validations" do
it "is valid with all valid attributes" do
team = Team.create(name: "Brett's Team")
player = team.players.create(first_name: "Brett", last_name: "Schwartz", position: "QB", nfl_team:"Jets")
expect(player).t... |
# -*- mode: ruby -*-
# # vi: set ft=ruby :
#
# Cookbook Name:: bigfairywall
# Recipe:: httpre
#
include_recipe "git::default"
# fixes CHEF-1699
ruby_block "reset group list" do
block do
Etc.endgrent
end
action :nothing
end
user node[:httpre][:username] do
comment "Proxy User"... |
class BlogDecorator < Draper::Decorator
delegate_all
def created_at_h
created_at.strftime('%B %d, %Y at %I:%M%p')
end
def check_password_is_blank?
check_password.blank?
end
end
|
require 'digest/sha1'
class ParamBuilder
attr_reader :req_params
def initialize
@req_params = {}
end
def build_params(params, uid)
merge_user_params(params)
add_dynamic_params(params, uid)
add_static_params()
q = build_query_string()
add_hash_key(q)
end
def merge_user_params(par... |
describe 'define_method' do
context "is available only inside a class or a module" do
it "should allow us to create a simple statically named method inside a class" do
class Multiplier
define_method(:times_2) do |val|
val * 2
end
end
m = Multiplier.new
expect(m.ti... |
require_relative 'lib/task'
namespace :svg do
desc "Update svg icon helper"
task :icon => [:environment] do |t, args|
helper_path = File.join(Rails.root, "app", "helpers", "icon_helper.rb")
File.open(helper_path, 'w') do |helper|
helper.write "module IconHelper\n\n"
path = File.join(Rails.root... |
#! ruby -Ku
# ironnews-classifier1を使って記事を分類する
require "cgi"
require "open-uri"
require "rubygems"
require "json"
require "config"
THRESHOLDS = {
"鉄道" => 1.0,
"非鉄" => 3.5,
}
def classify(body)
url = "http://ironnews-classifier1.appspot.com/bayes1/classify"
url += "?body=" + CGI.escape(body)
count = 0
... |
require 'lib/logconverter'
describe LogConverter do
describe 'convert' do
let(:lc) { LogConverter.new }
it 'returns "" if input is ""' do
expect(lc.convert('')).to eq('')
end
it 'returns "1,2,3,4\n" if input is "1,2,3,4"' do
expect(lc.convert("1,2,3,4\n")).to eq('1,2,3,4')
end
... |
require_relative "abstract"
class LastfmClient < AbstractClient
def initialize(auth)
@api = Lastfm.new(ENV["LASTFM_KEY"], ENV["LASTFM_SECRET"])
@api.session = auth.token
super
end
private
def default_playlists
[
{ id: "favorites", title: "Loved tracks" }
]
end
# :nocov: #
def... |
# frozen_string_literal: true
module Decidim
module Opinions
module Admin
class Permissions < Decidim::DefaultPermissions
def permissions
# The public part needs to be implemented yet
return permission_action if permission_action.scope != :admin
# Valuators can only p... |
class User < ApplicationRecord
has_one :cart
has_many :cart_products, through: :cart
has_many :products, through: :cart
has_one :inventory, foreign_key: 'seller_id', required: false
has_secure_password
end |
module Validation
def self.included(base)
base.extend ClassMethods
base.send :include, InstanceMethods
end
module ClassMethods
attr_accessor :rules
def validate(name, type, param = nil)
self.rules ||= []
self.rules << { var: name, type: type, param: param }
end
end
module In... |
class AddClassroomIdToSchools < ActiveRecord::Migration
def change
add_column :schools, :classroom_id, :integer
add_index :schools, :classroom_id
end
end
|
# encoding: UTF-8
module CDI
module V1
module LearningTracks
class PublishService < BaseUpdateService
record_type ::LearningTrack
attr_reader :classes_published, :classes_errors
def changed_attributes
return [] if fail?
[:status]
end
private
... |
require File.join(File.dirname(__FILE__), '..', 'test_helper')
# destroy
# -------
class IQ::Crud::Actions::Destroy::DeleteTest < Test::Unit::TestCase
def setup
['', 'admin_'].each do |prefix|
send(prefix + 'crudified_instance').stubs(:find_member).with().returns(valid_member)
end
end
def test_s... |
require 'bundler/setup'
require 'rspec/expectations'
require_relative '../lib/todo_list'
require_relative '../lib/exceptions'
describe TodoList do
subject(:list) { TodoList.new(items) }
let(:items) { [] }
let(:item_description) { "Buy toilet paper" }
it { should be_empty }
it "s... |
# Given a linked list, can you find the nth element from the end
#
class Node
# Constructor to initialize the node object
attr_accessor :data, :next
def initialize(data)
@data = data
@next = nil
end
end
class LinkedList
# Function to initialize head
def initialize
@head = nil
end
#... |
# -*- encoding : utf-8 -*-
class SecondWorksController < ApplicationController
# GET /second_works
before_filter :check_auth
# GET /second_works.json
def index
@second_works = SecondWork.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @second_wor... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most co... |
require './base_matrix'
require './matrix_factory'
require 'test/unit'
class SparseMatrix < BaseMatrix
include Test::Unit::Assertions
"""
Invariant:
self.sparse? == true (density <= 0.5)
"""
def initialize(height, width, dict)
super(height, width, dict)
# assert(self.sparse?, "... |
require 'json'
require 'logger'
module Configrr
module Log
def self.clogger
if @clog.nil?
@clog = Logger.new(Configrr::Config.get['logger']['file_path'],
'daily',
Configrr::Config.get['logger']['max_days'])
@clog.formatter = JSONFormatter.n... |
require_dependency "uns_core/application_controller"
require 'uns_feeder/feed'
require 'uns_feeder/refresh_river_job'
module UnsFeeder
class RiversController < UnsCore::ApplicationController
before_action :set_river, except: [:index, :create]
include RiversHelper
def index
@rivers = UnsFeeder::Fir... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.