text stringlengths 10 2.61M |
|---|
require 'test_helper'
class FriendshipTest < ActiveSupport::TestCase
setup do
@user_1 = users(:user)
@user_2 = users(:regulator)
end
test "should start with no friends" do
assert_equal([], @user_1.friends)
assert_equal([], @user_2.friends)
end
test "should find all friends" do
friendshi... |
class PointsController < ApplicationController
respond_to :json
def create
if current_user
@map = Map.find_by_id(params[:map_id])
@point = Point.new(:latitude => params[:latitude],
:longitude => params[:longitude],
:marker_id => params[:marker_id],
... |
# Copyright (c) 2009-2011 VMware, Inc.
$:.unshift File.join(File.dirname(__FILE__), "..")
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
require "rubygems"
require "rspec"
require "bundler/setup"
require "vcap_services_base"
require "nat... |
# before do
# $game.play_turn(weapon2: 'Rock')
# end
feature 'Game mechanics' do
# As a user
# So that I can play my turn
# I need to be able to choose one option between paper/scissors/rock
xscenario 'Player1 can pick rock/scissors/paper before each turn' do
sign_in
play_paper
expect(page).to ... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
CONFIG = YAML.load(File.read('config.yml'))
DEFAULT_IMAGE = 'centos/7'
Vagrant.configure("2") do |config|
CONFIG['groups'].each do |group_name, group_hash|
group_hash["vms"].each do |vm|
config.vm.define vm["name"] do |subconfig|
subconfig.v... |
class RegistrationsController < ApplicationController
skip_before_action :authenticate_user, only: [:new, :create]
def new
@form = RegistrationForm.new
end
def create
# binding.pry
@form = RegistrationForm.new(registration_params)
if @form.save
session[:user_id] = @... |
Rails.application.routes.draw do
# resources :follow_joins
# users
namespace :api do
namespace :v1 do
resources :users
get "/users/:id/designs", to: "users#designs"
get "/users/:id/designs/:id", to: "designs#show"
post "/users/:id/designs", to: "designs#create"
delete "/users... |
class HomesController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :except=> 'index'
# GET /homes
# GET /homes.xml
def index
#@homes = Home.all
if current_user.role
if current_user.role.name=='admin'
redirect_to(:controller =... |
class TaxAssignment < ActiveRecord::Base
# associates tax slab with finance fee particulars
belongs_to :taxable, :polymorphic => true, :dependent => :destroy
belongs_to :tax_slab
end |
require 'test_helper'
class SessionsControllerTest < ActionDispatch::IntegrationTest
def test_new
get new_session_path
assert_response :ok
assert_select '.js-new-users', count: 1
assert_select 'form[action=?]', '/sessions'
end
def test_create_success
@user = create_user
post sessions_pat... |
require 'Transaction'
describe 'Transaction' do
it 'contains a value' do
transaction_item = Transaction.new(value: 100, credit: true, debit: false)
expect(transaction_item.value).to eq(100)
end
before do
Timecop.freeze(Time.new(1982, 7 , 9))
end
it 'contains a date' do
transaction_ite... |
class Coach::EventsController < EventsController
def index
@coach_area = CoachesArea.find params[:coaches_area_id]
@events = @coach_area.events.paid_or_owned_by(current_user)
respond_to do |format|
format.json { render json: @events }
end
end
def event_params
params.require(:event).per... |
class Game
attr_reader :player_name, :whammy
attr_accessor :game_word
def initialize(player_name)
@player_name = player_name
rand_word = RandomWord.nouns.next.split("_")[0]
@game_word = Word.new(rand_word)
@whammy = 0
end
def take_turn(letter)
@game_word.replace_blanks(letter)
if !@g... |
require 'rexml/document'
require 'html5/liberalxmlparser'
module Planet
module XmlParser
begin
require 'xml/parser' # http://www.yoshidam.net/xmlparser_en.txt
@@parser = :expat
rescue LoadError
begin
require 'xml/libxml' # http://libxml.rubyforge.org/
@@parser = :libxml2
... |
class DatasetsTrait < ActiveRecord::Migration[5.1]
def change
create_table :datasets_traits, id: false do |t|
t.belongs_to :dataset, index: true
t.belongs_to :trait, index: true
end
end
end
|
module Api
module V1
class UsersController < ApplicationController
before_action :set_user, :except => [:index]
def index
render json: find_users_by_username(params[:username])
end
def show
render json: render_user_as_json(@user)
end
def update
update... |
class SearchResultsPage
include PageObject
div(:search_results_header, :class => 'page-header')
end |
class Market < ApplicationRecord
has_many :market_prices, autosave: true
has_many :aggregated_market_prices, autosave: true
end
|
class Teamstat < ActiveRecord::Base
include Auditable
attr_accessible :rosters_attributes, :points, :wins, :losses, :ties, :goals_for, :goals_against, :team_id, :league_id,
:person_tokens, :playinglocations_attributes, :technicalstaffs_attributes
attr_accessor :person_tokens
before_validation ... |
require_relative 'config/environment'
class App < Sinatra::Base
configure do
enable :sessions
set :session_secret, "secret"
end
get '/' do
erb :index
end
# The controller action `/checkout`, should take the params from the form and add it to the session hash.
... |
module MediasHelper
def embed_url(request = @request)
src = convert_url_to_format(request.original_url, 'js')
"<script src=\"#{src}\" type=\"text/javascript\"></script>".html_safe
end
def convert_url_to_format(url, format)
url = url.sub(/medias([^\?]*)/, 'medias.' + format)
if url =~ /refresh=1/
... |
#!/usr/bin/ruby
require 'pry'
def cals(ingredients, amounts)
ingredients = ingredients.clone
ingredients.keys.each do |name|
ingredients[name] = ingredients[name].values[-1] * amounts[name]
end
ingredients.values.reduce(:+)
end
def scale_ingredients(ingredient, amount)
ingredient.values[0...-1].map { |... |
class LcResult < ApplicationRecord
belongs_to :lc_class, foreign_key: 'lc_class_id'
validates :name, presence: true
end
|
class ApplicationController < ActionController::API
# Include Knock within your application.
include Knock::Authenticable
protected
# Method for checking if current_user is admin or not.
def authorize_as_admin
return_unauthorized unless !current_user.nil? && current_user.is_admin?
end
... |
require_relative "./shared/intcode"
class SpringDroid
def initialize(program)
@program = program
end
def run(script)
instructions = script.flat_map { |line| line.chars.map(&:ord) + [10] }
@program.run(inputs: instructions).last
end
end
program = Computer.new(INTCODE)
droid = SpringDroid.new(progr... |
require 'test_helper'
class API::V1::SearchTest < APITest
test 'GET /api/search requires an API key' do
get '/api/v1/search'
assert_equal 401, last_response.status
end
test 'GET /api/search works with search role' do
set_api_key(api_keys(:api_search))
get '/api/v1/search'
assert last_respons... |
require_relative '../../lib/shadefinale_minesweeper/board.rb'
describe Board do
let(:board){Board.new}
describe '#initialize' do
it 'should have a 10x10 board' do
expect(board.board_size).to eq(100)
end
it 'should have 9 mines' do
expect(board.mine_count).to eq(9)
end
end
desc... |
require 'amazon_pay'
# Your Amazon Pay keys are # available in your Seller Central account.
# Be sure to store your keys in a secure location.
merchant_id = 'YOUR_MERCHANT_ID'
access_key = 'YOUR_ACCESS_KEY'
secret_key = 'YOUR_SECRET_KEY'
client = AmazonPay::Client.new(
merchant_id,
access_key,
secret_key,
sa... |
class Outlet
attr_reader :coffee_machine, :ingredient_compartment
# This initilizes the Outlet
def initialize coffee_machine, ingredient_compartment
@coffee_machine = coffee_machine
@ingredient_compartment = ingredient_compartment
# Using Mutex so that we can use thread synchronization whenever requ... |
# displaying_likes_spec.rb
require 'rails_helper'
RSpec.describe 'displaying likes' do
before do
@user = create_user
log_in @user
@secret = @user.seeks.create(content: 'Oops')
Like.create(user: @user, seek: @secret)
end
it 'displays amount of likes next to each secret' do
visit '/seeks'
ex... |
class HomeController < ApplicationController
include HomeHelper
before_action :set_client
before_action :set_calendar_search, only: :calendars
def redirect
redirect_to @client.authorization_uri.to_s
end
def callback
@client.code = params[:code]
response = @client.fetch_access_token!
sessi... |
require "spec_helper"
describe User do
let(:user) { create(:user) }
let(:project) { create(:project, user: user) }
let(:other_project) do
other = create(:project)
other.add_member(user)
other
end
it "should automatically create a profile record" do
user.profile.should be_valid
end
it "... |
# frozen_string_literal: true
module WhitelabelDetection
protected
def switch_label
Whitelabel.reset!
return if Whitelabel.label_for(request.subdomains.first)
Whitelabel.label = Whitelabel.labels.find do |label|
label.domains && label.domains.any? do |custom_domain|
request.host =~ /#{... |
require 'badges_assignment'
class Action
attr_accessor :type
attr_accessor :count
attr_accessor :user
ACHIEVEMENTS = {['commit', 10] => '10th commit', ['fork', 5] => '5th fork', ['issue', 15] => 'problem solver'}
def initialize(type, count, user)
@type = type
@count = count
@user = user
... |
module Rubicus::Layers
class Prefab < Base
def initialize(options = {})
@type = options.delete(:prefab)
@data = options.delete(:data)
@options = options
@options[:delim] ||= :comma
end
def draw(image_type = "png", options = {})
options[image_type] = nil if image_type
... |
require 'rails_helper'
RSpec.describe User, type: :model do
it { should have_many(:doctors) }
it { is_expected.to have_db_column(:username) }
it { is_expected.to have_db_column(:email) }
it { is_expected.to have_db_column(:admin) }
end
|
#Fedena
#Copyright 2011 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#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 ... |
# As seen in the previous exercise, the time of day can be represented as the number of minutes before or after midnight. If the number of minutes is positive, the time is after midnight. If the number of minutes is negative, the time is before midnight.
# Write two methods that each take a time of day in 24 hour form... |
module NavigationHelpers
def path_to(page_name)
case page_name
when /the home page/
root_path
when /the sign-in page/
new_user_session_path
when /the registration page/
new_user_path
when /the activation page/
new_activation_path
when /the downl... |
module Requests
module DecodingPost
def test_decoding_gzip
server.run do |req, rep|
if req.body.include?("right")
rep.body = %w(Right)
rep.headers["content-length"] = rep.body.map(&:bytesize).reduce(:+)
else
rep.status = 400
rep.body = %w(Wrong)
... |
require 'test_helper'
class CommentsControllerTest < ActionDispatch::IntegrationTest
test "should redirect create when no logged in" do
assert_no_difference 'Comment.count' do
post postcomments_path
end
assert_redirected_to login_url
end
test "should reidirect destroy when no logged in" do
... |
class Gate
#運賃と駅名を配列として用意
STATIONS = [:umeda, :juso, :mikuni]
FARES = [150, 190]
def initialize(name) #引数として駅の名前を受け取れるようにする
@name = name #受け取った駅の名前はあとで使えるようにインスタンス変数へ格納
end
#enterメソッドは、引数として渡された切符(Ticket)に自分の駅名を保存する
#Ticketクラスのstampメソッドを参照(stampメソッドに駅名を渡すとその駅名がTicketクラスのインスタンスに保持... |
require 'bot_parser_format'
class BotParser
@formats = []
class << self
attr_reader :formats
def register_format(*args, &block)
formats << BotParserFormat.new(*args, &block)
end
def clear_formats
@formats = []
end
end
def formats() self.class.formats; end
... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "bonobo/version"
Gem::Specification.new do |s|
s.name = "bonobo"
s.version = Bonobo::VERSION
s.authors = ["Brian Alexander"]
s.email = ["balexand@gmail.com"]
s.homepage = "https://github.com/balexand/bonobo... |
class Author < ActiveRecord::Base
validates :name, presence: true, allow_blank: false
validates :email, uniqueness: true
validates :phone_number, length: {is: 10}
end
|
class Lab < ApplicationRecord
has_many :snippets
has_many :users, through: :snippets
validates_presence_of :name
end
|
require 'rubygems'
require 'builder'
module Repub
module Epub
# Open Packaging Format (OPF) 2.0 wrapper
# (see http://www.idpf.org/2007/opf/OPF_2.0_final_spec.html)
#
class OPF
include ContainerItem
def initialize(uid, file_path = 'package.opf')
@file_path = file_path
@media_type ... |
require 'rails_helper'
require_relative '../support/devise'
RSpec.describe "Accessories", type: :request do
def valid_attributes
{
accessory: attributes_for(:accessory,
status_label_id: create(:status_label).id,
model_id: create(:model).id,
... |
=begin
Write a method that takes an array of strings, and returns an array of the same string values, except with the vowels (a, e, i, o, u) removed.
Understand the problem:
- input: an array of strings with letters big and small
- output: same array with vowels removed
Algorithm:
- returned array has same # of eleme... |
class MessagesController < ApplicationController
before_filter :authenticate_user!
def create
unless message_params[:body].blank?
if message_params[:ticket].blank?
@ticket = current_user.tickets.new
@ticket.role_id = message_params[:role]
@ticket.save
else
@ticket = ... |
class CreateProviderContacts < ActiveRecord::Migration[5.0]
def change
create_table :provider_contacts do |t|
t.belongs_to :provider, index: true
t.belongs_to :user, index: true
# t.string :type
t.time :opening_hour
t.time :closing_hour
t.integer :working_days
t.timestam... |
FactoryGirl.define do
sequence :name do |n|
"name#{n}"
end
sequence :email do |n|
"name#{n}@example.com"
end
factory :user do
name
password '12345678'
email
end
factory :category do
name
end
factory :subcategory, class: Category do
name
association :parent, factory:... |
require 'rails_helper'
describe Item do
describe "making sure fields are filled in" do
it "should make sure an item has a name" do
item = Item.new(name: "", quantity: 5, price: 9.99)
item2 = Item.new(name: "test item", quantity: 5, price: 9.99)
expect(item).to_not be_valid
expect(item2).to be_valid... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
prepend_view_path Rails.root.join('frontend')
before_action :configure_permitted_parameters, if: :devise_controller?
rescue_from ActionController::RoutingError, with: :render_not_found
rescue_from ActiveReco... |
class SubscribersGroup < ActiveRecord::Base
belongs_to :user
has_many :subscribers_group_members
has_many :subscribers, through: :subscribers_group_members, source: :user_subscription
has_many :users_members, through: :subscribers, source: :user
alias :members :subscribers_group_members
include ResourceV... |
module CloudCapacitor
class DeploymentSpaceBuilder
def self.setup(vm_types)
@@categories = vm_types.map { |vm| vm.category }.uniq
@@max_price = Settings.deployment_space.max_price
@@max_num_instances = Settings.deployment_space.max_num_instances
@@configs_available = confi... |
class AddGoalcoordsToGoalevents < ActiveRecord::Migration[6.0]
def change
add_column :goalevents, :goalxcoord, :float
add_column :goalevents, :goalycoord, :float
end
end
|
# code here!
class School
def initialize(school_name)
@school_name = school_name
@roster = {}
end
attr_accessor :roster
def add_student(student, grade)
if roster[grade]
roster[grade] << student
else
roster[grade] = []
roster[grade] << student
end
end
def g... |
##
# Programs
#
FactoryGirl.define do
factory :kpcc_program, aliases: [:show] do
sequence(:title) { |n| "Show #{n}" }
slug { title.parameterize }
air_status "onair"
audio_dir "airtalk" # lazy
trait :episodic do
display_episodes 1
end
trait :segmented do
display_segments 1
... |
#
# Author:: Matt Ray (<matt@getchef.com>)
# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# 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
#
... |
require 'rails_helper'
RSpec.describe Paper, type: :model do
it "should have an empty list of authors" do
@paper = FactoryBot.create(:paper)
expect(@paper.authors.exists?)
end
end
|
# frozen_string_literal: true
require 'debt_management_center/models/va_awards_composite'
##
# Form Profile for VA Form 5655, the Financial Status Report Form
#
class FormProfiles::VA5655 < FormProfile
attribute :va_awards_composite, DebtManagementCenter::VaAwardsComposite
##
# Overrides the FormProfile metada... |
class ModifyColumnsCategory < ActiveRecord::Migration
def change
remove_column :categories, :comment_id
end
end
|
# -*- coding: utf-8 -*-
#
# Rakefile for OSZ
# Copyright(C)2014,2015,2016 MEG-OS project, ALL RIGHTS RESERVED.
#
require 'rake/clean'
require 'rake/packagetask'
require 'msgpack'
PATH_OUTPUT = "bin/"
PATH_SRC = "src/"
PATH_TOOLS = "tools/"
PATH_MISC = "misc/"
PATH_TEMP = "temp/"
CC = EN... |
require 'spec_helper'
describe MoviesController do
describe 'movie operations' do
before :each do
@fake_movie = mock(Movie)
@fake_movie.stub(:title)
end
describe 'creating movie' do
before :each do
@params = {:movie => {'title' => 'new title', 'description' => 'new de... |
class Board
def initialize
@grid = Array.new(6) { Array.new(7) { "-" } }
end
def drop_disc(column, disc)
(0..5).to_a.reverse.each do |row|
if @grid[row][column] == "-"
@grid[row][column] = disc
return
end
end
end
def remove_from(column)
(0..5).to_a.each do |row|
... |
module Adminpanel
module SortableGallery
extend ActiveSupport::Concern
included do
before_create :set_position
before_destroy :rearrange_positions
scope :ordered, -> { order('position ASC') }
end
module ClassMethods
def is_sortable?
true
end
def in_bette... |
#!/usr/bin/env ruby
# Use:
# evax /path/to/assets.yml /relative/path
begin
require 'evax'
rescue LoadError
require 'rubygems'
require 'evax'
end
if ( ARGV.size < 2 )
usage = "Usage:\n"\
"$ evax <config_file_path> <relative_path> [<options>]\n"\
"options:\n"\
"\t-w\t- watch assets for changes ... |
# Copyright 2019 The inspec-gcp-cis-benchmark Authors
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
# Tealeaf Academy Prep Course
# Intro to Programming
# Exercises
# Exercise 10
puts "Yes, hash values can be arrays! You can also have an array of hashes"
puts "Hash values as arrays:"
hash1 = {a:[1,2,3],b:[4,5,6]}
puts "Array of hashes:"
arr1 = [{a:4,b:5},{c:6,d:7}]
|
require 'spec_helper'
module Logical::Naf::ConstructionZone
describe Proletariat do
let!(:proletariat) { ::Logical::Naf::ConstructionZone::Proletariat.new }
let(:application) { FactoryGirl.create(:scheduled_application) }
let(:application_type) { FactoryGirl.create(:rails_app_type) }
let(:restriction) ... |
require 'omf-web/widget/abstract_data_widget'
module OMF::Web::Widget::Graph
# Maintains the context for a particular graph rendering within a specific session.
# It is primarily called upon maintaining communication with the browser and will
# create the necessary html and javascript code for that.
#
cla... |
class BarsController < ApplicationController
def index
@bars = Bar.all
respond_to do |format|
format.html
format.json { render :json => @bars }
end
end
def new
@bar = Bar.new
end
def create
bar = Bar.new(params[:bar]);
bar.save
respond_to do |format|
format.ht... |
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
devise_for :users
root 'pages#dashboard'
get '/login' => 'pages#login'
get '/index' => 'pages#index'
get '/documents' => 'pages#documents'
get '/admin' => 'pages#admin'
get 'dashboard' => 'pages#dashboard'
... |
class Graphite < DebianFormula
homepage 'http://launchpad.net/graphite'
url 'https://github.com/tmm1/graphite.git', :tag => '871ee7b'
name 'graphite'
version '0.9.9-pre2'
section 'python'
description 'Enterprise scalable realtime graphing'
build_depends 'python'
depends \
'python',
'python-cai... |
#encoding: utf-8
class User < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
has_secure_password
attr_accessible :email, :username, :bio, :role, :bean, :freetime, :github_name, :password, :password_confirmation, :token
serialize :freetime
before_create { generate_... |
class Board
attr_accessor :matrix
def initialize
@matrix = Hash.new
(1..8).each do |i|
@matrix[i] = Hash.new
(1..8).each do |j|
@matrix[i][j] = nil
end
end
# Pawn allocation
(1..8).each do |i|
@matrix[i][7] = Pawn.new [i, 7], :white
@matrix[i][2] = Pawn.ne... |
class ContactsController < ApplicationController
before_action :set_contact, only: [:show, :destroy]
def index
@contacts = Contact.all
render json:@contacts
end
def show
render json:@contact
end
def create
desc = params[:description]
name = params[:name... |
require 'rails_helper'
RSpec.describe CreditCard, :type => :model do
it { should belong_to :user }
it { should have_many :orders }
it { should validate_presence_of :ccv }
it { should validate_presence_of :expiration_month }
it { should validate_presence_of :expiration_year }
it { should validate_presence... |
#!/usr/bin/env ruby
require './account'
class CheckingAccount < Account
def initialize(amount, allowDebt)
super(amount)
@allowDebt = allowDebt == true
end
def debit(amount)
if !@allowDebt && amount > @amount
return @amount
end
super.debit(amount)
end
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'docker#dashboard'
get '/containers' => 'docker#containers'
post '/start_container' => 'docker#start_container', as: :start_container
post '/stop_container' => 'docker#sto... |
describe FayeServer do
describe '#incoming' do
it 'error' do
block = ->(_) {}
faye_message = { 'ext' => {} }
expect(subject).to receive(:check_version).and_return(nil)
expect(subject).to_not receive(:server_logic_class)
expect(block).to receive(:call).with(faye_message)
subje... |
require 'spec_helper'
require 'ccng_log_record'
describe CcngLogRecord do
subject { described_class.new(line) }
context 'valid line' do
let(:line) do
<<-EOS
10.10.16.19 -- {"timestamp":1372829110.0706873,"message":"resource_pool.download.using-cdn","log_level":"debug","source":"cc.resource_pool","data":... |
class IndicatorsController < ApplicationController
before_action :authenticate_analyst!
before_action :require_enterprise
before_action :set_indicator, only: %i[show edit update destroy]
helper_method :sort_column, :sort_direction
def index
if current_analyst.admin?
@indicators = Indicator.all.pag... |
module Plugins
class Meme
include Cinch::Plugin
include Cinch::Helpers
enable_acl
set(
plugin_name: "MeMe",
help: "Display a meme?.\nUsage: `?m <meme>`",
)
# Regex
match /m (.+)/, method: :find_meme
# Initialization
def initialize(*args)
@meme = lo... |
class Professor
attr_reader :ferias
attr_accessor :nome, :codigo, :ferias
def initialize(nome, codigo, disciplina)
@nome = nome
@codigo = codigo
@disciplina = disciplina
@ferias = false
end
def inicia_ferias()
@ferias = true
end
def encerra_ferias()
... |
class Sector < ActiveRecord::Base
audited
belongs_to :organ
has_many :phone_sectors, :validate => false, dependent: :destroy
accepts_nested_attributes_for :phone_sectors, allow_destroy: true, :reject_if => proc { |attrs| attrs[:phone].blank? }
has_many :email_sectors, :validate => false, dependent: :destroy
a... |
require 'spec_helper'
describe "Updating resources" do
example "Updating a resource" do
stub_auth_request(:put, "http://movida.example.com/projects/1").with do |req|
req.body == {:name => "Wadus Wadus"}.to_xml(:root => "project")
end.to_return(:body => <<-XML)
<project>
<name>Wadus Wad... |
class AddFieldsToPortfolioItems < ActiveRecord::Migration[5.0]
def change
add_column :portfolio_items, :live_url, :string
add_column :portfolio_items, :gh_url, :string
end
end
|
module SEPOMEX
class Strategy
ACROGENESIS = 'acrogenesis'.freeze
HCKDRK = 'hckdrk'.freeze
def self.call(*args, &block)
new(*args, &block).call
end
def initialize(zip_code)
@zip_code = zip_code
@clients = [HCKDRK, ACROGENESIS]
end
def call
raise ArgumentError if @... |
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'mocha/api'
require 'mini_magick'
RSpec.configure do |config|
config.mock_framework = :mocha
config.color = true
config.formatter = 'documentation'
config.raise_errors_for_deprecations!
end
# Image files from testunit port to RS... |
class Game
attr_reader :width, :height, :turn, :active, :p1_ships, :p1_torpedos, :p2_ships, :p2_torpedos
def initialize(width, height)
@width = width
@height = height
@turn = :p1
@active = true
@p1_ships = []
@p1_torpedos = []
@p2_ships = []
@p2_torpedos = []
end
def add_ship(... |
=begin
YanFly Compatible Customisable ATB/Stamina Based Battle System Script
by Fomar0153
Version 1.2
----------------------
Notes
----------------------
Requires Yanfly Engine Ace - Ace Battle Engine
Customises the battle system to be similar to
ATB or Stamina based battle systems.
----------------------
Instructions
... |
FactoryBot.define do
factory :url do
sequence(:original_url) { |i| "http://google.com/#{i}" }
short_url { ('A'..'Z').to_a.shuffle.join }
end
end |
require 'test_helper'
class MembershipControllerTest < ActionController::TestCase
test "should fail to upgrade a follower" do
put :upgrade, token: 'tokennicolas', assoc_id: 2, volunteer_id: 4
assert_response :success
body = JSON.parse(response.body)
assert body['message'] == "You can't do that with a... |
class StaticPagesController < ApplicationController
def index
@static_page = StaticPage.find_by!(permalink: params[:permalink])
end
end
|
class CreateTopics < ActiveRecord::Migration
def change
create_table :topics do |t|
t.string :tid
#挖掘信息
t.string :slary
t.string :area
t.string :company
t.string :level
#本来信息
t.string :title
t.datetime :pub_created_at
t.datetime :pub_updated_at
t... |
class BrandbeoController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
before_action :set_brand, only: [:show,:index]
def index
# if()
# format.html { redirect_to @brand, notice: 'Brand was successfully updated.' }
... |
require 'test_helper'
class AppearersControllerTest < ActionDispatch::IntegrationTest
setup do
@appearer = appearers(:one)
end
test "should get index" do
get appearers_url
assert_response :success
end
test "should get new" do
get new_appearer_url
assert_response :success
end
test "... |
#
# Cookbook Name:: base
# Recipe:: locale
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
execute "locale-gen" do
action :nothing
end
template "locale.gen" do
path "/etc/locale.gen"
source "locale.gen.erb"
owner "root"
group "root"
mode 0644
notifies :run, "execute[l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.