text stringlengths 10 2.61M |
|---|
module Verbs
class Verb
attr_reader :infinitive, :preterite, :past_participle
def initialize(infinitive, options = {}, &blk)
@infinitive = infinitive
@forms = {}
if block_given?
yield self
else
@preterite = options[:preterite]
@past_participle = options[:pa... |
module Jobs
module ResourceMixIn
def resource model
model.https? ? secured_resource(model.url) : plain_resource(model.url)
end
def secured_resource url
RestClient::Resource.new url,
:ssl_client_cert => Identity.certificate.certificate,
:ssl_client_key => Identity.private... |
class ReportsController < ApplicationController
before_filter :admin_user
def index
@posts = Post.all.sort
@users = User.all.sort_by {|user| -user.posts.length }
end
def admin_user
@user = self.current_user
if !@user
redirect_to signin_path, notice: "Please sign in."
else
if !... |
module Alf
module Operator::Relational
class Restrict < Alf::Operator()
include Operator::Relational, Operator::Unary
signature do |s|
s.argument :predicate, TuplePredicate, "true"
end
protected
# (see Operator#_each)
def _each
handle = Tuple... |
class BaseActivity < ApplicationRecord
include Searchable
searchable name: { unaccent: true }
belongs_to :base_activity_type
enum tcc: { one: 'TCC 1', two: 'TCC 2' }, _prefix: :tcc
validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :tcc, presence: true
def self.human_tcc... |
require 'spec_helper'
describe 'CspReport index view' do
describe 'Report data headers' do
before(:each) do
visit csp_reports_path
end
it 'should display the report id' do
page.should have_content 'ID'
end
it 'should display the report document URI' do
page.should have_content ... |
Date::DATE_FORMATS[:day_and_month] = lambda do |date|
date.strftime("#{date.day.ordinalize} %b")
end
|
class AnnotationSerializer
include FastJsonapi::ObjectSerializer
set_type :annotations
attribute :detail
attribute :annotation_category_id
attribute :created_at, if: Proc.new { |record, params| params.blank? || !params[:public] == true }
attribute :updated_at, if: Proc.new { |record, params| params.blank? ... |
# Prepare dirs for capistrano deployment, similar to running `cap deploy:setup`
directory app.path do
owner app.user.name
group app.user.group
mode 0755
end
[app.releases_path, app.shared_path, app.log_path, app.system_path, app.run_path, app.init_path].each do |dir|
directory dir do
owner app.user.name
... |
require 'spec_helper'
require 'typhoeus'
require 'rack'
require 'et_azure_insights'
require 'et_azure_insights/adapters/typhoeus'
require 'random-port'
RSpec.describe 'Typhoeus Integration' do
include_context 'with stubbed insights api'
around do |example|
begin
EtAzureInsights::Adapters::Typhoeus.setup
... |
#!/usr/bin/ruby
=begin
#---------------------------------------------------------------------------------------------------------
# euler12.rb- program to indicate the triangle number whose number of factors are just greater than the given threshold provided in the input file
# i/p - an ASCII txt file with a single nu... |
require 'easy_extensions/easy_xml_data/importables/importable'
module EasyXmlData
class IssueRelationImportable < Importable
def initialize(data)
@klass = IssueRelation
super
end
def mappable?
false
end
private
end
end |
class AddPriceToVoyages < ActiveRecord::Migration[6.0]
def change
add_column :voyages, :price, :integer
end
end
|
Rails.application.routes.draw do
root to: 'artists#index'
resources :artists, only: :show do
resources :albums, only: [:new, :create]
resources :artist_tags, as: :tags, only: [:new, :create]
end
resources :albums, only: :destroy
end
|
class EventsController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :index]
def index
@events = Event.all :include => [:event_dates], :order => 'event_dates.event_date desc'
end
def new
@event = Event.new
end
def create
@event = Event.new(params[:even... |
require 'sinatra/base'
require 'haml'
require 'json'
module Timetable
class Application < Sinatra::Base
include TimeHelpers
# Set the parent directory of this file as the project root
set :root, File.dirname(File.dirname(File.dirname(__FILE__)))
set :haml, :format => :html5
get '/' do
@co... |
require 'spec_helper'
describe User do
before do
@user = User.new(email: "user@example.com",
password: "somepassword",
password_confirmation: "somepassword",
isAdmin: false)
end
subject { @user }
it { should respond_to(:email) }
it { shou... |
Puppet::Parser::Functions.newfunction(:wreckit_scenarios, :type => :rvalue) do |args|
begin
raise(ArgumentError, 'wreckit_scenarios() expects a single optional argument') if args.size > 1
context = args.first
modpath = Puppet::Module.find('wreckit', compiler.environment.to_s).path
klasses = []
D... |
class Blog < ActiveRecord::Base
has_attached_file :eye_catch, :styles => { :small => "150x150>" },
:url => "/assets/blog_images/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/blog_images/:id/:style/:basename.:extension"
validates_attachment_content_type :eye_catch, :content_type => ... |
# == Schema Information
#
# Table name: airports
#
# id :uuid not null, primary key
# altitude :integer
# city :string
# country :string
# country_alpha2 :string
# dst :string
# iata :string
# icao :string
# kind ... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'welcome#index'
devise_for :users
get 'welcome/index'
resources :projects, except: :show, param: :name do
resources :publishings, path: 'publish', only: :create
e... |
module RatingAverage
extend ActiveSupport::Concern
def average_rating
if ratings.empty?
return 0.0
else
ratings.average(:score)
end
end
end |
- Build a calculator to run with Addition, Multiplication, Subtraction, and Division.
- User needs to be able to select what they want to do with the numbers and need to be able to pass in at least 6 numbers at a time. |
# == Schema Information
#
# Table name: recipes
#
# id :integer not null, primary key
# user_id :integer
# title :string
# kitchen_of :string
# ingredients :text
# instructions :text
# public :boolean
# created_at :datetime not null
# updated_at :datetime ... |
class OfferProductIdRename < ActiveRecord::Migration[5.0]
def change
rename_column :offers, :product_id, :card_product_id
end
end
|
class UserAuthService
class User < ActiveRecord::Base
before_create :generate_uid
def generate_uid
self.uid = SecureRandom.uuid
end
end
end
|
require 'test/unit'
require 'coderay'
class StatisticEncoderTest < Test::Unit::TestCase
def test_creation
assert CodeRay::Encoders::Statistic < CodeRay::Encoders::Encoder
stats = nil
assert_nothing_raised do
stats = CodeRay.encoder :statistic
end
assert_kind_of CodeRay::Encoders::Encoder... |
class Comment < ApplicationRecord
belongs_to :user
belongs_to :idea
default_scope {order({created_at: :desc}, :user_id)}
def get_user
User.find user_id
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
module Fog
module DNS
class Google
##
# Atomically updates a ResourceRecordSet collection.
#
# @see https://cloud.google.com/dns/api/v1/changes/create
class Real
def create_change(zone_name_or_id, additions = [], deletions = [])
@dns.create_change(
@proj... |
module Annotable
class User < ApplicationRecord
belongs_to :organization, optional: true
validates :email, presence: true, format: { with: /@/ }
end
end
|
require 'rails_helper'
RSpec.describe UserExpenseShareValue, type: :model do
let!(:expense) { create(:expense, cost: 10, owners: [user], user: user) }
let(:user) { create(:user) }
let(:user_expense) { build(:user_expense_share_value, status: 'resolved', expense: expense) }
describe "#settle_expense" do
it... |
require 'test_helper'
module Abilities
class ForumsTest < ActiveSupport::TestCase
def setup
@provider = FactoryBot.create(:provider_account)
@forum = @provider.forum
end
def test_posts
assert_equal [], @forum.posts.to_a
assert_equal 0, @forum.posts.size
end
test 'anyone ... |
require "java"
Dir["#{Dir.pwd}/.akephalos/#{ENV['htmlunit_version']}/*.jar"].each {|file| require file }
java.lang.System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog")
java.lang.System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "fatal")
java.lang.System... |
require 'spec_helper'
describe Rack::Utils::UrlStripper do
describe '.replace_id' do
it 'replaces BSON-like ids with ID' do
ids = %w(5005536b28330e5a8800005f 4f07931e3641417a88000002)
ids.each do |id|
Rack::Utils::UrlStripper.replace_id("/resource/#{id}").should == '/resource/ID'
end
... |
# SAPNW is Copyright (c) 2006-2010 Piers Harding. It is free software, and
# may be redistributed under the terms specified in the README file of
# the Ruby distribution.
#
# Author:: Piers Harding <piers@ompka.net>
# Requires:: Ruby 1.8 or later
#
module SAPNW
module Functions
class Base
end
end
module... |
class StoresController < ApplicationController
def index
@stores = Store.find(:all, :order => :number)
respond_to do |format|
format.html
format.xml { render xml: @stores }
format.json { render json: @stores }
# format.pdf { render pdf: @stores }
end
end
def show
@store = ... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
mount_uploader :profile_image, ProfileImageUploader
... |
module ManageIQ::Providers::Amazon::ParserHelperMethods
extend ActiveSupport::Concern
#
# Helper methods
#
def filter_unused_disabled_flavors
to_delete = @data[:flavors].reject { |f| f[:enabled] || @known_flavors.include?(f[:ems_ref]) }
to_delete.each do |f|
@data_index[:flavors].delete(f[:ems_... |
class RemoveDbValidationFromUser < ActiveRecord::Migration[5.2]
def change
remove_column :users, :first_name
remove_column :users, :uid
remove_column :users, :provider
add_column :users, :first_name, :string
add_column :users, :uid, :string, null: false
add_column :users, :provider, :string, null: f... |
require 'rails_helper'
require File.dirname(__FILE__) + '/../../app/models/person'
describe 'Person' do
it 'should have email as required' do
cust = Person.new
expect(cust.valid?).to be(false)
expect(cust.errors.messages[:email]).to include("can't be blank")
end
it 'should only accept valid email ad... |
class Admin::ProfilesController < Puffer::Base
setup do
group :users
end
index do
field 'user.email'
field :name
field :surname
field :birth_date
end
form do
field :user, :columns => [:email, :password]
field :name
field :surname
field :birth_date
field :created_at
... |
Rails.application.routes.draw do
resources :statuses
resources :questions
resources :users
root 'users#index'
end
|
class TracksController < ApplicationController
before_action :check_login
def check_login
unless logged_in?
redirect_to new_user_url
end
end
def index
render :index
end
def create
@track = Track.create(track_params)
redirect_to track_url(@track)
end
def new
@track = Tr... |
require "dhis2"
class Dhis2Exporter
attr_reader :facility_identifiers, :periods, :data_elements_map, :category_option_combo_ids
def initialize(facility_identifiers:, periods:, data_elements_map:, category_option_combo_ids: [])
throw "DHIS2 export not enabled in Flipper" unless Flipper.enabled?(:dhis2_export)
... |
class File < IO
SEPARATOR = "/"
ALT_SEPARATOR = nil
def self.file?(io)
false
end
def initialize(path, mode = "r")
STDERR.puts "File.init: #{path.inspect}"
%s(assign rpath (callm path __get_raw))
%s(assign fd (open rpath 0))
%s(perror 0)
# FIXME: Error checking
%s(if (le fd 0) (d... |
class ChangeDoctorDepartmentToRole < ActiveRecord::Migration
def change
rename_column :doctors, :department, :role
end
end
|
name 'oauth2_proxy'
maintainer 'Orion Labs, Inc.'
maintainer_email 'Mike Juarez <mike@orionlabs.co>'
license 'Apache License, Version 2.0'
description 'Installs/Configures oauth2_proxy'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version IO.read(File.join(Fil... |
require "twirloc/version"
require "twirloc/twitter_client"
require "twirloc/location_guesser"
require "twirloc/tweet_fetcher"
require "twirloc/tweet"
require "twirloc/midpoint_calculator"
require "twirloc/algorithms"
require "twirloc/google_location"
require "thor"
module Twirloc
class CLI < Thor
desc "total USE... |
module Mysears::MystoreHelper
# TODO | remove
# Article looks like:
# <Article
# id: 245,
# article_instance_id: 4,
# article_category_id: 57,
# title: "Saturday Family Fun!",
# content: "<p><img src=\"http://www.mysears.com/managed_images/...",
# permalink: "Saturday-Family-Fun... |
require 'rubygems'
require 'rake/testtask'
require 'rake/rdoctask'
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "typus/version"
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the typus plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = '... |
class CreateImageTable < ActiveRecord::Migration
def change
create_table :images do |t|
t.string :filename
t.string :hash_id
t.string :extension
t.timestamps
end
add_foreign_key :users, :images
add_foreign_key :games, :images
end
end
|
Rails.application.routes.draw do
devise_for :users
resources :users, only: [:index, :show]
resources :articles
root 'articles#index'
end
|
FactoryBot.define do
factory :__activity do
title { Faker::Lorem.sentence }
partner_organisation_identifier { "GCRF-#{Faker::Alphanumeric.alpha(number: 5).upcase!}" }
roda_identifier { nil }
beis_identifier { nil }
description { Faker::Lorem.paragraph }
sector_category { "111" }
sector { "... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# Every Vagrant... |
# Underline first letter of string
class Symbol
def underline_first
to_s.capitalize!
"\e[4m#{self[0]}\e[0m#{self[1..-1]}"
end
end
# Monkey-patch for want of better ideas. In the initial move, the colours and
# their positions are irrelevant; all codes with the same number of colours and
# repitions of thos... |
feature 'Deleting a comment' do
before(:each) do
sign_up
log_in
post_peep
comment
comment2
end
scenario 'User who made a can delete it' do
expect{ click_button('delete_comment_5') }.to change(Comment, :count).by(-1)
expect(page).not_to have_content('Test comment')
expect(page).to ... |
class Point < ActiveRecord::Base
belongs_to :user
belongs_to :show
validates_presence_of :user_id, :show_id, :points
end
|
#
# Cookbook:: aar
# Recipe:: default
#
# Copyright:: 2017, The Authors, All Rights Reserved.
include_recipe 'lamp::default'
passwords = data_bag_item('passwords', 'mysql')
# Flask and python
package [ 'libapache2-mod-wsgi', 'python-pip', 'python-mysqldb', 'git' ]
execute 'install-flask' do
command <<-EOF
pip... |
class UsersController < ApplicationController
respond_to :html, :json
include UserInfoHelper
# before_action :get_current_user
def show
user = User.find(params["id"])
if user
user = inject_extra_user_props(user)
render json: user
else
redirect_to root_path
end
end
# def... |
class Contact < ApplicationRecord
# belongs_to :kind
# Faz com que a chave para Kind seja Opcional
belongs_to :kind, optional:true
has_many :phones
# Um Contato terá um Endereço
has_one :address
# Permite que o telefone possa ser cadastrado ao mesmo tempo que se cadastra um Contato
# ... |
name "apt"
maintainer "Till Klampaeckel"
maintainer_email "till@php.net"
license "Apache 2.0"
description "Configures apt and apt services"
version "0.10.0"
recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories"
recipe ... |
# frozen_string_literal: true
require 'spec_helper'
require 'web_test/be_fast'
RSpec.describe WebTest::BeFast do
it { is_expected.not_to be_nil }
describe '#test' do
it 'handles a fast site' do
result = WebTest::BeFast.test url: 'http://nonstop.qa'
expect(result.success?).to be true
expect(r... |
class Customer < ActiveRecord::Base
validates :full_name, presence: true
belongs_to :province
end
|
module Downloadable
extend ActiveSupport::Concern
def download
return Rails.logger.info "File already downloaded: #{tmp_file}" if File.exist? tmp_file
source = open(external_address)
IO.copy_stream(source, tmp_file)
end
end
|
class NeighborsController < ApplicationController
before_action :set_neighbors
def neighbors
render json: @neighbors
end
private
def set_neighbors
@neighbors = NeighborList.instance
end
end
|
require 'memoist'
StubbedDestructiveMethod = Class.new(StandardError)
class Github
extend Memoist
attr_accessor :token, :client
def initialize(token = Env.github_api_token)
@token, @client = token, Octokit::Client.new(access_token: token)
end
def has_repo?(full_name)
client.repository?(full_name)
... |
class CreateTownHealthRecords < ActiveRecord::Migration
def change
create_table :town_health_records do |t|
t.string :city_name
t.integer :population
t.integer :number_of_children
t.integer :number_of_seniors
t.integer :per_capita_income
t.integer :number_below_poverty
t.... |
class AddConfirmationCodeToExpenses < ActiveRecord::Migration
def change
add_column :expenses, :confirmation_code, :string
end
end
|
class CreatePasFindings < ActiveRecord::Migration
def self.up
create_table 'pas_findings' do |t|
t.column :model_activity_dataset_id, :int
t.column :sequence, :integer
t.column :evidence, :string
t.column :text, :string
end
add_index "pas_findings", :model_activity_dataset_id
end... |
require 'rails_helper'
feature 'user visits monologue new page' do
context 'as a user I want to vist the monologue new page' do
let!(:user) { FactoryGirl.create(:user) }
scenario 'so that I can view a form for uploading a monologue' do
visit root_path
fill_in 'Email', with: user.email
fill... |
class AppSample::AdminController < ModuleController
component_info 'AppSample', :description => 'App Sample support',
:access => :public
# Register a handler feature
register_permission_category :app_sample, "AppSample" ,"Permissions related to App Samp... |
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
require 'yaml'
settings = YAML.load_file('settings.yml')
thread_id = settings['thread_id']
access_token = settings['access_token']
DB = Sequel.connect('sqlite://messages.db')
messages = DB[:messages]
g = Koala::Facebook::API.... |
with_tag(:div, :class => :address) do
address.hidden_field :id
address.text_area :street, :size => "30x3", :focus => true, :label_class => :street
address.select :kind, I18n.translate('contacts.address_types'), :no_label => true
address.buttons :delete
clear
address.text_field :locality
... |
require 'helper'
describe Esendex::Client do
subject { Esendex::Client }
describe '.get' do
let(:credentials) { dummy_credentials }
let(:path) { "some/url/path" }
let(:args) { { query: "what", thing: "yep" } }
let(:expected_code) { 418 }
let(:expected_body) { "Hi I'm a body" }
let(:uri) ... |
require 'spec_helper'
module Dustbag
describe Items do
include_context 'load xml from fixture'
it_behaves_like 'a collection node of', Item
describe '#request' do
it { expect(subject.request).to be_a_kind_of Request }
end
describe '#total_results' do
it { expect(subject.total_resul... |
ENV['RACK_ENV'] = 'test'
require 'rack/test'
require 'minitest/autorun'
require_relative '../todo'
require './lib/todo_helpers'
require './lib/task_store'
require './lib/task'
require 'sinatra'
enable :sessions
class TestToDoHelpers < Minitest::Test
include Rack::Test::Methods
def app
Sinatra::A... |
class ApplicationController < ActionController::Base
before_action :basic if Rails.env.production?
protect_from_forgery with: :exception
include SessionsHelper
private
def require_user_logged_in
unless logged_in?
redirect_to login_url
end
end
def counts(user)
@count_plans = ... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.admin?
can :manage, :admin
can :manage, :groupings
can :manage, :institutions
can :manage, :notices
can :manage, :states
can :manage, :users
else
can :access, :pages
end
... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = 'zero_logger'
s.version = '0.0.1'
s.date = '2018-04-10'
s.summary = "Indent console output for cli"
s.description = "Using zero logger to add indent of the output of programs"
... |
$:.push File.expand_path('../lib', __FILE__)
require 'filmbuff/version'
Gem::Specification.new do |s|
s.name = 'filmbuff'
s.version = FilmBuff::VERSION
s.authors = ['Kristoffer Sachse']
s.email = ['hello@kristoffer.is']
s.homepage = 'https://github.com/sachse/filmbuff'
s.summary ... |
# frozen_string_literal: true
Given("there is an extant species Lasius niger in a fossil genus") do
genus = create :genus, protonym: create(:protonym, :genus_group, :fossil)
create :species, name_string: "Lasius niger", genus: genus
end
Given("I open all database scripts one by one") do
script_names = DatabaseS... |
module SportsDataApi
module Mlb
class Exception < ::Exception
end
DIR = File.join(File.dirname(__FILE__), 'mlb')
BASE_URL = 'http://api.sportsdatallc.org/mlb-%{access_level}%{version}'
DEFAULT_VERSION = 4
SPORT = :mlb
autoload :Team, File.join(DIR, 'team')
autoload :Teams, File.join... |
class Beta03 < ActiveRecord::Migration
def self.up
create_table :compliments do |t|
t.column :review_id, :integer
t.column :user_id, :integer
t.column :from_user_id, :integer
t.column :created_at, :datetime
t.column :text, :text
end
add_index :compliments, :rev... |
namespace :prep do
desc 'Expose reoccurring events, correct occurrences dates'
task :do => :environment do
Occurrence.correct_dates
#Occurrence.expose
Occurrence.correct_categories
Event.correct_images
end
task :expose => :environment do
#Occurrence.correct_category
Occurrence.expose
... |
require 'spec_helper'
describe RightBranch::Updater do
let(:gh) { double(:github) }
let(:repo) { 'doge/wow' }
let(:updater) { described_class.new(repository: repo) }
before { allow(updater).to receive(:github).and_return(gh) }
describe '#resubmit_pr' do
it 'creats new pull request againts branch' do
... |
RSpec.describe Zenform::Param::RuleBase do
module Zenform
module Param
class DummyContentForRuleBase < RuleBase
FIELDS = %w{field value}
FIELDS.each { |f| attr_reader f }
end
end
end
let(:klass) { Zenform::Param::DummyContentForRuleBase }
let(:instance) { klass.new content... |
# coding: utf-8
class DepartmentsController < ApplicationController
before_filter :auth_required
def index
end
def search
@items = Department.order(:name)
if !params[:q].blank?
@items = @items.where("(name LIKE :q)", {:q => "%#{params[:q]}%"})
end
render :layout => false
end
def n... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Bulk insert' do
include PrimarySocket
let(:fail_point_base_command) do
{ 'configureFailPoint' => "failCommand" }
end
let(:collection_name) { 'bulk_insert_spec' }
let(:collection) { authorized_client[collection_name] }
... |
module Billing::ChargesHelper
def charge_header_tag(charge)
class_name, title = if charge.paid?
["success", "TRANSACCIÓN EXITOSA"]
elsif charge.created? || charge.pending?
["info", "PENDIENTE POR CONFIRMAR"]
elsif charge.error?
["danger", "ERROR EN LA TRANSACCIÓN"]
elsif charge.rejec... |
require 'game'
describe Game do
let(:game) { Game.new }
it "should score all gutter balls as 0" do
game.score("--" * 10).should == 0
end
it "should score single rolls in each frame" do
game.score("9-"*10).should == 90
end
context "spares" do
it "should score a spare without points in the... |
require 'spec_helper'
describe Game do
it { should have_db_column(:winner_id).of_type(:integer) }
it { should have_db_column(:loser_id).of_type(:integer) }
it { should belong_to :winner }
it { should belong_to :loser }
it { should have_many :user_games }
it { should have_many :users }
it { should have_m... |
require 'rails_helper'
RSpec.describe "StaticPages", type: :request do
describe "toppage" do
it "正常なレスポンスを返すこと" do
get root_path
expect(response).to be_success
expect(response).to have_http_status "200"
end
end
describe "aboutpage" do
it "正常なレスポンスを返すこと" do
get staticpages_abo... |
module UserBase
extend ActiveSupport::Concern
included do
## Mixin
# include Shared::Common
# include Redis::Objects
include ActiveModel::ForbiddenAttributesProtection
include ActiveModel::SecurePassword
extend Enumerize
# include Ransackable
# include Optionsable
# include Tras... |
class ApiAbility
include CanCan::Ability
def initialize(client)
client ||= Client.new
can :manage, Order, client_id: client.id
can :manage, OrderItem, order: {client_id: client.id}
end
end
|
Rails.application.routes.draw do
# Root page
root 'home#index'
# Person
resources :person
# Pets
resources :pet
# User
get 'signup' => 'user#new'
resources :user
# Login
get 'login' => 'session#new'
delete 'logout' => 'session#destroy'
resources :session
end
|
namespace :check do
namespace :migrate do
task add_user_id_to_relationship: :environment do
# Read the last annotation id we need to process that was set at migration time.
last_id = Rails.cache.read('check:migrate:add_user_id_to_relationship:last_id')
raise "No last_id found in cache for check:... |
require 'active_support/concern'
module Decorator
extend ActiveSupport::Concern
# Better way.
module ClassMethods
attr_accessor :my_message
end
#module ClassMethods
# def my_message=(value)
# @my_message = value
# end
#
# def my_message
# @my_message
# end
#end
alias :o... |
class Site2014Controller < ApplicationController
include HighVoltage::StaticPage
layout '2014/application'
def send_email
TransactionMailer.sponsor_mail(params).deliver
render nothing: true
end
end
|
#encoding: utf-8
require "spec_helper"
describe StatisticsHelper do
describe "calculate all or cetain tasks results summary" do
before(:each) do
@project = FactoryGirl.create(:project)
@task = @project.tasks.create(FactoryGirl.attributes_for(:task))
@task.reviewers.create(FactoryGirl.at... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.