text stringlengths 10 2.61M |
|---|
# require 'rails_helper'
# require 'awesome_print'
# RSpec.describe SlotsController, type: :controller do
# let(:my_slot) { Slot.create! }
# before :each do
# load Rails.root + 'db/seeds.rb'
# my_slot.cards = Card.all
# end
# describe 'GET show' do
# it 'renders slot view' do
# get :show, i... |
require 'rails_helper'
RSpec.describe SupplyTeachers::SuppliersController, type: :controller do
login_st_buyer
describe 'GET master_vendors' do
let(:supplier) { build(:supply_teachers_supplier) }
let(:suppliers) { [supplier] }
before do
allow(SupplyTeachers::Supplier)
.to receive(:with_... |
require_relative '../modules/users_module.rb'
class AuthenticationController < ApplicationController
attr_reader :user_repository
def initialize(user_repository = UsersRepository.new)
@user_repository = user_repository
end
def login
begin
user = user_repository.get_one('email' => params[:email]... |
require 'fcm'
# FCMService.ping
# FCMService.new_listing_is_added
# FCMService.ask_renew_listing
# FCMService.new_hot_investments
class FCMService
attr_reader :fcm_client, :message, :user_device_ids
MAX_USER_IDS_PER_CALL = 1000
def initialize(user_device_ids, message)
@fcm_client = FCM.new(ENV['FCM_SERVER_... |
class ShiftsController < ApplicationController
before_action :set_shift, only: [:show, :edit, :update, :destroy]
before_action :check_login
authorize_resource
def index
unless current_user.role?(:employee)
@upcoming_shifts = Shift.upcoming.by_store.chronological.paginate(page: params[:page]).per_... |
require_relative "kele/version"
require_relative "kele/roadmap"
# dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'httparty'
module Kele
class Kele
require 'json'
include HTTParty
include Roadmap
base_uri "https://www.bloc.io/api/v1"
de... |
class AddBalanceToFond < ActiveRecord::Migration[5.0]
def change
add_column :fonds, :already_collected, :integer, default: 0
add_column :fonds, :full_price, :integer, default: 0
end
end
|
class Channel
include Mongoid::Document
field :name, type: String
field :shortname, type: String
has_many :mentions
# Add new mentions for this channel
def add_new_mentions(start_time, end_time)
topics_json = Faraday.get("http://livetopics.prototyping.bbc.co.uk/topics?from=#{start_time.iso8601}&to=#{en... |
class Post < ActiveRecord::Base
scope :active, -> { where(deleted: false) }
def destroy
update(deleted: true)
end
end
|
class AddUniquenessToAvailabilities < ActiveRecord::Migration[5.1]
def change
add_index :availabilities, [:user_id, :time_range_id, :day], unique: true
end
end
|
require 'rails_helper'
RSpec.describe Organ, type: :model do
it 'has a valid factory' do
expect(create :organ).to be_valid
end
describe 'Validations' do
it { should validate_presence_of :sphere_id }
it { should validate_presence_of :name }
it { should validate_presence_of :phone }
it { should validate_pr... |
module PictureConcern
extend ActiveSupport::Concern
included do
rails_admin do
navigation_label I18n.t(:products)
object_label_method do
:description
end
list do
field :name
field :description
field :created_at
field :updated_at
field :i... |
# time manipulation which doesn't break background threads
Before do
original_now = Time.method(:now)
@set_time = nil
Time.stub(:now) do
if @set_time
@set_time
else
original_now.call
end
end
end
def set_time new_time
@set_time = new_time
end
|
# frozen_string_literal: true
require 'sqlite3'
require_relative 'sqlite3/version'
class SlugDB
##
# SlugDB backed by SQLite3
class SQLite3
def initialize(file) # rubocop:disable Metrics/MethodLength
@sdb = ::SQLite3::Database.new(file)
@sdb.execute(
<<~SQL
CREATE TABLE IF NOT ... |
helpers do
include HTTParty
def venmo_auth_url
return "https://api.venmo.com/v1/oauth/authorize?client_id=#{ENV['VENMO_CLIENT_ID']}&scope=make_payments%20access_profile%20access_email%20access_phone%20access_balance&response_type=code"
end
def venmo_auth_code
return params[:code] if params[:code]
en... |
require 'rails_helper'
feature 'Comments' do
let!(:user) { FactoryGirl.create(:user) }
let!(:image) { FactoryGirl.create(:image, user_id: user.id) }
context 'user not logged in' do
scenario 'cannot add a comment to an image' do
visit "/images/#{image.id}"
click_button 'Create Comment'
exp... |
# purpose:
# build a release: tgz, gem, zip.. etc
#
# depends on:
# unzip (infozip-version)
# zip (infozip-version)
# tar (gnu-version)
# rubygems
#
# the .gem is different from .zip and .tar.gz, because
# neither MANIFEST nor install.rb is necessary.
require 'fileutils'
require 'find'
require 'rubygems'
require 'r... |
class Physical < ActiveRecord::Base
belongs_to :patient
belongs_to :characteristic
end
|
class UserAuthorizer < ApplicationAuthorizer
def self.updatable_by?(user)
user.has_role? :owner
end
def self.readable_by?(user)
user.has_role?(:admin) || user.has_role?(:owner)
end
def self.deletable_by?(user)
user.has_role? :owner
end
def updatable_by?(user)
resource == user
end
... |
## Add instance methods
Spree::Product.class_eval do
# has_one :coupon_active_date_range, :as => :rangeable, :class_name => Spree::DateRange
# has_one :coupon_valid_date_range, :as => :rangeable, :class_name => Spree::DateRange
# Constants
PROPERTY_TYPES = ["Bed and Breakfast", "Extended Stay", "Home Stay", "Gu... |
class Patient
attr_reader :id, :name, :birthday, :doctor_id
def initialize(args)
@id = args.fetch(:id){ nil }
@name = args[:name]
@birthday = args[:birthday]
@doctor_id = args[:doctor_id]
end
def save
result = DB.exec("INSERT INTO patients (name, birthday, doctor_id) VALUES ('#{@name}', '#... |
# 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... |
class PotentialDuplicate < ActiveRecord::Base
self.table_name = :potential_duplicates
self.primary_key = :potential_duplicate_id
belongs_to :person, foreign_key: "person_id"
has_many :duplicate_records, foreign_key: "potential_duplicate_id"
def create_duplicate(id)
DuplicateRecord.create(potent... |
# frozen_string_literal: true
require 'active_support'
module HexletCode
autoload :Record, 'hexlet_code/record.rb'
autoload :Builder, 'hexlet_code/builder.rb'
autoload :Template, 'hexlet_code/template.rb'
autoload :Elements, 'hexlet_code/elements.rb'
def self.form_for(model, options)
builder = Builder.... |
class PostsController < ApplicationController
def index
render json: Post.all.to_json
end
def create
render json: Post.create!(post_params.merge(user: current_user)).to_json
end
def new
render json: Post.new.to_json
end
private
def post_params
params.require(:post).permit(:title, :bo... |
class Collection < ActiveRecord::Base
include PublicActivity::Common
extend FriendlyId
friendly_id :name, use: :slugged
acts_as_commentable
acts_as_follower
acts_as_followable
acts_as_likeable
has_many :collectibles
has_many :documents, through: :collectibles
belongs_to :user
validates_p... |
class ListsController < ApplicationController
def index
@new_task = List.new
@all_tasks = List.order(created_at: :desc).all
end
def create
@new_task = List.new(list_params)
if @new_task.save
redirect_to root_path
end
end
private
def list_params
params.require(:list).permit(:ta... |
class AddExtstoreToCompany < ActiveRecord::Migration
def change
add_column :companies, :extstore, :boolean
end
end
|
# -*- coding: utf-8 -*-
=begin
Uma academia deseja fazer um senso entre seus clientes para descobrir o mais
alto, o mais baixo, a mais gordo e o mais magro, para isto você deve fazer um
programa que pergunte a cada um dos clientes da academia seu código, sua altura
e seu peso. O final da digitação de dados deve ser da... |
loop do
puts '>> How many output lines do you want? Enter a number >= 3 (Q to quit):'
answer = gets.chomp
break if answer.upcase == 'Q'
count = answer.to_i
if count >= 3
while count > 0
puts 'Launch School is the best!'
count -= 1
end
else
puts ">> That's not enough lines."
end
end... |
require 'spec_helper'
describe Artist do
it 'has a valid factory' do
FactoryGirl.create(:artist).should be_valid
end
it 'is invalid without a name' do
FactoryGirl.build(:invalid_name_artist).should_not be_valid
end
end |
class CreateReviewFormInstance < ActiveRecord::Migration
def self.up
create_table :review_form_instances do |t|
t.integer :review_form_id
t.string :title
t.integer :cubicle_id
t.integer :user_id
t.integer :account_id
t.timestamps
end
end
def self.down
drop_t... |
class Startup
attr_reader :founder, :name, :domain
@@all = []
def initialize(name, founder, domain)
@name = name
@founder = founder
@domain = domain
@@all << self
end
def pivot=(domain, name) #setter
@domain = domain
@name = name
end
def pivot(domain, name) #getter
@domai... |
Rails.application.routes.draw do
devise_for :authors
get 'comments/create'
resources :posts do
resources :comments, only: :create
end
root to: "posts#index"
end
|
after(:contexts) do
User.find_each do |user|
[
{
group: 'Abdominal',
exercises: [
{ name: 'Abdominal Dragão' },
{ name: 'Abdominal Polia' },
{ name: 'Abdominal Prancha' },
{ name: 'Abdominal Rodinha' },
{ name: 'Abdominal Vela' },
{... |
module TaskMaster
class CustomRequest < ActiveRecord::Base
STATUSES = {
1 => "NEW",
5 => "OPEN",
7 => "AWAITING_RESPONSE",
20 => "CLOSED",
21 => "EXPIRED"
}
serialize :custom_fields, JSON
serialize :responses, JSON
serialize :answers, JSON
serialize :messages,... |
# Extremely early stage implementation of Transcation Process API
module TransactionService::API
class Process
def get(community_id:, process_id: nil)
# TODO Move this logic to behind Store layer
result_data =
if process_id.nil?
TransactionProcess.where(community_id: community_id)... |
require 'json'
module LoyaltyConnect
class ParsedApiClient < ApiClient
def initialize oauth_wrapper, result_parser = JSON
@result_parser = result_parser
super(oauth_wrapper)
end
attr_reader :result_parser
def get(*args)
result_parser.parse(super)
end
def post(*args)
... |
require 'ship'
require 'destroyer'
describe Ship do
context 'has by default' do
it 'start position of A1' do
expect(subject.start_position).to eq "A1"
end
end
context 'can create a ship' do
it 'size 2' do
destroyer = Destroyer.new("A1")
expect(destroyer.size).to eq 2
end
end
e... |
#diveshop
require "spec_helper"
def login_as(user)
visit new_dive_shop_session_path
fill_in "dive_shop_email", :with => user.email
fill_in "dive_shop_password", :with => "password"
click_button "Sign in"
end
feature "Dive shop defining dive slots" do
fixtures :dive_shops, :boats, :operators
scenario "Di... |
class RemoveLastUpdateDateFromSnippets < ActiveRecord::Migration
def change
remove_column :snippets, :last_update_date, :date
end
end
|
module Swiftcore
module Swiftiply
# The BackendProtocol is the EventMachine::Connection subclass that
# handles the communications between Swiftiply and the backend process
# it is proxying to.
class BackendProtocol < EventMachine::Connection
attr_accessor :associate, :id
C0rnrn = "0\r\... |
class CreateApiKeys < ActiveRecord::Migration
def change
create_table :api_keys, id: false do |t|
t.string :key, unique: true, index: true
t.integer :fb_user_id, limit: 8, index: true
t.boolean :active, default: true
t.timestamps
end
end
end |
# Class for handling all things related to monit configuration for individual rails applications
#
# @param app [String] the name of the application
class MonitApp
# Read only accessors
attr_reader :app, :base_dir, :directory
# Initializer for the class
#
# @return [String] the name of the application
# ... |
feature 'Viewing bookmarks' do
scenario 'visiting the index page' do
visit('/')
expect(page).to have_content "Bookmark Manager"
end
end
feature 'viewing bookmark links' do
scenario 'viewing the bookmark links' do
visit('/')
click_button "Show Bookmarks"
expect(page).to have_content "Google Ch... |
# frozen_string_literal: true
json.set! :errors do
json.set! :message, "Not Found"
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 SchedulePresenter
attr_reader :dates, :talk_title, :display
def initialize(schedule, event)
event_dates = (event.start_date..event.end_date).to_a
@dates = prepare_dates(event_dates, schedule)
schedule_talk = schedule.talk
@talk_title = schedule_talk ? schedule_talk.title : ''
@display... |
Rails.application.routes.draw do
#get 'pages/home' alternative version to "pages#home"
# get 'pages/about' get "/about" => "pages#about" is a better way of writing
get "/about" => "pages#about"
get "/contact" => "pages#contact"
root "pages#home"
end
|
class Oauth < ApplicationRecord
belongs_to :user, inverse_of: :oauths
validates :user, presence: true
validates :uid, uniqueness: { scope: :provider }, presence: true
end
|
class AddDeliveryTrackingToExchange < ActiveRecord::Migration
def change
add_column :exchanges, :delivery_tracking, :string
end
end
|
require 'narp/node_extensions.rb'
require 'narp/sql/adapter.rb'
module Narp
module Hive
# This class handles the generation of the ddl and hql for for transforming
# flat files with Hive
class Adapter < ::Narp::Sql::Adapter
include MyAppAccessor
def set_options
"set hive.groupby.ord... |
Rails.application.routes.draw do
devise_for :users
get "/posts/article/:id/edit" => "posts#edit"
get "/posts/article/:id" => "posts#article"
get "/" => "posts#index"
get "/posts/index" => "posts#index"
get "/posts/new" => "posts#new"
post "/posts/create" => "posts#create"
patch "/posts/article/:id/upd... |
# frozen_string_literal: true
require 'bolt/task'
require 'bolt/transport/base'
module Bolt
module Transport
class Remote < Base
OPTIONS = {
"run-on" => "The proxy target that the task executes on."
}.freeze
# The options for the remote transport not defined.
def self.filter_opt... |
class Tramway::User::User < ::Tramway::Core::ApplicationRecord
has_secure_password #FIXME remove repeating from tramway-user
enumerize :role, in: [ :user, :admin ], default: :user
def admin?
role.admin?
end
end
|
require 'hpricot'
require 'rest_client'
require 'libxml'
module Seek
module JWS
BASE_URL = "#{Seek::Config.jws_online_root}/webMathematica/Examples/"
UPLOAD_URL = "#{Seek::Config.jws_online_root}/webMathematica/upload/uploadSBML.jsp"
class Builder
include APIHandling
def saved_dat_downloa... |
# === Define: collector_installer
#
# Manage your LogicMonitor collectors. (Client side)
# This resource type allows the provider to download and run an installer for a LogicMonitor collector on the local machine.
# Requires a collector to have been created for this device. (see collector resource type)
#
# === Paramet... |
class CustomizeController < ApplicationController
before_action :check_user
def new_list
authorize! :create, CatchwordList if params[:list][:type] == 'word'
authorize! :create, ObjectionList if params[:list][:type] == 'objection'
authorize! :create, RatingList if params[:list][:type] == 'rating'
@list = @compan... |
class Findutils < Package
desc 'The GNU Find Utilities are the basic directory searching utilities of the GNU operating system'
homepage 'https://www.gnu.org/software/findutils/'
url 'https://ftp.gnu.org/pub/gnu/findutils/findutils-${version}.tar.gz'
release version: '4.6.0', crystax_version: 3
build_copy ... |
require 'uuid_helper'
class User < ActiveRecord::Base
include UUIDHelper
nilify_blanks
set_primary_key :uuid
attr_accessible :email, :password, :remember_me, :role
devise :database_authenticatable, :lockable, :rememberable, :timeoutable, :token_authenticatable, :trackable
enum_attr :role, %w(admin basic ... |
require 'formula'
class QemuLinaro < Formula
homepage 'https://wiki.linaro.org/WorkingGroups/ToolChain/QEMU'
head 'git://git.linaro.org/qemu/qemu-linaro.git', :using => :git
url 'https://launchpad.net/qemu-linaro/trunk/2013.06/+download/qemu-linaro-1.5.0-2013.06.tar.gz'
md5 'd34ce93d7c5f6b6c8d2b903fd85378a4'
... |
class Campaign < ApplicationRecord
belongs_to :user
has_many :comments
has_many :donations
validates :title, :review, presence: true
validates :review, length: { maximum: 140 }
validates :goal, numericality: { greater_than: 0 }
#validates :ended_at, numericality: { greater_than_or_equal_to: Time.now, les... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
has_and_belongs_to_many :classrooms
# Students receive many ... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_attached_file :avatar, :styles => { :medium => "30... |
# web elements and functions for page
class DroppablePage
include Capybara::DSL
include RSpec::Matchers
include Capybara::RSpecMatchers
def initialize
@simple_tab = Element.new(:css, '#droppableExample-tab-simple')
@accept_tab = Element.new(:css, '#droppableExample-tab-accept')
@prevent_tab = Eleme... |
class CreateSkillRatings < ActiveRecord::Migration[5.0]
def change
create_table :skill_ratings do |t|
t.references :user, foreign_key: true
t.references :skill, foreign_key: true
t.decimal :rating, precision: 15, scale: 5, default: 0
t.timestamps
end
end
end
|
require 'test_helper'
class RevisionreviewsControllerTest < ActionController::TestCase
setup do
@revisionreview = revisionreviews(:one)
@user = users(:one)
@admin = users(:admin)
@tb = users(:tb)
end
test "should get index" do
sign_in(@admin)
get :index
assert_response :success
a... |
require 'yaml'
require 'nenv/environment/dumper'
RSpec.describe Nenv::Environment::Dumper do
subject { described_class.setup.(value) }
context "with \"abc\"" do
let(:value) { 'abc' }
it { is_expected.to eq('abc') }
end
context 'with 123' do
let(:value) { 123 }
it { is_expected.to eq('123') }... |
class Decaf < Beverage
attr_reader :description
def initialize
@description = "Decaf"
end
def cost
1.05
end
end
|
FactoryBot.define do
sequence(:email) { |n| "users#{n}@example.com"}
factory :user do
email
password "123456"
first_name "Dact"
last_name "Tory"
admin false
end
factory :admin, class: User do
email
password "qwerty"
admin true
first_name "Add"
last_name "Min"
end
end
|
require 'spec_helper'
module TestModule
extend BetfairApiNgRails::Api::RequestMethods
end
describe "listEvents request method" do
it_behaves_like 'simple list filtering request', 'listEvents' do
let(:method_name) { "list_events" }
let(:result_class) { BetfairApiNgRails::EventResult }
let(:result_ha... |
require 'test_helper'
class SindicosControllerTest < ActionController::TestCase
setup do
@sindico = sindicos(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:sindicos)
end
test "should get new" do
get :new
assert_response :success
en... |
=begin
#Issue Looks like some hoodlum plumber and his brother has been running around and damaging your stages again.
The pipes connecting your level's stages together need to be fixed before you recieve any more complaints.
Each pipe should be connecting, since the levels ascend, you can assume every number in the s... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# 空文字制限(入力必須)
with_options presence: true do
val... |
source 'https://rubygems.org'
gemspec
group :deployment do
# Posts SimpleCov test coverage data from your Ruby test suite to Code Climate's hosted, automated code review service.
gem 'codeclimate-test-reporter', require: false
end
group :development do
# Byebug is a simple to use, feature rich debugger for Rub... |
# 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' }])
# ... |
# 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... |
# bannerizer.rb
# Write a method that will take a short line of text, and print it within a
# box.
# Pseudo-code:
# Data Structure:
# input: a string containing a short line of text.
# output: the string printed with a box as its border.
# rules: assume that the input will awlays fit in the terminal window.
# Algori... |
require_dependency 'referrer/application_controller'
module Referrer
class SessionsController < ApplicationController
def create
user = Referrer::User.where(id: session_params[:user_id], token: session_params[:user_token]).first
if user
@session = user.sessions.active_at(Time.now).first
... |
class ChangeCostumeStore < ActiveRecord::Migration[4.2]
def change
rename_column :costume_stores, :costume_integer, :costume_invetory
end
end
|
require_relative('./nursery.rb')
require_relative('../db/sql_runner.rb')
class Plant
attr_reader :nursery_id, :id
attr_accessor :name, :usp, :stock_quantity, :buying_cost, :selling_price, :url, :plant_type
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@us... |
class ItemType < ActiveRecord::Base
attr_accessible :active, :name
has_many :item_masters, dependent: :destroy
validates :name, presence: true, uniqueness: true
end
|
class RecordLabel < ActiveRecord::Base
has_many :artists, dependent: :destroy
validates_presence_of :label_name
end
|
class ChangeDefaultForUsersPermissions < ActiveRecord::Migration[4.2]
def change
change_column :users, :permissions, :integer, default: 100
end
end
|
require 'test_helper'
require 'generators/pattern/pattern_generator'
class PatternGeneratorTest < Rails::Generators::TestCase
tests PatternGenerator
destination Rails.root.join('tmp/generators')
setup :prepare_destination
test 'generator runs without errors' do
assert_nothing_raised do
run_generator... |
# frozen_string_literal: true
class RenameTypeToCategory < ActiveRecord::Migration[5.2]
def change
rename_column :tickets, :type, :category
end
end
|
class Restaurant
attr_accessor :customers, :reviews
@@all = []
def self.all
@@all
end
def self.find_by_name(restaurant_name)
#returns duplicates
all.select {|restaurant| restaurant.name == restaurant_name}
end
def initialize(name)
@@all << self
@reviews = []
@customers = []
e... |
require "spec_helper.rb"
describe "Creating posts" do
def create_post(options={})
options[:title] ||= "A new post"
options[:body] ||= "Content of a new post"
visit "/posts"
expect(page.all("div.post_wrapper").count).to eq(0)
click_link "New post"
fill_in "post_title", wit... |
class RosterPositionsController < ApplicationController
def index
@roster_positions = RosterPosition.
with_teams_and_players.
merge(FantasyLeague.only_league(fantasy_league_param)).
order("fantasy_teams.name",
"s... |
class Listing < ApplicationRecord
geocoded_by :address
after_validation :geocode, if: :address_changed?
mount_uploader :photo, PhotoUploader
validates :title, :price, :description, :zip, :category, presence: true
include PgSearch
pg_search_scope :search_by_title, :against => :title, :using => {
... |
class UsersController < ApplicationController
skip_before_filter :authenticate_user, :only => [:new, :create]
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
end
|
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], #top row
[3,4,5], #mid row
[6,7,8], #bot row
[0,3,6], #left col
[1,4,7], #mid col
[2,5,8], #right col
[0,4,8], #left diag
[2,4,6] #right diag ... |
class Question < ActiveRecord::Base
# Remember to create a migration!
validates :title, :presence => true
has_many :question_votes
has_many :answers
belongs_to :user
def vote_total
total = 0
for vote in self.question_votes do
total += vote.value
end
return total
end
end
|
require 'rails_helper'
feature "admin item edit page" do
fixtures :items
fixtures :users
fixtures :jokes
fixtures :categories
context "as an unauthenticated user" do
before(:each) do
visit "/admin/items/#{Item.second.id}/edit"
end
it "page isn't found" do
expect(page).not_to have_co... |
class ProjectNotificationSerializer < ApplicationSerializer
attributes :id,
:name,
:owner_display_name,
:owner_thumbnail_url,
:urls
def owner
@owner ||= object.owner
end
def owner_display_name
owner.display_name
end
def owner_thumbnail_url
o... |
describe Ta do
describe '#percentage_grades_array' do
let(:assignment) { create(:assignment_with_criteria_and_results) }
let(:ta) { create(:ta) }
context 'when the TA is not assigned any groupings' do
it 'returns no grades' do
expect(ta.percentage_grades_array(assignment)).to eq []
en... |
module GroupBuzz
class TruncationProcessor
def initialize(substitution_tracker, truncate_limit)
@substitution_tracker = substitution_tracker
@truncate_limit = truncate_limit
end
def truncate(text)
character_at_limit = character_at(text, @truncate_limit)
if !@substitution_tracker... |
class AddColumnsToPhotos < ActiveRecord::Migration[5.2]
def change
add_column :photos, :thumb_width, :integer
add_column :photos, :thumb_height, :integer
end
end
|
# encoding: utf-8
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment to clear the screen before every task
clearing :on
guard 'bundler' do
watch('Gemfile')
# Uncomment next line if Gemfile contain `gemspec' command
# watch(/^.+\.gemspec/)
end
guard :rspec, cmd: 'bundle exec ... |
class UserMailer < ApplicationMailer
def welcome_email(user)
@user = user
@specialtext = `Hello, #{user}, welcome to PolitiConnect!`
mail(to: @user.email, subject: "Welcome to PolitiConnect")
end
def rep_email(address, message)
@specialtext = ""
mail(to: address, subject: "A message from a c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.