text stringlengths 10 2.61M |
|---|
class SorceryResetPassword < ActiveRecord::Migration
def self.up
add_column :users, :reset_password_token, :string, default: nil
add_column :users, :reset_password_token_expires_at, :datetime, default: nil
add_column :users, :reset_password_email_sent_at, :datetime, default: nil
add_index :users,... |
require 'rails_helper'
RSpec.describe ElectronicPortal, type: :model do
it 'has a valid factory' do
expect(create :electronic_portal).to be_valid
end
it { should validate_presence_of :value }
it { should belong_to :organ }
end
|
class Project < ActiveRecord::Base
belongs_to :user
has_many :biodatabases
has_many :fasta_files
has_many :uploaded_fasta_files, :class_name =>'FastaFile', :conditions => 'is_generated = 0'
validates_presence_of :name
validates_uniqueness_of :name
validates_presence_of :user_id
after_create :create_de... |
class AddStartWeightAndBmiToSub < ActiveRecord::Migration[5.0]
def change
add_column :subscriptions, :start_weight, :integer
add_column :subscriptions, :start_bmi, :integer
end
end
|
module Sensors
class Desensewind < DesenseBase
attributes :temperature, :wind_speed
display_as :line_chart, group_by: :minute, attributes: [:wind_speed, :temperature]
def air_flow
@air_flow ||= values.air_flow / 1000.0
end
def temp
@temp ||= values.temperature / 1000.0
end
d... |
class AddTotalTweets < ActiveRecord::Migration[5.2]
def change
add_column :automated_tweets, :total_tweets, :integer, default: 0
remove_column :automated_tweets, :post_interval, :integer
remove_column :automated_tweets, :stop_at, :datetime
end
end
|
class Admin::ProductsController < AdminController
def enable
@product = Product.find_by_id(params[:id])
@product.deleted_at = nil
if @product.save
flash[:notice] = "Product is now available"
redirect_to admin_products_path
end
end
def disable
@product = Product.find_by_id(params... |
Deface::Override.new(:virtual_path => "spree/layouts/admin",
:name => "contacts",
:insert_bottom => "#admin-menu ul",
:text => "<%= tab :contacts %>")
|
class MusicInstrumentationType < ActiveRecord::Base
# Relations
has_and_belongs_to_many :music_works
# Validations
validates_uniqueness_of :name
validates_length_of :name, :minimum => 3, :maximum => 255
end |
FreshConnect::Application.routes.draw do
resources :markets do
resources :reviews
resources :recommendations
end
root 'welcome#index'
devise_for :users
end |
class Booking < ApplicationRecord
belongs_to :user
has_many :dishs, through: :cart_items
has_many :cart_items, dependent: :destroy
validates :payment_type, presence: true
PAYMENT_TYPES = ["Cash On Delivery", "Bank Transfer", "Dotpay"]
def add_cart_items_from_cart(cart)
cart.cart_items.each do |it... |
class ChangePeopleBirthDates < ActiveRecord::Migration
def change
Person.where(date_of_birth: 200.years.ago..101.years.ago).delete_all
end
end
|
module Processing
# This class creates blank sketches, with the boilerplate filled in.
class Creator < BaseExporter
ALL_DIGITS = /\A\d+\Z/
# Create a blank sketch, given a path.
def create!(path, args, bare)
usage path
main_file = File.basename(path, ".rb")
# Check to make... |
require 'spec_helper'
require 'ldap-relations'
# Example ActiveRecord style usage for LRel
#
# eg. Directory.where(sAMAccountName: 'test').all
class Directory
def self.where params
new.where(params)
end
def initialize params={}
self.manager = LRel::RelationManager.new
end
attr_accessor :manager
... |
# frozen_string_literal: true
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if !user.is_admin?
# Annonymous User Permissions
can :read, Listing
if !user.new_record?
# Add permisions here for returning users
# ... |
class MetrcHistory
include Mongoid::Document
include Mongoid::Timestamps::Short
field :code, type: String
field :value, type: Time
belongs_to :facility, class_name: 'Facility'
end
|
class UsersController < ApplicationController
after_action :verify_authorized
def index
@users = User.all
redirect_to root_path unless authorize @users
end
def show
@user = User.find(params[:id])
authorize @user
end
def destroy
@user = User.find(params[:id])
authorize @user
i... |
require File.dirname(__FILE__) + '/../spec_helper'
describe Game do
before :each do
@game = Game.new
end
it "should require a valid board_size" do
@game.board_size = 50
@game.should have(1).error_on(:board_size)
@game.board_size = 9
@game.should have(:no).errors_on(:board_size)
end
it "... |
# frozen_string_literal: true
module Kafkat
module Command
class TopicElect < Base
register_as 'topic_elect', deprecated: 'elect-leaders'
banner 'kafkat topic elect TOPIC'
description 'Begin election of the preferred leaders.'
def run
topic_name = arguments.last
topic_nam... |
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(email: sessions_params[:email])
if user && user.authenticate(sessions_params[:password])
session[:user_id] = user.id
flash[:notice] = 'Welcome! Please check-out new events i... |
require 'spec_helper'
describe 'tp::dir', :type => :define do
let (:title) { 'redis' }
context 'with title redis' do
it do
should contain_file('/etc/redis').only_with({
'ensure' => 'directory',
'path' => '/etc/redis',
'mode' => '0755',
'owner' => 'root',
... |
# Testing utils for those that involve chunks
# Opening Chunk so that we can test with smaller data set (2x2x8 per chunk),
#instead of 16x16x128 of regular minecraft chunk
class RubyCraft::Chunk
def matrixfromBytes(bytes)
Matrix3d.new(2, 2, 8).fromArray bytes.map {|byte| Block.get(byte) }
end
end
module Chunk... |
require 'spec_helper'
describe Road do
context 'associations' do
it { should have_many(:photos) }
it { should belong_to(:user) }
it { should have_many(:rated) }
it "should respond to polymorthic association with rating" do
@road = Road.make!(:road1)
@rating1 = Rating.make!(:road_twistin... |
# typed: true
class CreateEmployees < ActiveRecord::Migration[6.0]
def change
create_table :employees do |t|
t.text :Facebook
t.text :Linkedin
t.text :Role
t.text :e_mail
t.text :Mobile
t.text :Address
t.text :Country
t.text :Full_Name
t.text :Last_Name_2
... |
require 'rails_helper'
describe SendInformation do
describe '#create' do
context '新規登録がうまくいかない時'do
it "send_first_nameがないと登録できない" do
end
it "send_family_nameがない場合は登録できない" do
end
it "send_first_name_kanaがない場合は登録できない" do
end
it "send_family_name_kanaがない場合は登録できない" do
e... |
require_relative 'test_helper'
require_relative '../lib/merchant_repo'
require_relative '../lib/item_repo'
require_relative '../lib/invoice_repo'
require_relative '../lib/invoice_item_repo'
require_relative '../lib/transaction_repo'
require_relative '../lib/customer_repo'
require_relative '../lib/sales_analyst'
require... |
module Rubii
class Input
def sendevent evt
end
def sendkey key
end
def sendtext txt
end
def launch app
end
end
class InputDevice
attr_reader :controller, :driver, :config
def initialize controller, driver, cfg = Rubii::Config[:default]
@controller = controll... |
require 'pathname'
require 'vendor/homebrew-fork/exceptions'
def homebrew_fork_system cmd, *args
puts "#{cmd} #{args*' '}" if Hbc.verbose
pid = fork do
yield if block_given?
args.collect!{|arg| arg.to_s}
exec(cmd, *args) rescue nil
exit! 1 # never gets here unless exec failed
end
Process.wait(p... |
# `CanonicalItem` is later renamed to `BaseItem`. It was a bad choice to
# do it this way in a migration, but here we are. The database doesn't
# yet know about the BaseItem name change, but the codebase does.
class CanonicalItem < ApplicationRecord; end
# The partner key is used as the lingua franca when receiving Re... |
#
# Copyright (C) 2016 Gracenote
#
# 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 law or agreed to in writin... |
class AddHideTeamNamesToMeasuringSessions < ActiveRecord::Migration[6.1]
def change
add_column :measuring_sessions, :hide_team_names, :boolean
end
end
|
class Room
attr_reader :category,
:area
def initialize(category, length, width)
@category = category
@area = length * width.to_i
@paint = nil
end
def is_painted?
if @paint == nil
false
else
true
end
end
def paint
@paint = true
end
end
|
module Specmon
class ProjectsController < ApplicationController
def show
if @project
redirect_to controller: :examples, action: :index, project_id: @project.id
else
flash[:error] = 'Project not found'
end
end
end
end
|
class AddAcceptedToFeatures < ActiveRecord::Migration
def change
add_column :features, :accepted_date, :date, default: nil
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
acts_as_paranoid
has_many :cart_items, dependent: :destroy
has_many :orders, dependent: :destroy
has_many :delivery_addresses
devise :database_authen... |
require "test_helper"
class CartTest < ActiveSupport::TestCase
setup do
@customer = customers(:one)
@address = addresses(:one)
@cart = carts(:three)
@order = orders(:one)
end
test "test save cart" do
cart = Cart.new
cart.customer_id = @customer.id
assert_equal true, cart.save
end
... |
class FontLiuJianMaoCao < Formula
head "https://github.com/google/fonts/raw/main/ofl/liujianmaocao/LiuJianMaoCao-Regular.ttf", verified: "github.com/google/fonts/"
desc "Liu Jian Mao Cao"
homepage "https://fonts.google.com/specimen/Liu+Jian+Mao+Cao"
def install
(share/"fonts").install "LiuJianMaoCao-Regular... |
#!/usr/bin/env rspec
require 'spec_helper'
require File.join(File.dirname(__FILE__), "../../..", "util", "iptables", "ipv4.rb")
require File.join(File.dirname(__FILE__), "../../..", "util", "iptables", "ipv6.rb")
module MCollective
module Util
module IPTables
describe IPv6 do
before do
C... |
# frozen_string_literal: true
class Event < ApplicationRecord
validates :name, presence: true
validates :description, presence: true
validates :location, presence: true
validates :date, presence: true
validates :time, presence: true
validates :points, presence: true
validates :link, presence: true
end
|
class AddGeneratedAtToRosterArchiveFiles < ActiveRecord::Migration[5.2]
def change
add_column :roster_archive_files, :generated_at, :datetime
end
end
|
class InstitucionsController < ApplicationController
# GET /institucions
# GET /institucions.json
layout 'administracion'
#add_breadcrumb "Denuncias", :complaints_path, :options => { :title => "Home" }
#before_filter :authenticate_user!
#load_and_authorize_resource
def index
@institucions = ... |
# frozen_string_literal: true
module GraphQL
class StringEncodingError < GraphQL::RuntimeTypeError
attr_reader :string, :field, :path
def initialize(str, context:)
@string = str
@field = context[:current_field]
@path = context[:current_path]
message = "String #{str.inspect} was encoded... |
require 'spec_helper'
describe EccnData do
before { Eccn.recreate_index }
let(:fixtures_file) { "#{Rails.root}/spec/fixtures/eccns/eccns.csv" }
let(:importer) { described_class.new(fixtures_file) }
let(:expected) { YAML.load_file("#{File.dirname(__FILE__)}/eccn/results.yaml") }
it_behaves_like 'an importer ... |
class StoreController < ApplicationController
before_action :set_current_page
skip_before_action :authorize
include CurrentCart
before_action :set_cart
def index
@products = Product.paginate(:page => params[:page], :per_page => 5)
@carts = Cart.all
end
private
def set_current_page
@curre... |
class BaseOperation
UNPROCESSABLE_ENTITY = 422
attr_reader :model, :params
attr_accessor :status, :messages, :errors, :result
delegate :valid_model?, :all_model?, to: :operation_policy
def self.call(*args)
new(*args).call
end
def initialize(model, params = {})
@model = model.to_s
@param... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{jwoffindin-foreigner}
s.version = "0.7.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :re... |
class TransportAttendance < ActiveRecord::Base
attr_accessor :name, :dept, :stop, :marked, :disable_mark
belongs_to :receiver, :polymorphic => true
named_scope :in_academic_year, lambda {|academic_year_id| {
:joins => "INNER JOIN routes ON routes.id = transport_attendances.route_id",
:condit... |
class Seller < ApplicationRecord
has_many :properties
has_many :agents, through: :properties
end
|
xml = Builder::XmlMarkup.new(:indent => 2)
xml.instruct!
xml_string = xml.rss('xmlns:atom' => "http://www.w3.org/2005/Atom", :version => "2.0") do
xml.channel do
xml.title("Recent Apps")
xml.description("Applications recently installed (as recorded on installd.com)")
xml.link(url_for(:host => HOST))
x... |
#!/usr/bin/env ruby
# coding: utf-8
HOME = ENV['HOME']
OUT_DIR = "/Volumes/ImageLib/Pictures/ImageLib"
PATTERN = '**/*.{jpg,jpeg,JPG,JPEG,avi,AVI,wav,WAV,CR2,mp4,MOV,MP4}'
ERRORS = []
require 'fileutils'
require 'ruby-progressbar'
require 'yaml'
#require 'imagelib/mtp_storage'
require 'imagelib/file_storage'
require ... |
class LoginsController < ApplicationController
# GET /logins
# GET /logins.json
before_filter :check_login_status , :only => [:logout, :profile, :edit]
def index
@logins = Login.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @logins }
end
end
... |
# frozen_string_literal: true
module Api::V1::Sockets
class AuthController < ::Api::V1::ApplicationController
def create
api_action do |m|
m.success do |auth_key|
render json: auth_key
end
end
end
end
end
|
class ChangePasswordTypes < ActiveRecord::Migration
def up
change_column :users, :password, :password
end
def down
change_column :users, :password_confirm, :password
end
end
|
class Contact < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :address
default_scope :order => 'last_name, first_name'
named_scope :by_name, lambda { |name| {:conditions => ['upper(first_name) = :name OR upper(last_name) = :name', {:name => name.upcase}]} }
end
|
class BlogsController < ApplicationController
def index
@blogs = Blog.all
end
def new
@blog = Blog.new
end
def show
@blog = Blog.find(params[:id])
end
def create
blog = Blog.new(blog_params)
blog.save
redirect_to "/blogs"
end
private
def blog_params
params.require(:blog).permit(:title, ... |
class User
include Mongoid::Document
include Mongoid::Paperclip
include Sunspot::Mongoid2
after_create :send_mails_to_user
after_create :create_charity
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, ... |
FactoryGirl.define do
factory :deal do
title 'qazxsw'
price 100
max_qty 20
max_qty_per_customer 5
association :category, factory: :category
association :merchant, factory: :merchant
end
factory :deal_with_order, parent: :deal do
after(:build) do |deal|
deal.orders << create(:or... |
class Venue < ActiveRecord::Base
attr_accessible :address, :address2, :city, :name, :phone_number, :state, :user_id, :zipcode
validates_presence_of :name, :address, :city, :state, :zipcode, :phone_number, :user_id
def formatted_address
if self.address2
"#{self.address}, " + "#{self.address2}"
else
... |
class CommentsController < ApplicationController
def show
@comment = Comment.find(params[:id])
render :show
end
def new
@comment = Comment.new
render :new
end
def create
@post = Post.find_by_id(params[:post_id])
@comment = @post.comments.create(comment_params)
if @comment.save
redirect_to @post
... |
class QuestionPlaysController < ApplicationController
before_action :set_question_play, only: [:show, :edit, :update, :destroy]
# GET /question_plays
# GET /question_plays.json
def index
@question_plays = QuestionPlay.all
end
# GET /question_plays/1
# GET /question_plays/1.json
def show
end
... |
class Van
attr_reader :bikes
def initialize
@bikes = []
end
def load(bike)
@bikes << bike
self
end
def bike_count
@bikes.count
end
# def check_and_load(bike, station)
# if station.is_a?(DockingStation) && bike.broken?
# load(bike)
# end
# end
def collect_broken_bikes_from station
statio... |
module Roglew
module ImmediateContext
def deferred?
false
end
def finished
unbind
end
def immediate?
true
end
private
def make_call(target, method, *args)
send(target).public_send(method, *args)
end
def run
bind
retur... |
require 'spec_helper'
describe "BrowsingSupport::ExportMp3" do
subject { BrowsingSupport::ExportMp3.new }
describe 'メソッド' do
before do
BrowsingSupport::VoiceSynthesis.any_instance.stub(:html2m3u)
end
describe '.action_methods' do
it 'create_mp3 があること' do
expect(BrowsingSupport::Ex... |
class OldNode < ActiveRecord::Base
include GeoRecord
include ConsistencyValidations
set_table_name 'nodes'
# Should probably have the composite primary key set in the model
# however there are some weird bugs happening when you do
#set_primary_keys :id, :version
validates_presence_of :changeset_id,... |
# encoding: UTF-8
module CDI
module V1
module Posts
class DeleteService < BaseDeleteService
record_type ::Post
def destroy_record
@photos = @record.photos.map { |photo| photo }
super
end
def after_success
@photos.each { |p| p.destroy }
... |
require_relative '../user'
module CDI
module FakeData
module Generators
module Games
class GamePoll < Game
def initialize(options = {})
super(options)
@game_type = :game_poll
@total_questions = 1
end
def sample_game_data(index, gam... |
class Terms
attr_reader :designer_map, :term_map, :terms
def initialize(designer_map)
@designer_map = designer_map
@term_map = designer_map.invert
@terms = designer_map.to_a.flatten
@designer_map.each {|k,v| hashtag = v.gsub(/\s+/, ""); term_map[hashtag] = k; @terms << hashtag}
@terms.uniq!
e... |
require_relative '../app/spock'
describe Spock do
let(:spock) {Spock.new}
it "should have a name" do
expect(spock.name).to eq("Spock")
end
it "should beat scissors" do
expect(spock.beat_scissors).to be true
end
it "should beat rock" do
expect(spock.beat_rock).to be true
end
it "shouldn't beat lizard... |
describe Schedule do
describe '#calculate_next_occurence' do
let(:schedule) { FactoryGirl.create(:schedule) }
it 'indicates next_occurrence' do
expect(schedule.calculate_next_occurence.day).to eq(Date.today.day)
end
end
end
|
class Answer < ApplicationRecord
belongs_to(:user)
belongs_to(:question)
has_many(:votes)
end
|
# -*- mode: ruby; -*-
require "rubygems"
require "aws/s3"
require "digest/md5"
require "yaml"
module Statics
ALL_FILES = FileList["javascripts/**/*.js"] + FileList["stylesheets/**/*.css"]
HOSTNAME = "static.textovirtual.com"
SINES_FILENAMES = ["plataforma"]
CSS_FILENAMES = ["clides/admin"]
def self.s3_k... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt/pal/yaml_plan/parameter'
describe Bolt::PAL::YamlPlan::Parameter do
context '#transpile' do
let(:str_type) { 'String' }
let(:int_type) { 'Integer' }
let(:name) { 'myvar' }
let(:value) { nil }
let(:type) { nil }
let(:definitio... |
class AddAnswerToExercises < ActiveRecord::Migration
def change
add_column :exercises, :answer, :string
end
end
|
class CreatePayrollGroups < ActiveRecord::Migration
def self.up
create_table :payroll_groups do |t|
t.string :name
t.integer :salary_type
t.integer :payment_period
t.integer :generation_day
t.boolean :enable_lop, :default => false
t.integer :current_revision, :default => 1
... |
# --- Day 4: The Ideal Stocking Stuffer ---
# Santa needs help mining some AdventCoins (very similar to bitcoins) to use
# as gifts for all the economically forward-thinking little girls and boys.
# To do this, he needs to find MD5 hashes which, in hexadecimal, start with at
# least five zeroes. The input to the MD5 ... |
require 'canvas-api'
require_relative 'connection'
require_relative 'siktfunctions'
if(ARGV.size < 2)
dbg("Usage: ruby #{$0} prod/beta courseid]")
dbg("prod/beta angir om kommandoene skal kjøres mot henholdsvis #{$prod} eller #{$beta}")
dbg("Lister ut enrollments statistikk per dag for kurs med id cours... |
class IterationReviewsController < ApplicationController
before_action :set_iteration_review, only: [:show, :edit, :update, :destroy]
before_action :set_head
# GET /iteration_reviews
# GET /iteration_reviews.json
def index
@joined_iteration_reviews = current_user.iteration_reviews
@no_joined_iteration... |
class Api::V1::GoalsController < Api::V1::ApiController
before_action :set_goal, only: %i[show update destroy]
def index
@goals = current_context.goals
end
def show
end
def update
if @goal.update(goal_params)
render 'show', status: :ok
else
render 'show', status: :unprocessable_en... |
class Cat < ActiveRecord::Base
validates :color, inclusion: { in: %w( Brown Black White ) }
validates :sex, inclusion: { in: %w( M F ) }
validates :birth_date, :color, :sex, :name, presence: true
has_many :cat_rental_requests, dependent: :destroy
belongs_to :user
def age
Date.time.now - self.birth... |
require 'rails_helper'
RSpec.describe "brands/edit", type: :view do
before(:each) do
@brand = assign(:brand, create(:brand))
end
it "renders the edit brand form" do
render
assert_select "form[action=?][method=?]", brand_path(@brand), "post" do
assert_select "input#brand_name[name=?]", "brand[... |
module CamaleonCms
module Admin
module ApplicationHelper
# include CamaleonCms::Admin::ApiHelper
include CamaleonCms::Admin::MenusHelper
include CamaleonCms::Admin::PostTypeHelper
include CamaleonCms::Admin::CategoryHelper
include CamaleonCms::Admin::CustomFieldsHelper
# rende... |
Rails.application.routes.draw do
resources :parkings
resources :principals
root to: 'parkings#new'
get '/exit', to: 'parkings#exit'
get '/salida_vehiculo', to: 'parkings#salida_vehiculo'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
require File.dirname(File.realdirpath(__FILE__)) + '/test_helper.rb'
require 'active_redis/inspector'
describe ActiveRedis::Inspector do
subject { TestObject.new }
before do
TestObject.send :include, ActiveRedis::Inspector
end
describe "#inspect" do
before do
TestObject.stubs(:attributes_list... |
json.array!(@award_ceremonies) do |award_ceremony|
json.extract! award_ceremony, :id, :ceremony, :isMajor
json.url award_ceremony_url(award_ceremony, format: :json)
end
|
class BillingInformation < ActiveRecord::Base
belongs_to :user
def validate?
true
end
end |
class Job < ActiveRecord::Base
belongs_to :user
validates :user, :title,
presence: true
end
|
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
class AssessmentReportSettingCopy < ActiveRecord::Base
belongs_to :generated_report
serialize :settings, Hash
class << self
def res... |
#!/usr/bin/env ruby
require "rubygems"
require "httpclient"
require "soap/rpc/driver"
require "optparse"
# INSTALL GEMS:
# sudo gem install soap4r --no-ri --no-rdoc
# sudo gem install httpclient --no-ri --no-rdoc
#
# RUN LIKE THIS:
# ruby x_forwarded_for.rb --hostname=lb-n01.example.com --username=admin --p... |
class Song < ActiveRecord::Base
validates :title, presence: true
validates :artist_name, presence: true
validates :released, inclusion: {in: [true, false]}
validate :title_unique_by_artist_per_year
validate :release_year_optional_if_unreleased
def title_unique_by_artist_per_year
if !!self.release_... |
require 'spec_helper'
describe Member do
before {@member = Member.new(first_name:"Al", last_name:"Bundy", email:"al.bundy@gmail.com", location_id:0, country_code:"US", phone_number:"5555555", team_id:1, shib:"food", captain:true)}
subject { @member }
it { should respond_to(:email) }
it { should respond_to(... |
class Post < ActiveRecord::Base
has_and_belongs_to_many :tags
validates :body, :title, presence: true
end
|
#!/usr/bin/env rake
require 'mixlib/shellout'
chef_version = '12.19.36'
namespace :style do
desc 'Style check with rubocop'
task :rubocop do
ENV['RUBOCOP_OPTS'] = '--out rubocop.log' if ENV['CI']
# Force a zero exit code until we fix all the cops (someday)
sh '/opt/chefdk/embedded/bin/rubocop || true'... |
require 'rails_helper'
describe AddToMediaCollection do
let(:user) { FactoryGirl.create(:user) }
let(:item_url) { 'https://news.ycombinator.com/' }
let(:mock_item) { FactoryGirl.create(:media_item) }
subject { described_class.new(user: user, url: item_url, public: false) }
it "calls Repository with item_u... |
require 'rails_helper'
describe "authors/new" do
before :each do
assign(:author, Author.new)
end
it "displays fields for first name, last name and homepage" do
render :template => "authors/new.html.erb"
expect(rendered).to match /first_name/
expect(rendered).to match /last_name/
expect(rendered).to matc... |
class Customer < ActiveRecord::Base
belongs_to :party
has_many :orders
has_many :items, through: :orders
end
|
require "rails_helper"
feature "Update post" do
include_context "current user signed in"
let!(:post) { create :post, user: current_user }
background do
visit edit_post_path(post)
end
scenario "User updates a post" do
fill_in "Post title", with: "title for post"
fill_in "Post body", with: "body... |
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.belongs_to :user, foreign_key: true, index: true
t.belongs_to :venue, foreign_key: true, index: true
t.string :name, null: false, default: '', index: true
t.text :description
t.boolean :recurring, ... |
class PresidentsController < ApplicationController
def index
@presidents = President.all.shuffle
end
end
|
class ItemsController < ApplicationController
before_action :current_category, only: [ :new, :create]
before_action :current_item, only: [:show, :edit, :update, :destroy,
:delete_image, :buy_order, :sell_order]
def new
@item = @category.items.build
end
def create
@item = @category.items.build(item... |
response = { error: 'Bad Gateway', code: 502 }
case response
in { data: data, code: code }
puts "Success #{data}, Code: #{code}"
in { error: error, code: code }
puts "Error: #{error}, Code: #{code}"
end
# Error: Bad Gateway, Code: 502 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.