text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'fastlane/action'
require 'fastlane_core'
require 'fastlane'
require 'openssl'
require 'date'
require 'colorize'
require 'plist'
require 'json'
import 'Base/Helpers/EnvironmentHelper.rb'
class BaseHelper
@@env_helper = EnvironmentHelper.new
attr_accessor :fastlane
def in... |
class AddTotolModifiedToOrder < ActiveRecord::Migration
def change
add_column :orders, :total_modified, :boolean, default: false, null: false
add_column :orders, :origin_total, :decimal, precision: 10, scale: 2
end
end
|
require 'spec_helper'
describe CategoriesController do
def valid_attributes
{ name: "some name",
description: "some description" }
end
def valid_session
{}
end
describe "GET show" do
it "assigns the requested category as @category" do
category = Category.create! valid_attributes
... |
class CornersController < ApplicationController
before_action :set_corner, only: [:show, :edit, :update, :destroy]
# GET /corners
# GET /corners.json
def index
@corners = Corner.all
end
# GET /corners/1
# GET /corners/1.json
def show
end
# GET /corners/new
def new
@corner = Corner.new
... |
module Api
module V1
class ActivitiesController < APIController
def index
activities = Activity.order('date DESC')
respond_with activities
end
def create
activity = Activity.new(activity_params)
if activity.save
respond_with activity, location: nil
... |
module Extension
module Features
class ArgoServe
include SmartProperties
property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
property! :context, accepts: ShopifyCli::Context
YARN_SERVE_COMMAND = %w(server)
NPM_SERVE_COMMAND = %w(run-script s... |
class Medium < ActiveRecord::Base
has_many :appearances
has_many :users, :through => :appearances
scope :tv_series, -> {where(type: "TVSeries")}
scope :movie, -> {where(type: "Movie")}
scope :game, -> {where(type: "Game")}
scope :song, -> {where(type: "Song")}
scope :commercial, -> {where(type: "Commercia... |
require 'bookmark'
describe Bookmark do
describe '#.all' do
it 'views all saved bookmarks' do
Bookmark.create(url: 'http://www.makersacademy.com', title: 'Learning')
Bookmark.create(url: 'http://www.google.com', title: 'Searching')
Bookmark.create(url: 'http://www.destroyallsoftware.com', titl... |
require "uri"
module Vanity
# Playground catalogs all your experiments. For configuration please see
# Vanity::Configuration, for connection management, please see
# Vanity::Connection.
class Playground
# Returns hash of metrics (key is metric id).
#
# @see Vanity::Metric
# @since 1.1.0
# @... |
class NotificationsController < ApplicationController
def index
@notifications = current_user.notifications.order(created_at: :desc)
end
def show
@notification = Notification.find(params[:id])
@notification.read = true
@notification.save(validate: false)
end
def dismiss
@notificat... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'spec/mocks/scope_expectation'
describe PeopleController do
def mock_person(stubs={})
stubs = stubs.reverse_merge(:updated_at => 10.minutes.ago)
@mock_person ||= mock_model(Person, stubs)
end
def expect_person_retrievals(optio... |
module MStatsd
class Runner
def self.run!(config)
EM::run do
server = EM::open_datagram_socket('192.168.2.2', 8125, Server)
cassandra = MStatsd::MCassandra.new(config['cassandra'])
server.add_backend(cassandra)
EM::add_periodic_timer(1) do
server.flush!
end... |
class CreateRequestLogs < ActiveRecord::Migration[5.1]
def change
create_table :request_logs do |t|
t.belongs_to :user, null: false, index: true, foreign_key: true
t.integer :request_type, null: false, index: true
t.jsonb :request_content
t.timestamps
end
end
end
|
class Game < ActiveRecord::Base
validates :title, presence: true
validates :description, length:{ minimum: 10 }
validates :type , :developer, presence: true
validates :url, format: {with: /(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ }
has_attached_file :image,
styles: { medium: "600x60... |
# frozen_string_literal: true
module MondialRelay
module Services
class BaseService
attr_reader :name
def initialize(name)
@name = name
end
def client
@client ||= Client.new(wsdl_url)
end
def wsdl_url
raise NotImplementedError
end
end
end... |
require File.dirname(__FILE__) + "/../spec_helper"
describe DashboardController do
describe "GET index" do
it "should redirect to login screen when no current_user" do
get :index
response.should redirect_to(login_path)
end
it "" do
login_as(:guest)
get :index
respo... |
module SlackHelper
def link_to(path, text)
"<#{path}|#{text}>"
end
def user_url(user)
"<@#{user.slack_id}>"
end
['question', 'answer', 'comment', 'upvote', 'downvote'].each do |taggable|
define_method "#{taggable}_tag" do |id|
"[#{taggable.capitalize} ##{id}]"
end
end
end
|
# This module is a rails helper for events
# Author:: Mark Grebe
# Copyright:: Copyright (c) 2013 Mark Grebe
# License:: Distributes under the same terms as Ruby
# Developed for Master of Engineering Project
# University of Colorado - Boulder - Spring 2013
module EventsHelper
# Determine if the current user ... |
class JournalImage < ActiveRecord::Base
belongs_to :journal
belongs_to :profile
# Paperclip
has_attached_file :image,
styles: {
pixels_600: '600x600>',
pixels_400: '400x400>',
pixels_240: '240x240>'
}
... |
module Admin
class AdministratorsController < BaseController
PER_PAGE = 20
def index
@administrators = Administrator.order(created_at: :desc).paginate(page: params[:page], per_page: PER_PAGE)
end
def new
@administrator = Administrator.new
end
def create
@administrator = ... |
# Problem 406: Guessing Game
# http://projecteuler.net/problem=406
# We are trying to find a hidden number selected from the set of integers {1, 2, ..., n} by asking questions.
# Each number (question) we ask, we get one of three possible answers: "Your guess is lower than the hidden number" (and you incur a cost of ... |
Cogs::Application.routes.draw do
resources :gears, :except => [:new, :edit]
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
root 'static#home'
mount JasmineRails::Engine => "/specs" if defined?(JasmineRails)
end
|
class AddRepositoryUuidToCollections < ActiveRecord::Migration[5.2]
def change
add_column :collections, :repository_uuid, :string
end
end
|
# encoding: UTF-8
module PlaceholderParser
class Android < Parser
REGEX = Regexp.new(
'%' + # percent sign
'([1-9]*)?' + # optional argument index
'([,+ (\-0#$]*)?' + # optional flags
'(\d*)?' + # optional width
'(?:\.([\d]*))?' + # optional precis... |
module SayName
attr_accessor :name
def print_name
puts "My name is #{@name}"
end
end
class Person
include SayName
end
person = Person.new
person.name = "Austin"
person.print_name |
# Stack Machine Interpretation
# Finds if String value is really an integer
class String
def is_i?
/\A[-+]?\d+\z/ === self
end
end
def minilang(command)
# Register initialized to 0
register = 0
# Stack is empty array
stack = []
# Splits string into an array
arr = command.split(" ")
# Con... |
=begin
When looking at this method, we know that the last line is puts 'Dinner', therefore, the return value of meal is the evaluated result of that line.
Based on the previous exercise, we know that the return value of #puts is always nil.
Putting both of those together results in the return value of meal being nil
... |
require 'action_view'
class UserMailer < ActionMailer::Base
include ActionView::Helpers::SanitizeHelper
default from: "from@example.com"
def send_email(id)
@trigger = Trigger.find(id)
puts "Emails to send:"
puts "#{@trigger.id} #{@trigger.date_trigger}"
puts @trigger.item.title
#get message and... |
require 'pry'
class Song
attr_accessor :name, :artist_name
@@all = []
def self.all
@@all
end
def save
self.class.all << self
end
def self.create
song = self.new
song.save
song
end
def self.new_by_name(song_name)
song = self.new
song.name = song_name
song
end
d... |
class CreateLoans < ActiveRecord::Migration[5.2]
def change
create_table :loans do |t|
t.decimal :total_amount, precision: 30, scale: 5, default: "0.0"
t.string :currency, limit: 3, default: "USD"
t.string :status
t.string :financial_status
t.datetime :payoff
t.boolean :archived, def... |
require 'rails_helper'
feature 'Home' do
# RSpecの動作確認用なので削除して良い
scenario 'トップページが表示されること' do
visit root_path
expect(page).to have_http_status :ok
end
# RSpecの動作確認用なので削除して良い
scenario 'JSドライバが動作すること', js: true do
visit root_path
expect(page).to have_http_status :ok
end
end |
require 'spec_helper'
describe Susanoo::Exports::Sync::Rsync do
include Susanoo::Exports::Sync::Rsync
describe "メソッド" do
let(:do_sync_path) { Susanoo::Exports::Sync::Rsync::SYNC_ENABLE_FILE_PATH }
before do
File.open(do_sync_path, 'w') do |f|
f.print 'do_sync_file'
end
end
des... |
require 'rails_helper'
RSpec.describe Bug, type: :model do
describe "validations" do
it "has a uniq number per subscriber" do
subscriber = create(:subscriber)
bug1 = create(:bug, subscriber: subscriber)
bug2 = create(:bug, subscriber: subscriber)
expect(bug1.number).not_to eq(bug2.number)
end
it... |
class PartyOrder < ActiveRecord::Base
acts_as_content_block({:versioned => false})
attr_accessor :skip_callbacks
attr_accessible :details, :name, :contact_no, :email
validates :name, :presence => true
validates :contact_no, :presence => true
validates :email, :presence => true
end
|
module Api
module V1
class CoveragesController < ApplicationController
include DeviseTokenAuth::Concerns::SetUserByToken
respond_to :json
before_action :authenticate_user!
before_action :set_rider, only: [:index, :new, :show, :edit, :create, :update, :destroy]
before_action :set_cove... |
class Calculator::Ups::Standard < Calculator::Ups::Base
def self.description
"UPS Standard"
end
end
|
directory "#{node[:dynamodb][:local][:dir]}" do
owner "root"
group "root"
mode 0755
action :create
end
remote_file "#{node[:dynamodb][:local][:dir]}/#{node[:dynamodb][:local][:pkg]}" do
source "#{node[:dynamodb][:local][:pkg_url]}"
end
bash "install dynamodb local" do
user "root"
code <<-EOC
cd #{no... |
# Vote Model
class Vote < ApplicationRecord
belongs_to :choice
validates_presence_of :time
validates_inclusion_of :valid_vote, in: [true, false]
end
|
#
# hermeneutics.gemspec -- Hermeneutics Gem specification
#
require "./lib/hermeneutics/version.rb"
Gem::Specification.new do |s|
s.name = Hermeneutics::NAME
s.version = Hermeneutics::VERSION
s.summary = Hermeneutics::SUMMARY
s.description = Hermeneutics::DESCRIPTION... |
# frozen_string_literal: true
module V1
module Authenticated
class Chats < Grape::API
namespace :chats do
params do
end
get '' do
data = Invite.accepted
.where('from_user_id = ? OR to_user_id = ?', current_user.id, current_user.id)
... |
require ('helper_spec')
describe(Stylist) do
describe('.all') do
it('shows the Stylist class as empty upon initialization') do
expect(Stylist.all()).to(eq([]))
end
end
describe('#==') do
it('shows a stylist as being == equal when they share the same name and id') do
test_stylist1 = Stylis... |
require 'spec_helper'
describe ReviewsController do
describe "POST create" do
context "with authenticated user" do
let(:video) { Fabricate(:video) }
let(:user) { Fabricate(:user) }
before do
session[:user_id] = user.id
end
context "with valid input" do
let(:rev... |
class AppMigration < ActiveRecord::Migration
def change
create_table :tasks do |t|
t.references :requested_by
t.references :assigned_to
t.references :category
t.references :project
t.references :parent
t.integer :lft
t.integer :rgt
t.strin... |
require 'spec_helper'
describe Kata::Algorithms::Comparisons::HasDuplicateValue do
[
[[1, 2, 2], 2],
[[1, 2, 1], 1],
[[1, 2, 3], nil],
].each do |input, output|
it "when input is #{input}, then output is #{output}" do
subject = described_class.new(input)
expect(subject.duplicate_v... |
module SetItem
extend ActiveSupport::Concern
private
def set_item
@item = Item.find(params[:id])
end
end |
require 'test_helper'
class ParameterDevelopmentsControllerTest < ActionDispatch::IntegrationTest
setup do
@parameter_development = parameter_developments(:one)
end
test "should get index" do
get parameter_developments_url
assert_response :success
end
test "should get new" do
get new_parame... |
class Belly::HomeController < Belly::ApplicationController
def index
render text: 'Belly home'
end
end
|
require 'spec_helper'
describe 'certificates/_certificate_small' do
let(:certificate) { create(:certificate) }
let(:merchant) { certificate.merchant }
before do
assign(:certificate, certificate)
end
it "displays a small certificate" do
render :partial => 'certificates/certificate_small', :locals... |
require 'spec_helper'
require 'paperclip/storage/azure/environment'
describe 'Paperclip::Storage::Azure::Environment' do
subject { Paperclip::Storage::Azure::Environment }
describe '#url_for' do
let(:account_name) { 'foo' }
describe 'when the region is not supplied' do
it { expect(subject.url_for(a... |
class Admission < ActiveRecord::Base
belongs_to :consultation
belongs_to :hospital
end
|
require 'sinatra'
require 'tilt/erb'
require 'oauth2'
require 'data_mapper'
client = OAuth2::Client.new(ENV['STRAVA_APP_ID'], ENV['STRAVA_SECRET'], :site => 'https://www.strava.com/oauth/authorize')
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, ENV['DATABASE_URL'])
class User
include DataMapper... |
class Auth::RegistrationsController < DeviseTokenAuth::RegistrationsController
prepend_before_action :verify_tos_agreement, only: [:create]
prepend_before_action :verify_recaptcha, only: [:create]
private
def verify_tos_agreement
if params[:agree_tos] != 'yes'
render json: { errors: ["agree_tos is n... |
FactoryBot.define do
factory :simple_string, class: String do
argument { 'The simple string' }
end
factory :simple_regex_chars, class: Array do
argument do
%w([A-Z] [a-z] [a-z] \s [a-z] [a-z] [a-z] [a-z] [a-z] [a-z] \s [a-z]
[a-z] [a-z] [a-z] [a-z] [a-z])
end
end
factory :string_w... |
class Board
attr_accessor :board
def initialize
# board is a 3 * 3 array
@board = Array.new(9, "-")
end
def display
puts " --- --- --- "
puts "| #{@board[0]} | #{@board[1]} | #{@board[2]} |"
puts " --- --- --- "
puts "| #{@board[3]} | #{@board[4]} | #{@board[5]} |"
puts " --- --- --- "
puts "|... |
ActiveAdmin.register Agencia do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
permit_params :nombre, :dpto_mendoza_id, :direccion, :telefono, :email, :web, :logo, :latitud, :longitud, :alta
#... |
class RegistrationForm
include ActiveModel::Model
attr_accessor :email, :password, :password_confirmation, :token, :name, :surname, :birth_date, :short_bio
validates :email, :password, :password_confirmation, presence: true
validates :password, confirmation: { case_sensitive: true }
#validacja na... |
namespace :search_suggestions do
desc "Generate search suggestions from lists"
task :index => :environment do
SearchSuggestion.index_lists
end
end |
require_relative '../helpers/palindromes'
class OEIS
A060879_SEQUENCE = IntrinsicKPalindromes.new(9, 1000).all
def self.a060879(n)
raise "A060879 is not defined for n = #{n} < 1" if n < 1
A060879_SEQUENCE[n - 1]
end
end
|
json.array!(@paragraphs) do |paragraph|
json.extract! paragraph, :id, :content, :topic_id
json.url paragraph_url(paragraph, format: :json)
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
# http://unicode.org/reports/tr35/tr35-general.html#Transforms
# http://unicode.org/cldr/utility/transform.jsp
module TwitterCldr
module Transforms
class FilteredRuleSet
attr_reader :filter_rule, :transform_id
... |
class AddCommentToUsers < ActiveRecord::Migration
def change
add_column :users, :cmt, :text
end
end
|
require 'highline'
require_relative 'cure_muno.rb'
require_relative 'next_episode.rb'
require_relative 'search_n_markov.rb'
module CureMuno
module_function
def monitor_userstream
bot = CureMuno.new
h = HighLine.new
bot.stream.userstream do |t|
Thread.new{
# If the tweet is a reply to th... |
class UsersController < ApplicationController
def create
user = User.new
user.email = params[:email]
user.password = params[:password]
begin
user.save!
rescue ActiveRecord::RecordInvalid => e
render_error 400, :invalid_request, e.to_s
re... |
class AddCnfDataFileUrlToBoatType < ActiveRecord::Migration[5.0]
def change
add_column :boat_types, :cnf_data_file_url, :string
end
end
|
# frozen_string_literal: true
require 'uma'
class Config::Metadata::UMA < Config::Metadata
class Error < StandardError; end
class TokenError < Error; end
class ResourceError < Error; end
include Config::Discoverable
DiscoveryFailed = ::UMA::Discovery::DiscoveryFailed
def discover!
raise DiscoveryFa... |
class Hand
attr_accessor :hand
def initialize(hand = [])
@hand = hand
end
end
|
# verify java dependency
verify_java 'Wikipedia Example Java Plugin'
# check required attributes
verify_attributes do
attributes [
'node[:newrelic][:license_key]',
'node[:newrelic][:wikipedia_example_java][:install_path]',
'node[:newrelic][:wikipedia_example_java][:user]'
]
end
verify_license_key node... |
class RemoveSlackuidAndSlackAccessTokenFromUser < ActiveRecord::Migration[5.0]
def change
remove_column :users, :slack_uid
remove_column :users, :slack_access_token
end
end
|
class CreateImovels < ActiveRecord::Migration[5.0]
def change
create_table :imovels do |t|
t.string :nome
t.string :descricao
t.integer :valor
t.integer :proprietario_id
t.integer :finalidade_id
t.integer :categoria_id
t.timestamps
end
end
end
|
FactoryGirl.define do
factory :clinical_provider do
identity nil
organization nil
trait :with_organization do
organization
end
factory :clinical_provider_with_organization, traits: [:with_organization]
end
end
|
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'beanstalk-client'
# Global init
RBPM_APPDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
RBPM_LOGDIR = File.join(RBPM_APPDIR, 'log')
RBPM_HOSTNAME = `hostname`.chomp
RBPM_GLOBAL_LOGFILE = File.join(RBPM_LOGDIR, 'rbpm_global.log')
RBPM_W... |
require 'kimurai'
require 'yaml'
require 'pry'
require 'monetize'
require 'highline'
class UtaSpider < Kimurai::Base
@name = "UTA Spider"
@engine = :selenium_chrome
@start_urls = ['https://farepay.rideuta.com']
def initialize()
super
@cli = HighLine.new
@contributions = []
@usage = []
@tot... |
# encoding: utf-8
module TextUtils
module StringFilter
## turn accented char into ascii look alike if possible
##
## todo: add some more
## see http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references for more
## see http://en.wikipedia.org/wi... |
module DefaultUrlOptions
def default_url_options
{
:host => host,
:port => port
}
end
private
def host
Rails.env.development? ? "0.0.0.0" : ENV['DOMAIN']
end
def port
Rails.env.development? ? 3000 : 80
end
end |
class Badge < ApplicationRecord
IMAGES = [
['First try success', '1st_success.png'],
['Leader', 'leader.png'],
['Complete category', 'winner_category.png'],
['Complete level', 'winner_level.png'],
].freeze
has_many :user_badges, dependent: :delete_all
has_many :users, through: :user_badges
be... |
class AndroidStudio < Cask
url 'http://dl.google.com/dl/android/studio/ide-zips/0.4.0/android-studio-ide-132.955124-mac.zip'
homepage 'https://developer.android.com/sdk/installing/studio.html'
version '0.4.0 build-132.955124'
sha1 '439be59efc50cb4719288d26bb573476bdd1fbb8'
link 'Android Studio.app'
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... |
# -*- 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|
# Use the same ... |
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
describe "Validations[introspection]" do
before :each do
@contacts_validations = contacts_validations = Module.new do
include Validations
validate_presence_of :phone
validate_presence_of :email
end
@more_valid... |
class UpdateStatusJob < ApplicationJob
def perform(spot)
ActionCable.server.broadcast "spots",
message: SpotsController.render(partial: 'spots/spot', locals: { spot: spot })
end
end
|
module UsersHelper
def user_view
if !session[:user_id]
['Sign up', new_user_path, 'Sign in', signin_path]
elsif !User.find(session[:user_id]).admin?
['Log Out', logout_path]
else ['Log Out', logout_path, 'ADMIN', root_path]
end
end
def is_admin?
session[:user_id] && User.find(ses... |
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/skip_dsl'
require_relative '../lib/planet.rb'
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
describe 'Planet' do
it 'creates an instance of Planet' do
name = 'Earth'
color = 'blue-green'
mass_kg = 5.972e24
di... |
class CreatePatients < ActiveRecord::Migration
def change
create_table :patients do |t|
t.string :first_name, default: ""
t.string :middle_name, default: ""
t.string :last_name, default: ""
t.date :birthday
t.string :gender, default: ""
t.string :status, default: ""
t.int... |
class RateBooks
include Service
include ActiveModel::Model
def initialize
@top_books_ids = OrderBook.top_books.map!(&:book_id)
end
def call
@top_books = Book.find(@top_books_ids)
end
end |
#require_relative "test_helper"
require "test/unit"
require 'rack/test'
require_relative '../frontend/main'
class TestVersion < Test::Unit::TestCase
include Rack::Test::Methods
# Initialize testing objects
def app
Sinatra::Application
end
# Test static pages
def test_homepage
... |
class BokergenVote < ActiveRecord::Base
attr_accessible :name, :remark, :status, :vote_num, :user_id
default_value_for :status, "stash"
validates_uniqueness_of :name
belongs_to :user
end
|
require 'soundcloud'
Dotenv.load
class InitLeadsWorker
include Sidekiq::Worker
def perform(*args)
# for now we hard code artists to seed, with their soundcloud handles
client = Soundcloud.new(client_id: ENV['SOUNDCLOUD_CLIENT'])
genres = {
# 'Future Funk': 'yungestbae',
'Bay Area': 'mozzym... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# monitor
config.vm.define "snmpserver" do |snmpserver|
snmpserver.vm.hostname = "snmpserver"
snmpserver.vm.box = "ubuntu/trusty64"
snmpserver.vm.network "public_network"
snmpserver.vm.network "forwarded_port", guest: 80, ho... |
class UsersController < ApplicationController
attr_accessor :analytics
def create
password = SecureRandom.hex
@user = User.create(email: params[:mailing_email], password: password, password_confirmation: password)
if @user.save
flash[:notice] = 'You have been signed up for the mailing list.'
... |
Wherewhoresgo::Application.routes.draw do
root to: 'whores#index'
resources :whores, only: [:index, :create]
end
|
class Room < ActiveRecord::Base
attr_accessible :title, :url
has_many :messages
acts_as_url :title
validates :title, presence: true, uniqueness: true
def to_param
url
end
end
|
require 'rails_helper'
RSpec.describe Template1::Rails::FormActionHelper, :type => :helper do
context '.form_action_icon' do
it { expect(helper.form_action_icon(:delete)).to eq('<i class="fa fa-trash-o"></i>') }
it { expect(helper.form_action_icon(:view)).to eq('<i class="fa fa-eye"></i>') }
it { ... |
class User < ActiveRecord::Base
validates_presence_of :name, :email_address
validates_uniqueness_of :email_address
has_many :orders
before_create :generate_tokens, :validate_email
after_create :send_user_credentials
def generate_tokens
self.auth_token = loop do
random_token = SecureRandom.urlsafe... |
require 'rails_helper'
describe Event do
describe "Validations" do
let(:event) { FactoryGirl.create(:event) }
it "Must have a start time" do
expect(event).to be_valid
event.starts_at = nil
expect(event).not_to be_valid
end
it "Must have an end time" do
expect(event).to be_va... |
module Ruboty
class Action
def self.prefix_pattern(robot_name)
/\A@?#{Regexp.escape(robot_name)}:?\s*/
end
attr_reader :options, :pattern
def initialize(pattern, options = {})
@pattern = pattern
@options = options
end
def call(handler, message)
handler.send(name, mes... |
#! /usr/bin/ruby
require 'date'
require 'set'
module HolidayDates
# provides a Set of holidays where games should not be scheduled.
# The objects in the set are Date objects of the holidays, for
# simple testing.
def self.get_holiday_schedule ()
holidays = [
"2017-01-01", # new ye... |
class AddDeletedAtToPhotoEssays < ActiveRecord::Migration
def change
add_column :photo_essays, :deleted_at, :datetime
end
end
|
class ChatBan < ApplicationRecord
belongs_to :user
belongs_to :banned_user, class_name: 'User', foreign_key: 'banned_user_id'
end
|
require 'test_helper'
class ProgrammesControllerTest < ActionController::TestCase
include AuthenticatedTestHelper
#for now just admins can create programmes, later we will change this
test "new page accessible admin" do
login_as(Factory(:admin))
get :new
assert_response :success
end
test "new ... |
# frozen_string_literal: true
class Order < ApplicationRecord
belongs_to :user
has_many :order_products
validates :status, :pst, :gst, :hst, :total, presence: true
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.