text stringlengths 10 2.61M |
|---|
class CreateActualWorkOrders < ActiveRecord::Migration
def change
create_table :actual_work_orders do |t|
t.string 'work_order_id'
t.string 'project_description'
t.string 'program_office'
t.integer 'project_manager_id'
t.date 'start_date'
t.date 'end_date'
... |
# frozen_string_literal: true
require 'net/http'
require 'uri'
require 'json'
require_relative 'response'
class Config::Authorization::OPA < Config::Authorization
DEFAULTS = {
endpoint: 'http://localhost:8181',
data_api: '/v1/data/ostia/authz',
policy_api: '/v1/policies'
}
class Response < Config:... |
module Mutant
class Matcher
class Method
# Matcher for singleton methods
class Singleton < self
SUBJECT_CLASS = Subject::Method::Singleton
RECEIVER_INDEX = 0
NAME_INDEX = 1
private
# Test for node match
#
# @param [Parser::AST::Node] node
... |
require 'spec_helper'
RSpec.describe 'grouper factory' do
let(:reader) { SmartLogParser::LineByLineReader.new('spec/webserver_spec.log') }
let(:grouper_factory) { SmartLogParser::GrouperFactory.new(reader) }
describe 'creating a grouper' do
it 'throws an error if given grouping option is invalid' do
g... |
require 'net/http'
require 'json'
require "bsale/version"
require 'bsale/entity'
module Bsale
# Basic Bsale client
#
# client = Bsale::Client.new('someaccesstoken')
# products = client.get('products.json')
# products.count # 4
# products.limit # 25
# products.to_h # full hash resource
# products.items ... |
describe Wareki::Utils do
u = Wareki::Utils
it "returns proper era" do
d1 = Date.new(1860, 4, 8)
era = u.find_era(d1)
expect(era.name).to eq "万延"
d2 = Time.new(1860, 4, 7, 12, 1, 2)
era = u.find_era(d2)
expect(era.name).to eq "安政"
end
it "returns nil on missing era" do
e = u.find_... |
require_relative 'test_helper'
describe 'tilt/mapping' do
_Stub = Class.new
_Stub2 = Class.new
before do
@mapping = Tilt::Mapping.new
end
it "registered?" do
@mapping.register(_Stub, 'foo', 'bar')
assert @mapping.registered?('foo')
assert @mapping.registered?('bar')
refute @mapping.regi... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'roda/plugins/portier/version'
Gem::Specification.new do |spec|
spec.name = "roda-portier"
spec.version = Roda::RodaPlugins::Portier::VERSION
spec.authors = ["Malte Paskuda... |
class AddPriceRangeToPartnerProfile < ActiveRecord::Migration[5.0]
def change
add_column :partner_profiles, :min_price, :integer
add_column :partner_profiles, :max_price, :integer
end
end
|
Adhoq.configure do |config|
# if not set, use :on_the_fly.(default)
config.storage = [:local_file, Rails.root + './tmp/adhoq']
config.authorization = ->(controller) { controller.signed_in? }
end |
class Order < ApplicationRecord
belongs_to :product
belongs_to :cart
belongs_to :user
validates_presence_of :product_id
validates_presence_of :quantity
validates_presence_of :total_amount
def populate_fields(current_user, params)
self.fill_total_amount
self.fill_cart_id(params[:cart_id])
sel... |
# frozen_string_literal: true
require 'colorize'
# outputting error messages
class Error
def input_error
puts 'Please enter valid input...'.red
end
def pawn_movement
puts 'This is not a valid move for a pawn. Please try again...'.red
end
def piece
puts "\nYou did not select a valid piece".red
... |
# frozen_string_literal: true
module SyfyfancamDownloader
class CLI
def self.start(args)
raise SyfyfancamDownloader::HELP_MSG if args.nil? || args[0].nil?
SyfyfancamDownloader::Downloader.new(url: args[0])
.download_files
end
end
end
|
And(/^I select the "([^"]*)" task type with the "([^"]*)" template$/) do |task_type, template|
@mainpage.selectRadioButtonOption('Task Type', task_type)
sleep 2
templatename = ''
case task_type
when 'Submit Review' then
templatename = @generalreview.getReviewTemplate template
@mainpage.selectOpt... |
class AddColumnReturnReasonToOrders < ActiveRecord::Migration
def change
add_column :orders, :return_reason, :string
end
end
|
class ContractTemplatesController < ApplicationController
before_action :set_contract_template, only: [:show, :edit, :update, :destroy]
# GET /contract_templates
# GET /contract_templates.json
def index
@contract_templates = ContractTemplate.all
end
# GET /contract_templates/1
# GET /contract_templa... |
class Api::PostsController < ApplicationController
wrap_parameters false
before_action :set_post, only: [:show, :comments, :reblog, :new_comment, :update, :destroy]
# GET api/blogs/:blog_id/posts
def index
@blog = Blog.find(params[:blog_id])
@posts = @blog.posts.page(params[:page])
render 'index'
e... |
class FriendshipsController < ApplicationController
before_filter :authenticate
before_filter :correct_user, :only => :update
def create
#@friend = User.find(friendship_params[:friend_id])
@friendship = current_user.friendships.create(:friend_id => friendship_params[:friend_id], :status => friendshi... |
class ChangeColName < ActiveRecord::Migration
def change
rename_column :addresses, :address1, :address
end
end
|
Given /^I sign in via API as a (.*?) user$/ do |user|
@api_login = Api_login.post('/auth/as/token.oauth2',
query: {username: @users.css("#{user} email #{$session}").text,
password: @users.css("#{user} password").text})
assert @api_login.code == 200, 'Unsuccessful Login'
# following to be used for f... |
module OnTheWay
class Route
attr_reader :shape
def initialize(shape_points)
@shape_points = shape_points
@shape = geojson
end
def geojson
GeoJSONBuilder.build(@shape_points)
end
end
module GeoJSONBuilder
def self.build(points)
{'type' => 'LineString', 'coordinate... |
require 'spec_helper'
module GridCommands
class Sort < TheGrid::Api::Command::Sort; end
end
describe TheGrid::Api::Command do
subject{ TheGrid::Api::Command }
let(:commands_scope) { GridCommands }
it "can be executed on relation" do
subject.find(:paginate).should respond_to(:execute_on)
end
it "buil... |
require 'spec_helper'
describe Stream do
let :user do
Factory(:user)
end
let :feed do
Factory(:feed)
end
let :twitter_account do
Factory(:twitter_account)
end
let :stream do
Factory(:stream, :user_id => user.id, :feed_id => feed.id, :twitter_account_id => twitter_account.id)
end
it... |
Pod::Spec.new do |s|
s.module_name = "POD_NAME"
s.name = "PT+POD_NAME"
s.version = "0.1"
s.summary = "140 Characters Max"
s.homepage = "https://github.com/KenLPham/"
s.license = { :type => "MIT License", :file => "LICENSE.md" }
s.auth... |
class AddPlanetIdToHeros < ActiveRecord::Migration[6.0]
def change
add_column :heros, :planet_id, :integer
end
end
|
module OmniAuth
module PlanningCenterOnline
module Version
MAJOR = 0 unless defined? ::OmniAuth::PlanningCenterOnline::Version::MAJOR
MINOR = 1 unless defined? ::OmniAuth::PlanningCenterOnline::Version::MINOR
PATCH = 0 unless defined? ::OmniAuth::PlanningCenterOnline::Version::PATCH
STRING... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
attr_accessor :password, :password_confirmation, :encrypted_password, :remember_me, :provider, :uid, :oauth_token, :oauth_expires_at
devise :database_authenticatable... |
class Animal
attr_reader :height, :weight
def initialize
puts "New animal"
end
def name # get
@name
end
def name=(new_name) #set
if new_name.is_a?(Numeric)
puts "No numbers"
else
@name = new_name
end
end
end
cat = Animal.new
cat.name = 'Peekaboo'
puts cat.name
bla = An... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get 'apis', to: 'apis#index'
get 'apis/:date', to: 'apis#show'
end
|
class Admins::GenresController < ApplicationController
before_action :authenticate_admin!
before_action :set_admin
def index
@genre = Genre.new
@genres = Genre.all
end
def create
@genre = Genre.new(genre_params)
if @genre.save
redirect_to admins_genres_path, notice: 'ジャンルを追加しました'
... |
class RoomSerializer
include FastJsonapi::ObjectSerializer
attributes :id, :name
attribute :unread do |object, params|
params[:unread_map][object.id] || 0
end
end
|
class User < ApplicationRecord
attr_accessor :image
mount_uploader :image, AvatarUploader
validates :name, presence: true
validates :email, presence: true, uniqueness: { case_sensitive: false }
validates :phone_number, presence: true
validates :password, presence: true, length: { minimum: 5 }
validates... |
class Posting < ActiveRecord::Base
belongs_to :employer
has_many :posting_applications
validates :employer_id, presence: true
validates :compensation, inclusion: { in: %w(Pay Referral) }
def self.posted_by(employer)
where(employer_id: employer)
end
def applied?(student)
PostingApplication.where... |
class Admin::DealsController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_admin
def index
@deals = Deal.all
respond_to do |format|
format.html
format.csv { send_data @deals.to_csv, filename: "deals-#{Date.today}.csv"}
format.xlsx
end
... |
require 'spec_helper'
describe RiskFactor, "#to_s" do
before(:each) do
@risk = mock_model(Risk)
@risk.stub(:to_s).and_return("Hypertension")
end
it "returns risk name alone if severity is nil" do
RiskFactor.new(:risk => @risk, :severity => nil).to_s.should == "Hypertension"
end
it "returns risk n... |
class Pizza < ActiveRecord::Base
belongs_to :order
has_many :orders
validates_presence_of :name, :price
end
|
# encoding: utf-8
ActiveAdmin.register Device do
scope :all, :default => true
scope "В наличии", :avaliable
scope "Установлено клиентам", :unavaliable
filter :device_type_id, :label => "Модели", :as => :select, :collection => DeviceType.find(:all)
filter :name, :label => "Серийному номеру"
menu :la... |
require 'pry'
# Create a class called Atbash. This encapsulates all our code relating to en/coding a string using the Atbash cipher. This is handy because we can create objects that inherit common functionality from this class, we know that all our cipher-related code will be found in this object, and we've namespaced... |
class OodAuthMap
# The current version of {OodAuthMap}
VERSION = "0.0.3"
end
|
require 'spec_helper'
feature "Assigning permissions" do
let!(:admin) { FactoryGirl.create(:admin_user) }
let!(:user) { FactoryGirl.create(:user) }
let!(:activity) { FactoryGirl.create(:activity) }
let!(:folder) { FactoryGirl.create(:folder, activity: activity,
user: user) ... |
#
# Copyright 2012-2015 Chef Software, 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
#
# Unless required by applicable law or agreed ... |
class AppLink
include Datapathy::Model
service_type :kernel
resource_name :ApplicationLinks
persists :slug, :title, :target, :order, :pages, :icon_name
def self.register(attrs = {})
uri = ServiceDescriptor.discover(:kernel, "RegisterApplicationLink")
self.create(attrs.merge(:href => uri))
end
d... |
class AddTripcodeToTrip < ActiveRecord::Migration
def change
add_column :trips, :trip_code, :string
end
end
|
class ReplyController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
def index
@post = Post.find(params[:post_id])
@reply = Reply.new
@post.set_post_meta("views")
end
def create
@post = Post.find(params[:post_id])
@post.replys.build({content: params[:rep... |
Gem::Specification.new do |s|
s.name = "broomhlda"
s.version = "0.3.0"
s.authors = ["Alex Suraci"]
s.email = ["suraci.alex@gmail.com"]
s.homepage = "https://vito.github.io/atomy"
s.summary = "broomhlda syntax highlighter and tokenizer"
s.description = %q{
A DSL for authoring lexers, largely... |
require 'rails_helper'
include ActiveSupport::Testing::TimeHelpers
RSpec.feature 'Checking in/out by employees' do
before do
travel_to Time.zone.parse('2019-09-23')
@employee = create(:employee)
login_as(@employee, scope: :employee)
end
describe 'verifying network' do
context 'accessing from una... |
class RemoveRoleMaskFromAdmin < ActiveRecord::Migration[5.0]
def change
remove_column :admins, :roles_mask, :integer
end
end
|
class Level < ActiveRecord::Base
validates :permission, :numericality => { :greater_than_or_equal_to => 2 }
end
|
require 'test_helper'
class GroupsControllerTest < ActionController::TestCase
# testing the 'index' page features.
#
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:groups)
end
test "index should show only ten groups at a time" do
get :index
grou... |
class AuthenticationController < ApplicationController
before_action :authorize_request, except: :login
# POST /auth/login
def login
@user = User.find_by(username: login_params[:username])
if @user.authenticate(login_params[:password]) #authenticate method provided by Bcrypt and 'has_secure_password'
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def login_physician(physician)
session[:physician_id] = physician.id
end
def login_patient(pateint)
session[:patient_id] = patient.id
end
def login_required
if !logged_in?
redirect_to sign_path
... |
class Hotitem < Kb3
hobo_model # Don't put anything above this
fields do
hotitem :string, :name => true
end
set_table_name :hotitem
set_search_columns nil
belongs_to :doc, :foreign_key => 'id'
set_primary_key :hotitem
def self.import_from_bell
true
end
# --- Permissions --- #
def c... |
# encoding: UTF-8
module CDI
module V1
module Albums
class UpdateService < BaseUpdateService
include V1::ServiceConcerns::AlbumParams
record_type ::Album
def record_params
album_params
end
def after_success
if default_album_setted?
... |
#
# Cookbook Name:: bcpc-hadoop
# Recipe: jolokia
#
# Copyright 2017, Bloomberg Finance L.P.
#
# 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
#
#... |
Object oriented programming is used as a way to organize code into managable chunks of code. It aslo allows the user to think in a different
layer of abstration because we use Verbs and nouns to define the classes.
What is encapsulation?
Encapsulation is a term used for how we allow the code to be unaccessable or acc... |
# Alyssa was asked to write an implementation of a rolling buffer.
# Elements are added to the rolling buffer and if
# the buffer becomes full, then new elements that are
# added will displace the oldest elements in the buffer.
# She wrote two implementations saying, "Take your pick.
# Do you like << or + for modifyin... |
module ParkingSpaceHelper
module_function
attr_accessor :status_json
def refresh_parking_status_data
require 'open-uri'
request_uri = 'http://parker2.api.streetlinenetworks.com/api/testing/availability/f3/la/availability.json?decode=true'
parking_status_json = JSON.load(open(request_uri))
@stat... |
class Player
attr_accessor :x, :y, :speed, :width, :height, :item, :pickup, :moving
def initialize
@x = @y = 0
@frames = Dare::Image.load_tiles('assets/anim_player2.png', width: 32, height: 32)
@walk = Animation.new(0, 5)
@back = Animation.new(6, 11)
@right = Animation.new(12, 14)... |
=begin
Let's do some "ASCII Art" (a stone-age form of nerd artwork from back in the days before computers had video screens).
For this practice problem, write a one-line program that creates the following output 10 times, with the subsequent line indented 1 space to the right:
The Flintstones Rock!
The Flintstones Ro... |
require 'differ'
describe Differ do
describe '#process' do
subject { described_class.new(arr1, arr2).process }
context 'when arrays are the same' do
let(:arr1) { %w(a b c d e f g h) }
let(:arr2) { %w(a b c d e f g h) }
it do
is_expected.to eq([
['a', 'b', 'c', 'd', 'e', ... |
# frozen_string_literal: true
$:.push File.expand_path('lib', __dir__)
require 'solidus_graphql_api/version'
Gem::Specification.new do |s|
s.name = 'solidus_graphql_api'
s.version = SolidusGraphqlApi::VERSION
s.summary = 'Solidus GraphQL API'
s.description = 'GraphQL comes to Solidus'
s.licen... |
class CorrectUtilityRecordEnergyApplicationForeignKey < ActiveRecord::Migration[5.2]
def up
change_column :utility_records, :parent_application_id, :bigint
rename_column :utility_records, :parent_application_id, :energy_application_id
add_foreign_key :utility_records, :energy_applications, column: :energy... |
class StudentsController < ApplicationController
before_action :confirm_logged_in
#-------------------------------------------------
def index
if params[:classroom_id] == nil
@students = Student.all
else
@students = Student.where(classroom_id: params[:classroom_id].to_i)
end
end
#---------------------... |
module Writer
module Adapter
module Facebook
module To
module Schema
class PersonUser
attr_reader :source
def initialize source
@source = source
end
def hash
@attributes = @source.attributes
... |
class Location
include DataMapper::Resource
property :id, Serial
property :name, String
property :drugs_available, CommaSeparatedList
end |
class Api::UsersController < ApplicationController
before_action :authenticate_user!, only: :feed
def show
respond_with User.find params[:id]
end
def relationships_info
user = User.find params[:id]
respond_with following_count: user.followed_users.count,
followers_count: user.foll... |
Given(/^I visit dashboard path$/) do
visit admin_dashboard_path
end
Then(/^the current tab should be "([^"]*)"$/) do |tab|
expect(page).to have_css('li.active', text: tab)
end
Then(/^I should see link to projects page$/) do
expect(page).to have_link('Projects', href: admin_projects_path)
end
|
require 'rails_helper'
RSpec.describe Publisher, type: :model do
subject { FactoryGirl.create :publisher }
# ATTRS
it { should respond_to(:title) }
it { should respond_to(:info) }
# ! ATTRS
# VALIDATIONS
it { should validate_presence_of(:title) }
it { should have_many(:products) }
# ! VALIDATI... |
require 'nokogiri'
class SimpleExtractFromXML < Nokogiri::XML::SAX::Document
attr_accessor :parsing, :input, :output
def self.extract(input,output)
self.new.extract(input,output)
end
def extract(input,output)
@input, @output = input, output
parsing = false
parser = Nokogir... |
class BarsController < ApplicationController
before_filter :authenticate_manager!, :except => [:index, :show]
# GET /bars
# GET /bars.xml
def index
@title = "Campus Taps | Bars"
@regions = Region.all
if params[:region_id]
if params[:region_id] == "all"
@bars = Bar.all
else
... |
class Admin::ChallengesController < Admin::BaseController
before_filter :find_category
def new
@challenge = @category.challenges.new
end
def show
@challenge = @category.challenges.find(params[:id])
end
def create
challenge = Challenge.new(params[:challenge])
if @category.c... |
# encoding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "jotform/version"
Gem::Specification.new do |s|
s.name = "jotform"
s.version = JotForm::VERSION
s.authors = ["Filipe Dobreira"]
s.email = ["dobreira@gmail.com"]
... |
# frozen_string_literal: true
require 'slop'
require 'yaml'
require_relative './cli/signal_handlers'
require_relative './loggable'
require 'rabbitek'
module Rabbitek
##
# Rabbitek server CLI
class CLI
include ::Rabbitek::Loggable
def run
opts
require_application
map_consumer_workers... |
require "pry"
# A method which will return an array of the words in the string
# sorted by the length of the word.
# Time complexity: On^2
# Space complexity: On
#In this method you will take a string as a parameter. The method will return an array of words in the string, sorted by length. Solve the problem without... |
require 'bunny'
require 'json'
# Writes and returns channel using rabbit mq adapter, only one per thread
def set_up_channel
amqp_conn = Bunny.new
amqp_conn.start
channel = amqp_conn.create_channel
end
#take input from exchange and bind to new output queue, given names
def bind_exchange_to_queue(channel, exchang... |
class Agregardescripcionproductos < ActiveRecord::Migration
def change
change_table :productos do |x|
x.string :descripcion
x.date :fecha
end
end
end
|
require "rails/engine"
module Altria
module ProcessingTime
class Railtie < Rails::Engine
initializer "altria.processing_time.set_autoload_paths", before: :set_autoload_paths do |app|
app.config.autoload_paths << File.expand_path("../../../", __FILE__)
app.config.autoload_paths << File.expan... |
# write the jbuilder views for the PostsController actions and verify they are
# working in Chrome
json.set! @post.id do
json.extract! @post, :id, :title, :description
json.posterId @post.user.id
json.userPhoto @userPhoto
json.liked @liked
json.following @following
json.poster @post.user.username
json.c... |
class UserController < ApplicationController
before_action :authenticate_user!
def edit
@user = current_user
end
def update
if params[:user][:name].length <= 2
redirect_to edit_user_path(current_user.id), notice: 'Der Name ist zu kurz'
else
@user = current_user
@user.update_attri... |
class SearchesController < ApplicationController
before_action :authenticate_user!
def new
@search = Search.new
@categories = Category.uniq.pluck(:name)
@authors = Author.uniq.pluck(:lastname)
@conditions = Position.uniq.pluck(:condition)
@position_types = Position.uniq.pluck(:position_type)
@publishings... |
class Type < ApplicationRecord
has_many :work_type_relations,dependent: :destroy, foreign_key: 'type_id'
has_many :works, through: :work_type_relations, dependent: :destroy
end |
class AddWeichatlinkToTrainingArticle < ActiveRecord::Migration[5.1]
def change
add_column :training_articles, :wechatlink, :string
end
end
|
module KnapsackPro
module Runners
module Queue
class BaseRunner
def self.run(args)
raise NotImplementedError
end
def self.run_tests(accumulator)
raise NotImplementedError
end
def initialize(adapter_class)
@allocator_builder = KnapsackPr... |
class Partner < ApplicationRecord
self.table_name = 'partners'
has_secure_password
belongs_to :device, class_name: 'GlobalDevice', required: false
has_one :profile, class_name: 'Partner::Profile'
has_one :rating_report, class_name: 'Partner::RatingReport'
has_many :services, class_name: 'Partner::Service'... |
Gem::Specification.new do |s|
s.name = "rest-client"
s.version = "0.8.1"
s.summary = "Simple REST client for Ruby, inspired by microframework syntax for specifying actions."
s.description = "A simple REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post... |
class TalkQuery
def initialize(relation = Talk.scoped)
@relation = relation
end
def ranking_presentation_events(limit)
@relation.where(:counter_presentation_events.gt => 0)
.order(counter_presentation_events: :desc, slugs: :asc).limit(limit)
end
def search(search)
@relation.with_use... |
class TagService
def initialize(tags)
@input_tags = tags || []
@tag_format_validator = Tag
.validators
.find { |validator| validator.instance_of? ActiveModel::Validations::FormatValidator }
.options[:with]
end
def tags
tag_array = input_tags.select { |tag| tag =~ tag_format_validato... |
# encoding: utf-8
class EventParticipant < ActiveRecord::Base
include ::Notificationer::EventNotificationer::Participant
JOINED_STATUS = 1
CANCLE_STATUS = 0
belongs_to :user
belongs_to :event
has_one :event_owner, :through => :event, :source => :user
attr_accessible :cancle_note,
:email,
:join_... |
require_relative "../spec_helper"
require "omnimutant/string_mutator"
describe Omnimutant::StringMutator do
def mutate_string string
mutator = Omnimutant::StringMutator.new(string)
mutator.get_all_mutations()
end
it "should not replace ||= with &&=" do
string = "value ||= 'default'"
mutations ... |
if platform_family?('rhel')
remote_file "/etc/yum.repos.d/driskell-log-courier2-epel-6.repo" do
source 'https://copr.fedoraproject.org/coprs/driskell/log-courier2/repo/epel-6/driskell-log-courier2-epel-6.repo'
mode '0755'
end
package 'log-courier' do
package_name 'log-courier'
end
template '/etc/log-courier/... |
module UsersHelper
#false in quotations works on heroku but not local server
def user_count_unread(user)
user.notifications.where(read: false).count
end
def user_count_unread_chat_rooms(user)
user.chat_rooms_notifications.count
end
def user_count_unread_posts(user)
user.posts_notifications.co... |
class MovieSerializer < ActiveModel::Serializer
attributes :title, :director, :year, :categories
def categories
object.categories.map { |c| c.name }
end
end
|
require 'Assert'
require 'TestUtil'
class Test
include Assert
include TestUtil
private
def allInstanceMethods
self.class.public_instance_methods(false) +
self.class.private_instance_methods(false)
end
public
def doRun
testForTestDb
allInstanceMethods.eac... |
require File.dirname(__FILE__) + '/../spec_helper'
describe ImagensController do
describe "route generation" do
it "should map { :controller => 'imagens', :action => 'index' } to /imagens" do
route_for(:controller => "imagens", :action => "index").should == "/imagens"
end
it "should map { :cont... |
require "spec_helper"
feature "user resets forgotten password" do
background do
@user = Fabricate(:user, email: "test@test.com", full_name: "Joe Joe")
end
scenario "successfuly" do
visit root_path
click_link "Sign In"
click_on "Forgot Password?"
fill_in :email, with: "test@test.com"
cli... |
class NodeDatabaseInstanceAssignment < ActiveRecord::Base
acts_as_authorizable
acts_as_audited
named_scope :def_scope
acts_as_reportable
belongs_to :node
belongs_to :database_instance
validates_presence_of :node_id, :database_instance_id
validates_uniqueness_of :database_instance_id
def... |
# Userクラス
class User
def initialize(name)
@name = name
end
# インスタンスメソッドの定義
def hello
puts "Hello #{@name}"
end
end
# OrderItemクラス
class OrderItem
end
user = User.new('アリス')
user.hello |
# frozen_string_literal: true
RSpec.describe WkhtmltopdfRunner::Runner do
let(:runner) do
runner = described_class.new
runner.config.debug = true
runner
end
it 'generates pdf from string' do
result = runner.pdf_from_string(
'test',
page_size: 'A4',
disable_smart_shrinking: true... |
class Dish < ActiveRecord::Base
mount_uploader :image, ImageUploader
belongs_to :location
has_many :bookings, through: :cart_items
end
|
class Api::RewardsController < ApplicationController
def index
render json: current_user.rewards
end
def create
daily_rewards_count = current_user.rewards.where(
"created_at >= ? and source != ? and source != ? and source != ? and source != ? and source != ?",
Time.zone.now.beginning_of_day,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.