text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
class Category < ApplicationRecord
has_many :subscriptions
has_many :feeds, through: :subscriptions, source: 'feed'
has_many :users, through: :subscriptions
accepts_nested_attributes_for :subscriptions
scope(:for_nav, -> { order('name ASC') })
validates :name, presence: tru... |
#! /usr/bin/ruby
# factorial.rb displays factorial of n
#
# Completed by: David Choi
#
# Input: n, an integer
# Precondition: n >= 1
# Output: n!
if __FILE__ == $0
print "To calculate n!, enter n: "
n = gets.chomp.to_f
answer = 1
for i in 2..n
answer = answer * i
end
puts "The factorial... |
# == Schema Information
#
# Table name: post_contents
#
# id :bigint(8) not null, primary key
# content :text(65535)
# post_id :bigint(8)
# type :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
FactoryBot.define do
factory :contents, clas... |
class CreateOrder < ActiveRecord::Migration
def change
create_table :orders do |t|
t.float :global_price, :null => false
t.integer :customer_id, :null => false
#date
t.timestamps
end
add_index :orders, :customer_id
end
end
|
class Article < ApplicationRecord
has_many :article_categories
has_many :categories, through: :article_categories
has_many :user_articles
has_many :users, through: :user_articles
has_many :comments
has_many :likes
validates :title, presence: true, length: (3..128)
validates :content, presence: true, ... |
# == Schema Information
#
# Table name: characters
#
# id :integer not null, primary key
# movie_id :integer
# actor_id :integer
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
require 'rails_helper'
describe 'Character' do
it "valida... |
#
# Vagrant Configuration for GitHub Pages Rebuilder
#
default_box = "almalinux/9"
name = "website-rebuilder"
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-vbguest")
# Don't allow upgrades; the box has what it has.
config.vbguest.auto_update = false
end
# Basic configur... |
# frozen_string_literal: true
class Client::Api::V1::ClientsController < ApplicationController
before_action :authenticate_client!
def current
render json: ClientSerializer.new(current_user).serialized_json
end
end
|
require 'rails_helper'
RSpec.describe "EditUser", type: :request do
it "editing user banning him and sending him an email" do
@user = create(:editor)
@admin = create(:admin)
# p @user.id
# p @user.first_name
# p @admin.id
# p @admin.first_name
visit new_user_session_path
fill_in "Email", :... |
class SaferRawSQL
# The formats refer to the format of message
# There are two formats a client can use to exchange messages with a PostgreSQL server (text or binary).
# TEXT_FORMAT = 0
# BINARY_FORMAT = 1
##
# You must be using the PostgreSQL database to use this method because it
# relies on PostgreSQL... |
class EmailSerializer < ActiveModel::Serializer
attributes :id, :references, :email_status, :email_type
end
|
require 'rails_helper'
describe Movie do
it "all_ratings" do
expect(Movie.all_ratings).to eq %w(G PG PG-13 NC-17 R)
end
it "find_movie_with_same_director happy case" do
movie = Movie.new :director=>"happy"
moviedouble1 = double :director => "happy"
moviedouble2 = double :director => "hap... |
class RoadTripFacade
attr_reader :origin,
:destination,
:travel_time,
:arrival_forecast,
:id
def initialize(info)
@origin = info[:origin]
@destination = info[:destination]
@travel_time = fetch_travel_time
@arrival_forecast = fetch_arrival_fore... |
NS_MAP = {
'daitss' => "http://www.fcla.edu/dls/md/daitss/",
'premis' => 'info:lc/xmlns/premis-v2',
'mets' => 'http://www.loc.gov/METS/',
'xsi' => "http://www.w3.org/2001/XMLSchema-instance",
'xlink' => 'http://www.w3.org/1999/xlink'
}
Spec::Matchers.define :generate_a_valid_sip do
match do |rxp|
... |
class CookingRecipeCli::Recipe
attr_reader :author, :name, :detail_url, :ingredients, :directions
@@all = []
def initialize(name, author_name, detail_url)
@name = name
self.author=(author_name)
@detail_url = detail_url
@ingredients = []
@directions = []
save
... |
class ChangeTasksType < ActiveRecord::Migration
TYPES = [
%w{Task::Records::Action action},
%w{Task::Records::Project project},
]
class Task < ActiveRecord::Base
set_inheritance_column nil
end
def up
Task.all.each do |task|
task.update_column :type, TYPES.assoc(task.type)[1]
end
... |
require 'spec_helper'
describe ProductThickness do
let(:product_thickness) { FactoryGirl.create(:product_thickness) }
subject { product_thickness }
describe "validations" do
it { should be_an_instance_of(ProductThickness) }
it { should be_valid }
it { should validate_presence_of(:name) }
it { s... |
#!/usr/bin/env ruby
require "rvg/rvg"
include Magick
RVG::dpi = 72
# base function for making an image with a circle
# yields to block to allow further transformation of the circle
def draw_circle
RVG.new(2.5.in, 2.5.in).viewbox(0,0,250,250) do |canvas|
canvas.background_fill = 'white'
circle = canvas.circ... |
class AddInvitedAtToUsers < ActiveRecord::Migration
def self.up
add_column :users, :invited_at, :datetime
update %{ UPDATE users SET invited_at = created_at WHERE invited_at IS NULL }
end
def self.down
remove_column :users, :invited_at
end
end
|
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 6379, host: 6379
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/redis.yml"
ansible.host_key_checking = false
end
end
|
class DashboardController < ApplicationController
before_filter :current_user
def show
@resturants = Resturant.where(user_id: current_user.id).all
@ratings = Rating.where(user_id: current_user.id).all
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 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 EventSearchesController < ApplicationController
def new
end
def create
@event_search = EventSearch.create(event_search_params)
if @event_search.save
redirect_to event_search_path(@event_search)
else
render :new, notice: "Please fill out all form details"
end
end
def show
... |
class Subject < ApplicationRecord
has_many :course_subjects, dependent: :destroy
has_many :courses, through: :course_subjects
has_many :tasks, dependent: :destroy
has_many :user_subjects, dependent: :destroy
has_many :users, through: :user_subjects
accepts_nested_attributes_for :tasks, allow_destroy: true
... |
# frozen_string_literal: true
# Author: Usman Ahmad
require 'date'
require_relative '../lib/calendar'
describe Cal::Event, '#==' do
context 'attributes of both events are the same' do
date = Date.iso8601('2020-01-20')
event1 = Cal::Event.new('An event', 'This is an event', date)
event2 = Cal::Event.new... |
json.data do
json.user do
json.call(
@user,
:id,
:name,
:email,
:uid,
)
end
end
|
class CreateWines < ActiveRecord::Migration
def change
create_table :wines do |t|
t.string :name , limit: 100 ,null: false
t.references :country
t.references :localregion
t.decimal :svg_x , precision: 8, scale: 5 , null: false
t.decimal :svg_y , precision: 8, scale: 5 , null: false
... |
class AddKindToNotes < ActiveRecord::Migration
def change
add_column :notes, :kind, :string, default: 'note'
end
end
|
module Kantox
module Chronoscope
# Dummy module to be used in production-like environments.
module Generic
COLOR_VIVID = "\033[#{Kantox::Chronoscope.kungfuig.colors!.vivid || '01;38;05;226'}m".freeze
COLOR_PALE = "\033[#{Kantox::Chronoscope.kungfuig.colors!.pale || '01;38;05;178'}m".freeze
... |
Shindo.tests('Fog::Compute::DigitalOceanV2 | list_flavors request', ['digitalocean', 'compute']) do
service = Fog::Compute.new(:provider => 'DigitalOcean', :version => 'V2')
size_format = {
'slug' => String,
'memory' => Integer,
'vcpus' => Integer,
'disk' => Integer,
'transfer' => Float,
'p... |
class DocumentParserWorker < BaseWorker
def perform(document_id)
unless document = Document.find_by_id(document_id)
log "No document Fetched using document_id - #{document_id}"
return
end
log "document_id - #{document.id} - \n\
Parsing #{document.document_type} document \n\
schoo... |
include ActionView::Helpers::NumberHelper # to pass a display value to a javascript function that adds characters to view
require 'tempfile'
require 'open-uri'
require 'fileutils'
require 'net/http'
require Rails.root.join('app', 'uploaders', 'binary_uploader.rb')
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE... |
RSpec.describe Tasks::Crud do
let(:now) { Time.now }
let(:seven_days_from_now) { Time.now + 7.days }
let(:agent) { FactoryGirl.create(:agent) }
let(:created_task) { FactoryGirl.create(:task) }
let(:create_params) do
{
name: 'ttt1', path: '/sdsf/', arguments: 'f f', start_time: now,
end_time:... |
class AddLastConfirmedFreeAtToParkingSpots < ActiveRecord::Migration[5.2]
def change
add_column :parking_spots, :last_confirmed_free_at, :datetime
end
end
|
class SquaresController < ApplicationController
before_action :authenticate_request!
def index
get_project_squares
end
def show
get_square
end
def create
new_square
end
def update
update_square
end
# def destroy
# delete_square
# end
private
def get_project_squares
if check_subs... |
class CreateProductTags < ActiveRecord::Migration[5.2]
def change
create_table :product_tags, id: false do |t|
t.integer :product_id, index: true
t.integer :tag_id, index: true
t.timestamps
end
add_index(:product_tags, [:product_id, :tag_id])
end
end
|
require 'rails_helper'
describe 'factory url' do
describe 'with popularities' do
before(:all) do
@url_with_popularities = FactoryGirl.create(:url_with_popularities)
end
let(:popularities){ @url_with_popularities.popularities }
let(:popularity){ popularities[0] }
it 'creates... |
class StorySerializer < ActiveModel::Serializer
attributes :name, :body
end |
# Preview all emails at http://localhost:3000/rails/mailers/employee_mailer
class EmployeeMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/employee_mailer/record_activation
def record_activation
EmployeeMailer.record_activation
end
end
|
require 'rails_helper'
RSpec.describe Fighter, :type => :model do
context "#alive?" do
let(:bruce) { FactoryGirl.create(:human_bruce_lee) }
it "should return true if healthy" do
expect(bruce.alive?).to be true
end
it "should return false if not healthy" do
bruce.take_damage bruce.re... |
module AcceptanceHelper
def sign_up
visit new_user_session_path
click_on 'Sign up'
end
def fill_password
fill_in 'Password', with: 12345678
fill_in 'Password confirmation', with: 12345678
end
def sign_in(user)
visit new_user_session_path
fill_in 'Email', with: user.email
fill_in ... |
# Virus Predictor
# I worked on this challenge [by myself, with: Allyse Groover].
# We spent [#3] hours on this challenge.
# EXPLANATION OF require_relative
# Require is an absolute path, require relative is a relative path
# Require means that Ruby will look in a predetermined location for the file specified
# Requi... |
task :email_delivered_stories => :environment do
reporter = DeliveredStoriesReport.new
Rails.logger.info "Finding Delivered Stories"
reporter.find_stories
reporter.print_stories
Rails.logger.info "Sending Email"
reporter.email_report
reporter.set_report_time
reporter.set_reported_stories
Rails.logger.... |
class UsersController < ApplicationController
load_and_authorize_resource
def index
@users = User.all
end
def show
@user = current_user
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
@user.update(user_params)
redirect_to(@user)
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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
require 'rails_helper'
RSpec.feature 'Display asset properties' do
let(:user) { create(:support_user, :third_line) }
let(:asset) { create(:asset) }
let(:bios_unlockable_asset) { create(:asset, :unlockable) }
let(:asset_page) { PageObjects::Assets::ShowPage.new }
let(:asset_attr_labels) do
[
'Asset ... |
class Admin::MenusController < Admin::ApplicationController
before_filter :find_menu, :except => [:index, :new, :index]
include Base
def new
@menu = Menu.new(params[:menu])
if request.get?
return render(:layout=> !request.xhr?)
end
if @menu.save
flash["notice"] = "保存成功!"
redirect_to_menu(... |
class RemoveUserIdFromDocument < ActiveRecord::Migration[5.1]
def up
remove_column :documents, :user_id
end
end
|
class TeachingsController < ApplicationController
before_filter :confirm_admin
def index
@teachings = Teaching.order('semester').page(params[:page]).per(10)
end
def new
@teaching = Teaching.new
end
def edit
@teaching = Teaching.find(params[:id])
end
def create
@teaching = Teaching.n... |
class AddingActionsToUserPages < ActiveRecord::Migration
def up
add_column :users, :username, :string
add_index :users, :username, unique: true
remove_column :user_pages, :favorited
remove_column :user_pages, :archived
add_column :user_pages, :shared, :datetime
add_column :user_pages... |
class Users::SubscriptionsController < ::ApplicationController
layout 'user'
before_action :authenticate_user!
before_action :load_subscription, only: [:show, :cancel]
before_action :check_subscription_active, only: :cancel
before_action :check_reason_provided, only: :cancel
def index
@subscriptions = ... |
class OrangeTree
def initialize
@age = 0
@height = 1
@oranges = 0
end
def height
if @height == 1
puts 'Orange tree is 1 foot tall.'
else
puts 'Orange tree is ' + @height.to_s + ' feet tall.'
end
end
def oneYearPasses
@age = @age + 1
@height = @height + 1
@oran... |
class Question < ActiveRecord::Base
has_many :answers
has_many :results
end
|
class Users::AssetsController < ApplicationController
include SlugRedirectable
before_action :authenticate_user!, only: [:create, :update, :destroy, :import_from_furaffinity]
before_action :find_user, only: [:index, :create, :update, :destroy]
before_action :set_asset, only: [:show, :update, :destroy]
def ... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :check_if_logged_in, :except => ['login']
protected
def check_if_logged_in
if session[:user].... |
INSTALL = <<-SCRIPT
apt-get install -y software-properties-common
apt-add-repository -y ppa:ansible/ansible
apt-get update
apt-get install -y ansible
ansible-playbook /opt/beam/vagrant/playbook.yml -e main_user=vagrant -c local -i /opt/beam/vagrant/inventory
SCRIPT
Vagrant.configure(2) do |config|
config.vm.box = "u... |
require 'spec_helper'
describe Event do
let(:event) { create(:event) }
it 'provides end_date' do
expect(event.end_date).to be > event.date
end
context 'validation' do
it 'is valid' do
expect(event).to be_valid
end
it 'validates uniqueness' do
expect(build(:event, name: event.name... |
class Responder < ActiveRecord::Base
self.inheritance_column = nil
validates :capacity, presence: true, numericality: {only_integer: true,
greater_than_or_equal_to: 1,
less_than_or_equal_to: 5,
... |
class CommentsController < ApplicationController
load_and_authorize_resource
def create
@candidate = Candidate.find(params[:candidate_id])
@comment = @candidate.comments.build(comment_params)
@comment.user_id = current_user.id
if @comment.save
flash[:notice]= "Comment Saved. Thanks!"
redirect_to job_c... |
# clean_up_the_words.rb
# Given a string that consists of some words and an assortment of non-
# alphabetic characters, write a method that returns that string with all of
# the non-alphabetic characters replaced by spaces. If one or more non-
# alphabetic characters occur in a row, you should only have one space in th... |
class RegistrationsController < Devise::RegistrationsController
def login=(username_or_email)
@username_or_email = username_or_email
end
def login
@username_or_email || self.username || self.email
end
end |
require_relative "../lib/sudoku_solver"
describe "SudokuSolver" do
let(:puzzle) {[
[0, 4, 0, 8, 0, 7, 0, 0, 2],
[1, 0, 8, 9, 4, 0, 7, 5, 0],
[3, 2, 0, 6, 0, 0, 0, 9, 0],
[0, 9, 0, 0, 0, 3, 8, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[7, 0, 5, 4, 0, 0, 0, 3, 0],
[0, 5, 0, 0, 0, 4... |
require 'gooddata'
require 'prettyprint'
require 'optparse'
require "json"
require_relative('lib/core/metadata')
#
#
# Simple example
# 126102 Hard Example with custom metric
#
# Notes
# Twilio Flex Insights Solution uses GoodData platform for
# GoodData workspaces contain dashboards, reports, definition, attributes, ... |
class OrdersController < ApplicationController
def indexByUser
@orders = current_user.orders
render json: @orders , each_serializer: OrdersSerializer
end
def indexBySeller
@orders = Order.where(:seller_id => current_user.id)
render json: @orders , each_serializer: OrdersS... |
class Pawn < Piece
SYMBOL = ['♙', '♟']
def moves
dir = (@color ? 1 : -1)
single, double = [dir, 0], [dir * 2, 0]
m = if @board.get(rel(single))
[]
elsif @moved || @board.get(rel(double))
[single]
else
[single, double]
end
[[dir, 1], [dir, -1]]... |
require_relative './init'
require_relative '../helpers/notifications/zero_push_notification_handler'
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
describe NotificationHandler do
def setup_logger
log_instance_double = double('logger instance')
allow(log_instance_double).to re... |
class Item < ApplicationRecord
has_many :category_items
has_many :categories, through: :category_items
has_many :customer_items
has_many :customers, through: :customer_items
accepts_nested_attributes_for :categories
scope :order_by_name, -> { order(name: :asc)}
end
|
class AliasedInterpretationsController < ApplicationController
before_action :set_owner
before_action :set_agent
before_action :check_user_rights
def index
referrer = Rails.application.routes.recognize_path(URI(request.referer).path)
@user_comes_from_index = referrer[:action] == 'index'
if referre... |
#
# Tests de la class Mail
#
require 'spec_helper'
require_in_other_class 'mail'
describe Mail do
# -------------------------------------------------------------------
# Mail
# -------------------------------------------------------------------
describe "La classe" do
it "doit répondre à :send" do
Mail... |
require "rails_helper"
feature "visitor viewing loans" do
include_context("features")
scenario "can view loans" do
visit "/loans"
within(".header") do
expect(page).to have_content("Loans")
end
within(".loans") do
expect(page).to have_content("test title")
expect(page).to have_con... |
require 'spec_helper'
describe LicensePresenter, :type => :view do
let(:license) { License.instance }
before do
stub.proxy(license).[](anything)
end
let(:presenter) { LicensePresenter.new(license, view, {}) }
let(:hash) { presenter.to_hash }
let(:sample) do
{
:admins => 5,
:developers... |
require 'spec_helper'
require 'rails_helper'
require 'webmock/rspec'
feature 'User views homepage' do
scenario 'sucess' do
visit root_path
expect(page).to have_headline_text
end
private
def have_headline_text
have_text ('Values of Currency')
end
end
|
class Answer < ApplicationRecord
default_scope { order(accepted: :desc, created_at: :asc) }
belongs_to :user
belongs_to :question
validates :body, presence: true
def accept!
transaction do
question.answers.where(accepted: true).update(accepted: false)
update(accepted: true)
end
end
en... |
# models/cohort.rb
class Cohort < ActiveRecord::Base
# allows .students method to be called on instance of cohort
has_many :students # <= method call!
end |
unless Capistrano::Configuration.respond_to?(:instance)
abort "This extension requires Capistrano 2"
end
Capistrano::Configuration.instance.load do
namespace :deploy do
namespace :timestamp do
desc "Copies the timestamp template to the public directory."
task :create, :except => { :no_release => t... |
module RecipesHelper
# convert prep_time(minutes) to "hour(s), minute(s)" format
def time_converter(time_in_minutes)
hours = time_in_minutes / 60
minutes = time_in_minutes % 60
hours_string = ""
minutes_string = ""
# format hour
hours == 1 ? (hours_string = "1 hour") : (hours_string = "#{... |
# frozen_string_literal: true
require 'spec_helper'
require 'uri'
describe SFRest::Task do
before :each do
@conn = SFRest.new "http://#{@mock_endpoint}", @mock_user, @mock_pass
define_task_statuses
# @running_statuses = [SFRest::Task::STATUS_WAITING,
# SFRest::Task::STATUS_IN_PR... |
require 'test/unit'
require_relative 'bowling_game'
class BowlingGameTest < Test::Unit::TestCase
@@perfect_game = BowlingGame.new("XXXXXXXXXXXX")
@@nine_and_miss = BowlingGame.new("9-9-9-9-9-9-9-9-9-9-")
@@threes_and_fours = BowlingGame.new("34343434343434343434")
@@five_to_spare = BowlingGame.new("5/5/... |
class AddProfileableToStocks < ActiveRecord::Migration
def change
add_reference :stocks, :profileable, polymorphic: true, index: true
end
end
|
# frozen_string_literal: true
RSpec.shared_examples_for Dry::Logic::Rule do
let(:arity) { 2 }
let(:predicate) { double(:predicate, arity: arity, name: predicate_name) }
let(:rule_type) { described_class }
let(:predicate_name) { :good? }
describe "#arity" do
it "returns its predicate arity" do
rule... |
class AddTimeStamps < ActiveRecord::Migration[5.2]
def change
add_timestamps :users, null: false
add_timestamps :follows, null: false
add_timestamps :comments, null: false
add_timestamps :likes, null: false
add_timestamps :photos, null: false
end
end
|
class Startup
attr_accessor :name
attr_reader :founder_name, :domain
@@all = []
def initialize(name,founder_name, domain)
@name = name
@founder_name = founder_name
@domain = domain
@@all << self
end
def self.all
@@all
end
def pivot(new_domain, n... |
require 'rails_helper'
RSpec.describe TripActivity, type: :model do
it 'joins a trip and activity together via id' do
activity = FactoryGirl.create(:activity)
trip = FactoryGirl.create(:trip)
trip_activity = TripActivity.new
trip_activity.trip_id = trip.id
trip_activity.activity_id = activity.id... |
set :deploy_to, "/home/app_user/www/glico/staging/"
set :user, "app_user"
role :app, "114.80.203.77"
role :web, "114.80.203.77"
role :db, "114.80.203.77", :primary => true
# tasks
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
task :stop, :roles => :app... |
# Test bastion setting
sshd_service = 'sshd'
sshd_service = 'ssh' if os.family == "debian"
sshd_configfile = '/etc/ssh/sshd_config'
bastion_shell = '/usr/bin/bastion/shell'
control 'bastion-01' do
impact 1.0
title 'sshd service'
desc 'sshd service should be started'
describe service(sshd_service) do
it ... |
class Team < ActiveRecord::Base
has_many :players
has_many :users, :through => :players
belongs_to :game
accepts_nested_attributes_for :players, :allow_destroy => true
end
|
# Problem 162: Hexadecimal numbers
# http://projecteuler.net/problem=162
# In the hexadecimal number system numbers are represented using 16 different digits:
# 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
# The hexadecimal number AF when written in the decimal number system equals 10x16+15=175.
# In the 3-digit hexadecimal numbe... |
Sidekiq.configure_server do |config|
schedule_file = 'config/sidekiq_schedule.yml'
if File.exist?(schedule_file) && Sidekiq.server?
Sidekiq::Cron::Job.load_from_hash! YAML.load_file(schedule_file)
puts 'schedule loaded'
StartScrapingWorker.perform_async
end
end
|
require "application_system_test_case"
class AgentsShowTest < ApplicationSystemTestCase
test "Navigation to agent show" do
admin_go_to_agents_index
click_link "My awesome weather bot admin/weather"
assert has_text?("admin/weather")
assert has_text?("Sharing overview")
assert_equal "/agents/admin... |
class BookingsController < ApplicationController
skip_before_action :authenticate_user!, only: [:index, :show]
before_action :set_tuxedo, only: [:new, :create, :show, :edit, :index, :destroy]
before_action :set_booking, only: [:show, :edit, :update, :destroy]
def index
@bookings = current_user.bookings
e... |
Rails.application.routes.draw do
mount AccountProfile::Engine, at: '/profile', as: 'account_profile'
mount AccountAuthentication::Engine, at: '/account', as: 'account_auth'
mount KanbanBoardUi::Engine, at: '/projects', as: 'kanban_board'
root to: 'kanban_board_ui/projects#index'
end
|
require 'spec_helper'
describe Feedback do
describe '#contact' do
it "should send an email from the desired sender" do
sender = 'bub@hub.com'
message = 'my happy message'
email = Feedback.contact(sender, message).deliver
ActionMailer::Base.deliveries.should_not be_empty
... |
class WithdrawalRequestObserver < ActiveRecord::Observer
def after_update request
if request.success?
WithdrawalRequestMailer.withdrawal_succeeded(request).deliver_now
elsif request.failure?
WithdrawalRequestMailer.withdrawal_failed(request).deliver_now
end
end
end |
# data structure containing the drivers and a detailed list of their rides
RIDE_SHARES = {
"DR0001": [
{
date: "3rd Feb 2016",
cost: 10,
rider: "RD0003",
rating: 3
},
{
date: "3rd Feb 2016",
cost: 30,
rider: "RD0015",
rating: 4
},
{
date: "5th... |
class Launch::Component::Topbar::Logo < Launch::Component
def html
link_to path do
content_tag :li, class: css_class do
content.html_safe
end
end
end
def css_classes
["logo"]
end
def required_attributes
[:path]
end
end |
class PolyTreeNode
attr_reader :parent
attr_accessor :value, :children
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(node)
self.parent.children.delete(self) if self.parent
# deletes itself from parent array
@parent... |
require 'rails_helper'
RSpec.describe Company do
describe 'validations' do
let(:company) { FactoryBot.create(:company) }
it 'validates name' do
company.name = ''
expect(company).to_not be_valid
expect(company.errors[:name]).to eq ["can't be blank"]
end
end
end
|
# frozen_string_literal: true
module Capybara
VERSION = '3.16.0'
end
|
# encoding: UTF-8
module CDI
module V1
module ContactForms
module Feedback
class CreateService < ContactForms::BaseCreateService
record_type ::FeedbackContactForm, alias_name: :feedback_contact
def contact_type
:feedback_contact_form
end
def re... |
class TodoDetail < Sequel::Model
plugin :validation_helpers
plugin :json_serializer
set_primary_key :todo_detail_id
one_to_many :bom_parent_items, class: :Bom, key: :parent_item_id
one_to_many :bom_child_items, class: :Bom, key: :child_item_id
one_to_many :onhand_quantities
def validate
super
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.