text stringlengths 10 2.61M |
|---|
module CDI
module V1
module Challenges
class CreateService < BaseCreateService
include V1::ServiceConcerns::ChallengeParams
record_type ::Challenge
def build_record
Challenge.new(challenge_params)
end
def can_create_record?
unless valid_deliver... |
module MomentumCms
module Authentication
module HttpAuthentication
# Set username and password in config/initializers/momentum_cms.rb
# Like this:
# MomentumCms::Authentication::HttpAuthentication.username = 'myname'
# MomentumCms::Authentication::HttpAuthentication.password = 'mypassw... |
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Glimmer
# Author: Kread-EX
# Version 1.0
# Release date: 13/12/2011
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#--------------------------------------------------------------------------------... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
include Pundit
protect_from_forgery with: :exception
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
before_action :configure_permit... |
class StuffCategory < ApplicationRecord
belongs_to :stuff
belongs_to :category
end |
class SendmessagesController < ApplicationController
def new
@send = Text.new
end
def create
@send = Text.new(text_params)
if @send.save
session[:text_id] = @send.id
redirect_to root_path, notice: "Successfully send messages"
else
render new
end
end
private
def text_pa... |
class CreatePrivilegeTags < ActiveRecord::Migration
def self.up
create_table :privilege_tags do |t|
t.string :name_tag
t.integer :priority
t.timestamps
end
create_privilege_tag_and_update_privilege
end
def self.down
drop_table :privilege_tags
end
def self.create_privilege_... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniaut... |
class InquiryMailer < ActionMailer::Base
default from: 'enpit.s04@gmail.com'
default to: 'enpit.s04@gmail.com'
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.inquiry_mailer.received_email.subject
#
def received_email(inquiry)
@inquiry = inquiry... |
require 'spec_helper'
describe MovesController do
fixtures :all
render_views
it "should show moves in game" do
game = Factory(:game, :moves => "aa-bb-cc")
get "index", :game_id => game.id, :format => "js", :after => 1
response.body.should include("\"bb-cc\"")
end
it "should add a move and respo... |
require "rubygems"
# Feature: Upload files to the server by using HTTP POST requests.
# Description: This feature initially is for the PCAP project
# Usages:
# $curl -F file=@C:\test.txt http://10.100.162.63:8082/files
# $curl -k -F file=@test.txt https://sprintcm.analytics.smithmicro.com/files
class FilesCo... |
class AddColumnToUser < ActiveRecord::Migration
def change
add_column :users, :user_name, :string
add_column :users, :first_name, :string
add_column :users, :middle_name, :string
add_column :users, :last_name, :string
add_column :users, :mobile_no, :integer,:limit => 8
add_column :users, :address, :... |
class QuizAnswer < ApplicationRecord
belongs_to :quiz_question, optional: true
end
|
require_relative 'vehicle_builder'
require_relative 'vehicle'
class MotorcycleBuilder < VehicleBuilder
def initialize
@vehicle = Vehicle.new('Motorcycle')
end
def build_frame
@vehicle[:frame] = 'Motorcycle frame'
end
def build_engine
@vehicle[:engine] = '500 cc'
end
def build_wheels
@v... |
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
# initializes a song
song = self.new
song.save
song
end
def self.new_by_name(name)
# song = self.create
# song.name =... |
module Coco
# Compute results of interest from the big results information (from
# Coverage.result)
#
class CoverageResult
# Returns a Hash coverage for all the sources that live in the root
# project folder.
#
attr_reader :coverable_files
# Returns a Hash coverage for sources that are no... |
require 'rubygems'
require 'active_record'
module Datasource
class ActiveRecordInterface
def initialize(config)
#puts config
ActiveRecord::Base.establish_connection(
:adapter => config["adapter"],
:host => config["host"],
:database => config["database"],
:username => config["usernam... |
module Slickr
module Actions
# Adapter for calling the different types of Generators.
#
# This class takes the name of the generator, in any form, and
# the name the user wants to give to the new piece of code. It
# will normalize both to follow Slickr conventions.
#
# == Naming Convention... |
class CommentsController < ApplicationController
def new
@comment.recipe_id = params[:id]
render 'form', layout: false
end
def edit
render 'form', layout: false
end
def answer
@comment = Comment.new
@comment.answer_to_id = params[:id]
@comment.recipe_id = Comment.find(param... |
class BoardBlogsController < BoardsController
before_action :set_boardable, only: [:show,:edit, :update, :destroy]
before_action :set_title
before_action :set_search, only: [:index, :show]
load_and_authorize_resource
def index
super
if Board.where(boardable_type:@model) != []
params[:id] = con... |
Rails.application.routes.draw do
devise_for :users
root to: 'home#home'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get "about", to: "home#about"
get "recycling", to: "home#recycling"
get "lifestyle", to: "home#lifestyle"
end
|
require 'bundler/setup'
require 'active_record'
require 'temping'
require 'minitest/autorun'
require 'minitest/pride'
ActiveRecord::Base.establish_connection adapter: :sqlite3, database: ':memory:'
require 'handle_in_transaction'
class HandleInTransactionTest < MiniTest::Spec
describe HandleInTransaction do
b... |
# frozen_string_literal: true
require "cell/partial"
module Decidim
module Opinions
# This cell renders the linked resource of a opinion.
class OpinionLinkedResourcesCell < Decidim::ViewModel
def show
render if linked_resource
end
end
end
end
|
feature 'Viewing an article' do
scenario "title, content and authors's name is shown" do
article = create_article
formatted_date = article.published_at.strftime('%d %B, %Y')
visit article_path(article)
expect(page).to have_content article.title
expect(page).to have_content article.content
... |
class Compatible < ApplicationRecord
# themes
has_many :datacompatibles
has_many :themes, through: :datacompatibles
has_many :codes, through: :datacompatibles
end
|
class Employees
attr_accessor :name
def initialize(name)
@name = name
end
def change
puts 'do you want to modify the employee name?'
answer = gets.chomp
if answer == 'yes'
puts 'enter new name'
newname = gets.chomp
@name = newname
else
puts 'exiting...'
end
e... |
module ChefHelper
class KibanaRoleAttributesGenerator < GenericRoleAttributesGenerator
def initialize(component, infrastructure_components, opts = {})
@elasticsearch_hosts = fetch_hosts_address_by(
infrastructure_components, 'component_type', 'elasticsearch')
@elasticsearch_port = opts[:elasti... |
Rails.application.routes.draw do
resources :lockers
resources :offers
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
#Admin Session
get 'admin/login', to: 'admin_session#new'
post 'admin/login', to: 'admin_session#create'
delete 'admin/logout', to: 'ad... |
feature "Official Diary - Create" do
context 'Visitor' do
scenario "Access invalid" do
visit new_official_diary_path
expect(current_path).to eq new_session_path
end
end
context 'Admin' do
let(:user) { create :user}
background do
login us... |
module Fib
# return [1,2,3,5,8,13,21,34...limit]
def get_fib_numbers(limit)
@@limit = limit
fib
end
# return [2,8,34...]
def get_sum_of_even(limit)
sum_of_even get_fib_numbers(limit)
end
# push numbers to arr, and return that
def fib(arr=[1,2])
next_term = arr[-1] + arr[-2]
return... |
require 'v1/publish_logic'
RSpec.describe V1::PublishLogic do
let(:user) { create(:user) }
describe '.incoming' do
it 'Message type is invalid' do
faye_message = {
"channel" => "/v1/users/ea8fb465c9fe1f7cab2b53fcf12b9b53/messages",
"ext" => {"access_token"=>user.access_tokens.first.t... |
class Category < ActiveRecord::Base
has_many :categorizations
has_many :movies, :through => :categorizations
end
|
module Authentication
def self.included(base)
base.extend ClassMethods
base.helper_method :current_user, :current_user?, :logged_in?, :role?, :self?, :owner?, :admin?, :moderator?
end
module ClassMethods
def login(filters = {})
before_filter :login, filters
end
def skip_login(filters =... |
# More advanced project: https://learn.launchacademy.com/teams/alumni/curricula/on-campus-boston-26/lesson_groups/week_1:_advanced_oop/lessons/high-card-dealer
#
# Basic objects Ruby:
# Square:
#
# Make a square class that takes the length of a side as the only argument.
# class Square
# def initialize(length)
#... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
def cat_hash_rev
{'1' => 'Linux', '2'=>'Hardware', '3'=>'Science', '4'=>'Net & Security'... |
require 'rails_helper'
RSpec.describe Review, type: :model do
it {should have_valid(:reason_of_visit).when("Sports game")}
it {should_not have_valid(:reason_of_visit).when(nil, '')}
it {should have_valid(:quality_of_service).when(1)}
it {should_not have_valid(:quality_of_service).when(nil, '')}
it {should ... |
class RoomsController < ApplicationController
def home
end
def index
@rooms = Room.search(params[:search])
end
def keyword
@rooms = Room.keyword_search(params[:search])
end
def new
@room = Room.new
end
def create
@room = Room.ne... |
class List < ActiveRecord::Base
belongs_to :board
has_many :todos
accepts_nested_attributes_for :todos
end
|
class AddPriceToWidgets < ActiveRecord::Migration[5.2]
def change
add_column :widgets, :thing, :string
end
end
|
Rails.application.routes.draw do
namespace :api, path: '/', constraints: { subdomain: 'api', format: 'json' } do
resources :articles, except: [:edit, :new]
end
end
|
require 'rails_helper'
RSpec.describe 'Returns EtaForecast'do
it 'Returns time less than a day' do
data = {temp: 72, weather:[{description: "perfect"}]}
forecast = EtaForecast.new(data)
expect(forecast.temperature).to be_a(Integer)
expect(forecast.temperature).to eq(72)
expect(forecast.conditio... |
class FontSitara < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/sitara"
desc "Sitara"
homepage "https://www.cdnfonts.com/sitara.font"
def install
(share/"fonts").install "Sitara-Bold.ttf"
(share/"fonts").install "Sitara-BoldItal... |
require 'test_helper'
class PhotographersLoginTest < ActionDispatch::IntegrationTest
def setup
@photographer = Photographer.create!(togname: "Brassai", email: "brass@pocket.com",password: "barryregan")
end
test "disallow invalid login" do
get login_path
assert_template 'sessions/new'
... |
# represent a package offered by sribulancer
class PackageLancer
include ActionView::Helpers::NumberHelper
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
store_in database: 'sribulancer_development', collection: 'packages'
field :price, type: Float, default: 0
field :cna... |
# A controller to handle boards
class BoardsController < ApplicationController
layout "application"
def new
@board = Board.new
end
def get_name(url)
@name = Board.find_by(url).name
end
# Show a board. This is called every time user types in site.com/something-number or just
# site.com/someth... |
class IterativeLinkedList
attr_accessor :head
def initialize
@head = nil
end
def append(node)
if head.nil?
self.head = node
else
current = head
current = current.link until current.link.nil?
current.link = node
end
end
def prepend(node)
node.link = head unless ... |
class CreateDevices < ActiveRecord::Migration[5.1]
def change
create_table :devices, id: :string, primary_key: :uuid do |t|
t.string :user_uuid
t.string :name
t.integer :type
t.string :push_token
t.string :access_token
t.string :refresh_token
t.datetime :token_expires_at
... |
class Api::PostsController < ApplicationController
def index
# currently pulling up the last updated posts, may work the same if i don't reverse the order of my posts seed generation and order by created at, sounds like
# what I was doing before though, while this loads the posts in the right ord... |
class AddStatusProgressIdToStudents < ActiveRecord::Migration
def change
add_column :students, :status_progress_id, :integer
end
end
|
#
# Cookbook Name:: base
# Recipe:: ipv6
#
# Copyright 2014, oshiire
#
# All rights reserved - Do Not Redistribute
#
execute "update-grub" do
action :nothing
end
execute "rewrite-grub" do
command 'sed -i s%^GRUB_CMDLINE_LINUX=\"%GRUB_CMDLINE_LINUX=\"ipv6.disable=1\ % /etc/default/grub'
action :run
not_if "egr... |
FactoryGirl.define do
factory :desk do
sequence(:name){ |i| "desk#{i}@gmail.com" }
user_id 1
factory :desk_with_cards do
transient do
cards_count 5
end
after(:create) do |desk, evaluator|
create_list(:desk, evaluator.cards_count, desk: desk)
end
end
end
end
|
class MatchesController < ApplicationController
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end
def index_current_NOTUSED
active_competitions = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # FIXME
if not current_user.nil? and params[:show_my].present? and pa... |
module NoteHelper
include TextHelper
def get_note_by_id_in_list(id)
Note.where(id: id)
end
def get_user_name_by_note_id(note_id)
note = Note.find_by(id: note_id)
return nil if note.nil?
note.user_id
end
def note_has_reply?(note)
return false if Note.find_by(parse_to: note.id).nil?
... |
#Ce programme permet de récupérer de la data et de faire un envoi de
#mails en masse grace à google
require 'gmail' # on va chercher la gem gmail qui va nous permettre de transmettre nos messages
require 'dotenv' # permet de se servir du .env qui contient le password
require 'mail' # permet de mettre en format ht... |
require 'sinatra/json'
require_relative '../model/cart'
require_relative '../lib/errors/mongo_errors'
module CartService
module Endpoints
# Module representing DELETE /:id/product/:product_id endpoint
module RemoveProduct
def self.registered(app)
app.delete '/:id/product/:product_id' do
... |
require 'uri'
require 'rest-client'
require 'json'
class Daggregator::Connection
def get(path, params={})
response = RestClient.get uri_from(path), :params => params, :content_type => :json, :accept => :json
JSON.parse(response.body)
end
def put(path, data={})
response = RestClient.put uri_from(path... |
class Order
attr_accessor :id, :delivered
attr_reader :meal, :employee, :customer
def initialize(attr = {})
@id = attr[:id]
@delivered = attr[:delivered] || false
@meal = attr[:meal]
@employee = attr[:employee]
@customer = attr[:customer]
end
def self.headers
['id', 'delivered', 'meal... |
class UsersController < ApplicationController
def show
@user = authorize User.find(params[:id])
@items = Item.where(user: @user)
end
def edit
@user = authorize User.new
end
def update
@user = authorize User.find(params[:id])
@user.update(user_params)
redirect_to user_path(@user)
... |
Rails.application.routes.draw do
root 'static_pages#home'
get '/regulation', to: 'static_pages#regulation'
get '/about_me', to: 'static_pages#about_me'
get '/producer/login', to: 'sessions#new'
post '/producer/login', to: 'sessions#create'
delete '/producer/logout', to: 'sessions#de... |
json.array!(@dtcs) do |dtc|
json.extract! dtc, :id, :code, :description, :meaning, :source
json.url dtc_url(dtc, format: :json)
end
|
class CashRegister
attr_accessor :total, :discount, :items, :last_transaction_amount
def initialize(discount = 0)
@total = 0
@discount = discount
@items = [ ]
end
def add_item(title, price, quantity = 1)
if quantity > 1
#putting in a while-loop counter to keep track of quantity o... |
class CartitemsController < ApplicationController
before_action :find_cartitem, except: [:create]
def add_qty
# find the product
product_inventory = @cart_item.product.inventory
if @cart_item.qty < product_inventory
@cart_item.qty += 1
@cart_item.save
else
# not enough inventory... |
#---
# Excerpted from "Agile Web Development with Rails, 4rd Ed.",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any pur... |
class AddReminderOptionsToResolution < ActiveRecord::Migration[5.1]
def change
add_column :resolutions, :cell, :boolean
add_column :resolutions, :email, :boolean
end
end
|
module VisitorsHelper
def stadium_infowindow(stadium)
result = "#{stadium.name}<br/>#{stadium.phone}<br/>#{stadium.address}<br/>"
if stadium.active?
result += " #{link_to 'Перейти на страницу', Rails.application.routes.url_helpers.stadium_path(stadium)}"
end
return result
end
def stadium_ge... |
FactoryBot.define do
factory :country, class: SomeModule::Country do
name {"Poland"}
code {"PL"}
end
end |
class AddStuffToStudents < ActiveRecord::Migration
def change
add_reference :students, :student_meals, index: true
add_column :students, :priority, :bool
remove_column :students, :approved_by_id
end
end
|
module Doc
module Model::Subject
extend ActiveSupport::Concern
included do
attribute :name, :string
attribute :path_params, :json
attribute :request_params, :json
attribute :request_headers, :json
attribute :request_type, :string
attribute :request_body, :json
attrib... |
# == Schema Information
#
# Table name: boxes
#
# id :integer(4) not null, primary key
# name :string(255)
# bar_code :string(255)
# n_fridge :string(255)
# n_shelf :string(255)
# n_rack :string(255)
# created_a... |
class Admin::StoresController < Admin::BaseController
include ActiveModel::ForbiddenAttributesProtection
load_and_authorize_resource
# GET /admin/stores
#-----------------------------------------------------------------------
def index
@stores = Store.all
respond_with(:admin, @stores)
end
# GET ... |
class Activity < ActiveRecord::Base
attr_accessor :linked_content
belongs_to :project
belongs_to :user
validates :project_id, presence: true
validates :resource, presence: true
# 自動リンク
def linked_content
if self[:resource] == "talk"
content_safe = ERB::Util.html_escape self[:content]
... |
require 'spec_helper'
describe "charities/landing" do
let(:campaign) { mock_model(Campaign, :slug => 'donate') }
let(:charity) { mock_model(Charity, :name => 'Alameda Red Cross', :campaign => campaign) }
before do
assign(:charity, charity)
render
end
it "has a title" do
rendered.should have_sel... |
# == Schema Information
#
# Table name: orders
#
# id :integer not null, primary key
# address :string(255)
# state :string(255)
# city :string(255)
# user_id :integer
# listing_id :integer
# created_at :datetime
# updated_at :datetime
#
class Order < ActiveRecord::Base
belo... |
# app/controllers/organisations_controller.rb
class OrganisationsController < ApplicationController
# skip_before_action :authenticate_user!, only: :show
# before_action :set_organisation # , only: [:show, :edit, :update, :destroy]
# GET /organisations
# GET /organisations.json
# def index
# @organisatio... |
require 'sterilize'
RSpec.describe "Cleaning text" do
it "tidies messy a tag" do
input = '<a onclick="function() { alert("hello")">hijack</a>'
expect(Sterilize.perform(input)).to eq('<a rel="noopener noreferrer">hijack</a>')
end
it "removes script tags" do
input = 'this is some text with a <script>a... |
class FeaturesController < ApplicationController
def index
@features = Feature.includes(:item)
respond_to do |format|
format.json { render json: featured_json }
end
end
def create
Feature.create! feature_params
redirect_to :back
end
private
def featured_json
@features.each_... |
require 'csv'
require 'descriptive_statistics'
class TeacherAssistant
attr_accessor :student_data, :student_average_scores, :student_grades
def initialize(file)
@student_data = {}
@student_average_scores = {}
@student_grades = {}
CSV.foreach(file) do |row|
student = row[0]
scores = row[1..(row.length... |
class AddLatLongToOutlet < ActiveRecord::Migration
def change
add_column :outlets, :lat, :string
add_column :outlets, :long, :string
end
end
|
class CreateGames < ActiveRecord::Migration
def change
create_table :games do |t|
t.datetime :starts_at
t.integer :visiting_team_id
t.integer :home_team_id
t.integer :field_id
t.integer :home_team_score
t.integer :visiting_team_score
t.timestamps
end
end
def sel... |
class Doctor < ActiveRecord::Base
attr_accessible :name, :photo, :address,:street1, :city, :state, :zip, :fee, :speciality, :experience, :phone
has_attached_file :photo, :styles => { :small => "150x150", :large => "300x300" ,:mini => "50x50"}
do_not_validate_attachment_file_type :photo
acts_as_gmappabl... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Email do
describe "validations" do
before(:each) do
@email = Email.new(:address => 'man@google.com')
end
it "should be valid with valid attributes" do
@email.should be_valid
end
it "should be valid with va... |
class User < ActiveRecord::Base
enum role: [:user, :vip, :admin]
after_initialize :set_default_role, :if => :new_record?
has_many :recipes
def set_default_role
self.role ||= :user
end
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
... |
class ActionService
attr_reader :form, :result
def self.call(attrs = {})
new(attrs).call
end
def initialize(attrs = {})
@form = attrs.fetch(:form)
end
protected
def build_result(attrs = {})
@result = Result.new(attrs)
end
end
|
class HolidayMailer < ApplicationMailer
def new_holiday_notifier(holiday_id)
@holiday = Holiday.find(holiday_id)
mail(to: Employee.pluck(:email), subject: @holiday.name)
end
end
|
class AddPreuveToCompanies < ActiveRecord::Migration[5.2]
def change
add_column :companies, :preuve, :string
end
end
|
module Fakes
class RegularArgMatcher
def initialize(value_to_match)
@value_to_match = value_to_match
end
def matches?(item)
@value_to_match == item
end
end
end
|
# -*- coding: utf-8 -*-
=begin
Sua organização acaba de contratar um estagiário para trabalhar no Suporte de
Informática, com a intenção de fazer um levantamento nas sucatas encontradas
nesta área. A primeira tarefa dele é testar todos os cerca de 200 mouses que se
encontram lá, testando e anotando o estado de cada um... |
class ResearchTopicAuthorizer < ApplicationAuthorizer
# def self.creatable_by?(user)
# user.can?(:participate_in_social)
# end
# openpprn divergence
def moderatable_by?(user)
user.has_role? :moderator
end
def self.updatable_by?(user)
user.has_role? :moderator
end
def self.deletable_by?(... |
class User < ActiveRecord::Base
has_many :articles
has_secure_password
validates :username, :email, {presence: true}
end
|
require 'uri'
module SermepaWebTpv
class Request < Struct.new(:transaction, :description)
include SermepaWebTpv::Persistence::ActiveRecord
def bank_url
SermepaWebTpv.bank_url
end
def transact(&block)
generate_transaction_number!
yield(transaction)
transaction
end
de... |
# frozen_string_literal: true
module Vedeu
module Runtime
# Orchestrates the running of the main application loop.
#
# @api private
#
class Application
class << self
# @return [void]
def start
new.start
end
# @return [void]
def restart
... |
FactoryBot.define do
factory :project do
title {'Go Creative'}
description {'Crowdfunding platform'}
amount_required {100000}
min_amount_per_contribution {100}
end_date { 30.days.from_now.end_of_day }
# Association: belongs_to :user
association :user, factory: :user
trait :published ... |
require 'fileutils'
require 'rubygems'
require 'yaml'
def read_version
base = File.dirname(__FILE__)
File.read(File.join(base, 'src', 'uki-core', 'uki.js')).match(%r{uki.version\s*=\s*'([^']+)'})[1]
end
desc "Build scripts"
task :build_scripts do
require 'uki/include_js'
version = read_version
FileUtils.... |
class BlogPosts
attr_accessor :items,
:tags,
:archives
def initialize()
@items = []
@tags = []
@archives = []
end
end |
# frozen_string_literal: true
require 'spec_helper'
describe SFRest::Site_update_priority do
before :each do
@conn = SFRest.new "http://#{@mock_endpoint}", @mock_user, @mock_pass
end
describe '#get_current_site_update_priority' do
path = '/api/v1/site-update-priority'
it 'calls the site update pri... |
require 'benchmark'
require 'pry'
class Day19
attr_accessor :file, :path, :rules, :messages, :trie
STRING = 'string'.freeze
POINTER = 'pointer'.freeze
def initialize(path)
@path = path
@file = File.open(path)
@rules = {}
@messages = []
@trie = {}
while (line = file.readline.strip) != ... |
class Message < ActiveRecord::Base
has_many :sent_messages, :dependent => :destroy
has_many :users, :through => :sent_messages
# Step through each of the users on the model, and send them this message
def send!
self.to_csv.split(/\n/).each do |line|
user = User.find_by_email(line.split(/\t/)[0])
... |
class Parser
def parse_request(request_lines)
request_hash = parse_verb_path_protocol(request_lines)
parse_params(request_hash) if params_exist?(request_hash)
request_hash = parse_remaining_data(request_lines, request_hash)
request_hash
end
def params_exist?(request_hash)
return request_hash[... |
require 'test_helper'
class KidsnamesControllerTest < ActionController::TestCase
setup do
@kidsname = kidsnames(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:kidsnames)
end
test "should get new" do
get :new
assert_response :success
... |
class Group < ApplicationRecord
belongs_to :member
has_many :group_members
has_many :group_memberships, class_name: 'Member', through: :group_members
has_many :album_groups
has_many :albums, through: :album_groups
accepts_nested_attributes_for :group_members
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.