text stringlengths 10 2.61M |
|---|
module Dijit
module Rails
MAJOR = 1
MINOR = 0
TINY = 0
VERSION = [MAJOR, MINOR, TINY].compact.join(".")
end
end
|
class AddUserIdToUserProfile < ActiveRecord::Migration
def change
add_column :user_profiles, :uid, :string
end
end
|
class DejaGnu < Formula
homepage "https://www.gnu.org/software/dejagnu/"
url "http://ftpmirror.gnu.org/dejagnu/dejagnu-1.5.2.tar.gz"
mirror "https://ftp.gnu.org/gnu/dejagnu/dejagnu-1.5.2.tar.gz"
sha1 "20a6c64e8165c1e6dbbe3638c4f737859942c94d"
head "http://git.sv.gnu.org/r/dejagnu.git"
def install
ENV.... |
class PigLatinizer
def piglatinize(text)
arr = text.split(' ')
arr.map do |word|
if /^[aeiou]/i.match(word)
word + "way"
else
pig_chars = word.split(/([aeiou].*)/)
"#{pig_chars[1]}#{pig_chars[0]}ay"
end
end.... |
require "minitest/autorun"
require "minitest/pride"
require "./lib/linked_list"
class LinkedListTest < Minitest::Test
def test_head_is_nil
list = LinkedList.new
assert_nil list.head
end
def test_adds_a_node
list = LinkedList.new
list.append("doop")
expected = "doop"
actual = list.... |
#fronze_string_literal: true
module ::FormComponent
class TextFieldComponent < BaseInputComponent
def initialize(*)
super
@template = wrapper{|input_options| text_field(input_options) }
end
private
def text_field(method, options={})
super(@object_name, @attribute_name, options)
... |
require 'spec_helper'
require 'imdb'
require "zimdb"
describe MovieDB do
describe "#get_imdb_movie_data" do
context "Get multiple movie data from IMDb" do
MovieDB::Movie.send(:clear_data_store)
MovieDB::Movie.send(:get_multiple_imdb_movie_data, "0120338", "0120815", "0120915")
#MovieDB::Movi... |
require 'test_helper'
class ResourcesControllerTest < ActionController::TestCase
def setup
@controller.stub! :oauth_handshake, :return => true
end
test "should get index" do
get :index
assert_response :success, @response.body
assert_not_nil assigns(:resources)
end
end
|
class CreateSnacks < ActiveRecord::Migration
def change
create_table :snacks do |t|
t.integer :product_id
t.datetime :manufacture_date
t.datetime :best_before
t.string :brand
t.string :production_place
t.string :ingredient
t.string :weight
t.timestamps null: false
... |
module GroupsHelper
def is_current_owner_logged_in?(owned)
current_user && current_user == owned.user
end
def is_current_user_belongs_to?(group)
current_user && current_user.is_member_of?(group)
end
def render_group_description(group)
simple_format(group.description)
end
end
|
require 'spec_helper'
module Alf
module Support
describe TupleScope, "to_s and inspect" do
let(:tuple){ {:a => 1, :b => 2} }
context 'with a simple TupleScope' do
let(:scope){ TupleScope.new(tuple) }
it "delegates to_s to the tuple" do
expect(scope.to_s).to eq(tuple.to_s)
... |
class ContactsController < InheritedResources::Base
before_action :set_contact , only: [:show, :edit, :update, :destroy]
def index
@contacts = Contact.all
end
def show
end
def new
@contact = Contact.new
end
def edit
end
def create
@contact = Contact.new(contact_params)
respond_to do |format|
if @contact.sav... |
#!/usr/bin/env ruby
TEST_DIR = File.expand_path(File.dirname(__FILE__))
TOP_SRC_DIR = File.join(TEST_DIR, '..')
require File.join(TOP_SRC_DIR, 'lib', 'tracelines19.rb')
def dump_file(file, opts)
puts file
begin
fp = File.open(file, 'r')
rescue Errno::ENOENT
puts "File #{file} is not readable."
retur... |
class TranslationEvent < ApplicationRecord
has_many :translations
end
|
# frozen_string_literal: true
RSpec.describe Storages::BuilderFactory, type: :factory do
subject(:factory) { described_class.new }
describe '.create_for' do
subject(:create_for) { factory.create_for(storage_name) }
context 'when storage builder does exists' do
let(:storage_name) { 'google_sheets' }... |
class UpdateContentPages < ActiveRecord::Migration
def self.up
rename_column :content_pages, :name, :title
remove_column :content_pages, :page_type
rename_column :content_pages, :page_locale, :locale
add_column :content_pages, :body_raw, :text, :default => ''
add_column :content_pages, :co... |
require "test_helper"
class LocalTransactionPresenterTest < ActiveSupport::TestCase
def subject(content_item)
LocalTransactionPresenter.new(content_item.deep_stringify_keys!)
end
test "#introduction" do
assert_equal "foo", subject(details: { introduction: "foo" }).introduction
end
test "#more_infor... |
# Make sure we’re using the latest Homebrew
update
# Add taps
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
tap "koekeishiya/formulae"
# Core utilities
brew "python"
brew "git"
brew "gnu-tar"
brew "gnutls"
brew "stow"
brew "make"
brew "tmux"
brew "vim"... |
When /^I run the rake task '(.+?)' with '(.*?)' as parameters$/ do |task_name, params|
args = params.split(',')
@rake_output = run_rake_task(task_name, *args)
end
When /^I run the rake task '(.+?)'$/ do |task_name|
@rake_output = run_rake_task(task_name)
end
Then /^the contents of STDOUT should contain '(.*?)'... |
class Api::V1::TripsController < ApplicationController
def index
render json: session_user.trips
end
def show
trip = Trip.find(params[:id])
render json: trip
end
def create
creator = User.find(trip_params[:creator_id])
trip = Trip.create(trip_params)
trip.users.push(creator)
user... |
require 'rails_helper'
describe Api::V1::TournamentsController do
let(:tournament_params) do
{ tournament_name: 'football_it_league', team_names: %w[M.City M.United Arsenal Chelsea] }
end
describe 'POST#create' do
it 'has to be success' do
process :create,
method: :post,
... |
module Apicast
GENERATORS = [
Apicast::LuaAuthorizeGenerator,
Apicast::LuaGetTokenGenerator,
Apicast::LuaThreescaleUtilsGenerator,
Apicast::LuaAuthorizedCallbackGenerator
].map(&:new).freeze
end
|
class Item < ApplicationRecord
has_many :documents
attr_accessor :document_data
end
|
class Round < ApplicationRecord
belongs_to :game
belongs_to :question
belongs_to :answer
end
|
class GoodsController < ApplicationController
def index
@goods = Good.all
end
def new
@good = Good.new
end
def create
@good = Good.create(good_params)
redirect_to root_path
end
def show
id = params[:id]
@good = Good.find(id)
end
def edit
@good = Good.find(params[:id])
end
def update
@go... |
# Copyright (c) 2006, 2007 Ruffdogs Software, Inc.
# Authors: Adam Lebsack <adam@holonyx.com>
#
# This program 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 Foundation; either version 2 of the License.
#
# This program ... |
# == Schema Information
#
# Table name: channels
#
# id :integer not null, primary key
# name :string(255)
# url :string(255)
# not_in_id :boolean
# slug :string(255)
# image :string(255)
# description :text
# time_zone_id :integer default(1), not ... |
class AddSuffixToVariants < ActiveRecord::Migration
def change
change_table :variants do |t|
t.string :suffix, null: false, default: ''
end
end
end
|
module AppUp
class Repo < Struct.new(:shell, :options)
private :shell, :options
def files
ignores = options.has_key?(:ingore) ? options[:ignore] : Configuration::Config.ignore
default_files.reject {|f| ignores.any? {|i| f.match(i)} }
end
private
def default_files
if options[:... |
# encoding: utf-8
require 'spec/helper'
require 'minitest/spec'
require 'minitest/autorun'
require 'interval-tree'
describe "IntervalTree::Node" do
describe '.new' do
describe 'given ([], [], [], [])' do
it 'returns a Node object' do
IntervalTree::Node.new([], [], [], []).must_be_instance_of(Int... |
Given /^I am logged in$/ do
visit "/"
end
When /^I click "(.*?)"$/ do |arg1|
click_link(arg1)
end
When /^I press "(.*?)"$/ do |arg1|
click_button(arg1)
end
When /^I fill in "(.*?)" with "(.*?)"$/ do |arg1, arg2|
fill_in(arg1, :with => arg2)
end
Then /^I should see "(.*?)"$/ do |arg1|
page.has_content?(ar... |
class AgencyArtist < ApplicationRecord
has_many :agency_artist_songs
belongs_to :agency
end
|
require 'spec_helper'
describe DeploymentTargetSerializer do
let(:deployment_target_model) { DeploymentTarget.new }
subject(:serialized) { described_class.new(deployment_target_model).as_json }
it 'exposes the attributes to be jsonified' do
expected_keys = [
:id,
:name,
:endpoint_url,
... |
# encoding: utf-8
require 'spec_helper'
describe Mail::Field do
describe "initialization" do
it "should be instantiated" do
expect {Mail::Field.new('To: Mikel')}.not_to raise_error
expect(Mail::Field.new('To: Mikel').field.class).to eq Mail::ToField
end
it "should allow you to init on an a... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "blue_shoes/version"
Gem::Specification.new do |s|
s.name = "blue_shoes"
s.version = BlueShoes::VERSION
s.authors = ["Team Shoes", "Steve Klabnik"]
s.email = "shoes@librelist.com"
s.homepage = "http://githu... |
class ArticleController < ApplicationController
before_action :authorize_request
# GET /articles
def index
@articles = Article.all
render json: @articles, include: {user: {only: [:name]}}, status: :ok
end
# GET /articles/:id
def show
@article = Article.find(params[:id])
render json: @article, incl... |
require 'rails_helper'
RSpec.describe IdentifierController, type: :controller do
before do
@company = FactoryGirl.create :company
@recruiter = FactoryGirl.create :recruiter
end
describe "GET #identify" do
context "successfully" do
before do
get :identify
end
it "sho... |
class RelationshipsController < ApplicationController
def create
@relationship = current_user.relationships.build(friend_id: params[:friend_id])
respond_to do |format|
if @relationship.save
format.html {redirect_to profile_path(current_user.id), notice: 'User Followed Successfully'}
else... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2019-2020 MongoDB Inc.
#
# 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
#
# U... |
class API < Grape::API
version 'v1', :using => :header, :vendor => 'twitter'
format :json
default_format :json
helpers do
def warden
env['warden']
end
def current_user
@current_user ||= warden.user
end
def authenticate!
error!('401 Unauthorized', 401) unless warden.auth... |
require 'spec_helper'
describe "occurences/show.html.erb" do
before(:each) do
@occurence = assign(:occurence, stub_model(Occurence))
end
it "renders attributes in <p>" do
render
end
end
|
FactoryBot.define do
factory :user do
nickname { Faker::Name.initials(number: 2) }
email { Faker::Internet.free_email }
password { 'abcd12' }
password_confirmation { password }
last_name { '一あア' }
first_name { '一あア' }
last_na... |
# frozen_string_literal: true
require 'support/entities/gizmo'
# @note Integration spec for a subclassed Stannum::Entity.
RSpec.describe Spec::Gizmo do
shared_context 'when initialized with attribute values' do
let(:attributes) do
{
id: 0,
name: 'Self-Sealing Stem Bolt',
... |
class Ethnicity < ActiveRecord::Base
has_and_belongs_to_many :targets
has_and_belongs_to_many :members
has_and_belongs_to_many :participant_surveys
default_scope order('position asc')
end
|
Rails.application.routes.draw do
resources :user_sessions
get 'login', to: 'user_sessions#new', as: :login
get 'logout', to: 'user_sessions#destroy', as: :logout
get 'admin', to: 'admin#index'
post 'admin', to: 'admin#create'
root to: redirect('/game')
resource :game, only: :show
namespace :api do
... |
require "test_helper"
class ServiceCategoryTest < ActiveSupport::TestCase
test "should validate required fields" do
c = ServiceCategory.new
assert !c.valid?
c.name = "Category"
assert c.save
end
test "should delete only if no services" do
c = service_categories(:one)
!assert c.can_be_... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# vbox name
config.vm.box = "centos_6_5_64"
# vbox url
config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box"
# enable package caching
config.cache.auto_detect = t... |
# encoding: utf-8
control "V-54033" do
title "Sensitive data stored in the database must be identified in the System Security Plan and AIS Functional Architecture documentation."
desc "A DBMS that does not have the correct confidentiality level identified or any confidentiality level assigned is not being secured at... |
# frozen_string_literal: true
class UsersController < ApplicationController
def show
## We can remove the 2nd instance variable since we have the relation
## specified for Posts in our User model.
@user = User.find(params[:id])
respond_to do |format|
format.html
## Before this simply out... |
# Tasks from https://gist.github.com/dimasumskoy/86e05e4af223212c68c746ca93dc1d0e
# 1 task
def count_chars(words = [])
result = {}
words.each { |word| result[word] = word.length }
result
end
# 2 task
def remove_duplicates(num1 = [], num2 = [])
return if num1.empty? || num2.empty?
num2.reject { |num| num1.any... |
class UserPoint::Buy < UserPoint
def self.apply!(user:, used_amount:)
return if used_amount.zero?
ApplicationRecord.transaction do
user_point = find_or_initialize_by(user_id: user.id)
raise 'Over the available points' if user_point.amount < used_amount
ApplicationRecord.transaction do
... |
class KapaiController < ApplicationController
#
# 更新弟子信息
#
def update_disciples
re, user = validate_session_key(get_params(params, :session_key))
return unless re
disciples = params[:disciples]
if disciples.nil? || !disciples.kind_of?(Array)
render_result(ResultCode::INVALID_PARAMETERS, ... |
class UsersController < ApplicationController
def index
@users = User.all
end
def index_unapproved
if params [:approved] == false
@users = User.find_all_by_approved(false)
else
"All current users approved."
end
end
end
|
name 'instus-epel'
maintainer 'Instus'
maintainer_email 'instus.com@gmail.com'
license 'Apache-2.0'
description 'Installs/Configures EPEL'
version '0.1.0'
chef_version '>= 14.0'
issues_url 'https://github.com/instus/instus.epel/issues'
source_url 'https://github.com/instus/instus.epel'
%w( centos redhat ).each do |os|... |
require "rails_helper"
RSpec.describe Messaging::Bsnl::Api do
def stub_credentials
allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with("BSNL_IHCI_HEADER").and_return("ABCDEF")
allow(ENV).to receive(:[]).with("BSNL_IHCI_ENTITY_ID").and_return("123")
Configuration.create(name: ... |
class ScheduledJobsController < ApplicationController
before_action :set_scheduled_job, only: %i[ show edit update destroy ]
# GET /scheduled_jobs or /scheduled_jobs.json
def index
@scheduled_jobs = ScheduledJob.all
end
# GET /scheduled_jobs/1 or /scheduled_jobs/1.json
def show
end
# GET /schedul... |
# frozen_string_literal: true
# module as namespace
module Fusuma
require 'logger'
require 'singleton'
# logger separate between stdout and strerr
class MultiLogger < Logger
include Singleton
attr_reader :err_logger
attr_accessor :debug_mode
def initialize
super(STDOUT)
@err_logge... |
module Urbanairship
module Push
module Payload
require 'urbanairship/common'
include Urbanairship::Common
# Notification Object for a Push Payload
def notification(alert: nil, ios: nil, android: nil, amazon: nil,
blackberry: nil, wns: nil, mpns: nil, actions: nil,
... |
class TripsController < ApplicationController
load_and_authorize_resource
# GET /trips
# GET /trips.json
def index
@trips = Trip.all
# @trips = Trip.where(user_id: current_user.id)
respond_to do |format|
format.html # index.html.erb
format.json {
render json: @trips.to_json(inc... |
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
# can :read, :all
# end
#
# The first argume... |
class ApplicationController < ActionController::Base
def sanitize_nested_params(params)
# we strip off '0' from [{ '0' => { :id => '1', :foo => '234'}}]
filter_params = params.select{ |k,v| k =~ /_attributes$/ }
filter_params.each_pair do |k,v|
filter_params[k] = v.map{ |x| x.values.first}
end
... |
module CoolXBRL
module EDINET
class Label
DEFAULT_LANGUAGE = :ja
STANDARD_LABEL = "http://www.xbrl.org/2003/role/label"
VERBOSE_LABEL = "http://www.xbrl.org/2003/role/verboseLabel"
class << self
def get_label(locator, preferred_label=nil)
#name, doc, href, role = cr... |
require 'rails_helper'
describe "As a visitor" do
describe "When I visit a doctor's show page" do
it "I see all of that doctor's info" do
memorial = Hospital.create(name: "Grey Sloan Memorial Hospital")
meredith = Doctor.create(name: "Meredith Grey", specialty: "General Surgery", education: "Harvard ... |
class ApplicationController < ActionController::API
include Response
def not_found
json_response({message: "Endpoint not found"},:not_found)
end
end
|
class TwilioController < ActionController::API
def index
render xml: <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather numDigits="4" timeout="10" action="#{access_twilio_index_path}">
<Say>Please enter your 4 digit code, followed by the pound sign.</Say>
</Gath... |
require "itamae"
module Itamae
module Plugin
module Resource
class Cron < ::Itamae::Resource::Base
class Error < StandardError; end
define_attribute :action, default: :create
define_attribute :minute, type: String, default: '*'
define_attribute :hour, type: String, default:... |
require 'openssl'
require 'Base64'
require 'socket'
require 'digest/sha1'
require 'optparse'
require './protobuf/protocol.pb'
require './util.rb'
class Client
include MixUtil
def initialize(options = {})
@id = options[:id]
@client_name = "client#{@id}"
@key_dir = File.join(File.dirname(__FILE__), 'key... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2019-2021 MongoDB Inc.
#
# 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
#
# U... |
class ListPositionsDecorator < SimpleDelegator
def list_position_arr
order(role: :asc, position_id: :desc)
.joins(:player, :position, :fpl_team_list)
.joins('JOIN rounds ON rounds.id = fpl_team_lists.round_id')
.joins('JOIN teams ON teams.id = players.team_id')
.joins(
'LEFT JOIN f... |
require 'spec_helper'
describe FaradayMiddleware::ConvertSdataToHeaders do
def connection(include_mashify=true)
Faraday.new(url: sage_url(nil)) do |conn|
conn.request :json
conn.use FaradayMiddleware::Mashify if include_mashify
conn.use FaradayMiddleware::ConvertSdataToHeaders
conn.use F... |
require "paperclip/matchers/have_attached_file_matcher"
require "paperclip/matchers/validate_attachment_presence_matcher"
require "paperclip/matchers/validate_attachment_content_type_matcher"
require "paperclip/matchers/validate_attachment_size_matcher"
module Paperclip
module Shoulda
# Provides RSpec-compatible... |
class Area < ActiveRecord::Base
attr_accessible :area_prototype
belongs_to :area_prototype, :foreign_key => "area_code"
belongs_to :game
has_many :locations
def name
area_prototype.name
end
end |
class ChangeTotalTypeOfItems < ActiveRecord::Migration
def self.up
change_column :sales_return_items, :amount, :integer
change_column :sales_return_items, :total, :float
end
def self.down
change_column :sales_return_items, :amount, :float
change_column :sales_return_items, :total, :integer
end
... |
require 'test_helper'
class Rayadmin::MarkinfosControllerTest < ActionController::TestCase
setup do
@markinfo = markinfos(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:markinfos)
end
test "should get new" do
get :new
assert_response... |
class Test < ApplicationRecord
belongs_to :subject
has_many :results
end
|
class User < ApplicationRecord
acts_as_voter
has_many :likes, dependent: :destroy
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
... |
Pod::Spec.new do |s|
s.name = 'FASDFEWSSDGD'
s.version = '1.0.3'
s.summary = 'A view like UIAlertView on iOS.'
s.homepage = 'http://blog.csdn.net/codingfire'
s.authors = { ‘liuxuanshuo’ => ‘lxuanshuo@gmail.com' }
s.source = { :git => 'https://github.com/codeliu6572/CustomAlertView.git', :tag => '1.0.3' }
s.requires_arc... |
class League
class DivisionPresenter < BasePresenter
presents :division
def bracket_data(rosters, matches)
rosters = rosters.index_by(&:id)
matches = matches.group_by(&:round_number)
rounds = matches.keys.sort
# rubocop:disable Rails/OutputSafety
{
rounds: rounds.map ... |
#
# Cookbook Name:: snapshot_timer
# Recipe:: install_plugin
#
# Copyright (C) 2013 Ryan Cragun
#
# 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... |
require_relative "lib/usercommunications/version"
Gem::Specification.new do |spec|
spec.name = "usercommunications"
spec.version = Usercommunications::VERSION
spec.authors = ["vineethmoturi"]
spec.email = ["moturivineeth321@gmail.com"]
spec.homepage = "http://website.com"
spec.summa... |
class User < ActiveRecord::Base
has_many :tweets
validates :name, presence: true
validates :salutation, presence: true
validates :email, presence: true
validates :email, presence:
end |
require 'date'
class Calendar
def initialize(birthday_date)
@birthday_date = birthday_date
end
def days_left
# modulos work for negatives
return (((@birthday_date - Date.today).to_i) % 365)
end
end
|
require 'spec_helper'
describe 'nmax', type: :acceptance do
context 'with valid arguments and input stream' do
let(:max) { 100 }
let!(:numbers) { (1..1000).to_a }
let(:file) { generate_file('data.txt', numbers) }
let(:max_numbers) { (901..1000).to_a.reverse }
it 'return max numbers' do
exp... |
require "rails_helper"
RSpec.describe HomeController do
render_views
describe "GET :faq" do
it "renders the view" do
get :faq
expect(response).to render_template(:faq)
end
end
end
|
require 'spec_helper'
describe GapIntelligence::RecordSet do
subject(:record_set) { described_class.new [1, 2, 3] }
it 'allows record sets to be created' do
expect(described_class).to respond_to(:new)
end
it 'accepts meta' do
expect(record_set).to respond_to(:meta)
end
it 'iterates over collecti... |
class InstancesController < ApplicationController
before_filter :fetch_player
def index
@instances = @player.instances.find(:all, :order => 'created_at')
@stats = {}
@instances.each { |instance| @stats[instance.id] = ETQWStats.parse(instance.data) }
end
def destroy
if @player.instances.find(params... |
# frozen_string_literal: true
module LabelHelper
def label_color(slug)
case slug
when /todo/ then 'bg-info'
when /in-progress/ then 'bg-primary'
when /qa/ then 'bg-warning'
when /done/ then 'bg-success'
else
'bg-info'
end
end
end
|
#require 'dm-timestamps'
class Post
include DataMapper::Resource
REXP_TAG = /#(\S+)/
property :id, Serial
property :posted_at, DateTime
validates_present :posted_at
property :message, String, :length => (1..420)
has n, :taggings
has n, :tags, :through => :taggings, :mutable => true
before :save... |
class Login < ActiveRecord::Base
attr_accessible :password, :username
validates :username, :presence => true
validates :password, :presence => true
def self.authenticate(username="", login_password="")
user = Login.find_by_username(username)
password = Login.find_by_password(login_password)
if user && pass... |
class BasePresenter
def initialize(object, template)
@object = object
@template = template
end
private
def self.presents(name)
define_method(name) do
@object
end
end
def h
@template
end
def markdown(text)
Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(:hard_wrap => t... |
require 'test_helper'
class PayloadControllerTest < ActionController::TestCase
setup do
@payload_attributes = payload_factory
end
test "should accept payload that creates a profile and measurements" do
assert_difference('Profile.count') do
assert_difference('Measurement.count', 4) do
post... |
# frozen_string_literal: true
module PgParty
VERSION = "1.6.0"
end
|
module Rails
module ConsoleMethods
def self.included(_base)
catch(:halt) do
ConsoleCreep.config.authorization.call
return true
end
exit("Exiting console.")
end
end
end
|
class DropCertificates < ActiveRecord::Migration
def down
drop_table :certificates
drop_table :certificates_drivers
end
end
|
class Mood < ActiveRecord::Base
has_many :songs
validates :name, presence: true, uniqueness: true
validates :description, presence: true
end
|
require 'account'
describe Account do
it 'creates an account with a default empty balance' do
account = Account.new
expect(account.balance).to eq 0
end
describe '#credit' do
it 'adds the amount stated as param to the balance' do
account = Account.new
account.credi... |
FactoryBot.define do
factory :request_statistic do
truncated_time { generate(:truncated_time) }
tenant { generate(:name) }
number_of_hits { generate(:number_of_hits) }
number_of_lti_launches { generate(:number_of_lti_launches) }
number_of_errors { generate(:number_of_errors) }
end
end
|
require 'spec_helper'
require_relative '../../../lib/paths'
using StringExtension
using ArrayExtension
using SymbolExtension
module Jabverwock
RSpec.describe 'css test' do
class << self
def bodier
body = BODY.new
### JSFunction ####
h1 = HEADING.new.attr(:id__id01).... |
require 'perlin_noise'
require 'delve/generator/map'
class Noise < Map
@@grains = {
:fine => 0.03,
:coarse => 0.1
}
def initialize width, height, grain
raise 'Cannot initialize noise generator when width is less than zero' if width < 0
raise 'Cannot initialize noise generator when height is les... |
class CreateBookmarks < ActiveRecord::Migration
def self.up
create_table :bookmarks do |t|
t.text :meta
t.string :orig_title
t.string :orig_description
t.string :url
t.string :uid
t.timestamps
end
Bookmark.create_translation_table! :title => :string, :description => :te... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.