text stringlengths 10 2.61M |
|---|
# Be sure to restart your server when you modify this file.
#
# 5 stars is a common ranking use case. They are not given at specified
# actions like badges, you should define a cron job to test if ranks are to be
# granted.
#
# +set_rank+ accepts:
# * :+level+ ranking level (greater is better)
# * :+to+ model or scope ... |
class Tournament < ApplicationRecord
has_many :groups, dependent: :destroy
after_initialize :set_default_attributes, if: :new_record?
validates :title, presence: true
validates :date, presence: true,
inclusion: {
in: Date.new(1990,1,1)...Date.new(Date.current.year + 2, 1, 1),
message: I18n.t('... |
# coding:utf-8
module PlainSite
module Commands
require 'pp'
require 'fileutils'
require 'commander/import'
require 'plain_site/site'
SELF_DIR=File.dirname(__FILE__)
def self.die(msg="\nExit now.\n")
$stderr.puts msg
exit 1
end
... |
require 'rails_helper'
RSpec.describe Customer, type: :model do
describe "validations" do
it { should validate_presence_of (:name) }
it { should validate_presence_of :email}
it { should validate_presence_of :phone_number}
it { should have_many :estimate}
it { should belong_to :user }
end
context " in ... |
class Ability
# See the wiki for details:
# https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
alias_action :create, :read, :update, :destroy, to: :crud
alias_action :add_user, :r... |
module ApplicationHelper
def display_numbers_with_commas_separator(number:, delimiter: ",", rounded: false)
if rounded
round_numbers_to_decimals(number_with_delimiter(number.to_f, delimiter: delimiter))
else
number_with_delimiter(number, delimiter: delimiter)
end
end
def round_numbers_to_... |
Rails.application.routes.draw do
devise_for :trainers
root to: "home#index"
resources :trainers #creates these paths for us that we see in the rails routes
# perhaps handled the error for trainer id (wrong string interpolation) as just showing the view of trainers
# it doesn't depend on the model
patch '/ca... |
class Admin::UsersController < ApplicationController
before_action :admin_access_check
def index
@users = User.order(:id).page(params[:page]).per(8)
end
def show
@user = User.find(params[:id].to_i)
end
def create
end
def update
end
def new
end
def destroy
@user = User.find(param... |
class TasksController < ApplicationController
# GET /tasks
# GET /tasks.json
def index
@tasks = Task.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tasks }
end
end
# GET /tasks/1
# GET /tasks/1.json
def show
@task = Task.find(params[:id])
... |
class AddVkImageColumnToPosts < ActiveRecord::Migration
def change
add_column :posts, :vk_image, :string
end
end
|
class Bus < ApplicationRecord
mount_uploader :img_bus, ImgBusUploader # Tells rails to use this uploader for this model.
validates :no_bus, presence: true # Make sure the owner's name is present.
end
|
control "M-1.4" do
title "1.4 Ensure only trusted users are allowed to control Docker
daemon(Scored)"
desc "
The Docker daemon currently requires root privileges. A user added to the
docker group
gives him full root access rights.
Docker allows you to share a directory between the Docker host and a gue... |
class CreateSongs < ActiveRecord::Migration
def self.up
create_table :songs do |t|
t.column :artist_id, :integer
t.column :album_id, :integer
t.column :media_file_id, :integer, :null => false
t.column :name, :string, :null => false
end
end
def self.down
drop_table :songs
end... |
class CreateDeeds < ActiveRecord::Migration
def self.up
create_table :deeds do |t|
t.string :name, :limit => 120
t.integer :user_id
t.integer :author_id, :references => :user
t.integer :original_deed_id
t.boolean :is_private
t.string :slug
t.timestamps
end
add_ind... |
class Teacher < ApplicationRecord
has_many :teacher_relationships
has_many :students, :through => :teacher_relationships, :source => :student
has_many :courses, :dependent => :destroy
end
|
require 'rails_helper'
describe UnsplashService do
it 'fetches images with a search term', :vcr do
search_term = 'denver,co'
service = UnsplashService.new(search_term)
unsplash_response = service.fetch_image_info
expect(unsplash_response).to have_key :results
expect(unsplash_response[:results][... |
#!/usr/bin/env ruby
require 'json'
require 'yaml'
output_hash = {
'controls' => {},
'ce' => {},
'checks' => {},
'profiles' => {},
}
params = {}
Dir.glob('../data/compliance_profiles/**/*.json') do |filename|
data = JSON.parse(File.read(filename))
data['compliance_markup::compliance_map'].each do |profile,... |
# Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# 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 ... |
class User < ApplicationRecord
include Rails.application.routes.url_helpers
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_ma... |
class FixInquiry < ActiveRecord::Migration[5.1]
def change
rename_column :inquiries, :company_function, :first_name
add_column :inquiries, :last_name, :string
end
end
|
module ActivityService
extend self
def current_user
Proc.new{ |controller, model| controller.current_user }
end
def system_admin
Proc.new{ |controller, model| Admin.new(id: 0) }
end
end
|
module SubdomainRoutes
module TestUnitMatcher
class Base
class TestCase < ActionController::TestCase
end
def initialize(count_method, messages, spec)
@count_method, @messages, @spec = count_method, messages, spec
end
def run_test(target)
result = Test::Uni... |
json.listers do
json.partial! 'api/v1/listers/show', collection: @listers, as: :lister
end
|
class JsonController < ApplicationController
before_filter :fill_variables
def index
render :json => @records
end
def show
@record = @records.find(params[:id])
render :json => @record
end
def create
record = @model.new(params[get_record_key])
record = prepare_record record
if reco... |
require "rails_helper"
require 'float'
RSpec.describe "Корзина", :type => :model do
before do
@order = FactoryGirl.create(:order)
@product = FactoryGirl.create(:product)
end
it 'Создание корзины и проверка правильной генерации номера заказа :number' do
10.times do
FactoryGirl.create(:order)
... |
require "rails_helper"
RSpec.describe Comic, type: :model do
let(:category) {FactoryBot.create :category}
subject {FactoryBot.create :comic, category_id: category.id}
context "Create" do
it {is_expected.to be_valid}
end
context "Database" do
it {is_expected.to have_db_column(:name).of_type :string}... |
class NvsSubsystemsController < ApplicationController
before_filter :find_project, :prepare_combos
before_filter :authorize
before_filter :get_related_projects , :except => [:index, :new, :destroy, :create]
# GET /nvs_subsystems
# GET /nvs_subsystems.json
def index
@nvs_subsystems = NvsSubsystem.all
... |
class SecurityCodesPdfPrinter
include Sidekiq::Worker
sidekiq_options retry: false
def perform(user_ids)
users = User.find(user_ids)
# create an instance of ActionView, so we can use the render method outside of a controller
av = ActionView::Base.new()
av.view_paths = ActionController::Base.view_pa... |
require 'test_helper'
class GenreableTest < ActiveSupport::TestCase
def setup
@song = songs(:one_love)
super
end
test "should set genres" do
reggae = genres(:reggae)
assert_difference "Genre.count", 1, "Didn't create new genre" do
@song.genre = "#{reggae}, Roots reggae"
end
roots_reggae = Genre.f... |
require_relative 'student'
require_relative 'course'
@students = Array.new
@courses = Array.new
@student_courses = Hash.new
def print_menu(option)
if option == "Y"
system 'clear'
end
puts "*********************************"
puts "Enter a selection from the menu: "
puts "**************... |
class WordChains
def initialize('dictionary.txt')
@dictionary = File.readlines('dictionary.txt').chomp |
require 'packman'
require 'packman/web_settings'
require 'thor'
class Packman::CLI < Thor
map ["-v", "--version"] => :version
desc "settings", "Generate the funpack settings"
def settings
check_funpackfile!
settings = Packman::WebSettings.generate(funpackfile)
$stdout.puts JSON.pretty_generate(sett... |
# Question 1
10.times { |number| puts (" " * number) + "The Flintstones Rock!" }
# Question 2
statement = "The Flintstones Rock"
result = {}
letters = ('A'..'Z').to_a + ('a'..'z').to_a
letters.each do |letter|
letter_frequency = statement.scan(letter).count
result[letter] = letter_frequency if letter_fre... |
# frozen_string_literal: true
module SolidusPaysafe
class PaymentMethod < ::Spree::PaymentMethod::CreditCard
preference :api_key, :string
preference :api_secret, :string
preference :account_number, :string
preference :single_use_token_key, :string
preference :single_use_token_secret, :string
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_devise_params, if: :devise_controller?
before_action :authenticate_user!, unless: :devise_controller?
private
def configure_devise_params
devise_parameter_sanitizer.permit(:sign_up, key... |
require 'spec_helper'
require 'rake'
require 'csv'
require 'active_record'
describe Player do
pending "add some examples to (or delete) #{__FILE__}"
end
describe Player do
before(:each) do
@attr = { :playerID => "aaronha01", :birthYear => 1934, :nameFirst => "Hank", :nameLast => "Aaron" }
end
it "shou... |
class AddDateAndDaytimeToPeople < ActiveRecord::Migration
def change
add_column :people, :date, :date
add_column :people, :datetime, :datetime
end
end
|
# ------------ Models ----------------
Question.create({
text: "Name a super model",
answer: "Jeff Bowne",
difficulty: 0,
topic: 0
})
Question.create({
text: "Up to how many models can a rails app have?",
answer: " virtually infinitely many ",
difficulty: 0,
topic: 0
})
Que... |
module Legion
module Transport
class Exchange < Legion::Transport::CONNECTOR::Exchange
include Legion::Transport::Common
def initialize(exchange = exchange_name, options = {})
@options = options
@type = options[:type] || default_type
if Legion::Transport::TYPE == 'march_hare'
... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Events
describe Aliases do
let(:described) { Vedeu::Events::Aliases }
before { described.reset! }
describe '.add' do
let(:alias_name) { :alias_test }
let(:event_name) { :event_test }
subject {... |
Puppet::Functions.create_function(:'example::azure_subscription_id') do
def azure_subscription_id
ENV['azure_subscription_id']
end
end
|
module WiKey
module Views
# view object for a single wiki's topic
class Subject
def initialize(topic)
@topic = topic
end
def topic
@topic.topic
end
def link_to_topic_default
"/topic/#{topic}"
end
end
end
end |
# config valid only for current version of Capistrano
lock '3.6.0'
set :application, 'ronaldchacon'
set :repo_url, 'git@github.com:ronaldchacon/ronaldchacon.git'
set :rbenv_type, :user
set :rbenv_ruby, '2.3.1'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path... |
require_relative 'spec_helper'
describe Robot do
before :each do
Robot.class_variable_set :@@robot_list, []
@robot_array = []
5.times {@robot_array << Robot.new}
#[0] at (0,1)
1.times {@robot_array[0].move_up}
#[1] at (0, -1)
1.times {@robot_array[1].move_down}
#[2] at (-1, 0)
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe EarningRulePresenter do
subject { EarningRulePresenter.new(earning_rule, earning_rule) }
describe '#name' do
let(:earning_rule) { double(name: 'Order') }
it 'returns Name' do
expect(subject.name).to eq earning_rule.name
end
... |
class HomeMailer < ApplicationMailer
def send_contact_email(email_name,email_address,email_message)
@email_name = email_name
@email_address = email_address
@email_message = email_message
mail(to: "mckibben@att.net", subject: "Contact from WorldPz")
end
end |
require 'test_helper'
class RecipeMenuItemsControllerTest < ActionController::TestCase
setup do
@recipe_menu_item = recipe_menu_items(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:recipe_menu_items)
end
test "should get new" do
get :new... |
#Interval Search in RlogN time where R is the number of intersections
class Noder
attr_accessor :lo, :hi, :left, :right, :red, :highest
def initialize(lo,hi,highest,red=false)
@lo = lo
@hi = hi
@left = nil
@right = nil
@highest = highest
@red = red
end
end
class IntervalSearcher
attr_ac... |
require 'test_helper'
class TbpostTest < ActiveSupport::TestCase
def setup
@user = users(:bryan)
@tbpost = Tbpost.new(content: "Lorem ipsum", user_id: @user.id)
end
test "should be valid" do
assert @tbpost.valid?
end
test "user id should be present" do
@tbpost.user_id = nil
assert_not ... |
module ApplicationHelper
def breadcrumps
links = [['HOME', root_path]]
if @category
if @category.new_record?
links << ["New category", new_category_path]
else
links << [@category.name, @category]
end
end
if @topic
if @topic.new_record?
links << ["New top... |
# JSON Pointer
module Nidyx
class Pointer
attr_reader :source, :path
def initialize(str)
match = /^(?<source>.*)#\/*(?<path>.*)$/.match(str)
@source = match[:source]
@path = match[:path].split("/")
end
def to_s
puts "source: #{source}"
puts "path: #{path}"
end
end... |
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# determine which list has a higher start value
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
def merge_two_lists(l1, l2)
... |
# Simple base class for all resource provider classes.
class RubyAdmin::Resource::Provider
attr_reader :resource
def initialize(resource)
@resource = resource
end
end
|
require_relative '../spec_helper.rb'
include Bitcoin
include Builder
class Array
def stringify_keys
map do |e|
(e.is_a?(Array) || e.is_a?(Hash)) ? e.stringify_keys : e
end
end
end
class Hash
def stringify_keys
Hash[map do |k, v|
v = v.stringify_keys if v.is_a?(Hash) || v.is_a?(Array)
... |
require_relative "movie_collection"
require_relative "cash"
require "money"
class Theatre
include Cash::Cashable
def initialize(filename)
@movies = MovieCollection.new(filename)
@filename = filename
@balance = 25
end
def show(time)
if time >= 9.00 && time < 12.00
@movies.all.select { |m... |
module Eshealth
# This factory is used to communicate with Elasticsearch
#
class Requestfactory
def self.build(type,options={})
case type
when "FakeRequest" then FakeRequest.new(options)
when "HttpRequest" then HttpRequest.new(options)
end
end
def fetch(path,params={})
... |
require 'rails_helper'
RSpec.describe Transaction, type: :model do
describe 'validations' do
it { should define_enum_for(:result).with_values(failed: 0, success: 1) }
it { should validate_presence_of(:credit_card_number) }
it { should validate_numericality_of(:credit_card_number) }
it { should valida... |
class ProjectmodesController < ApplicationController
def index
@projectmodes = Projectmode.paginate(:page => params[:page]).order(:id)
respond_to do |format|
format.html
format.csv { send_data @projectmodes.as_csv }
end
end
def new
@projectmode = Projectmode.new
end
def create
@projectmo... |
class Node
include Comparable
attr_accessor :value, :left, :right
def initialize(value = nil, left = nil, right = nil)
@value = value
@left = left
@right = right
end
def add_left(value)
@left = Node.new(value)
end
def add_right(value)
@right = Node.new(value)
end
def <=>(other)... |
require 'rspec'
require 'rack'
require 'thin'
require 'nokogiri'
require 'restclient'
require 'fileutils'
require './lib/upton'
describe Upton do
before :all do
#start the server
class Server
def call(env)
@root = File.expand_path(File.dirname(__FILE__))
path = Rack::Utils.unescape(env[... |
class Project < ApplicationRecord
has_many :todos
has_many :users, through: :todos
validates :name, presence: true
validates :name, uniqueness: true, on: :create
accepts_nested_attributes_for :todos, allow_destroy: true
end
|
class AddSelfReferenceToCloudFile < ActiveRecord::Migration
def change
add_column :cloud_files, :parent_id, :integer
end
end
|
class Channel < ApplicationRecord
validates :title, presence: true
belongs_to :server
has_many :messages
has_many :users,
through: :messages,
source: :user
belongs_to :dm_server,
foreign_key: :dm_id,
class_name: "Server",
optional: true
end |
# # encoding: utf-8
# The Inspec reference, with examples and extensive documentation, can be
# found at http://inspec.io/docs/reference/resources/
# Make sure the hab-sup process is running
describe processes(Regexp.new('hab-sup run')) do
it { should exist }
end
# Make sure the consul process is running
describe ... |
#!/usr/local/bin/ruby
# RTsingle - ReTweet a single account to your twitter feed. Uses oldschool RT @user.
$:.unshift "."
require 'twitter'
require 'credentials' # put your API keys in here
client = Twitter::REST::Client.new do |config|
config.consumer_key = APIKEY
config.consumer_secret = APISECRET
config.acces... |
# frozen_string_literal: true
FactoryGirl.define do
factory :subcategory do
sequence(:name) { |n| Faker::Pokemon.name + n.to_s }
category
end
end
|
class FontCoveredByYourGrace < Formula
head "https://github.com/google/fonts/raw/main/ofl/coveredbyyourgrace/CoveredByYourGrace.ttf", verified: "github.com/google/fonts/"
desc "Covered By Your Grace"
homepage "https://fonts.google.com/specimen/Covered+By+Your+Grace"
def install
(share/"fonts").install "Cove... |
# Problem 382: Generating polygons
# http://projecteuler.net/problem=382
#
# A polygon is a flat shape consisting of straight line segments that are joined to form a closed chain or circuit. A polygon consists of at least three sides and does not self-intersect.
#
#
#
# A set S of positive numbers is said to gener... |
Rails.application.routes.draw do
post '/d/create', to: 'db#create'
get '/d/:uid', to: 'db#show', as: 'db'
resources :db, :path => 'd', :only => [:new]
get 'stocks.json', to: "db#stocks", as: 'stocks'
get 'about', to: 'db#about'
root 'db#index'
end
|
json.array!(@notifications) do |notification|
json.extract! notification, :id, :created_at #, :rules
if notification.notifyable_type == 'Collaboration'
json.type 'Collaboration'
json.actor do
profile = notification.notifyable.submission.profile
json.id profile.id
json.type profile.c... |
require 'test_helper'
class TextStylesControllerTest < ActionDispatch::IntegrationTest
setup do
@text_style = text_styles(:one)
end
test "should get index" do
get text_styles_url
assert_response :success
end
test "should get new" do
get new_text_style_url
assert_response :success
end
... |
require "helper"
class TestCommandGuesser < Minitest::Test
def self.should_guess_command_name(expectation, *argv)
argv.each do |args|
should "return '#{expectation}' for '#{args}'" do
SimpleCov::CommandGuesser.original_run_command = args
assert_equal expectation, SimpleCov::CommandGuesser.g... |
#!/usr/bin/env ruby
require 'easy_start'
require 'optparse'
require 'active_support/all'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: easy_start [options]"
opts.on('-a', '--add add', 'Add new project') do |add|
options['project_name'] = add;
end
opts.on('-p', '--path path', 'path, should be... |
require 'data_mapper'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, ENV["DATABASE_URL"] || "sqlite:students.db")
class Students
include DataMapper::Resource
property :firstname, String
property :lastname, String
property :birthday, Date
property :address, String
property :student_id, Serial... |
require 'cloudformation_mapper/resource'
class CloudformationMapper::Resource::AwsPropertiesElasticacheCacheCluster < CloudformationMapper::Resource
register_type 'AWS::ElastiCache::CacheCluster'
type 'Template'
parameter do
type 'Template'
name :Properties
parameter do
type 'Boolean'
... |
require './employee'
class Department
attr_reader :name
attr_accessor :employees
def initialize(name, employees = [])
@name = name
@employees = employees
end
def add_employee(employee)
employees << employee
end
def total_salary
employees.map {|emp| emp.salary}.reduce(:+)
end
def ... |
require 'rspec'
describe 'My behaviour' do
it 'should do something' do
end
end
# can push code in before each to page objects and call from there
# page object is an abstract class
# each page object is its own class - each page on the webapp corresponds to one page
# each succeeding page inherits from basepage... |
require_relative '../test_helper'
require 'hquery-patient-api'
class HqmfJavascriptTest < Minitest::Test
def setup
# Open a path to all of our fixtures
model = JSON.parse(File.open("test/fixtures/NQF59New.json").read)
doc = HQMF::Document.from_json(model)
codes_file_path = File.expand_path("../../fi... |
class RockPaperScissorsController < ApplicationController
def new
@rock_paper_scissors = secret_numbers
end
def show
@rock_paper_scissors = secret_numbers.sample
@chosen_number = params[:id].to_i
@winner = is_winner?
end
private
def secret_numbers
(0..2).to_a
end
def is_winner?
... |
=begin
You are given a text. Write a program which outputs its lines according to the following rules:
If line length is ≤ 55 characters, print it without any changes.
If the line length is > 55 characters, change it as follows:
Trim the line to 40 characters.
If there are spaces ‘ ’ in the resulting string, trim it o... |
class AddTitleAndJobTitleAndCountryAndStateAndCityAndCategoryIdToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :title, :string
add_column :users, :job_title, :string
add_column :users, :country, :string
add_column :users, :state, :string
add_column :users, :city, :string
a... |
class EventMailer < ActionMailer::Base
def invitation(current_user, email, event)
@event = event
@current_user = current_user
mail(to: email,
from: "services@eventhop.com",
subject: "Invitation from eventhop"
)
end
end
|
def roll_call_dwarves(dwarves)
i = 1
dwarves.each do |dwarf|
puts "#{i}. #{dwarf}"
i += 1
end
end
def summon_captain_planet(planeteer_calls)
planeteer_calls.collect do |planeteer_call|
"#{planeteer_call.capitalize()}!"
end
end
def long_planeteer_calls(planeteer_calls)
planeteer_calls.... |
require "pry"
def consolidate_cart(cart)
new_cart = {}
cart.each do |item|
count = cart.count(item)
new_cart[item.keys[0]] = item.values[0]
new_cart[item.keys[0]][:count] = count
end
new_cart
end
def apply_coupons(cart, coupons)
new_cart = cart.clone
cart.each do |item, attributes|
coupons.eac... |
module Invitable
extend ActiveSupport::Concern
def invitations_received
ProjectInvitation.where(recipient_user_id: self.id)
end
def open_invitations_received
invitations_received.eligible_for_response
end
def invitations_sent
ProjectInvitation.joins(:project).where("projects.user_id = ?", sel... |
class MainSalesController < ApplicationController
def update
@variant = Variant.find(params[:variant_id])
session_cart.change_main_sale(@variant, most_likely_user)
redirect_to preorders_url(:anchor => 'order-summary')
end
end
|
class ApplicationLayoutPage
include Capybara::DSL
def initialize
@sign_in_link = "a#sign_in"
@sign_up_link = "a#sign_up"
@sign_out_link = "a#sign_out"
@user_profile_link = "a#edit_user_profile"
end
def has_sign_in_link?
has_css? @sign_in_link
end
def has_sign_up_link?
has_css... |
json.episodes do
json.extract! @episode, :id, :anime_id, :title, :genre
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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?
#
# Example:
#
# makeNegative(1); # return -1
# makeNegative(-5); # return -5
# makeNegative(0); # return 0
# Notes:
#
# The number can be negative already, in which case no change is required.
# Z... |
class ProvidersController < ApplicationController
before_filter :find_provider, :only => [:connect, :connect_callback, :album, :albums]
def connect
connect_action = :"connect_#{@provider_code}"
if self.respond_to?(connect_action, include_private=true)
self.send(connect_action)
else
Rails.lo... |
require 'spec_helper'
describe Page do
before :each do
@page = Factory.create(:page)
end
describe "sections" do
it "should parse page html content" do
@page.content = <<-EOS
<html>
<body>
<div class='editfu'><h1>Hello, <b>World</b>!</h1></div>
</body>
... |
class SitesController < ApplicationController
before_filter :authenticate_all!, :only => [:index]
before_filter :authenticate_owner!, :except => [:index, :ls]
before_filter :find_site, :only => [:show, :edit, :update, :destroy]
before_filter :redirect_from_cookie, :only => [:index]
def index
@sites = cur... |
# -*- coding: utf-8 -*-
module SiteDesign
module Susanoo
module PageView
extend ActiveSupport::Concern
#
# === 使用するテンプレートのパスを返す
#
def set_templates
if top?
# トップページ
return "/susanoo/visitors/top/show"
else
# その他のページ
if @engine... |
class User < ApplicationRecord
belongs_to :group, optional: true
has_many :containers
# has_many :items, through: :containers
has_many :items
has_secure_password
validates :username, presence: true, uniqueness: true
#! 1
def titlecase_name
self.username.titlecase
end
... |
require 'spec_helper'
describe Topic do
it "has a valid factory" do
FactoryGirl.create(:topic).should be_valid
end
it "is invalid without a title" do
FactoryGirl.build(:topic, title: nil).should_not be_valid
end
it "is invalid with a short title" do
FactoryGirl.build(:topic, title: "a").should_no... |
class Sponsorship < ActiveRecord::Base
has_many :transactions, class_name: 'SponsoredTransaction', foreign_key: "sponsorship_id"
monetize :amount_per_party_cents
monetize :total_amount_cents
def amount_sponsored
Money.new(transactions.sum(:amount_cents))
end
end |
class PlanningConfirmationComment < ActiveRecord::Base
unloadable
belongs_to :planning_confirmation
belongs_to :user
scope :kgips, -> {where(:confirmation_type => 0)}
scope :heads, -> {where(:confirmation_type => 1)}
end
|
class FontKawkabMono < Formula
version "0.501"
sha256 "11c06f57dddefaf0166d74caaa072865ab6ff8d34076e7ec5d2c20edda145666"
url "https://github.com/aiaf/kawkab-mono/releases/download/v#{version}/kawkab-mono-#{version}.zip", verified: "github.com/aiaf/kawkab-mono/"
desc "Kawkab Mono"
homepage "https://makkuk.com/... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
###########################################################################
### PORTALGUN #############################################################
###########################################################################
# As time goes on we will adjust these helpers to b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.