text stringlengths 10 2.61M |
|---|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5.0"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = "sixpack-ab-berkshelf"
config.omnibus.chef_versi... |
require "rails_helper"
describe "Link" do
context "validations" do
it "is invalid with non-conforming url" do
link = Link.new(url: "wrong", title: "title")
expect(link).to_not be_valid
end
it "is invalid without a title" do
link = Link.new(url: "https://google.com")
expect(link... |
class TravelsController < ApplicationController
before_action :set_travel, only: [:show, :edit, :update, :destroy]
# GET /travels
# GET /travels.json
def index
@travels = Travel.where("user_id = #{current_user.id}").paginate(page: params[:page], per_page: 10)
@admin_travels = Travel.all.paginate(page: ... |
require 'spec_helper'
require 'support/integrations_tools'
RSpec.describe "Request an ggroup update", type: :integration do
let(:before_start_proc) {Proc.new{LogMessageHandler.listen_to 'reply.mailinglist.delete'}}
let(:message) {GorgService::Message.new(event:'request.mailinglist.update',
... |
class CreateTuanCategoryTemps < ActiveRecord::Migration
def self.up
create_table :tuan_category_temps do |t|
t.string :name
t.integer :tuan_category_id
t.integer :tuans_count, :default=>0
t.timestamps
end
add_column :tuans, :tuan_category_temp_id, :integer
end
def self.d... |
require 'csv'
require 'google/apis/civicinfo_v2'
require 'erb'
def clean_zipcode(zipcode)
zipcode.to_s.rjust(5, "0")[0..4]
end
def legislators_by_zipcode(zip)
civic_info = Google::Apis::CivicinfoV2::CivicInfoService.new
civic_info.key = 'AIzaSyClRzDqDh5MsXwnCWi0kOiiBivP6JsSyBw'
begin
civic_info.represen... |
class AuditsController < ApplicationController
# sets the @auth object and @object
before_filter :get_obj_auth
before_filter :modelperms
# GET /audits
# GET /audits.xml
def index
special_joins = {}
# Custom sort parameter because we want to see the latest changes first
params[:sort] = 'created_... |
#!/usr/bin/env ruby -w
class String
def replace_with_array(regex, arr)
self.gsub(regex) { |str| arr[self.scan(regex).index(str)] }
end
def to_tr
str = "<tr>"
gsub!("|") do |split|
starts_with?(split) ? "<td>" : (self.ends_with?(split) ? "</td>" : "</td><td>")
end
str += self
str +=... |
module VagrantPlugins
module WinAzure
module Action
class PowerShellRun
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new('vagrant_azure::action::powershell_run_command')
end
def call(env)
if env[:machine].communicate.ready?
e... |
class ProductsController < ApplicationController
before_action :find_category, only: [:create]
before_action :find_product, only: [:edit, :update, :destroy]
before_action :getAllCategories, only: [:new, :edit]
def index
@title = header_title( :"All Products" )
@products = Product.select("p... |
# Prefix Verb URI Pattern Controller#Action
# login GET /login(.:format) session#new
# session POST /session(.:format) session#create
# GET /session(.:format) session#show
# DELETE /session(.:format) session#destroy
# ... |
require 'rails_helper'
RSpec.describe "authors/profiles/index", type: :view do
before(:each) do
assign(:authors_profiles, [
Authors::Profile.create!(),
Authors::Profile.create!()
])
end
it "renders a list of authors/profiles" do
render
end
end
|
require 'json'
module Nyaplot
module Base
attr_accessor :dependency, :uuid
def self.included(cls)
cls.extend ClassMethods
end
# @example
# Glyph::Scatter.new(data: data, x: :x, y: :y)
# #-> #<Nyaplot::Glyph::Scatter|0aff1e>
#
def initialize(*args)
@uuid = SecureRando... |
module Compass
# Based on [Eric Meyer's reset 2.0](http://meyerweb.com/eric/tools/css/reset/index.html)
# Global reset rules.
# For more specific resets, use the reset mixins provided below
def global_reset
all = %w(
a
abbr
acronym
address
applet
article
aside
... |
# frozen_string_literal: true
module FileReaderTest
module SeekUnsupported
def test_cannot_seek_to_absolute_pos
file = file_containing("takahē")
assert_raises Tar::SeekNotSupported do
file.seek 3
end
end
def test_cannot_explicitly_seek_to_absolute_pos_with_constant
file ... |
class Neopet
attr_reader :name, :species, :strength, :defence, :movement
attr_accessor :happiness, :items, :mood
def initialize(name)
@name = name
@strength = get_points
@defence = get_points
@movement = get_points
@happiness = get_points
@species = get_species
@items = []
end
... |
# frozen_string_literal: true
require 'optparse'
require 'etc'
options = ARGV.getopts('a', 'l', 'r')
files = if options['a']
Dir.glob('*', File::FNM_DOTMATCH)
elsif options['r']
Dir.glob('*').reverse
else
Dir.glob('*')
end
if options['l']
def file_type(type)
... |
class CreateShares < ActiveRecord::Migration
def change
create_table :shares do |t|
t.decimal :share_total_beginning, precision: 30, scale: 20
t.decimal :shares_added_by_donation, precision: 30, scale: 20
t.decimal :shares_subtracted_by_grants, precision: 30, scale: 20
t.decimal :... |
class CreateProfiles < ActiveRecord::Migration
def change
create_table :profiles do |t|
t.integer :user_id, null: false
t.text :self_sum
t.text :life_sum
t.text :skills
t.text :favorites
t.text :needs
t.text :thoughts
t.text :fun_acts
t.text :msg_reason
... |
require_relative "../lib/item"
require_relative "test_helper"
require 'bigdecimal'
class ItemTest < Minitest::Test
def setup
@parent = mock("parent")
@item = Item.new({
:id => 1,
:name => "Pencil",
:description => "You can use it to write things",
... |
class CreateEpis < ActiveRecord::Migration
def change
create_table :epis do |t|
t.float :elec_energy
t.float :gas_energy
t.float :co2
t.float :money
t.integer :year
t.timestamps
end
end
end
|
require 'account'
describe Account do
FAKE_AMOUNT = rand(1000)
DATE = Date.new(2016,5,16)
let(:account) { described_class.new }
let(:transaction) { double(:transaction, calculate_change: FAKE_AMOUNT) }
describe '#initialize' do
it 'has an empty array' do
expect(account.transactions).to eq([])
... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'uvcli/version'
Gem::Specification.new do |spec|
spec.name = "uvcli"
spec.version = Uvcli::VERSION
spec.authors = ["Boy van Amstel"]
spec.email = ["boy@dangerc... |
class CreateAccounts < ActiveRecord::Migration
def change
create_table :accounts do |t|
t.integer :parent_left
t.integer :parent_right
t.string :code, :limit => 20, :null => false
t.string :name, :limit => 100, :null => false
t.integer :level
t.boolean :acti... |
class Person < ActiveRecord::Base
#attr_accessible :url, :firstname, :lastname, :birthname, :sex, :birthdate, :deathdate, :birthplace, :birthplaceurl, :thumbnail
has_many :residences, :dependent => :destroy
has_many :locations, :through => :residences
has_many :relations, :class_name => "Relation", :foreign_key =... |
require 'rails_helper'
RSpec.describe FindTheBestLocationsController do
let!(:find_the_best_location) { create(:find_the_best_location) }
let!(:video) { create(:video, videoable: find_the_best_location) }
describe 'GET embed' do
it 'renders page' do
get :embed, id: find_the_best_location
expect(... |
class Account < ActiveRecord::Base
attr_accessible :checked, :description, :license, :policy, :privateCar
validates_presence_of :description,:policy
belongs_to :user
end
|
require "bcrypt"
class Usr < ActiveRecord::Base
has_many :custom_field
has_many :contact
attr_accessor :password, :password_confirmation
validates_presence_of :name, :login, :password, :password_confirmation
validates_uniqueness_of :login
validates_length_of :password, minimum:6
validates_confirmation_of :p... |
require 'active_support/core_ext/date_time'
module CollectionSpace
module Tools
StructuredDate = Struct.new(
:parsed_datetime,
:date_string,
:display_date,
:earliest_day,
:earliest_month,
:earliest_year,
:earliest_scalar,
:latest_day,
:lates... |
namespace :github do
desc "Create Github Release."
namespace :release_by_branch do
desc "Create Github Release."
task :create, [:branch, :release, :env, :token] do |t, args|
require 'rest-client'
require 'json'
begin
release_hash = { "devnet" => "DevNet", "testnet" ... |
# frozen_string_literal: true
module Devise
module Models
#= Devise::Models::ValidatableWithPersonEmail
#
# A re-implementation of Devise::Models::Validatable, but instead of
# expecting the `email` field to be in the authenticatable model, is located
# instead in the `Person` associated model
... |
# http://classic.battle.net/war3/human/units/footman.shtml
class Footman < Unit
def initialize(hp = 60, ap = 10)
@health_points = hp
@attack_power = ap
end
def attack!(enemy)
if enemy.is_a? Building
super(enemy, 0.5)
else
super
end
end
end |
class LoginControllerStylesheet < ApplicationStylesheet
# Add your view stylesheets here. You can then override styles if needed, example:
# include FooStylesheet
def setup
# Add stylesheet specific setup stuff here.
# Add application specific setup stuff in application_stylesheet.rb
end
def root_vi... |
require "communard"
module Communard
class Rake
extend ::Rake::DSL if defined?(::Rake::DSL)
def self.add_tasks(*args, &block)
task :_load_communard do
@_communard_commands = Communard.commands(*args, &block)
end
desc "Creates the database, migrate the schema, and loads seed data"... |
class QuestionsController < ApplicationController
def index
@questions = Question.all.order("RANDOM()")
end
def new
@question = Question.new
@topic = Topic.new
end
def create
puts "QUESTIONS IS: "
puts params
@q = Question.create(q_params)
redirect_to question_path(@q)
end
... |
class ApplicationController < ActionController::Base
protect_from_forgery
around_filter :user_time_zone, if: :current_user
private
def current_user
current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def authorize
redirect_to root_path, alert: "Please sign in" if current_user.n... |
FactoryGirl.define do
factory :city do
sequence(:name) { Faker::Address.city }
# association :hour
end
end
|
# encoding: utf-8
class ElasticsearchRasi
module Common
# prepare array indexes,lengths in the manner of slices
# e.g. for a.length=25 and cnt=10 return [[0,10],[10,10],[20,5]]
def array_slice_indexes(ids, cnt = SLICES)
rslt = []
rslt << ids.shift(cnt) until ids.empty?
rslt
end
... |
require 'spec_helper'
describe Googl::Expand do
before :each do
fake_urls
end
context "when expand any goo.gl short URL" do
it { Googl.should respond_to(:expand) }
subject { Googl.expand('http://goo.gl/7lob') }
describe "#long_url" do
it "should return a long url" do
subject.... |
class Movie < ActiveRecord::Base
def self.all_ratings
select('rating').distinct.map(&:rating).sort
end
def self.ratings(ratings)
hash = {}
arr = all_ratings
arr.each do |rating|
hash[rating] = ratings.include? rating
end
hash
end
def self.with_ratings(ratings)
where(rating... |
class Dinosaur
attr_accessor :name, :period, :contintent, :diet, :weight, :walking_type, :description
def initialize (params)
@name = params[:name] || params[:genus]
@period = params[:period]
@continent = params[:continent]
@diet = params[:diet] || diet_parser(params)
@... |
require 'rails_helper'
RSpec.describe ChangeSchoolHeadteacherService, type: :model do
let(:service) { described_class.new(school, **details) }
let(:email_address) { Faker::Internet.email }
let(:full_name) { Faker::Name.name }
let(:details) do
{
email_address: email_address,
full_name: full_name... |
class CreateDayHasHours < ActiveRecord::Migration[5.2]
def change
create_table :day_has_hours do |t|
t.references :day, foreign_key: true, null: false
t.references :hour, foreign_key: true, null: false
t.timestamps
end
end
end
|
class Api::V1::ProfilesController < Api::V1::BaseController
authorize_resource class: User
def me
#render json: current_user
# так написать нельзя
# current_user - метод devise, он работает в обычных контроллерах, а в api контроллеры защищены не девайсом,
# защищены doorkeeper-ом и у него нет метод... |
class BiodatabaseLinkType < ActiveRecord::Base
CLEANED = 'Cleaned'
has_many :biodatabase_links
def self.cleaned
find_by_name(CLEANED)
end
def authorized_for_destroy?
not [CLEANED].include? self.name
end
end
|
# frozen_string_literal: true
class Slide < ApplicationRecord
belongs_to :playlist
belongs_to :content
validates :weight, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :name, presence: true, length: { maximum: 255 }, allow_blank: false
end
|
require File.join(File.dirname(__FILE__), 'spec_helper')
describe "Class package support" do
describe "#package" do
before :each do
@class = Class.new
end
it "should not take into account consecutive calls after the first one" do
@class.package "org.jruby.ruby2java"
@class... |
require 'spec_helper'
describe Auction do
describe " auction creation " do
before :each do
@auction = Auction.create
@charity = Charity.create(:legal_name => "Cool Charity")
end
it "should allow a buy_now price for the seller to change" do
end
it "should close the auction... |
require 'socket'
module Naf
class Machine < NafBase
include ::Af::Application::SafeProxy
include PgAdvisoryLocker
# Protect from mass-assignment issue
attr_accessible :server_address,
:server_name,
:server_note,
:enabled,
... |
#!/usr/bin/ruby -w
# order_manager.rb
require 'yaml'
require 'file_helper'
require 'order'
class Order_manager
attr_reader :orders, :orders_file, :fh
def initialize
@orders = Array.new
@orders_file = "data/all_orders.txt"
@fh = File_helper.new
@fh.file_name=@orders_file
load_orders
end... |
#!/usr/bin/env ruby
#-----------------------------------------------------------------------------#
# bing_images.rb #
# #
# Copyright (c) 2012, Rajiv Bakulesh Shah, original autho... |
Rails.application.routes.draw do
scope :api do
devise_for :users
end
namespace :api do
resources :articles, only: [:index, :show, :create, :update, :destroy] do
resources :comments, only: [:index, :create]
resource :attachment, only: [:update]
end
resources :comments, o... |
class Types::QuestionType < Types::BaseObject
field :id, Integer, null: false
field :description, String, null: false
field :answers, [Types::AnswerType], null: true, description: 'Answers'
end |
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
include ActionView::Helpers::OutputSafetyHelper
include Cms::Helpers::ImageHelper
include ActionView::Helpers::A... |
class UploadController < ApplicationController
def index
end
def import
email = signed_in? ? current_user.email : params[:email]
doc = Document.import(params[:file], email)
if doc
redirect_to file_path(key: doc.key), :notice => "Documents uploaded!"
else
flash.now[:error] = "Something... |
require_relative 'container'
class BookingPage < Container
def booked_in?
booked_hotel == 'Rendezvous Hotels'
end
def loaded?
@browser.window.url.include? 'https://www.phptravels.net/account'
end
private
def booked_hotel
@browser.element(css: "#bookings > div.row > div.col-... |
class SettingsController < ApplicationController
before_action :authenticate_user!
before_action :find_user_and_services
def show
end
def update
if @user.update_attributes(params.require(:user).permit(:game_confirmed_email, :commented_email, :game_unconfirmed_email))
redirect_to setting_path, :not... |
class Manage::QuestionsController < ApplicationController
def index
load_index()
end
def show
@question = Question.find(params[:id])
end
def new
@question = Question.new()
2.times do
@question.answers.build
end
end
def edit
@question = Question.find(params[:id])
end
... |
feature 'page has title' do
scenario 'Chitter is shown' do
visit('/')
expect(page).to have_content('Welcome to Chitter!')
end
end
|
# bin/rake routes to see table of URL endpoints (see bottom!)
Rails.application.routes.draw do
root to: 'products#index'
resources :products, only: [:index, :show] do
resources :reviews, only: [:create, :destroy]
end
resources :categories, only: [:show]
resource :cart, only: [:show] do
post :ad... |
# frozen_string_literal: true
module Dealersocket
module Client
# This class is responsible for logic for CRUD actions of Dealersocket activities
class Activity < Base
APPROVED_ATTRIBUTES = %i[id customer_id event_id dealer_number_id].freeze
class << self
def create(activity_params)
... |
# frozen_string_literal: true
# Advent of Code 2020
#
# Robert Haines
#
# Public Domain
require 'test_helper'
require 'aoc2020/crab_cups'
class AOC2020::CrabCupsTest < MiniTest::Test
LABELS = [3, 8, 9, 1, 2, 5, 4, 6, 7].freeze
def setup
@cc = AOC2020::CrabCups.new
end
def test_play
assert_equal([5,... |
class HomepagesController < ApplicationController
expose(:articles) { Article.available_to(current_user) }
expose(:articles_data) do
ActiveModel::ArraySerializer
.new(articles)
.to_json
end
def show
end
end
|
=begin
Destruction complète du film
=end
film = Film.new(param :film_id)
if film.exists?
film.destroy
else
error("Impossible de trouver le film #{param(:film_id)}…")
end |
require File.expand_path('../spec_helper', File.dirname(__FILE__))
describe Tr8n::TokenizedLabel do
describe 'registering tokens' do
context "registering correct tokens" do
it "should register all tokens" do
str = 'Dear {user:gender}, you have [bold: {count:number|| new message}] in your mailbox!'... |
# As a Maker
# So that I can let people know what I am doing
# I want to post a message (peep) to chitter
# As a maker
# So that I can see what others are saying
# I want to see all peeps in reverse chronological order
# As a maker
# So that I can better appreciate the context of a peep
# I want to see the time at wh... |
#Classe per il parsing delle tabelle
#Riconosce le opzioni aggiunitve:
# table_name
# singular
# plural
# class_name
# foreign_key
# controller_name
# controller_path
class SfsTable
attr_accessor :name,
:table_name, :singular, :plural, :class_name, :foreign_key, :controller_name, :controller_path,
:id, :prima... |
#!/usr/bin/ruby
configs = [
{
:schema => "org.gnome.libgnomekbd.keyboard",
:key => "layouts",
:value => "us",
:type => "array",
:append => true,
:comment => 'Make sure US English keyboard is set'
},
{
:schema => "org.gnome.libgnomekbd.keyboard",
:key => "layouts",
:value => "r... |
class ClientsController < ApplicationController
include ApplicationHelper
before_action :set_client, only: [:show, :edit, :update, :destroy]
before_action :checkLogIn
# GET /clients
# GET /clients.json
def index
if isAdmin?
@clients = Client.all
else
@clients = Client.where(user_id: ... |
class ConsController < ApplicationController
before_action :select_con, only: [:destroy]
before_filter :authorize
def new
@con = Con.new
end
def create
@con = Con.create(con_params)
respond_to do |format|
format.js
end
end
def destroy
@con.destroy
respond_to do |format|
... |
require 'spec_helper'
require 'virtus'
describe 'Mongo adapter' do
let(:rom) { ROM.setup(mongo: 'mongo://127.0.0.1:27017/test') }
after do
rom.mongo.connection.drop
end
it 'works' do
rom.schema do
base_relation(:users) do
repository :mongo
attribute "_id"
attribute "na... |
# frozen_string_literal: true
class Episode < ApplicationRecord
## Associations
belongs_to :season
## Validations
validates_numericality_of :sequence_number, greater_than: 0
end
|
class City < ApplicationRecord
# plugins
extend FriendlyId
friendly_id :name, use: :slugged
# associations
belongs_to :country
end
|
module Chanko
def self.configure(&block)
yield @config ||= Configuration.new
end
def self.config
@config
end
class Configuration
include ActiveSupport::Configurable
config_accessor :raise
config_accessor :propagated_errors
config_accessor :test
config_accessor :cache_classes
... |
# encoding: UTF-8
module API
module V1
module Games
class GroupItems < API::V1::Base
helpers API::Helpers::V1::GamesHelpers
before do
authenticate_user
end
namespace :games do
namespace :group_items do
desc "Create a new game GameGroupItem ... |
class RenamePasswordOnUsers < ActiveRecord::Migration
def change
rename_column :users, :password, :hashed_password
end
# TODO: change existing passwords into hashed
end
|
module Lolita
class NotORMClassError < ArgumentError; end
class NoFieldsGivenError < ArgumentError; end
class SameTabTypeError < ArgumentError; end
class ReferenceError < ArgumentError; end
class FieldNameError < NoMethodError; end
class FieldTypeError < ArgumentError; end
class ModuleNotFound < ArgumentE... |
module Lolita
module Configuration
# Tab is used as a container for different type of resource content.
# It can contain fields, images, audio, video files, maps and other stuff.
# Tab contain following parts, that also are configurable through block or
# arguments passed to tab.
# * <tt>nested_fi... |
class Article < ActiveRecord::Base
attr_accessible :title, :body, :image
has_many :comments
has_many :taggings
has_many :tags, through: :taggings
attr_accessible :tag_list
has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }
attr_accessible :image
belongs_to :author
def tag_list
self... |
require 'bcrypt'
class User < ActiveRecord::Base
# users.password_hash in the database is a :string
include BCrypt
validate :is_not_a_minor
def age
now = Time.now.utc.to_date
now.year - self.birthday.year - ((now.month > self.birthday.month || (now.month == self.birthday.month && now.day >= self.birt... |
class Comment < ApplicationRecord
belongs_to :user
belongs_to :commentables, polymorphic: true
has_many :votes, as: :voteables
validates :body, presence: true
end
|
class CreateForms < ActiveRecord::Migration[6.0]
def change
create_table :forms do |t|
t.string :form_field_1
t.string :form_field_2
t.string :form_field_3
t.references :company, null: false, foreign_key: true
t.timestamps
end
end
end
|
class Image < ActiveRecord::Base
attr_accessible :attachment
has_attached_file :attachment,
:styles => {
:thumbnail => ['160x160', :jpg]
}
validates_attachment_content_type :attachment, :content_type => /\Aimage\/.*\Z/
end
|
require 'spec_helper'
describe Time do
describe "#second_of_week" do
let(:t) { Time.new(2012, 10, 30, 1, 0, 0) } # 49 hours after Sunday 12am
context "seconds" do
it "returns the seconds since the beginning of the week" do
seconds = 3600 * 49
t.second_of_week.should eq seconds
... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: stories
#
# id :bigint(8) not null, primary key
# user_id :bigint(8)
# working_article_id :bigint(8)
# date :date
# reporter :string
# group :string
# title :... |
class Admin::GeoSettingsController < Admin::BaseController
before_filter :set_geolocation, :only => [:show]
def update
Spree::Config.set(params[:preferences])
respond_to do |f|
f.html {
redirect_to admin_geo_settings_path
}
end
end
private
def set_geolocation
if Spre... |
require 'spec_helper'
describe "31178771 has_sage_flow_states add class method to find all the objects in a certain state (assumes ActiveRecord), e.g. MyClass.all_saved" do
before(:each) do
class Foo < Sample
has_sage_flow_states :zing, :bar
end
end
it "has the class method all_zing" do
Foo.met... |
require "ruboty/sidedish/actions/sidedish"
require "ruboty/sidedish/actions/translate"
module Ruboty
module Handlers
class Sidedish < Base
# test
on(
/sidedish (?<number>.*?)\z/,
name: 'sidedish',
description: 'output sidedish result'
)
# 翻訳
on(
/(?<... |
require_relative '../automated_init'
context "Put" do
context "Missing ID" do
stream_name = Controls::StreamName.example
write_event = Controls::EventData::Write.example(id: :none)
position = Put.(write_event, stream_name)
read_event = Get.(stream_name, position: position).first
context "An ID... |
puts "What is your name?"
user_name = gets.chomp
puts "Do you want to play RPS?"
answer = gets.chomp
answer.downcase!
if answer == "yes"
puts "Awesome!"
#This gets user's weapon choice
puts "Choose Rock, Paper, or Scissors.."
user_choice = gets.chomp
user_choice.downcase!
puts "#{user_name}'s choice: #{user_choic... |
require 'spec_helper'
feature "Viewing Projects" do
scenario "Listing projects" do
project = FactoryGirl.create(:project, :title => "Build a gizmo")
visit projects_path
click_link 'Build a gizmo'
page.current_url.should == project_url(project)
end
end
|
class Review < ApplicationRecord
belongs_to :reservation
validates :reservation_id, presence: true
validates :content, presence: true
validates :content, length: { minimum: 5 }
validates :rating, presence: true
validates :rating, numericality: true
def change_reviewed_status
self.reservation.reviewe... |
Rails.application.routes.draw do
mount_devise_token_auth_for "User", at: "auth", controllers: {
confirmations: "auth/confirmations",
passwords: "auth/passwords",
omniauth_callbacks: "auth/omniauth_callbacks",
registrations: "auth/registrations",
sessions: "auth/sessions",
token_va... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
attr_accessor :login
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :participants
has_ma... |
class Work::PrescriptionsController < Admin::BaseController
before_action :set_prescription, only: [:show, :edit, :update, :destroy]
# GET /prescriptions
# GET /prescriptions.json
def index
@q = SearchParams.new(params[:search_params] || {})
search_params = @q.attributes(self)
@prescriptions = Pres... |
class AddVendorUsersIdToProducts < ActiveRecord::Migration
def change
add_column :products, :vendor_user_id, :int
end
end
|
# Locator class to declare the locators in the Upwork Search listing page
require_relative "../utils/locators"
# include Libraries
class SearchListing
attr_reader :search_list_cards, :search_list_profile_stats, :back_button
# constructor for 3 main elements on page, Locator class inherited
# card is the whole ... |
module OAuthService
class GetOAuthUser
def self.call(auth)
# 認証データに対応するSocialProfileが存在するか確認し
# なければSocialProfileを新規作成
# 認証データをSocialProfileオブジェクトにセットし,DBに保存
profile = SocialProfile.find_for_oauth(auth)
# ユーザーを探す.
# 第1候補:ログイン中のユーザー,第2候補:SocialProfileオブジェクトに
# 紐付けられているユーザ... |
class Admin::LinkCollectionsController < ApplicationController
before_filter :authenticate_admin!
# GET /link_collections
# GET /link_collections.xml
def index
@link_collections = LinkCollection.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @link_colle... |
require "hoze"
script = ARGV[0]
unless script
puts "No worker script given"
exit 1
end
puts "Running with worker script #{script}"
script_path = Pathname.new(script).realpath
puts "Loading script from file #{script_path}"
require script_path |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.