text stringlengths 10 2.61M |
|---|
Rails.application.routes.draw do
namespace:api , defaults: { format: :json } do
resources :posts do
resources :comments do
resources :replies
end
end
end
end
|
class Person
attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed, :complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :pant_width
def initialize(attributes)
attributes.each {|key, value| self.send(("#{key}="), value)}
end
end
#user_name = Person.new(name: "Al... |
require "logstash/filters/metrics"
describe LogStash::Filters::Metrics do
context "with basic config" do
context "when no events were received" do
it "should not flush" do
config = {"meter" => ["http.%{response}"]}
filter = LogStash::Filters::Metrics.new config
filter.register
... |
class TeamsController < ApplicationController
def show
@team = Team.find(params[:id])
end
def new
@team = Team.new
@walk = Walk.find(params[:walk])
end
def create
@team = Team.new(team_params)
if @team.save
redirect_to walk_path(@team.walk)
else
render :new
end
... |
# frozen_string_literal: true
module Helpers
def authorization_account!(account, payload = { account_id: account.id })
{
'Authorization' => 'JWT ' + JwtStorage.generate_token!(payload, account.id)
}
end
end
|
class AddMultipostingColumnsToAccount < ActiveRecord::Migration
def self.up
add_column :accounts, :multiposting_login, :string
add_column :accounts, :multiposting_password, :string
add_column :accounts, :multiposting_activated, :boolean, :default => false
end
def self.down
remove_column :accounts... |
class CommentsController < ApplicationController
before_action :find_comment, only: [:destroy]
before_action :authenticate_user!, except: [:show, :index]
def create
@post = Post.find params[:post_id]
@comment = Comment.new comment_params
@comment.post = @post
@comment.user = current_user
re... |
class ChefsController < ApplicationController
def index
@chefscount = Chef.all
# @chefs = Chef.order(:name).page params[:page]
if params[:query].present?
sql_query = " \
chefs.description ILIKE :query \
OR chefs.cuisine ILIKE :query \
OR users.first_name ILIKE :query \
... |
Rails.application.routes.draw do
mount ActionCable.server => '/cable'
# root 'conversations#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'home#index'
resources :events do
resources :groups, only: %i(new show create destroy)
resources :reviews, ... |
# load libraries and DSL
require "spec_helper"
# what we're expecting this thing to do
describe "This Is My Homepage", :type => :feature, :js => true do
it "Shows me the home page copy" do
visit '/'
within("h1") do
expect(page).to have_content 'Welcome'
end
end
it "Lets me view the blog archi... |
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter
def foreign_keys(table_name)#:nodoc:
data = select_all(<<-EOF)
select t.constraint_name as name,
k.table_name as from_table,
k.column_name as from_column,
c.table_name as to_table,
... |
# frozen_string_literal: true
describe Account do
let(:account) { described_class.new(statement_class, transaction_class) }
let(:statement_class) { double(:statement_class, new: statement) }
let(:transaction_class) { double(:transaction_class, new: transaction) }
let(:transaction) { double(:transaction) }
le... |
require 'test_helper'
class GenerosFilmesControllerTest < ActionController::TestCase
setup do
@generos_filme = generos_filmes(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:generos_filmes)
end
test "should get new" do
get :new
assert... |
require_relative 'validation_exception'
class Format
attr_reader :field, :pattern
def initialize(field, params)
@field = field
pattern = params.pop
raise 'Не указано регулярное выражение' if pattern.nil?
raise TypeError, 'Параметр должен быть регулярным выражением' unless pattern.is_a? Regexp
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos65"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box"
config.vm.hostname = "puppet.learnpuppet.net"
config.vm.n... |
require 'io/console'
module GTD
class Timer
attr_reader :work_period, :sleep_period, :break_actions, :renderers
def initialize(work_period: 1500, sleep_period: 60, break_actions: [], renderers: [])
@work_period = work_period
@sleep_period = sleep_period
@break_actions = break_actions
... |
class Country < ApplicationRecord
self.table_name = "country"
has_many :city
accepts_nested_attributes_for :city
end
|
class Lexer
attr_reader :tokens, :cur_token
def initialize
@cur_token = ""
@tokens = []
@state = :start
@keywords = [
'stop'
]
end
def add_char(char)
case @state
when :start
if char.to_i.to_s == char
build_token(:integer, char.to_i)
elsif char == ... |
ActiveAdmin.register Material do
menu :parent => "Assets", :if => proc{ can?(:manage, Material) }
controller.authorize_resource
scope :all, :default => true
scope "Reorder", :low_quantity
index do
column :id
column "Material", :sortable => :name do |mat|
link_to mat.name, admin_material_p... |
class Api::Picker::ProfileController < Api::PickerController
before_action :init_service
def show
@user = current_user
render json: @user, serializer: UserDetailSerializer
end
def update
@result = @service.update(params)
if @result.errors.any?
render json: {error: {code: 4000, msg: @resu... |
class AddLoginAndShowToControllerActions < ActiveRecord::Migration
def change
ControllerAction.create(:name => "login", :controller_action_id => 1)
ControllerAction.create(:name => "show", :controller_action_id => 1)
end
end
|
class CommentsController < ApplicationController
def create
@topic = Topic.find(params[:topic_id])
@comment = @topic.comments.build(comment_params)
if @comment.save
flash[:notice] = 'コメントしました'
else
flash[:error] = '名前、本文を入力してください'
end
redirect_to topic_path(@topic)
end
# TODO:... |
ActiveAdmin.register Ban do
permit_params :ip, :reason, :expires_at
end
|
class AddUserIdToPosts < ActiveRecord::Migration[5.2]
def change
add_reference :posts, :user, foreign_key: true, index: true, after: :caption
end
end
|
json.array!(@offers) do |offer|
json.extract! offer, :id, :theater_id, :anme, :description, :discount, :promo_code, :starting_date, :ending_date, :is_deleted
json.url offer_url(offer, format: :json)
end
|
# coding: utf-8
begin
require 'rubygems'
rescue LoadError
end
require 'fileutils'
require 'multi_json'
require 'rest-client'
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'status/base'
require 'status/jenkins'
require 'status/config'
require 'status/request'
require 'status/github/statuses'
r... |
require 'spec_helper'
describe RecurringScheduleRule do
describe 'validations' do
it "validates program presence, but also adds the program_obj_key to the errors" do
rule = build :recurring_schedule_rule, program: nil, program_obj_key: nil
rule.valid?.should eq false
rule.errors.keys.should inc... |
require 'test_helper'
class FormulationsControllerTest < ActionDispatch::IntegrationTest
#
# Create
#
test 'Create entity access' do
sign_in users(:edit_on_agent_weather)
post user_agent_entities_list_entities_url(users(:admin), agents(:weather), entities_lists(:weather_conditions)),
params: {... |
require 'open3'
module SonyCameraRemoteAPI
# Helper module for connecting to camera by wi-fi.
module Scripts
module_function
# Connects to camera by Wi-Fi.
# This method does nothing if already connected, which is judged by ifconfig command.
# @param [String] interface Interface name, e.g. wlan0
... |
class ReputationJob < ApplicationJob
queue_as :default
def perform(*object)
ReputationService.calculate(object)
end
end
|
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.hostmanager.enabled = true
config.hostmanager.ignore_private_ip = true
config.hostmanager.include_offine = false
config.vm.provider "vmware_fusion" do |v, override|
config.ssh.insert_key = false
end
#Using this to avo... |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use postgresql as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'bootstrap-sass'
end
gem '... |
Rails.application.routes.draw do
# get 'trip_reports/index'
# get 'trip_reports/new'
devise_for :users
root to: 'climbs#index'
resources :trip_reports, only: [:index, :new, :create, :show, :edit, :update, :destroy]
resources :climbs, only: [:show, :edit, :update]
resources :favorites, only: [:index, :upd... |
class CreateActions < ActiveRecord::Migration
def up
create_table :actions do |column|
column.integer :player_id
column.string :name
column.timestamps
end
end
def down
drop_table :actions
end
end
|
class PeopleDocument
# Instance variables use snake_case:
# With high coupling (In my opinion is very bad way), but in rails is correct and comum.
# We can use `attr_reader`, `attr_accessor` and `attr_writer` to create auto getter and setter:
attr_accessor :name
attr_accessor :age
def to_presen... |
require 'mustache'
require "./prune/prune_plan"
class EmailFormatter
def format(prune_plan, config)
Mustache.render(
File.read(File.join(File.dirname(__FILE__),"template.html")),
{
elements_retained: prune_plan.elements_retained.map(&method(:file_name)),
elements_deleted: prune_plan.... |
class Console < ApplicationRecord
has_many :console_users
has_many :users, -> { distinct }, through: :console_users
validates :name, uniqueness: true
def self.most_popular
# This code only allows one console object to be shown, but multiple consoles can have the most number of users
# ... |
require "rubygems"
require "rake"
source_dir = "jekyll_site"
desc "Start Sass so that is compiles to css upon file save"
task :sass do
system "sass --watch #{source_dir}/assets/sass:#{source_dir}/assets/css"
end # task :sass
desc "Start Sass so that is compiles to css upon file save"
task :minify do
system "sass... |
Rails.application.routes.draw do
devise_for :users, controllers: {
registrations: "users/registrations"
}
root to: 'dogs#index'
resources :dogs do
resources :inquiry_records
end
resources :users
end
|
class CreateData < ActiveRecord::Migration[5.0]
def change
create_table :data do |t|
t.references :user, foreign_key: true
t.string :excercise
t.decimal :sets
t.decimal :reps
t.decimal :weight
t.string :srw
t.string :decimal
t.timestamps
end
end
end
|
require "./item"
module Factory
module Tray
include item
def tray(caption:)
super(caption)
end
def add(item:)
tray.add(item)
end
end
end
|
require 'pg'
require 'net/ssh'
require_relative 'ssh_datasource'
require_relative 'pg_datasource'
require_relative 'mysql_datasource'
require_relative 'rs_datasource'
require_relative 'load_postgres_to_aws'
class OfferDailyJob
CONTENT_TABLENAME = 'offer'
CONTENT_TABLEKEY = 'offerid'
CONTENT_SOURCE_SYS = 'postgr... |
class Api::V1::Invoices::InvoiceItemsController < ApplicationController
def index
invoice_items = InvoiceItem.find_all(item_params)
render json: invoice_items
end
private
def item_params
params.permit(:invoice_id)
end
end
|
require "erb"
require "yaml"
require "yaml_ext/version"
module YamlExt
class << self
def load(path)
parse_nodes(:ref_inner_node, load_with_extended_nodes(path), path)
end
def load_with_extended_nodes(path)
parse_nodes(:ref_extended_node, load_with_erb(path), path)
end
def load_with_... |
# frozen_string_literal: true
module MFCCase
# Модуль, предоставляющий функцию `reject` для выставления состояния «Возврат
# результата в ведомство» заявкам
module Rejector
# Выставляет состояние «Возврат результата в ведомство» тем заявкам, чей
# результат должен быть выдан, но срок выдачи истёк
def... |
class ArticlesController < ApplicationController
#before_action :validate_user, except: [:show,:index]
before_action :authenticate_user!, only: [:show,:new]
before_action :set_article , except: [:index,:new,:create]
#GET /articles
def index
#@articles variable gloval
@articles= Article.all
e... |
class Admin::EventsController < Admin::ApplicationController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :set_event, only: [:show, :edit, :update, :assign_additional_user, :destroy]
before_filter :check_authorization
before_filter :check_client_eligible_to_mo... |
class ShareController < ApplicationController
before_action :find_post
def create
flash[:success] = "shared!"
puts share_params[:email]
p share_params[:email]
UserMailer.share(@post, share_params[:email]).deliver
redirect_to @post
end
def new
flash[:share] = "enter email to share with... |
class ChartsDeviationController < ChartsController
unloadable
protected
def get_data(conditions, grouping, range)
conditions = ["issues.project_id in (?) and issues.estimated_hours > 0", conditions[:project_id]]
joins = "left join time_entries on issues.id = time_entries.issue_id"
group = "issu... |
require_relative '../board'
require_relative 'null_piece'
module Stepable
def moves
moves = []
possible_steps.each do |offset_r, offset_c|
move = check_step(offset_r, offset_c)
moves << move if move
end
moves
end
def possible_steps
end
def check_step(offset_r, offset_c)
r... |
class ClassEnrollmentsController < ApplicationController
before_action :require_family
before_action :set_class_enrollment, only: [:show, :edit, :update, :destroy]
def index
# TODO only display a subset
# @class_enrollments = ClassEnrollment.all
end
def show
end
def new
@class_enrollment =... |
class Api::V2::ScreeningLists::ConsolidatedController < Api::V2Controller
search_by :countries, :q, :type, :sources, :name, :distance, :address,
:end_date, :start_date, :expiration_date, :issue_date, :fuzzy_name
private
def sv_filename
"CSL_#{Time.now.strftime('%Y_%m_%d')}"
end
end
|
class AddFlowToApprovalGroups < ActiveRecord::Migration
class ApprovalGroup < ActiveRecord::Base
end
def change
add_column :approval_groups, :flow, :string
reversible do |dir|
dir.up do
ApprovalGroup.update_all(flow: 'parallel')
end
end
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
around_filter :pry_rescue if Rails.env == 'development'
def pry_rescue
Pry::rescue{ yield }
end
private
def octokey_username
Octokey.login(params[:auth_request], :client_ip => client_ip, :valid_hostnames => valid_hostnames... |
json.array!(@filmes) do |filme|
json.extract! filme, :id, :titulo, :ano, :sinopse, :duracao
json.url filme_url(filme, format: :json)
end
|
require 'open-uri'
require 'net/http'
class HomeController < ApplicationController
def index
if current_user
@catalogs = current_user.catalogs.as_json(:include => 'links').to_json
end
end
def search
if params["q"].nil?
redirect_to "https://www.google.com/", status: 301
else
red... |
# frozen_string_literal: true
module Api
module V1
# Playlists controller
class PlaylistsController < AuthenticatedController
def index
result = Playlists::ShowPlaylistsService.call(current_user)
render json: {
data: ActiveModelSerializers::SerializableResource.new(result.pla... |
require 'yaml'
module Tem::SeClosures
module MixedMethods
def assemble(&block)
return Tem::Assembler.assemble(&block)
end
end
include MixedMethods
def self.included(klass)
klass.extend MixedMethods
end
def sec_trace
#begin
trace = @transport.iso_apdu!... |
class User < ApplicationRecord
has_many :permissions, dependent: :destroy
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
def permit?(role)
permissions.any? { |permission| permission.name.to_s == role }
end
end
|
class AddApplicationIdToInput < ActiveRecord::Migration
def change
add_column :inputs, :application_id, :integer
end
end
|
class Subject < ApplicationRecord
has_many :homeworks
before_save { self.name = name.titleize }
end
|
json.comments do
@comments.each do |comment|
json.set! comment.id do
json.partial! 'api/comments/comment', comment: comment
end
end
end
json.users do
@users.each do |user|
json.set! user.id do
json.extract! user, :id, :username, :name, :profile_url, :photos, :profile_picture
json.fo... |
class Article < ApplicationRecord
has_and_belongs_to_many :books
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
has_many :comments, as: :commentable
has_attached_file :photo_article
validates_attachment_content_type :photo_article, :content_type => ["image/jpg", "image/jpeg", ... |
require 'rails_helper'
RSpec.describe Api::Partners::WorkingTimesController, type: :controller do
before do
partner_data = {
id: 1,
email: 'zofy@espass.vn',
password: 'password'
}
@partner = Partner.new(partner_data)
@partner.refresh_token({})
@partner.save!
partner_profile_... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'S3.put_object' do
before(:all) do
@s3 = Fog::AWS::S3.gen
@s3.put_bucket('fogputobject')
end
after(:all) do
@s3.delete_object('fogputobject', 'fog_put_object')
@s3.delete_bucket('fogputobject')
end
it 'should return proper attr... |
class AddCityToEvent < ActiveRecord::Migration
def change
add_column :events, :city, :text
end
end
|
module Fog
module Parsers
module Vcloud
def self.de_camel(str)
str.gsub(/(.)([A-Z])/,'\1_\2').downcase
end
class Base < Fog::Parsers::Base
private
def generate_link(attributes)
link = Struct::VcloudLink.new
until attributes.empty?
link[... |
Pokerlogger::Application.routes.draw do
root to: 'sessions#index'
get 'sessions' => 'sessions#index'
#Create empty session to fill in
get 'sessions/new' => 'sessions#new'
# Show a single session according to it's ID
get 'sessions/:id' => 'sessions#show'
get 'sessions/:id/edit' => 'sessions#edit'
... |
# frozen_string_literal: true
class PaymentAmountCalculator < MortgageCalculator
attr_accessor :asking_price, :down_payment
validates :asking_price,
presence: true,
numericality: { integer_only: true,
greater_than: VALUE_MIN,
less_tha... |
class ShelfSerializer < ActiveModel::Serializer
attributes :id, :name, :sections, :food_items
end |
class Cat
attr_accessor :name
attr_accessor :fav_food
attr_accessor :meal_time
def initialize(name, fav_food, meal_time)
@name = name
@fav_food = fav_food
@meal_time = meal_time.to_i
end
def eats_at
if self.meal_time > 12
print "#{self.name} eats at #{self.meal_time.to_i - 12}pm"
... |
class AddPositionToComponents < ActiveRecord::Migration
def change
add_column :tr8n_components, :position, :integer
end
end
|
require 'pg'
feature 'Viewing peeps in reverse chronological order' do
scenario 'user sees most recent peep at the top of the page' do
Peep.create(peep: 'This is my first peep')
Peep.create(peep: 'This is my second peep')
Peep.create(peep: 'This is my third peep')
visit('/chitter')
expect(page... |
# == Schema Information
#
# Table name: tweets
#
# id :integer not null, primary key
# text :string(255)
# twitter_id :string(255)
# created_at :datetime
# updated_at :datetime
# user_id :integer
# retweeted_id ... |
class Api::V1::LcResultsController < ApplicationController
before_action :require_have_comp_class, except: [:search]
def search
query_name = params[:name].blank? ? nil : '%'+params[:name].strip+'%'
query_club = params[:club].blank? ? nil : '%'+params[:club].strip+'%'
if query_name.nil? && query_club.nil?
re... |
require_relative 'test_helper'
module BicFinder
describe GermanBank do
it 'knows where its remote source lives' do
source_uri = URI.parse('https://www.bundesbank.de/resource/blob/602632/a44cbafa539a539be6222ffa06d33996/mL/blz-2018-09-03-txt-data.txt')
assert_equal(GermanBank::REMOTE_SOURCE_URI, sourc... |
# frozen_string_literal: true
module Sandbox
module Repositories
class Messages
class Message
def initialize(id:, body:)
@id = id
@body = body
end
attr_reader :id, :body
end
STORE = {
1 => "Subscribe to the channel, it really matters :>)",
... |
# coding: utf-8
# 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.crea... |
class User < ActiveRecord::Base
attr_accessible :name, :sex, :date_of_birth,
:hometown, :lives_in,
:status, :last_seen_at,
:avatar, :remote_avatar_url, :crop_x, :crop_y, :crop_h, :crop_w
belongs_to :account
mount_uploader :avata... |
require "jekyll/utils"
#require "pp" #prettyprint
def product_sort(a, b)
ra = a.data["rank"]
rb = b.data["rank"]
if ra && rb
return ra <=> rb
elsif ra
return 1 #b follows a
elsif rb
return -1 #a follows b
else
return 0
end
end
def product_filter(a)
return a.data && a.data.key?("title"... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "NoUseFreak/clastic-dev"
config.vm.network "forwarded_port", guest: 80, host: 8080, aut... |
class Individuo
attr_reader :nombre, :edad, :sexo
include Comparable
def initialize(nombre, edad, sexo)
@nombre = nombre
@edad = edad
@sexo = sexo
end
def obtener_nombre
@nombre
end
def obtener_edad
@edad
end
def to_s
... |
# frozen_string_literal: true
module AsciiPngfy
module Settings
# Reponsibilities
# - Keeps track of the font_height setting
# - Validates font_height
class FontHeightSetting
include SetableGetable
def initialize(initial_font_height)
self.font_height = GLYPH_DESIGN_HEIGHT
... |
module DynamodbOrm
module Connection
def setup(options)
@options = options
end
def default_options
{
region: 'eu-west-1',
endpoint: ENV['DYNAMODB_ENDPOINT'].presence
}.reject { |_, v| !v }
end
def connect
options = @options || {}
opts = default_opti... |
class KMeansClustering::DataPoint
def initialize(dimensions_hash)
@dimensions = dimensions_hash
end
attr_reader :dimensions
def distance_to(other_datapoint)
hash1 = dimensions
hash2 = other_datapoint.dimensions
dimensions = (hash1.keys + hash2.keys).uniq
Math.sqrt(dimensions.map do |dimen... |
class BooksController < ApplicationController
before_action :authenticate_user!, only: [:new, :create]
before_action :set_wooden_background, only: [:index, :search, :show]
before_action :set_small_book_block, only: [:index, :search]
before_action :set_big_book_block, only: [:show, :show_goodreads]
def i... |
module <%= former_class_name %>
extend ActiveSupport::Concern
included do
former "<%= class_name %>" do
field :id, ->(instance) {instance.id.to_s}
<% attributes.reject{|attr| attr.reference?}.each do |attribute| -%>
field :<%= attribute.name %>
<% end -%>
#logic :method, ->(instance) {
... |
class CreateTransactionLineItems < ActiveRecord::Migration
def change
create_table :transaction_line_items do |t|
t.references :roster_transaction, index: true, foreign_key: true
t.references :fantasy_team, index: true, foreign_key: true
t.references :fantasy_player, index: true, foreign_key: tr... |
class Student
attr_accessor :name, :cohort, :language
def initialize(input_name, input_cohort, input_language)
@name = input_name
@cohort = input_cohort
@language = input_language
end
def name
return @name
end
def cohort
return @cohort
end
def new_student(name)
return name
... |
#
# Be sure to run `pod spec lint YfPlayerDemo-iOS.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://g... |
# frozen_string_literal: true
namespace 'graticules' do
desc 'Build graticle geojson files for map'
task :build, [:step] => :environment do |_t, args|
step = args[:step].to_f
# abort "Bad step #{step}, divide evenly into 180" if (180.0.modulo(step)) > 0
lines = []
(-180..180).step(step) do |long|... |
require 'test_helper'
class CoffeeBeansControllerTest < ActionController::TestCase
setup do
@coffee_bean = coffee_beans(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:coffee_beans)
end
test "should get new" do
get :new
assert_respons... |
#Product Class Spec
require 'spec_helper'
describe 'Testing Product Class' do
it 'testing that self.all method for Product Class returns an array equal to the length of the csv file' do
filename = "./support/products.csv"
line_count = %x{sed -n '=' #{filename} | wc -l}.to_i
expect ((FarMar::Product.all... |
class FixedSchedule < Schedule
validates_presence_of :timescale
def sort_messages
messages.sort_by!(&:offset)
end
def expected_delivery_time message, subscriber
subscriber.reference_time + message.offset.send(self.timescale.to_sym)
end
def reminders
self.messages.all
end
def enqu... |
class PostsController < ApplicationController
before_filter :get_logged_in_user, :only => [:new, :create]
def new
@post = Post.new
end
def create
post_params = params.require(:post).permit(:content)
@post = Post.new post_params
@post.posted = Time.now
@post.user = @user1
if @post.save
... |
class AddDeleteImageToPlacetextblocks < ActiveRecord::Migration
def change
add_column :placetextblocks, :delete_image, :boolean, default: false
end
end
|
require 'rails_helper'
require 'fm_calculator/calculator'
RSpec.describe FMCalculator::Calculator do
let(:rates) { CCS::FM::Rate.read_benchmark_rates }
let(:calc) do
# args Service ref, uom_vol, occupants, tuoe involved, london_location, CAFM, helpdesk
described_class.new(3, 'G1', 'A', 23000, 125, true, ... |
require 'spec_helper'
describe QML::JSFunction do
let(:function) do
QML.engine.evaluate <<-JS
(function(a, b) {
return a + b;
});
JS
end
let(:constructor) do
QML.engine.evaluate <<-JS
(function(a, b) {
this.value = a + b;
});
JS
end
describe '#call' ... |
class ArtsController < ApplicationController
# renders all the art on the page
before_action :authenticate_user!
def index
@addToRoom = ArtsRoom.new
@arts = Art.where(user_id: current_user.id)
end
def create
# create a new piece of art
@art = Art.new(art_params)
@art.user = current_user
... |
source 'https://rubygems.org'
gem 'rails', '4.1.4'
gem 'thin'
# Project dependencies
gem 'coderay' # coderay to assist in text styling
gem 'dotenv-rails' # dotenv to make setting env variables easy
gem 'gollum' # gollum to assi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.