text stringlengths 10 2.61M |
|---|
class Api::V1::EventsController < Api::V1::ApiController
version 1
before_action :doorkeeper_authorize!
def index
events = Event.all
expose events, each_serializer: EventSerializer
end
end |
class TeamsController < ApplicationController
def index
@teams = Team.all
@team = Team.new
@users = User.all
end
def create
@team = Team.new(params[:team])
if @team.save
redirect_to teams_path, notice: "Team created!"
else
render 'index'
end
end
def repopulate
@t... |
# encoding: utf-8
require 'spec_helper'
describe "Initializing a processor's failure chain" do
subject { chain.call(request) }
let(:env) {
Environment.build {
register :evaluate, Processor::Evaluator
register :wrap, Processor::Wrapper
}
}
let(:chain) {
env.chain {
evaluate(... |
class Test < Thor
desc "example FILE", "an example task that does something with a file"
def example()
puts "You supplied the file"
end
end |
module Collisions
INV_MAGIC_1 = 0xa81e14edd9de2c7f
INV_MAGIC_2 = 0xa98409e882ce4d7d
MASK64 = 0xffffffffffffffff
DIFF = "\x00\x00\x00\x00\x10\x00\x00\x00" \
"\x00\x00\x00\x00\x01\x00\x00\x00" \
"\x00\x00\x00\x00\x00\x00\x00\x80" \
"\x00\x00\x00\x00\x00\x00\x00\x00"
module_functio... |
ActiveAdmin.register RentalOrder do
permit_params :num
belongs_to :group, optional: true
index do
selectable_column
id_column
column :group
column :rental_item
column :num
actions
end
form do |f|
panel '編集上の注意' do
"数量のみ変更可能です. グループと物品は変更できません. "
end
f.inputs do
... |
module HashDiffDecorator
def self.html_for(change)
case change[:type]
when "+"
HashDiffDecorator::Added.new(change).to_html
when "~"
HashDiffDecorator::Modified.new(change).to_html
when "-"
HashDiffDecorator::Removed.new(change).to_html
else
change.inspect
end
end
end... |
# frozen_string_literal: true
module Api::V1::Users
class CreateAction < ::Api::V1::BaseAction
include ::TransactionContext[:request]
try :deserialize, with: 'params.deserialize', catch: JSONAPI::Parser::InvalidDocument
step :validate, with: 'params.validate'
try :create, catch: Sequel::Error
te... |
class ChangeArticleColumn < ActiveRecord::Migration
def change
rename_column :comments, :atricle_id, :article_id
end
end
|
class Trimgalore < Formula
homepage "http://www.bioinformatics.babraham.ac.uk/projects/trim_galore/"
# tag "bioinformatics"
url "http://www.bioinformatics.babraham.ac.uk/projects/trim_galore/trim_galore_v0.3.7.zip"
sha256 "f8adfab475452b9c1e9d0e94ffc7bfa2cd2ae6f6e0e7c0cf5c354d9a8fe66680"
def install
ch... |
class DropGenresUsers < ActiveRecord::Migration[6.0]
def change
drop_table :genres_users do |t|
t.integer :user_id, null: false
t.integer :genre_id, null: false
end
end
end
|
#Ruby Challenge file by Ian Mason
#April 14, 2015
require 'json'
class String
def palindrome?
letters = self.downcase.scan(/\w/)
letters == letters.reverse
end
end
tempHash = {
"characters" => "val_a",
"special_characters" => "val_b",
"sum" => "val_c",
"palindromes" => "val_d"
}
text=Fi... |
class Admin::UserObserver < ActiveRecord::Observer
def after_create(user)
Admin::UserMailer.deliver_create_notification(user)
end
def after_save(user)
Admin::UserMailer.deliver_reset_password_notification(user) if user.recently_reset_password?
end
end
|
class CreateOrder < ActiveRecord::Migration[5.0]
def change
create_table :orders do |t|
t.integer :number_order
t.integer :ra
t.float :valor
t.text :descricao
t.decimal :subtotal, precision: 12, scale: 3
t.decimal :total, precision: 12, scale: 3
t.timestamps
end
... |
class ChangeMjwebDetails < ActiveRecord::Migration
def change
add_column :mjweb_details, :instagram, :string
end
end |
require 'rails_helper'
RSpec.describe PurchaseShipping, type: :model do
describe '購入情報の保存' do
before do
user = FactoryBot.create(:user)
item = FactoryBot.create(:item, user_id: user.id)
@purchase_shipping = FactoryBot.build(:purchase_shipping, user_id: user, item_id: item)
sleep 0.04
e... |
# Memory where InnoDB caches table and index data (in MB). Default is 128M.
default['bcpc']['mysql']['innodb_buffer_pool_size'] =
([(node[:memory][:total].to_i / 1024 * 0.02).floor, 128].max)
# Maximum connections per MySQL host. The MySQL default is 151.
default['bcpc']['mysql']['max_connections'] = 500
# This att... |
class AddFfgToPilot < ActiveRecord::Migration[5.1]
def change
add_column :pilots, :ffg, :integer
end
end
|
class Review < ApplicationRecord
belongs_to :club
validates :rating, numericality: {greater_than: 0, less_than_or_equal_to: 5}
validates :rating, :date, :club, :content, presence: true
end
|
require 'rails_helper'
RSpec.describe Person, type: :model do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:email) }
it "validates uniqueness of email" do
create(:person)
should validate_uniqueness_of(:email).scoped_to(:account_id)
end
it { should validate_presence_of(:h... |
require "byebug"
# EASY
# Define a method that, given a sentence, returns a hash of each of the words as
# keys with their lengths as values. Assume the argument lacks punctuation.
def word_lengths(str)
hash = Hash.new(0)
str.split.each { |word| hash[word] = word.length }
return hash
end
# Define a method that,... |
class ChangeNotNullTitleOfProposals < ActiveRecord::Migration[5.0]
def change
change_column_null :proposals, :title, false
end
end
|
module Exports
class ExportRequestService
def initialize(requests)
@requests = requests
@headers = %w[Date Requestor Status]
end
def call
[].tap do |csv_data|
csv_data << headers
rows.each do |request_row|
csv_data << headers.map { |header| request_row[header]... |
Pod::Spec.new do |s|
s.name = 'DataStructures'
s.version = '0.1.0'
s.license = 'MIT'
s.summary = 'Data Structures in Swift.'
s.homepage = 'https://github.com/rtodddev/DataStructures'
s.authors = { 'Ryan Todd' => 'r.todd.dev@gmail.com' }
s.source = { :git => 'https://github.com/rtodddev/DataStructures.git'... |
class EpicsController < ApplicationController
respond_to :json
def index
epics = Epic.all
json = epics.to_json
render json: json
end
end |
# Rubocop File
# For this lesson, and the rest of this course, you can use the following Rubocop configuration. Remember to save it as a hidden file called .rubocop.yml in the current, or a parent directory, and make sure you are using Rubocop version 0.46.0. For a refresher on how to check or change your current Ruboc... |
class User < ActiveRecord::Base
has_many :tweets
validates :email, format: {with: /@/}, uniqueness: true
validates :password_digest, presence: true
validates :password, length: { minimum: 6, too_short: "Please make your password at least 6 characters long" },confirmation: true
def self.sign_up(user_hash)
... |
class Fahrenheit < Temperature
def initialize(val, from_unit, to_unit)
super(val)
@from_type = from_unit
@to_type = to_unit
@return_type = to_unit
end
def convert
if @to_type == 'FAHRENHEIT'
new_temp = @temp
elsif @to_type == 'CELSIUS'
new_temp = (@temp - 32)*(5/9.0)
elsif @to_type == 'KELVIN... |
class ApplicationController < ActionController::Base
before_action :require_login
protected
def not_authenticated
redirect_to login_path, alert: "ログインしてください"
end
protect_from_forgery with: :exception
add_flash_types :success, :info, :warning, :danger
end
|
module CopyPeste
module Require
module Graphics
include Mixin
module_function
# Get namespace path
# Implementing it overrides the behavior of [Mixin]
#
# @return [String] graphic namespace path
def namespace_path
Path.graphics
end
end
end
end
|
# 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.provision "ansible" do |ansible|
ansible.playbook = "ansible/provision.yml"
end
config.vm.box = "puphpet/debian75-x64"
config.vm... |
class Dive < ApplicationRecord
has_many :user_dives
has_many :users, through: :user_dives
attr_accessor :i_have_been_responsible
validates :i_have_been_responsible,
acceptance: true,
presence: true,
on: :create
def finish
self.update(finished_at: Time.now)
end
def finished?
finishe... |
class Language < ApplicationRecord
has_many :users_languages
has_many :users, through: :users_languages
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :roster_archive_file, class: 'Roster::ArchiveFile'
end
|
class ProfileController < ApplicationController
before_action :authenticate_user!
def edit
end
def show
@user = User.find(params[:id])
@profile = @user.profile
@post = @user.posts
end
def update
if params[:user][:password].blank?
params[:user].delete(:password)
params[:user]... |
module Roglew
module GLX
FRONT_LEFT_BUFFER_BIT_SGIX ||= 0x00000001
FRONT_RIGHT_BUFFER_BIT_SGIX ||= 0x00000002
PBUFFER_BIT_SGIX ||= 0x00000004
BACK_LEFT_BUFFER_BIT_SGIX ||= 0x00000004
BACK_RIGHT_BUFFER_BIT_SGIX ||= 0x00000008
AUX_BUFFERS_BIT_SGIX ||= 0x00000010
... |
class ApplicantSidebarCell < Cell::Rails
def display(args)
user = args[:user]
@applications = user.job_applications
render
end
end
|
class TicketsController < ApplicationController
before_action :set_ticket, only: [:show, :edit, :update, :destroy]
# GET /tickets
# GET /tickets.json
def index
@tickets = Ticket.all.paginate(:page => params[:page], :per_page => 15)
end
# GET /tickets/1
# GET /tickets/1.json
def show
end
# G... |
require 'gcoder'
module VWorkApp
class Job < Resource
hattr_accessor :id, :customer_name, :template_name, :planned_duration, {:steps => Array(VWorkApp::Step)}, :published_at,
{:custom_fields => Array(VWorkApp::CustomField)}, :third_party_id, :worker_id, :planned_start_at, :customer_id, :confir... |
class ChangeDateInOrders < ActiveRecord::Migration
def up
change_column :orders, :date, :date
end
end
|
Then /^monogramming cell is displayed$/ do
@wait.until {@scarfbar_pdp.monogrammingCell_element.exists?}
$general.scroll(@scarfbar_pdp.monogrammingCell_element)
assert @scarfbar_pdp.monogrammingCell_element.visible?, 'Monogramming cell is not visible'
end
Then /^storytelling cell is displayed$/ do
@wait.until {... |
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "sinatra-mongomapper"
gem.summary = "A MongoMapper extension for Sinatra."
gem.description = "You got your Ruby Mongo ODM mixed with my web framework!!!"
gem.email = "jcbledsoe@gmail.com"
gem.homepage = "http://gi... |
require './spec/helper'
require 'yaml'
describe "Configuration legacy" do
before do
@v = $VERBOSE; $VERBOSE = nil
end
after do
FileUtils.rm '.coco', force: true
FileUtils.rm '.coco.yml', force: true
$VERBOSE = @v
end
# TODO Remove the support of .coco file in version 1.0.
#
describe 'O... |
class CreateGamedata < ActiveRecord::Migration
def change
create_table :gamedata do |t|
t.integer :game_id
t.integer :user_id
t.string :r1answer
t.string :r2answer
t.string :r3answer
t.string :r4answer
t.integer :gamepoints
t.boolean :r1voted
t.boolean :r2vote... |
FactoryBot.define do
factory :restriction_group do
pricing_rule_id do
PricingRule.find_or_create_by(
attributes_for(:pricing_rule, :line_items)
).id
end
end
end
|
class CreateJobs < ActiveRecord::Migration
def change
create_table :jobs do |t|
t.string :board_name
t.string :post_name
t.string :qualification
t.string :last_date
t.string :more
t.string :type
t.timestamps
end
end
end
|
require "spec_helper"
describe Schedule, "validations", :type => :model do
context "when valid data" do
let!(:user) { create(:user, :paul) }
let!(:event) { create(:event, :tasafoconf, :users => [ user ], :owner => user.id) }
let!(:schedule) { create(:schedule, :abertura, :event => event) }
it "accep... |
require "test_helper"
class TestMapnikRasterColorizer < Test::Unit::TestCase
def setup
@colorizer = Mapnik::RasterColorizer.new
end
def test_presence
assert Mapnik::RasterColorizer
["INHERIT","LINEAR","DISCRETE","EXACT"].each do |colorizer_mode|
assert Mapnik::ColorizerMode.const_get(co... |
# build a program that asks user for the length and width
# of a room in meters
# and then displays the area of the room
# in both sq meters and sq feet
# 1 sq meter == 10.7639 sq ft
# Example run:
# Enter the length of the room in meters:
# 10
# Enter the width of the room in meters:
# 7
# The area of the room is 7... |
class CSVWriter
attr_reader :user
TIME_FORMAT = "%l:%M%p"
DATE_FORMAT = "%m/%d/%Y"
def initialize(user_id)
@user = User.find(user_id)
end
def generate_csv
CSV.generate do |csv|
csv << ["TIME","DATE","TEMP INSIDE","HUMIDITY INSIDE (%)", "TEMP OUTSIDE","TEMP OF HOT WATER","NOTES"]
self... |
#!/usr/bin/env ruby
# :title: PlanR::Content::DictNode
=begin rdoc
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'plan-r/content_repo/content_node'
require 'plan-r/datatype/dict'
module PlanR
module ContentRepo
class DictNode < ContentNode
KEY = :dict
PATHNAME = '.CONTENT... |
# == Schema Information
#
# Table name: favicons
#
# id :integer not null, primary key
# feed_id :integer default(0), not null
# image :binary
#
class Favicon < ActiveRecord::Base
belongs_to :feed
end
|
require "./lib/interface/source.rb"
require "./lib/pubsub/message.rb"
module Hoze
class TestSource < Source
def initialize configuration
@queue = []
end
def enqueue_message payload, metadata
msg = Hoze::TestMessage.new(payload,Date.now,metadata)
@queue << msg
msg
end
d... |
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'development'
require File.expand_path("#{__dir__}/dummy/config/environment", __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.en... |
module FastUsers
def current_user
if @current_user
@current_user
else
if user = warden.authenticate(scope: :user)
@current_user = user.as_json.deep_symbolize_keys
@current_user.except!(:authentication_token, :provider, :latest_location_id, :data)
@current_user[:image] = {}
... |
Rails.application.routes.draw do
get 'oauth2/redirect', to: 'oauth2#redirect', as: 'redirect'
get 'oauth2/callback', to: 'oauth2#callback', as: 'callback'
resources :subscriptions
resources :notifications
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrail... |
json.array!(@comentario_autenticados) do |comentario_autenticado|
json.extract! comentario_autenticado, :id, :comentario_id, :usuario_id
json.url comentario_autenticado_url(comentario_autenticado, format: :json)
end
|
module Paperclip
class ForceActualFormatProcessor < Processor
def make
if actual_file_format.present? && current_file_extension.present? && actual_file_format != current_file_extension
convert("\"#{current_file_name}\" \"#{destination_path}\"", source: current_file_name, dest: destination_path)
... |
class Node
attr_accessor :data
attr_accessor :left # 왼쪽 자식노드
attr_accessor :right # 오른쪽 자식노드
def initialize (data)
@data = data
@left = nil
@right = nil
end
def to_s
puts "Node: #{@data} left: #{@left.data} right: #{@right.data}"
end
end
class BinaryTree
def initialize(data = nil)
... |
class TicketType < ApplicationRecord
belongs_to :event
belongs_to :ticket_zone
validates :price, numericality: {:greater_than => 0, only_integer: true, message: "must be positive integer"}
end
|
class Message < ActiveRecord::Base
belongs_to :sender, class_name: 'User'
belongs_to :recipient, class_name: 'User'
def read?
end
def self.search_sent(query)
# where(:title, query) -> This would return an exact match of the query
new_query = query.to_i
where("s... |
class AddEmployeeToBooking < ActiveRecord::Migration[5.0]
def change
add_reference :bookings, :employee, foreign_key: true
end
end
|
require "spec_helper"
require "factory_girl"
describe "validations" do
before(:each) do
@user_attr = FactoryGirl.attributes_for(:user)
end
it "should create a new instance of a user given valid attributes" do
User.create!(@user_attr)
end
it "should not create a new instance of a user given empty ... |
class Work2 < ActiveHash::Base
self.data = [
{ id: 1, name: '--' },
{ id: 2, name: '血液浄化' },
{ id: 3, name: '呼吸療法' },
{ id: 4, name: '人工心肺' },
{ id: 5, name: '心カテ' },
{ id: 6, name: '内視鏡' },
{ id: 7, name: '機器管理' }
]
include ActiveHash::Associations
has_many :jobs
end |
module Jekyll
module Commands
class BuildEbook < Command
EBOOK_OPTIONS = %w[destination file_name kindle].freeze
# Create the Mercenary command for the Jekyll CLI for this Command
def self.init_with_program(prog)
prog.command(:'build-ebook') do |c|
c.syntax 'build-ebook [optio... |
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
with_options presence: true do
with_options format: { with: /\A[ぁ-んァ-ヶ一-龥々ー]+\z/, message: 'is invalid. Input full-width characters.' } do
validates :last_name
validate... |
# == Schema Information
#
# Table name: characters
#
# id :bigint(8) not null, primary key
# user_id :bigint(8)
# raider_io_pull :datetime
# name :string
# realm :string
# region :string
# raider_io_score :integer
# item_level :integer
# verified ... |
require 'spec_helper'
require 'poms/configuration'
module Poms
RSpec.describe Configuration do
subject do
described_class.new do |c|
c.key = 'a'
c.secret = 'b'
c.origin = 'c'
c.base_uri = 'd'
end
end
before do
stub_const('ENV', {})
end
it 'is bu... |
module Skore
module DB
module Category
def create
db.execute <<-SQL
create table if not exists categories (
id integer,
name varchar(150)
);
SQL
end
def save(resources = [])
resources.each do |resource|
db.execute(
... |
class ThemesController < ApplicationController
before_action :set_admintheme, only: [:show, :edit, :update, :destroy]
def index
@themes = Theme.all
@themeclas = Themecla.all
end
def show
end
# GET /tests/new
def new
@admintheme = Theme.new
end
# GET /tests/1/edit
def edit
end... |
class ChangeAnswerOptionsTemplateTableName < ActiveRecord::Migration
# This is an intermediary fix for anyone who ran the migration that switched the table name to answer_options_templates.
def up
if ActiveRecord::Base.connection.table_exists? :answer_options_templates
rename_table :answer_options_templa... |
class AddSlugToMothers < ActiveRecord::Migration[5.2]
def change
add_column :mothers, :slug, :string
add_index :mothers, :slug, unique: true
end
end
|
class JobType < ApplicationRecord
validates_presence_of :title
validates :title, uniqueness: true
has_and_belongs_to_many :resumes
has_many :jobs
end
|
class BookRequestExtensionState < ActiveRecord::Migration
def change
add_column(:book_requests, :extension_state, :integer, default: 0)
end
end
|
module Fog
module DNS
class PowerDNS
class Real
# Searches for term in server logs
#
# ==== Parameters
# * server<~String> - server id
# * term<~String> - search term
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
... |
class Frequency
attr_reader :freq
def initialize
@freq = Hash.new(0)
@total = 0
end
def add(char)
@freq[char] += 1
@total += 1
end
def highest_freq
key, = @freq.max { |f1, f2| f1[1] <=> f2[1]}
key
end
def random
n = rand(@total)
count = 0
key, = @freq.find do |c... |
FactoryBot.define do
factory :facilities_management_regional_availability, class: FacilitiesManagement::RegionalAvailability do
association :supplier, factory: :facilities_management_supplier
lot_number { '1a' }
region_code { 'UKC1' }
end
end
|
require 'spec_helper'
require 'rack/test'
ENV['RACK_ENV'] = 'test'
describe AdiosNaco do
include Rack::Test::Methods
def app
AdiosNaco::Server
end
it 'has a version number' do
expect(AdiosNaco::VERSION).not_to be nil
end
it 'provides a version end-point' do
get '/version'
expect(... |
When /^I edit the event$/ do
theHomeTailgate = FactoryGirl.create(:tailgate, team_id: @edit_event.home_team.id, official:true)
theVisitingTailgate = FactoryGirl.create(:tailgate, team_id: @edit_event.visiting_team.id, official:true)
fill_in "event_name", with: "Superbowl"
click_button "commit"
end
Then /^... |
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments, dependent: :destroy
mount_uploader :image1, ImageUploader
mount_uploader :image2, ImageUploader
mount_uploader :image3, ImageUploader
end
|
# frozen_string_literal: true
module DogBiscuitsHelper
# Return the label for publication status
#
# @param value [String]
# @return [String]
def publication_status(value)
if value.is_a? String
publication_status_label(status)
elsif value.is_a? Hash
value[:value].map { |status| publication... |
require 'spec_helper'
module ActiveRecord
class Base
end
end
require 'simple_money/active_record'
describe SimpleMoney::ActiveRecord::MoneyField do
describe "::money_field" do
let(:model_class) do
Class.new do
extend SimpleMoney::ActiveRecord::MoneyField::ClassMethods
money_... |
require 'nil/file'
require 'nil/serialise'
require_relative 'Player'
require_relative 'HeroStatistics'
class DatabaseCreator
def initialize(incompleteDatabasePath)
@incompletePlayers = Nil.deserialise(incompleteDatabasePath)
@completePlayers = []
end
def getPlayer(id)
@incompletePlayers.each do |pl... |
class DelayedAdditionalReportPdf
attr_accessor :pdf_report_id
def initialize(pdf_report_id)
@pdf_report_id = pdf_report_id
end
def perform
@pdf_report=AdditionalReportPdf.find(@pdf_report_id)
begin
@pdf_report.pdf_generation
@pdf_report.update_attributes(:is_generated => true)
rescu... |
module Api
class PictureLikesController < ApiController
def index
@picture_likes = PictureLike.all
end
def create
@like = PictureLike.new(picture_like_params)
@like.user = current_user
if @like.save
# make an activity record unless on yourself
unless current_user.... |
class MealPlan < ActiveRecord::Base
belongs_to :user
belongs_to :recipe
has_many :quantities, through: :recipe
validates :date, presence: true
validates :daytime, presence: true
validates :user_id, presence: true #, numericality: { greater_than_or_equal: 0 }
validates :recipe_id, presence: true #... |
class FontNotoSansLinearA < Formula
head "https://github.com/google/fonts/raw/main/ofl/notosanslineara/NotoSansLinearA-Regular.ttf", verified: "github.com/google/fonts/"
desc "Noto Sans Linear A"
homepage "https://fonts.google.com/specimen/Noto+Sans+Linear+A"
def install
(share/"fonts").install "NotoSansLin... |
require "cookie"
require "ostruct"
require "uri"
describe Cookie do
let(:request_uri) { URI.parse("http://example.com") }
it "has value semantics" do
a = Cookie.new("SID", "31d4d96e407aad42", "Domain" => "example.com")
b = Cookie.new("SID", "31d4d96e407aad42", "Domain" => "example.com")
a.should eq(b)... |
class ExpenseItemsController < ApplicationController
# GET /expense_items
# GET /expense_items.json
def index
@expense_items = ExpenseItem.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @expense_items }
end
end
# GET /expense_items/1
# GET /expen... |
class EventSearch < ApplicationRecord
validates :repo_name, :user_name, :event_type, presence: true
class_attribute :backend
self.backend = Github
def events
backend.activity.events.repository(user_name, repo_name)
end
def events_by_type
events.select{|e| e.type == event_type}
end
end
|
require 'spec_helper'
module Boilerpipe::Filters
describe ListAtEndFilter do
describe '#process' do
context 'when a text block is the last LI tag in a list' do
let(:text_block) { Boilerpipe::Document::TextBlock }
let(:text_block1) { text_block.new('one') }
let(:text_block2) { text_b... |
module CamaleonCms
class UserDecorator < CamaleonCms::ApplicationDecorator
include CamaleonCms::CustomFieldsConcern
delegate_all
# return the identifier
def the_username
object.username
end
# return the fullname
def the_name
object.fullname
end
# return the role titl... |
require 'test_helper'
class PostsTest < ActionDispatch::IntegrationTest
[:blog, :news].each do |blog|
test "should create #{blog} post" do
visit new_blog_post_path(blog)
fill_in 'post_title', :with => "some title"
fill_in 'post_body', :with => "some body"
assert_difference(... |
require 'spec_helper'
require 'belafonte/helpers/arguments'
module Belafonte
module Helpers
describe Arguments do
let(:dummy) {Object.new.extend(described_class)}
describe '#args' do
it 'is a hash' do
expect(dummy.args).to be_a(Hash)
end
end
describe '#arg' do
... |
require 'rails_helper'
RSpec.describe Item, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
describe '#create' do
before do
@item = FactoryBot.build(:item)
end
describe '出品登録' do
context '出品登録がうまくいくとき' do
it "すべて入力すれば登録できる" do
expect(@item).to be_valid
end... |
module CommonHelpers
def stub_get_json(url, response)
stub_request(:get, url).to_return(
headers: {
'Content-Type' => 'application/json'
},
body: response.to_json
)
end
def fixtures_path
File.join(File.dirname(__FILE__), '..', 'fixtures')
end
def fixture_path(filename)
... |
class Car < ApplicationRecord
has_many :races
has_many :drivers, through: :races
validates :year, presence: :true
validates :model, presence: :true
def full_name
"#{year} #{make} #{model}"
end
end
|
# This class overrides the devise controller to also allow other params - namely first name and last name
class RegistrationsController < Devise::RegistrationsController
before_action :set_user, only: [:update]
def create
@user = User.new(user_params)
if @user.save
redirect_to user_path(@user)
el... |
class CustomActivity < ActiveRecord::Base
belongs_to :category, foreign_key: "course_category_id", class_name: "CourseCategory"
belongs_to :user
end
|
#!/usr/bin/env ruby
# :title: PlanR::ContentRepo
=begin rdoc
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
ContentRepo module. The repository of all documents and metadata.
=Content Repo
==Repository
The Content Repository contains two types of trees: Data trees and Metadata
trees.
Each tree contains ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.