text stringlengths 10 2.61M |
|---|
module DamperRepairReport
class TabularBreakdownPage
include Report::RepairDataPageWritable
def initialize(records, damper_type, building_section, tech)
@records = records
@damper_type = damper_type
@building_section = building_section
@tech = tech
end
def write(pdf)
... |
class AddUserRefToPost < ActiveRecord::Migration[5.0]
def change
add_column :posts, :user, :refernces
end
end
|
class ArrowFiredNotifier < Struct.new(:from_user_id,:to_user_id)
def perform
from_user = User.find(from_user_id)
to_user = User.find(to_user_id)
Notifications::arrow_fired(from_user,to_user).deliver
end
end
|
class ShiftListsController < ApplicationController
before_action :set_q2, only: [:index, :search]
def index
@staff = Staff.where(user_id: current_user.id)
end
def search
@results = @q.result.where(user_id: current_user.id)
end
private
def set_q2
@q = Shift.ransack(params[:q])
end
end
|
require 'rails_helper'
RSpec.describe ChildrenController, type: :controller do
describe "children#new action" do
before :each do
@user = FactoryGirl.create(:user)
@school = FactoryGirl.create(:school)
@family = FactoryGirl.create(:family)
end
it "should successfully show the new f... |
#!/usr/bin/env ruby
# encoding: utf-8
require "bunny"
require_relative "../config/rabbitmq"
conn = Bunny.new(Config::RabbitMQ::CONF)
conn.start
ch = conn.create_channel
class FibonacciServer
def initialize(ch)
@ch = ch
end
def start(queue_name)
@q = @ch.queue(queue_name)
@x = @ch.default_exchange... |
class ApplicantsController < ApplicationController
before_action :require_login, only: [:edit, :background_check, :background_check_confirm]
before_action :require_background_check_confirmed, only: [:background_check, :background_check_confirm]
def new
@applicant = Applicant.new
end
def create
@appl... |
require "net/http"
require "json"
require "pry"
require "dotenv"
class OnConnect
def initialize(zip_code, date = Date.today)
@zip_code = zip_code
@date = date
@data = api_call(@zip_code, @date)
end
def showtimes
all_movies = []
@data.each do |movie|
movie_info = movie['title']
mo... |
FactoryBot.define do
factory :user, aliases: [:owner] do
provider { 'github' }
sequence(:uid) { |i| i }
sequence(:name) { |i| "ユーザー#{format('%03d', i)}" }
sequence(:image_url) { |i| "http://example.com/image_#{i}.jpg" }
end
end
|
class CreateBuchungOnline < ActiveRecord::Migration
def self.up
create_table(:BuchungOnline, :primary_key => :id) do |t|
#ID PS
t.integer :id, :uniqueness => true, :limit => 10, :null => false
#Mnr FS
t.integer :mnr, :uniqueness => true, :limit => 10, :null => false
#Überweisungsdatum
t.date ... |
require "./lib/victory_checker"
describe 'VictoryChecker' do
let(:victory_checker) { VictoryChecker.new }
let(:board) { Board.new }
context "Computer player makes winning move" do
it "should determine that the Computer Player has won" do
board.grid = {1 => 'O', 2 => 'O', 3 => 'X',
4 =>... |
RSpec.describe Zenform::FileCache do
let(:project_path) { File.expand_path "../fixtures/", File.dirname(__FILE__) }
let(:cache_path) { File.expand_path file_name, project_path }
let(:file_name) { Zenform::FileCache::FILENAME % { content_name: content_name } }
let(:content_name) { "test" }
after do
F... |
class Cohort < ApplicationRecord
# belongs_to :lead, class_name: "User"
has_many :students, foreign_key: "cohort_id", class_name: "User"
has_many :projects, through: :students
end
|
class CatRentalRequest < ActiveRecord::Base
validates :status, inclusion: { in: %w(PENDING APPROVED DENIED),
message: "%{ value } is not a valid status"}
# validate :overlapping_approved_requests
belongs_to :cat
def overlapping_approved_requests
binds = { start_date: self.start_date, end_date: sel... |
require ('Message')
require ('pry')
require ('rspec')
describe('#Message') do
before(:each) do
Board.clear()
Message.clear()
@board = Board.new({:name => "music", :id => nil})
@board.save()
end
describe('.clear') do
it('clears all messages') do
message = Message.new({:text => "music... |
a = "bob"
case a
when /b$/
puts "it ends with b"
when /^b/
puts "it starts with b"
when "bob"
puts "its the word bob"
else
puts "it doesnt match any of these terms"
end
|
require 'spec_helper'
describe ProjectsController do
before do
@user = mock_current_user
controller.stub(:current_user).and_return(@user)
end
describe '#index' do
it "lists user's projects" do
@user.should_receive(:projects).and_return([mock_model(Project)])
get :index
response.sho... |
class ProjectComment < ApplicationRecord
belongs_to :user
belongs_to :project
has_paper_trail
validates :content, presence: true
end
|
# frozen_string_literal: true
require "renalware"
require "dotenv-rails"
module Renalware
module Diaverum
def self.table_name_prefix
"renalware_diaverum."
end
class Engine < ::Rails::Engine
isolate_namespace Renalware::Diaverum
initializer :append_migrations do |app|
# Preven... |
RSpec.describe Overrider do
RSpec::Matchers.define :ensure_trace_point_disable do
match do |klass|
klass.instance_variable_get("@__overrider_trace_point").nil? &&
klass.instance_variable_get("@__overrider_singleton_trace_point").nil?
end
failure_message do
"trace_point cleared"
en... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Error::Parser do
let(:parser) do
described_class.new(document)
end
describe '#message' do
context 'when the document contains no error message' do
let(:document) do
{ 'ok' => 1 }
end
it '... |
class AddToAuthentications < ActiveRecord::Migration[5.0]
def change
add_column :authentications, :lti_user_id, :string
add_index :authentications, :lti_user_id
end
end
|
class PdfsController < ApplicationController
def show
@pdf = Pdf.find_by_slug(params[:id]);
redirect_to @pdf.file.url
end
end
|
class Lead < ApplicationRecord
belongs_to :user, optional: true
validates :name, presence: true
validates :email, presence: true, format: { with: /\A.*@.*\.\S*\z/ }
validates :user, presence: true
validates :phone, presence: true
validates :source, presence: true
validates :html, presence: true
validat... |
# 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... |
require 'test_helper'
require 'nokogiri'
describe Jekyll::Haml::Markup do
before do
options = {}
options['source'] = source_dir('sites', 'fake')
@destination = Dir.mktmpdir 'fake', dest_dir
options['destination'] = @destination
config = Jekyll::Configuration::DEFAULTS.merge options
@site = fi... |
# REPOS
command :create_repo do |c|
c.syntax = 'archivesspace-cli create_repo [options]'
c.summary = ''
c.description = 'Create a repository'
c.example 'create repository TEST',
'./archivesspace-cli create_repo --repo_code=test --name="Test Archives" --contact="John Doe"'
c.option '--repo_code STRING', S... |
require File.dirname(__FILE__) + '/test_helper.rb'
class TestCountryCode54 < Test::Unit::TestCase
context "A Buenos Aires phone number" do
setup { @phone_number = PhoneNumber.new("54-11-4444-3333") }
area_code_should_be "11"
city_should_be "Buenos Aires"
country_code_should_be "54"
country_sho... |
require 'mongoid'
module Mongoid #:nodoc:
module MagicCounterCache
extend ActiveSupport::Concern
module ClassMethods
def counter_cache(*args, &block)
options = args.extract_options!
name = options[:class] || args.first.to_s
if options[:field]
counter_name = "#{o... |
class Aluno < ActiveRecord::Base
belongs_to :curso
require 'csv'
validates :nome, presence:true
validates :email, presence:true
validates :nota_enade, presence:true
def self.import(file)
CSV.foreach(file.path, headers:true) do |row|
aluno = find_by_id(row["id"]) || new
aluno.attribut... |
require '../ruby_setup'
require './buses'
describe WaitInterval do
describe "#wait_time" do
describe "when arrival_time is 0" do
before(:each) do
@arrival_time = 0
end
describe "and start_time is 0.20" do
before(:each) do
@start_time = 0.20
@wait_interval = ... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2009-2020 MongoDB 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
#
# U... |
class CreateBills < ActiveRecord::Migration[6.0]
def change
create_table :bills do |t|
t.integer :workspace_id
t.string :name
t.integer :bill_type
t.float :amount
t.float :actual_amount
t.integer :cargo_category_id
t.integer :count
t.date :billed_at
t.timesta... |
require 'wsdl_mapper_testing/schema_test'
module WsdlMapperTesting
class GenerationTest < SchemaTest
def setup
@tmp_path = TestHelper.get_tmp_path
end
def teardown
@tmp_path.unlink
end
def tmp_path
@tmp_path
end
def path_for(*name)
tmp_path.join(*name)
end
... |
class CreateEdgeAes < ActiveRecord::Migration
def change
create_table :edge_aes do |t|
t.integer :actor_id
t.integer :event_id
t.integer :kind
t.timestamps
end
end
end
|
include_recipe 'apt' if platform?('ubuntu')
node.override['mysql']['bind_address'] = '0.0.0.0'
node.override['mysql']['server_root_password'] = 'root'
include_recipe 'mysql::server'
node.override['sonarqube-mysql']['mysql']['host'] = 'localhost'
node.override['sonarqube-mysql']['mysql']['username'] = 'root'
node.over... |
class Bind < ActiveRecord::Base
belongs_to :user
belongs_to :project
validates_presence_of :user, :project
validates_uniqueness_of :user_id, :scope => [:project_id, :kind]
symbolize :kind, :in => [:watch, :owner, :dev]
end
# == Schema Information
#
# Table name: binds
#
# id :integer not ... |
#
# Be sure to run `pod lib lint NAME.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = "BayeuxClient"
s.version = "0.1.1"
s.summar... |
require "test_helper"
describe OrderItem do
# it "does a thing" do
# value(1+1).must_equal 2
# end
describe "validations" do
before do
@item = order_items(:oi1)
end
it "must be connected to a product" do
product = Product.find_by(id: @item.product_id)
expect(product).must_be_in... |
module Moip
module Header
def default_header json = nil
header = {}
header.merge! :basic_auth => auth
header.merge! :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
header.merge! :body => json if json
header
end
def auth
@auth ||= {:username => Moip.config.... |
class TopicsController < ApplicationController
before_action :set_topic, only: [:show, :edit, :update, :destroy]
def index
@topic = Topic.all
end
def show
@reference = @topic.references.new
end
def new
@topic = Topic.new
end
def create
@topic = Topic.new(params.require(:topic).permit(:title, :descri... |
class CreateResearchDirectionUsers < ActiveRecord::Migration
def change
create_table :research_direction_users do |t|
t.integer :research_direction_id
t.integer :user_id
t.timestamps
end
end
end
|
class List < ActiveRecord::Base
# has_paper_trail
extend FriendlyId
friendly_id :title, use: :slugged
include Ownable
has_many :list_items, lambda { order(position: :asc) }, dependent: :destroy
belongs_to :user
# Override friendly_id's original slug generation for not downcasing original characters.
... |
require 'rails_helper'
RSpec.describe Comment, :type => :model do
before do
@comment = Comment.create(commenter_id: 1,commentable_id: 1, commentable_type: "photo", text: "comment")
@user = User.create(name: "Jonathan", email_address: "jonyoungg@gmail.com", password: "123456", password_confirmation: "123456")... |
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "NdcTree::Node searching" do
subject { NdcTree << %w{ 913.6 913.6 914 400 007 515 } }
it {
result = subject["913.6"]
result.should be_instance_of NdcTree::Node
result.name.should == "913.6"
result.weight.should == 2
}
... |
module MWS
module API
# The Amazon MWS Products API helps you get information to match your
# products to existing product listings on Amazon Marketplace websites and
# to make sourcing and pricing decisions for listing those products on
# Amazon Marketplace websites.
#
# The Amazon MWS Produc... |
class Tool < ActiveRecord::Base
belongs_to :user
has_many :reservations
has_attached_file :image, :styles => { :medium => "300x300>",
:thumb => "100x100>" },
:storage => :s3,
:bucket => '... |
class InviteMailer < ApplicationMailer
def invitation(github_member, current_user)
@user = current_user
@github_member = github_member
mail(to: github_member.email, subject: 'Turing Tutorial Invitation')
end
end |
class Cart < ApplicationRecord
belongs_to :user
has_many :selected_items, dependent: :destroy, counter_cache: :items_count
has_many :items, through: :selected_items, class_name: 'AccessoryItem'
# Adds the specified AccessoryItem to Cart
#
# @param [AccessoryItem] item The AccessoryItem to be added in... |
class RemoveAnnouncementFromAnnouncements < ActiveRecord::Migration
def change
remove_column :announcements, :announcement, :string
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
file_to_disk1 = '/home//storage1.vdi'
file_to_disk2 = '/home//storage2.vdi'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is don... |
#!/usr/bin/env ruby
require 'contentful/moderator'
STDOUT.sync = true
trap('TERM') do
puts "Graceful shutdown"
exit
end
def usage
puts "Usage: contentful_moderator <configuration_file>"
end
if ARGV.empty?
usage
exit(1)
end
if ['-h', '-H', '--help'].include?(ARGV.first)
usage
exit(0)
end
if File.fi... |
class StylesheetSweeper < ActionController::Caching::Sweeper
observe Stylesheet
def after_update(asset)
expire_cache_for asset if asset.type == 'Stylesheet'
end
def after_destroy(asset)
expire_cache_for asset if asset.type == 'Stylesheet'
end
private
def expire_cache_for(record)
... |
require 'sequel'
existing_methods = Sequel::Dataset::Pagination.instance_methods
Sequel::Dataset::Pagination.module_eval do
# it should quack like a WillPaginate::Collection
alias :total_pages :page_count unless existing_methods.include? 'total_pages'
alias :per_page :page_size unless existing_meth... |
# == Schema Information
#
# Table name: movies
#
# id :integer not null, primary key
# description :text
# duration :integer
# image :string
# title :string
# year :integer
# created_at :datetime not null
# updated_at :datetime not null
# director_id :i... |
class ProjectsStatisticsService
def initialize(project)
@project = project
@statistics_for_phase = {}
@overall_stat = Hash.new(0)
end
def count_statistics
if @statistics_for_phase.empty?
PhaseType.all.each do |phase|
time_logs = @project.time_logs.where(phase_type: phase)
... |
require 'open-uri'
require 'nokogiri'
require 'date'
require 'line-notify-client'
require_relative 'contribution_count/version'
require_relative 'contribution_count/client'
module ContributionCount
class Error < StandardError; end
def self.new(account_name)
ContributionCount::Client.new(account_name)
end
e... |
module HomeHelper
def to_euro(amount, currency)
return btc_to_euro(amount) if currency == 'BTC'
return ltc_to_euro(amount) if currency == 'LTC'
bch_to_euro(amount) if currency == 'BCH'
end
def btc_to_euro(amount)
round_income(amount * Currency.bitcoin_rate, 8)
end
def ltc_to_euro(amount)
... |
class EvaluateTargetController < BaseController
before_filter :authenticate_user!
def create
create_params
country = Country.where(country_code: params[:country_code]).first
if country
panel_provider_id = country.panel_provider_id
panel_provider_price_service = Pan... |
require 'rails_helper'
describe Api::V1::ProjectsController, type: :controller do
context 'POST #create' do
before(:each) do
@user = FactoryGirl.create(:user)
@organization = FactoryGirl.create(:organization)
@project = {
name: 'Test',
description: 'Test create project',
... |
class CreateCallslots < ActiveRecord::Migration
def change
create_table :callslots do |t|
t.integer :user_id
t.date :starts_on
t.date :ends_on
t.time :starts_at
t.time :ends_at
t.integer :frequency
t.integer :f_day
t.integer ... |
require 'spec_helper'
describe 'nexus::postconfig' do
let(:default_parameters) {
{
'nexus_root' => '/nexus/root',
'admin_password' => 'some_password',
'enable_anonymous_access' => false,
'initialize_passwords' => true
}
}
context 'with default parameters'... |
require 'rails_helper'
RSpec.describe Comment, type: :model do
before do
@comment = FactoryBot.build(:comment)
end
describe 'コメントする' do
context 'コメントできる時' do
it 'textが存在する時' do
expect(@comment).to be_valid
end
end
context 'コメントできない時' do
it 'textが空の時コメントできない' do
... |
require 'singleton'
def Option val
(not val.nil?) ? Some.new(val) : None
end
class Option
include Enumerable
include Comparable
end
class None < Option
include Singleton
def self.get
raise "None has no value"
end
# can either take a normal argument or a block if laziness is desired
def self... |
class AddFeatureOnHomepageToProject < ActiveRecord::Migration
def change
add_column :projects, :feature_on_homepage, :boolean
add_index :projects, :feature_on_homepage
end
end
|
require_relative '../../../defaults'
require_relative '../action_item'
require 'fileutils'
module Simp; end
class Simp::Cli; end
module Simp::Cli::Config
class Item::WarnLockoutRiskAction < ActionItem
attr_accessor :warning_file
attr_reader :warning_message
def initialize(puppet_env_info = DEFAULT_PUPPE... |
module Fog
module Compute
class Google
class Mock
def insert_image(_image_name, _image = {})
# :no-coverage:
Fog::Mock.not_implemented
# :no-coverage:
end
end
class Real
def insert_image(image_name, image = {}, project = @project)
... |
class Project < ActiveRecord::Base
attr_accessible :due_date, :name
validates_presence_of :name
has_many :tasks
#has_many :users
#has_one :teams
def progress_in_percentage
return (completed_task_by_project.to_f /
total_assigned_tasks_by_project.to_f ) * 100
end
def completed_task_by_project
... |
class RemoveColumnImgUrlFromDogsTable < ActiveRecord::Migration[5.2]
def change
remove_column :dogs, :img_url
end
end
|
######################################################################
# Copyright (c) 2008-2014, Alliance for Sustainable Energy.
# All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by th... |
class SubmissionMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.submission_mailer.new_submission_notification.subject
#
def new_submission_notification(submission)
@submission = submission
reviewers = Reviewer.all
... |
Quando("faço uma requisão POST sem enviar dados") do
body_sem_dados()
@response = JSON.parse(@consulta_idwall.Consulta.body)
end
Então("recebo o código {string} e a mensagem {string}") do |codigo, mensagem|
expect(@response["message"]).to eql mensagem
expect(@response["status_code"].to_s).... |
#encoding: utf-8
module Refinery
module Fg
class Student < Refinery::Core::BaseModel
attr_accessible :name, :address, :email, :qq, :msn, :know_from, :leave_message, :tel, :profession_id,
:staying, :grade, :study_class, :interest, :job, :avatar, :avatar_id, :feedback, :position,
... |
# require '../librerias/bcrypt/crypt'
require_relative 'crypt'
class Student
include Crypt # incluye los métodos del módulo Crypt
# insertar getters y setters automaticamente
attr_accessor :first_name, :last_name, :email, :username, :password
# insertar solo getters
# attr_reader :username
... |
require "clustering/ai4r_modifications"
require 'csv'
module ClusteringModule
class GeneticErrorClustering
attr_accessor :last_run_stats
=begin
def initialize(prosumers: Prosumer.all,
startDate: Time.now - 1.week,
endDate: Time.now,
algorithm:... |
class EmailBuilder
EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/
WHITESPACE = /\s+/
DELIMITERS = /[\n,;]+/
def initialize(attributes)
@recipients = attributes[:recipients] || ''
end
def invalid_recipients
recipient_list.map do |item|
unless item.match(EMAIL_REGEX)
item
... |
# frozen_string_literal: true
class MessageCreateWorker
include Sidekiq::Worker
sidekiq_options queue: :message_create
def perform(chat_id, message_number, body)
@chat = Message.create(chat_id: chat_id, message_number: message_number, body: body)
if @chat.save
puts "Saved"
else
puts ... |
class AddVideoAndDescriptionAndSubtitlesToSlides < ActiveRecord::Migration[5.0]
def change
add_column :slides, :video, :string
add_column :slides, :description, :text
add_column :slides, :subtitles, :string
end
end
|
require_relative '../bank.rb'
describe Bank do
describe "#add_account" do
let(:bank){ Bank.new }
it "should create an account with the given value" do
bank.add_account("Paul", 200)
expect(bank.account_value("Paul")).to eq 200
end
it "should prevent duplicate account names" do
bank... |
require 'test_helper'
require 'mocha'
class MathHotSpotErrorsTest < ActionView::TestCase
test "message.display" do
msg = MathHotSpotErrors::Message.display(MathHotSpotErrors::ProblemReplacementErrors::UNIQUE_PROBLEM_REPLACE_ERROR.new)
assert_equal MathHotSpotErrors::Message::UNIQUE, msg
end
test "Emp... |
require 'csv'
class Transaction < ApplicationRecord
belongs_to :user
before_create :generate_id
self.per_page = 10
def generate_id
begin
self.transaction_id = SecureRandom.hex
end while Transaction.where(transaction_id: transaction_id).exists?
end
def self.to_csv(options = {})
CSV.generate... |
cities = {
"London" => { "country" => "England", "monument" => "Big Ben" },
"Paris" => { "country" => "France", "monument" => "Tour Eiffel" }
}
cities["Paris"]["monument"]
"name" # This is a string
:name # This is a symbol
# Having symbols as keys
cities = {
:London => { :country => "England", :monument => "B... |
require_relative "../github_client"
require_relative "./update_version"
class UpdatePackage
include Sidekiq::Worker
include GithubClient
def perform(full_name)
puts "Updating: #{full_name}"
# List all files in tree
client.tree(full_name, "gh-pages").tree.each do |file|
if match_data = file["pa... |
class OrdersController < ApplicationController
include ActionView::Helpers::NumberHelper
load_and_authorize_resource :order, except: :confirm_payment
helper_method :sort_column, :sort_direction, :pool_sort_column
def index
if current_admin
@orders = current_admin.orders.order(sort_column + ' ' + so... |
require 'test_helper'
class ApiControllerTest < ActionDispatch::IntegrationTest
test "should get error response" do
post api_path, params: { "asd" => { "kek" => "000" } }, as: :json
assert_equal JSON.parse(@response.body), { "error" => "JSON validation failed" }
end
test "should get booking response" do... |
require 'card'
describe Card do
def card(params = {})
defaults = {
suit: :hearts,
rank: 7,
}
Card.new(**defaults.merge(params))
end
it 'has a suit' do
raise unless card(suit: :spades).suit == :spades
end
it 'has a rank' do
raise unless card(rank: :queen).rank == 12
e... |
# 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... |
class Word < ActiveRecord::Base
belongs_to :List
def record
"#{correct_guess_count}/#{guess_count}"
end
def streak
return "n/a" if streak_type.nil?
"#{streak_type}#{streak_count}"
end
def guessed_correctly
self.guess_count += 1
self.correct_guess_count += 1
if self.streak_type == ... |
class TextFieldForm < Form
@@name = TextField.new("Purchase", :required=>true)
@@cost = TextField.new("Cost", :required=>true)
def redefine_defaults
{ :wrapper => :div, :wrapper_attributes => {:class => :field}, :hash_wrapper => :purchase }
end
def cleaned_cost(cost)
cost = cost.to_i
raise Field... |
require 'rails_helper'
RSpec.describe 'Profiles', type: :request do
let!(:user) { create(:user, :with_profile) }
describe 'GET /profiles' do
context 'ログインしている場合' do
before do
sign_in user
end
it 'レスポンスが正常に表示' do
get profile_path
expect(response).to render_template('pr... |
require 'spec_helper'
describe SessionsController do
let(:user_attrs) { { email: "me@example.com", password: "testing123" } }
let!(:user) { User.create(user_attrs) }
context "sign in" do
it "should create a session" do
post :create, user_attrs
expect(session[:user_id]).to eq user.id
end
en... |
require 'test_helper'
class UserStoriesTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
LineItem.delete_all
Order.delete_all
ruby_book = products(:ruby)
get '/'
assert_response :success
assert_template "index"
post_via_redirect "/orders",
order: {name: "Ka... |
class AchievementCategoriesController < ApplicationController
before_action :require_administrator
before_action :set_achievement_category, only: [:show, :edit, :update,:destroy]
def index
@achievement_categories = AchievementCategory.order(:name)
end
def show
end
def new
@achievement_category = AchievementCateg... |
class Menu < ApplicationRecord
belongs_to :chef, class_name: 'User', foreign_key: :user_id
has_many :menu_selections
has_many :menu_items, through: :menu_selections
validates :start_date, presence: true
def self.add_menu_items(item_ids)
end
end
|
class DayChip < ApplicationRecord
belongs_to :user ,foreign_key: [:id], optional: true
end
|
require 'rails_helper'
RSpec.describe Event, type: :model do
let(:event) { FactoryGirl.build(:event) }
it 'is valid with a valid title, description, location, start time, and end time' do
expect(event).to be_valid
end
it 'is not valid with a missing title' do
event.title = nil
expect(event).to_no... |
require 'boxzooka/list_request'
module Boxzooka
# The InboundDiscrepancy data set is used by Boxzooka to provide you with information about
# discrepancies between what your Inbound notifications declared, and what we actually received.
class InboundDiscrepancyListRequest < ListRequest
root node_name: 'Inbou... |
require 'yaml'
class S3Wrapper
class Profile
attr_accessor :name, :aws_access_key, :aws_secret_key, :bucket_name, :host_name
CONFIG_FILE = '.s3-wrapper.rc'
def self.config_default(params)
self::create('default', params)
end
def self.create(name, params)
config = read_config(name, fa... |
class UserDecorator
include ActionView::Helpers::DateHelper
attr_reader :user
def initialize(user)
@user = user
end
def simple_decorate
{
:average_rating => average_rating,
:client => @user.client?,
:country => country,
:email => email,
:first_name => first_name,
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
def destroy
@djoker.destroy
respond_to do |format|
format.html { redirect_to djoques_url, notice: "Votre Djoque à bi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.