text stringlengths 10 2.61M |
|---|
class Table < ActiveRecord::Base
has_many :orders
validates :name , presence:true, uniqueness:true
end
|
# Grabs a full track listing for the provided
# credentials.
module VelocitasCore
class TrackFetcher
# Currently just fetches a global list.
def fetch
Track.all
end
end
end
|
user = node['ubuntu_i3-gaps_workstation']['user']
playerctl_deb_path = "#{node['ubuntu_i3-gaps_workstation']['tmp_dir']}/playerctl.deb"
version = node['ubuntu_i3-gaps_workstation']['playerctl']['version']
# Download playerctl deb package
remote_file playerctl_deb_path do
source "https://github.com/acrisci/playerctl/... |
Copyright (c) 2014 Francesco Balestrieri
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribu... |
require 'pry'
module BinaryTree
# Definition for binary tree node
class TreeNode
attr_accessor :val, :left, :right
def initialize(val)
@val = val
@left, @right = nil, nil
end
end
# @param {Integer[]} inorder
# @param {Integer[]} postorder
# @return {TreeNode}
def self.build... |
class AddShipFeeAndSnToOrders < ActiveRecord::Migration
def change
add_column :orders, :ship_fee, :integer
add_column :orders, :sn, :string
end
end
|
require 'rails_helper'
describe AwardsController, type: :controller do
award = Award.create(:award => "Academy")
describe "GET index" do
it "have 200 response for getting all awards" do
get :index
expect(response).to have_http_status(200)
end
end
describe "GET show" do
it "have 200 respo... |
require 'spec_helper'
describe Application do
let(:user) { User.make! }
it "should be invalid without a name, user, server and deployment" do
application = Application.new()
application.should have(1).error_on(:name)
application.should have(1).error_on(:user_id)
application.should have(1).error_on... |
class Army < ActiveRecord::Base
# Associations
belongs_to :power
belongs_to :unit
belongs_to :occupation
# Validation
validates :amount, :power_id, :unit_id, presence: true
validate :check_amount
private
def check_amount
errors[:content] << "Amount of units has to be 1 at least." if amount <= 0
... |
class VotesController < ApplicationController
before_action :set_vote, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@votes = Vote.all
end
def show
end
def new
@vote = Vote.new
end
def create
@vote = Vote.create(vote_params)
respond_to do |format|
if @vo... |
# frozen_string_literal: true
module Exfiles
VERSION = "0.0.1"
end
|
require_relative 'node'
module Dom
# NoDoc is used by {Dom} and {Dom::Node} to preserve the correct hierachy of
# the tree, while inserting nodes with non (or not yet) existing parents.
#
# For example let's add the node 'foo.bar.baz' in our empty Dom. This will
# result in the following tree:
#
# ... |
module PlusganttUtilsHelper
class Utils
def initialize()
end
def get_hollidays_between(earlier_date, later_date)
hollidays = 0
Rails.logger.info("get_hollidays_between: " + Plusgantt.get_hollidays.to_s)
if Plusgantt.get_hollidays
hollidays += Plusgantt.get_hollidays.count{|d| (earlier_date <= d.... |
unless node["nfs"]["mounts"].empty?
mounts = node["nfs"]["mounts"]
mounts.each do |mount_point, v|
directory mount_point do
owner v["owner"]
group v["group"]
mode v["mode"]
recursive true
end # directory
mount mount_point do
device v["device"]
fstype "nfs"
if v.... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
require 'spec_helper'
describe StaffMember do
before(:each) do
@member = Factory.build(:staff_member)
end
it "validates the presence of name" do
@member.name = ""
@member.should_not be_valid
end
it "validates the presence of bio" do
@member.bio = ""
@member.should_not be_valid
end
... |
# frozen_string_literal: true
class AddCampusRefToSchoolsTable < ActiveRecord::Migration[4.2]
def change
add_column :schools, :campus_id, :int
add_index :schools, [:campus_id]
end
end
|
module ReadyForI18N
class I18nGenerator
EXTRACTORS = [ErbHelperExtractor, HtmlTextExtractor, HtmlAttrExtractor]
PATH_PATTERN = /\/views\/(.*)/
def self.dict
@dict
end
def self.path
@path
end
def self.excute(opt)
setupOptions(opt)
f = @src_path
ReadyForI18N... |
# Nice wrapper around VolleyWrapper, to use in BluePotion.
#
# result that is returned has these attributes:
# response
# object
# body
# status_code
# headers
# not_modified?
# success?
# failure?
#
# @example
# # Create a session and do a single HTML get. It's better
# # to use the shared session ... |
# Copyright © 2011-2019 MUSC Foundation for Research Development~
# All rights reserved.~
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~
# 1. Redistributions of source code must retain the above copyright notice, this l... |
class << ActiveRecord::Base
def each(batch_size = 100, opts = {}, &block)
batch_size ||= 100
opts ||= {}
maximum = opts.delete :maximum
deleting = opts.delete :deleting
hide_counter = opts.delete :hide_counter
total = count opts
offset = 0
whi... |
import "Setupfile"
fastlane_version "2.143.0"
default_platform :ios
platform :ios do
before_each do |lane, options|
setup_jenkins(
keychain_path: @keychain_name,
keychain_password: @keychain_password,
add_keychain_to_search_list: true,
)
end
lane :pods do
cocoapods(try_repo_updat... |
class TenantSerializer < ActiveModel::Serializer
attributes :name, :age, :total_rent, :apartments_with_rent
has_many :apartments
def total_rent
all_rents = object.leases.map do |lease|
lease.rent
end
all_rents.sum
end
def apartments_with_rent
all_leases = object.leases.map do |lease|
... |
class ClientsController < ApplicationController
before_action :find_client, except: :index
def index
render json: Client.all
end
def show
render json: @client, serializer: TotalMembershipsSerializer
end
def update
@client.update!(client_params)
render json: @c... |
require 'spec_helper'
describe Table do
before :each do
@table = Table.new 5, 5
end
describe "#new" do
it "took a width and a height and made a table" do
@table.should be_an_instance_of Table
end
end
describe "#width" do
it "returned the width" do
@table.width.should eql 5
e... |
require 'spec_helper'
describe FeaturesController do
let(:user) { create_user! }
let(:market) { Factory(:market) }
let(:feature) { Factory(:feature, :market => market, :user => user) }
context "standard users" do
it "cannot access a feature for a market" do
sign_in(:user, user)
get :show... |
class City < ActiveRecord::Base
set_table_name(:city)
set_primary_key(:city_id)
belongs_to :country
# def self.rentals_per_city
# self
# .select("city.*, COUNT(*) AS rental_count")
# .joins("address ON city.city_id = address.city_id")
# .joins("store ON address.address_id = store.address... |
# input: string
# output: string with first character of every word capitalised and the rest lowercase
# split every word in the string argument as an array, delimited by whitespace
# use capitalise method for each word
# join all elements in array into string using join method
# data structure: array
# algo:
# set ne... |
class ChangeFriendsStatusColumnType < ActiveRecord::Migration
def up
change_column :friends, :status, :string
end
def down
change_column :friends, :status, :boolean
end
end
|
class Location < ApplicationRecord
validates :name, presence: true
geocoded_by :address
after_validation :geocode
has_many :activity_locations
has_many :activity, through: :activity_locations
has_many :events
def address
[street, city, state, country].compact.join(',')
end
end
|
class Listing < ActiveRecord::Base
belongs_to :neighborhood
belongs_to :host, :class_name => "User"
has_many :reservations
has_many :reviews, :through => :reservations
has_many :guests, :class_name => "User", :through => :reservations
validates_presence_of :address, :listing_type, :title, :description, :pr... |
class AddOpenedToReview < ActiveRecord::Migration
def change
add_column :reviews, :opened, :boolean, default: :false
end
end
|
require 'csv'
require 'byebug'
namespace :import do
desc "import users from csv"
task users: :environment do
filename = File.join Rails.root, "db/csv/users.csv"
CSV.foreach(filename, headers: true) do |row|
User.create(email: row['email'], password: row['password'], role: row['role'])
end
en... |
# frozen_string_literal: true
class AddCompletionsCountToChallenges < ActiveRecord::Migration[5.1]
def change
add_column :challenges, :completions_count, :integer, default: 0, null: false
Challenge.reset_column_information
Challenge.find_each.pluck(:id) { |challenge_id| Challenge.reset_counters challeng... |
# Object to get password stored in session variable
class GetPasswordInSessionVar
def initialize(token)
@token = token
end
def call
return nil unless @token
decoded_token = JWT.decode @token, ENV['MSG_KEY'], true
payload = decoded_token.first
payload['specially_hashed_password']
end
end
|
module Tokenizer
class Lexer
module TokenLexers
def eol?(chunk)
chunk == "\n"
end
# On eol, check the indent for the next line.
# Because whitespace is not tokenized, it is difficult to determine the
# indent level when encountering a non-whitespace chunk. If we check on
... |
require 'rails_helper'
describe 'navigation' do
it 'has login and registration links if the user is not logged in' do
visit root_path
expect(page).to have_link('Login')
expect(page).to have_link('Register')
end
it 'does not has login and registration links if the user is logged in' do
user = Fac... |
# frozen_string_literal: true
require 'rsolr'
module FindIt
module Data
# Sends deletion requests to solr
module Delete
def by_record_provider_facet(facet_value)
connection = RSolr.connect(Blacklight.connection_config.without(:adapter))
connection.delete_by_query "record_provider_facet... |
require File.expand_path("../.gemspec", __FILE__)
require File.expand_path("../lib/ultimaker/version", __FILE__)
Gem::Specification.new do |gem|
gem.name = "ultimaker"
gem.authors = ["Samuel Kadolph"]
gem.email = ["samuel@kadolph.com"]
gem.summary = readme.summary
gem.homepage = "https://github.com/... |
class StripeCache
def initialize(user)
@user = user
end
def refresh
if user.stripe_customer_id.present? && user.stripe_subscription_id.present?
purge_all
cache_all
end
self
end
def customer
return @customer if @customer
@customer = Rails.cache.fetch(cache_key("customer")... |
class Character < ActiveRecord::Base
belongs_to :guild
has_many :events
has_many :remoteQueries
belongs_to :user
has_many :attendances
serialize :profession1
serialize :profession2
serialize :talentspec1
serialize :talentspec2
serialize :items
validates_uniqueness_of :name
validates_presen... |
# == Schema Information
#
# Table name: c14_labs
#
# id :bigint not null, primary key
# active :boolean
# name :string
# superseded_by :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_c14_labs_on_active ... |
class AddLaboratoryToUser < ActiveRecord::Migration
def up
change_table :users do |t|
t.belongs_to :laboratory, index: true
end
end
end
|
require 'spec_helper'
describe SimpleCoffee do
before :each do
@coffee = SimpleCoffee.new
end
describe "#new" do
it "returns a coffee object" do
@coffee.should be_an_instance_of SimpleCoffee
end
end
it "returns the cost" do
@coffee.get_cost().should == 1
end
it "describes the ingredient... |
class Rooms::AlertsController < AlertsController
before_action :set_alertable
private
def set_alertable
@alertable = Room.find(params[:room_id])
end
end
|
class FitnessGoal < ApplicationRecord
has_many :members
validates_presence_of :goal_name
def self.options_for_select
order('LOWER(goal_name)').map { |e| [e.goal_name, e.id]}
end
end
|
require 'test_helper'
class SentinelTest < ActiveSupport::TestCase
context "When assigning attributes" do
setup do
@sentinel = Sentinel::Sentinel
end
should "create attr_accessor's for each valid key" do
sentinel = @sentinel.new(:user => {:name => "John", :active => true}, :forum => {:name =... |
class CreateTagMovements < ActiveRecord::Migration
def change
create_table :tag_movements do |t|
t.float :credit
t.integer :tag_id
t.timestamps
end
end
end |
require_relative './mocks/telldus-mock/lib/telldus_state'
require 'rbtelldus'
shared_examples 'a controll function' do |args|
method = args[:method]
argument = args[:arg]
let(:id) { 1 }
let!(:state) { TelldusSwitchState.new id: 1 }
subject { described_class.send(method, id, *argument) }
context 'device... |
# Use these two arrays to generate a deck of cards.
ranks = ["A", 2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K" ]
ranks.rotate!(1)
suits = [ "hearts", "spades", "clubs", "diamonds" ]
players = []
deck = ranks.product(suits) # creating combined deck
shuff_deck = deck.shuffle # creating shuffled deck
player = nil
# I need... |
require 'httparty'
require 'singleton'
class MarkusRESTfulAPI
# Stores the api_url and auth_key for later use
def MarkusRESTfulAPI.configure(api_url, auth_key)
@@auth_key = auth_key
api_url = "#{api_url}/" if api_url[-1, 1] != '/'
@@api_url = api_url
end
# Makes a GET request to the provided URL ... |
class Followship < ActiveRecord::Base
belongs_to :follower, class_name:"User", foreign_key:"user_id"
belongs_to :following, class_name:"User", foreign_key:"following_user_id"
end
|
require 'ddtrace/monkey'
require 'ddtrace/pin'
require 'ddtrace/tracer'
require 'ddtrace/error'
require 'ddtrace/pipeline'
# \Datadog global namespace that includes all tracing functionality for Tracer and Span classes.
module Datadog
@tracer = Datadog::Tracer.new()
# Default tracer that can be used as soon as +d... |
# Defines the core upload and view TracksAPIs.
module Commuting
class StoplightAPI < Grape::API
version "v1", vendor: "g9labs"
format :json
helpers do
params :pagination do
optional :page, type: Integer
optional :per_page, type: Integer
end
end
namespace :commuting do... |
ActiveAdmin.register Contact do
action_item :only => :show do
link_to('Add New', new_admin_contact_path)
end
action_item :only => [:new, :edit, :show] do
link_to('Back to Index', admin_contacts_path)
end
index do
selectable_column
column :id
column :full_name
column :email
... |
describe do
attr :title, 'Journal'
content file('views/article.html.erb')
end
act do
@notes = recent_articles
end
|
require File.dirname(__FILE__) + '/../test_helper'
class AdUnitsTest < ActiveSupport::TestCase
def test_cant_execute
assert_raise(AdUnits::InvalidDslInput) do
AdUnits::execute_viewpoints_ad_unit nil
end
assert_raise(AdUnits::InvalidDslInput) do
AdUnits::execute_viewpoints_ad_unit ''... |
require 'rails_helper'
RSpec.describe Bookmark, type: :model do
describe 'validations' do
it { should validate_presence_of(:url) }
end
describe 'relations' do
it { should belong_to(:user) }
#it { should have_one_attached(:screenshot) } come back to this one!!!
it { should have_and_belong_to_many(:tags)... |
class Notifier < ActionMailer::Base
def register_notification(recipient)
recipients recipient.email_address_with_name
from "i@soulup.net"
subject "Вы успешно зарегистрировались на сайте soulup.net"
body :account => recipient
content_type "text/html"
end
def activation_notification(recipient)
... |
json.array!(@line_services) do |line_service|
json.extract! line_service, :id, :service_id, :cart_id
json.url line_service_url(line_service, format: :json)
end
|
class ConnectCallToVoicemail
def initialize(incoming_call:, adapter: TwilioAdapter.new)
@incoming_call = incoming_call
@adapter = adapter
end
def call
if connect_to_voicemail(incoming_call.from_sid)
Result.success
else
Result.failure("Could not connect call to voicemail")
end
en... |
require_relative '../rails_helper'
describe SectionsController do
login_admin
describe "GET #index" do
it "populates an array of sections" do
section = create(:section)
get :index
expect(assigns(:sections)).to match_array([section])
end
it "renders the :index view" do
get :ind... |
class ChangeColumnsNoAdmin < ActiveRecord::Migration
def change
remove_column :users, :admin_id
end
end
|
require 'rails_helper'
describe StructureFieldPresenter do
let(:audit_structure) { instance_double(AuditStructure) }
describe '#partial' do
it 'returns the corresponding partial name for field types' do
audit_field = instance_double(AuditField, value_type: 'switch')
presenter = described_class.new... |
#ExStart:
require 'aspose_email_cloud'
class Attachment
include AsposeEmailCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@email_api = EmailApi.new
end
def upload_file(file_name)
@storage_api = Storag... |
# frozen_string_literal: true
Given("there is a reference") do
create :any_reference, :with_author_name
end
Given("there is an article reference") do
create :article_reference, :with_author_name
end
Given("there is a book reference") do
create :book_reference, :with_author_name
end
Given(/^(?:this reference e... |
class Links::Misc::ScMatchups < Links::Base
def site_name
"Sporting Charts"
end
def description
"Matchups"
end
def url
"http://www.sportingcharts.com/nhl/rivalrylisting/"
end
def group
5
end
def position
3
end
end
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'rubberband-audio'
describe RubberBand::Options do
describe "basic" do
it "should use quite" do
RubberBand::Options.new.to_s.should =~ /-q/
end
end
describe "configurable parameters" do
it "should support time" do
... |
Rails.application.routes.draw do
mount Ckeditor::Engine => '/ckeditor'
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
root 'static_pages#home'
devise_for :trainees, :skip => [:registrations]
devise_for :trainers, :skip => [:registrations]
namespace :trainee do
resources :courses, only:[:show] do... |
module SNMPTableViewer
# Formatting class for CSV output.
class Formatter::CSV < Formatter
# Output the data (and headings if provided).
# @return [String] the CSV data
def output()
data_with_headings.map(&:to_csv).join
end
end # CSV Formatter
end # module SNMPTableViewer
|
#==============================================================================
# +++ MOG - Picture Effects (v1.0) +++
#==============================================================================
# By Moghunter
# https://atelierrgss.wordpress.com/
#=========================================================... |
# frozen_string_literal: true
class User < ApplicationRecord
devise :database_authenticatable, :validatable
has_many :contacts
has_many :tasks
has_many :touched_contacts, class_name: 'Contact', foreign_key: :touched_id
has_one_attached :avatar
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
## class: Userを入れないとインスタンスメソッドのテストが出来ないようです。
factory :twitter_user, class: User do
sequence(:nickname) { |i| "nickname#{i}" }
sequence(:image_url) { |i| "http://example.com/image#{i}.jpg" }
after(:create) do|use... |
# frozen_string_literal: true
require 'test_helper'
class LabelTest < ActiveSupport::TestCase
test 'label is valid' do
valid_label = Label.new(
value: 'Sport'
)
assert valid_label.valid?
end
test 'label is invalid' do
valid_label = Label.new(
value: ''
)
assert_not valid_la... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :military do
consultant
rank
branch
clearance_level
investigation_date { 1.years.ago }
service_start_date { 6.months.ago }
end
end
|
# frozen_string_literal: true
# config/db/migrate/enable_uuid.rb
class EnableUuid < ActiveRecord::Migration[6.0]
def change
enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
enable_extension 'uuid-ossp' unless extension_enabled?('uuid-oosp')
end
end
|
FactoryBot.define do
factory :project do
user
sequence(:name) { |n| "project-#{n}" }
title { "title" }
trait :released do
released_at { Time.current }
end
trait :deployed do
after(:create) { |project| create(:deployment, :finished, project: project) }
end
trait :deployme... |
class RoutineTasksController < ApplicationController
include RoutineTasksHelper
before_action :authenticate_user!
before_action :set_routine_task, only: [:edit, :destroy]
def edit
end
def create
@routine_task = RoutineTask.verify_routine_task(
RoutineTask.new(routine_task_params), current_user.... |
class CreateCourses < ActiveRecord::Migration
def change
create_table :courses do |t|
t.integer :user_id, null: false
t.integer :area_id, null: false
t.string :name, null: false
t.float :distance, null: false
t.string :image_url, null: false
t.timestamps null: false
end
... |
#!/usr/bin/env ruby1.9.3
# For small experiments, run as ./OhlohJavaRepoFetcher.rb --max_repos 20
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'optparse'
# this script fetches all git repositories of projects with
# "java" (as tag | in title | in project description) from ohloh
PROJECTS_PER_PAG... |
# frozen_string_literal: true
class ApplicationController < ActionController::Base
def access_denied(exception)
respond_to do |format|
format.json { head :forbidden, content_type: "text/html" }
format.html { redirect_to root_url, notice: exception.message }
format.js { head :forbidden, conten... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'clocker/version'
Gem::Specification.new do |spec|
spec.name = 'clocker'
spec.version = Clocker::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors ... |
class AuthenticateUser
def initialize(email, password)
@email = email
@password = password
end
# Service entry point
def call
data
end
private
attr_reader :email, :password
# verify user credentials
def user
user = User.find_by(email: email)
return user if user && user.authenti... |
module ThreeScale
module Backend
module Stats
module Aggregators
module Base
SERVICE_GRANULARITIES =
[:eternity, :month, :week, :day, :hour].map do |g|
Period[g]
end.freeze
private_constant :SERVICE_GRANULARITIES
# For application... |
# frozen_string_literal: true
module ApplicationHelper
def title_app
I18n.t('app')
end
def view_active?(controller)
params[:controller] == controller ? 'active' : nil
end
def devise_active?
params[:controller].include?('devise') ? 'active' : nil
end
def size_types
Pet.size_types
end
... |
class RemoveRepoIdFromHooks < ActiveRecord::Migration
def up
remove_column :hooks, :repo_id
end
def down
add_column :hooks, :repo_id, :string
end
end
|
class Is
class Point
attr_reader :longitude, :latitude
def initialize(lat, long)
@latitude = lat.to_f
@longitude = long.to_f
end
def in?(area)
area = Is::Area.new(area) unless area.is_a?(Is::Area) # :)
area.contains? self
end
end
end
|
class AccountCredential < ActiveRecord::Base
belongs_to :user
TYPES = {
fb: 'facebook',
tw: 'twitter'
}
attr_accessible :token, :uid, :account_type, :token_secret, :user_id
validates :uid, :uniqueness => { :scope => :account_type,
:message => "The social network ac... |
class PlaylistViewOption
def message
"View Playlist"
end
def perform
puts "\nPlaylist\n==========================\n"
Playlist.songs.each_with_index do |song, index|
puts "#{index + 1}: #{song.title}"
end
puts
end
end
|
AppTitle = "Hello World"
IMAGE_URLS = {
antani: "https://upload.wikimedia.org/wikipedia/it/thumb/1/1b/Amicimiei-Tognazzi.jpg/310px-Amicimiei-Tognazzi.jpg" # antani is a word that makes no sense (like foo)
}
def Image(tag)
url = IMAGE_URLS.fetch tag
{
type: "image",
url: url,
}
end
def Label(text)
... |
module DockerClient
def self.create(server_url, options = {})
Base.new(server_url, options)
end
class Base
def initialize(server_url, options)
@server_url = server_url
@connection = Docker::Connection.new(server_url, options)
validate_version!
end
def validate_version!
Do... |
class CreateWeixinXiaodianProduct < ActiveRecord::Migration[5.1]
def change
create_table :weixin_xiaodian_products do |t|
t.string :product_id, :limit => 100
t.string :name, :limit => 200
t.text :properties
t.string :sku_info, :limit => 300
end
end
end
|
class Studio < ActiveRecord::Base
attr_accessible :name
has_many :movies
end
|
Rails.application.routes.draw do
resources :blueprints
root "blueprints#index"
end
|
require 'server_spec_helper'
require 'pry-byebug'
# require 'pg'
describe ListMore::Server do
def app
ListMore::Server.new
end
let(:dbhelper) { ListMore::Repositories::DBHelper.new 'listmore_test' }
let(:user_1) { ListMore::Entities::User.new({:username => "Ramses", :password_digest => "pitbull"})}
let... |
FactoryBot.define do
factory :shop do
user_id { 1 }
name { 'ラーメン大王' }
prefecture { 1 }
address { '札幌市1丁目' }
phone { '000-000-1234' }
image { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec/fixtures/ramen-01.jpg')) }
end
end
|
require 'exifr'
class Picture < ActiveRecord::Base
has_and_belongs_to_many :details
has_and_belongs_to_many :tags
belongs_to :divelog
belongs_to :divesite
has_one :exif
has_attached_file :image, :styles => { :medium => "720x540>", :thumb => "105x80>" }
after_save :process_exif
def process_exif
... |
class SevensController < ApplicationController
def index
@sevens = Seven.all
end
def new
@seven = Seven.new
end
def create
@seven = Seven.new(seven_params)
if @seven.save
redirect_to sevens_path
else
render 'new'
end
end
def seven_params
params.require(:seve... |
class RankingValue < ActiveRecord::Base
# associations
belongs_to :ranking
belongs_to :ranked_object, :polymorphic => true
# validations
validates :value, :position, :ranking, :ranked_object, :presence => true
validates_uniqueness_of :position, :scope => [:ranking_id]
# scoping by ranking
scope :for_... |
require File.dirname(__FILE__) + "/../../spec_helper"
require File.dirname(__FILE__)+ '/../fixtures/classes'
describe "Equality" do
it "maps Object#eql? to System.Object.Equals for Ruby classes" do
o = EqualitySpecs::RubyClassWithEql.new
EqualityChecker.equals(o, :ruby_marker).should be_true
end
it "map... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.