text stringlengths 10 2.61M |
|---|
class HomeController < ApplicationController
def index
@setting = Setting.for_host(request.host)
if !@setting.homepage == nil?
redirect_to page_path(@setting.homepage)
end
end
end
|
require 'thomas'
require_relative 'ship'
class Good < Thomas::Thing
def initialize
super([[Thomas::Space.new('Y')]])
@drawable = true
@collidable = true
end
def handle_collision(other_thing)
return unless other_thing.class.to_s == 'Ship'
other_thing.collect(self)
end
end |
# encoding: utf-8
#! /usr/bin/env ruby
##
# Auteur CrakeTeam
# Version 0.1 : Date : Mon Mar 17 09:42 2013
#
require_relative 'Fenetre'
class FenetreJeu < Fenetre
@texteTemps
# Affiche le texte "Temps écoulé :"
@minutes
# Contient les minutes écoulées
@secondes
# Contient les secondes écoulées
@affich... |
class AddConfirmTokenToUsers < CamaManager.migration_class
def change
add_column CamaleonCms::User.table_name, :confirm_email_token, :string, default: nil
add_column CamaleonCms::User.table_name, :confirm_email_sent_at, :datetime, default: nil
add_column CamaleonCms::User.table_name, :is_valid_email, :boo... |
RSpec.describe Knuckles::Stages::Fetcher do
describe ".call" do
it "fetches all cached data for top level objects" do
objects = [Tag.new(1, "alpha"), Tag.new(2, "gamma")]
Knuckles.cache.write(Knuckles.keygen.expand_key(objects.first), "result")
objects = prepare(objects)
results = Knuckl... |
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "/admin/posts/new.html.erb" do
include Admin::UsersHelper
before(:each) do
@user = mock_model(User)
@user.should_receive(:password_confirmation=).with(nil).and_return(true)
@user.should_receive(:password=).with(nil)... |
require 'spec_helper'
describe ArticlesController, :controller do
describe 'GET index' do
before(:each) { Category.all.map { |e| FactoryGirl.create(:article, :published, category: e) } }
# TODO: weird order of specs bug. Sometimes 2 of the articles are missing from @articles. ids 1 & 2.
it 'assigns @arti... |
manager_ip = "10.0.4.2";
Vagrant.configure(2) do |config|
config.vm.define "manager" do |manager|
manager.vm.hostname = "manager"
manager.vm.box = "ubuntu/bionic64"
manager.vm.network "private_network", ip: manager_ip
manager.vm.provider :virtualbox do |v|
v.cpus = 1
v.memory = 2048
... |
class NtTemplate < ActiveRecord::Base
validates :node_type_id, :name, :body, :owner, :mode, presence: true
validates :name, uniqueness: {scope: :node_type_id}
belongs_to :node_type
def to_sh
<<-SHELL
#!/bin/sh
[ -d #{File.dirname self.name} ] || mkdir #{File.dirname self.name}
cat > #{self.name} <<'EOF'
... |
class ContractsController < ApplicationController
respond_to :html, :json
def show
@contract = Contract.find(params[:id])
respond_with @contract
end
end
|
require 'spec_helper'
describe Graphlient::Client do
include_context 'Github Client'
it 'has a schema', vcr: { cassette_name: 'github/schema' } do
expect(client.schema).to be_a Graphlient::Schema
end
it 'queries current user', vcr: { cassette_name: 'github/viewer' } do
rc = client.query <<-GRAPHQL
... |
require 'spec_helper'
describe Roark::Aws::Ec2::AmiState do
it "should return the state of the given ami" do
image_stub = stub 'image', :state => :available
images_stub = stub :images => { 'ami-12345678' => image_stub }
connection_stub = stub 'connection', :ec2 => images_stub
ami_state = Ro... |
class Model::Section::CtaBox < SitePrism::Section
element :header, "h2"
element :supporting_text, ".bc-box p"
element :title_link, "a.bc-link-button"
element :strapline, "div.first"
end |
class UsersController < ApplicationController
before_action :require_user_logged_in, only: [:index, :show, :destroy]
def index
@users = User.search(params[:search])
end
def show
@user = User.find(params[:id])
@lover = @user.followings.first
@chats = @user.chats.order(id: :desc).page(params[:pa... |
class Email
include ActiveModel::Validations
include MailWrap
attr_reader :address, :subject, :message
def initialize(options)
@address = options[:address]
@subject = options[:subject]
@message = options[:message]
end
def self.all
conn.get("#{DOMAIN_NAME}.mailgun.org/log")
end
def s... |
require 'pry'
class Api::ItemsController < ApplicationController
before_action :find_section
def index
# item = Item.all
# @items = Section.find(params[:section_id])
# @id = params[:section_id]
# render json: item
render json: @section.items
end
def show
end
def create
# bindi... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/node.rb'
class NodeTest < Minitest::Test
def test_new_returns_a_node
subject = Node.new('Burke')
assert_instance_of Node, subject
end
def test_surname_returns_name
subject = Node.new('Burke')
assert_equal 'Burke', subject.surname... |
#!/usr/bin/env ruby
# encoding: utf-8
# File: pending_table.rb
# Created: 24/09/13
#
# (c) Michel Demazure <michel@demazure.com>
# script methods for Jacinthe Management
module JacintheManagement
# all classes and methods for both GUIs
module GuiQt
# suspending user events for at most 20 seconds
# @yield... |
require 'spec_helper'
describe "Portrait pages" do
subject { page }
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
describe "portrait creation" do
#let(:portrait) { FactoryGirl.build(:portrait, user: user) }
#before { visit portraits_path(portrait) }
describe "with invalid info... |
module StatMenHelper
def stat_sheet_dialog_js(stat_man_id)
dialog_id = "#dialog_form_ss_#{stat_man_id}"
button_id = "#create_stat_sheet_#{stat_man_id}"
do_dialog(dialog_id, button_id)
end
def edit_delete_stat_man_js(stat_man_id)
ahref_id = "#edit_delete_stat_man_#{stat_man_id}"
html_guts = "... |
class Batch < ActiveRecord::Base
has_many :tickets, dependent: :destroy
belongs_to :ticket_kind
scope :ordered, -> { order('created_at asc') }
validates_presence_of :ticket_kind_id
validates_presence_of :emails
before_validation :create_tickets
after_validation :validate_tickets
# Process all ticket... |
RSpec.describe UpdateDiaperPartnerJob, job: true do
describe '#perform(partner_id)' do
subject { described_class.new.perform(partner_id) }
let(:partner_id) { Faker::Number.number }
context 'when the email feature is active' do
let(:fake_partner) { instance_double(Partner, attributes: { fake: 'data'... |
# encoding: ascii-8bit
# Models defines objects that are returned from storage.
# These objects inherit from their {Bitcoin::Protocol} counterpart
# and add some additional data and methods.
#
# * {Bitcoin::Blockchain::Models::Block}
# * {Bitcoin::Blockchain::Models::Tx}
# * {Bitcoin::Blockchain::Models::TxIn}
# * {Bi... |
require "application_system_test_case"
class RolsTest < ApplicationSystemTestCase
setup do
@rol = rols(:one)
end
test "visiting the index" do
visit rols_url
assert_selector "h1", text: "Rols"
end
test "creating a Rol" do
visit rols_url
click_on "New Rol"
fill_in "Name", with: @rol.... |
class RegistrationsController < Devise::RegistrationsController
protected
=begin
def new
flash[:info] = 'Registrations are not open yet, because the site is not functional.'
redirect_to root_path
end
def create
flash[:info] = 'Registrations are not open yet, because the site is not functional.'
... |
class Photo < ActiveRecord::Base
attr_accessible :url
has_many :tags
end
|
require 'singleton'
class OVOST::Database
include Singleton
attr_reader :links, :users, :clicks, :join_users_links, :join_links_clicks
def initialize
@links_created = 0
@users_created = 0
@total_clicks = 0
@links = {}
@users = {}
@clicks = {}
@join_users_links = []
@join_links_c... |
class ClI
def start
puts 'Welcome'
API.fetch
self.menu
end
def menu
puts "Would you like to see a list of Studio Ghibli's movies?"
puts "Type 'yes' to continue or any other key to exit"
user_input = gets.strip.downcase
if user_input == 'yes' || user_input == 'y'
puts "Good ... |
# class Compliance
module Compliance
# module CodeRelatedInformation
module CodeRelatedInformation
extend ActiveSupport::Concern
included do
def description_with_other_details
render json: return_values(find_code).to_json
end
def return_values(code)
if code.nil?
... |
require 'spec_helper'
module Naf
describe Machine do
let!(:machine) { FactoryGirl.create(:machine) }
# Mass-assignment
[:server_address,
:server_name,
:server_note,
:enabled,
:thread_pool_size,
:log_level,
:marked_down,
:short_name,
:deleted].each do |a|
it ... |
<% module_namespacing do -%>
#
# Author: <%= ENV["USER"] %>
#
# Usage: Consumers::<%= class_name %>Consumer.new.run
#
class Consumers::<%= class_name %>Consumer < Kafka::Consumer
# Which connection, from the config in kafka.yml, default is ':default'
# self.connection = :default
# Change it to real topic name
... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{tarantula-rails3}
s.version = "0.3.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Relevance, Inc."]
s.date = %q{2011-02-14}
s.description = %q{A big hairy fuzzy spi... |
require "fpm/namespace"
require "fpm/source"
require "rubygems/package"
require "rubygems"
require "fileutils"
class FPM::Source::Gem < FPM::Source
def self.flags(opts, settings)
opts.on("--bin-path DIRECTORY",
"The directory to install gem executables") do |path|
settings.source[:bin_path] = p... |
require "rails_helper"
RSpec.describe "/redirects", type: :request do
context "not logged in" do
describe "GET /index" do
before { get redirects_url }
it { should redirect_to(user_session_path) }
end
describe "GET /new" do
before { get new_redirect_url }
it { should redirect_to(u... |
class Actor < ActiveRecord::Base
attr_accessor :characters, :shows, :networks
has_many :characters
has_many :shows, through: :characters
has_many :networks, through: :shows
def characters
Character.select{|character| character.actor == self}
end
def list_roles
characters.map{|character| "#{char... |
require 'test_helper'
class MentorConfirmationMailerTest < ActionMailer::TestCase
test "assigned without personalized message" do
mail = MentorConfirmationMailer.assigned(doctors(:bob), '')
assert_equal 'Your Student, Bob, Has Been Assigned To A Patient', mail.subject
assert_equal ["lulu.sheng1418@gmail.... |
# frozen_string_literal: true
require 'active_support/concern'
require 'xml_mapper'
require 'nokogiri'
require 'expedia/resource'
module Expedia
module API
# The Product, Availability and Rate Retrieval Request and Response API
# https://expediaconnectivity.com/apis/product-management/expedia-quickconnect-p... |
Discount = Struct.new(:number, :discount)
class Scanner
def prices
{
apples: 100,
cherries: 75,
bananas: 150
}
end
def discounts
{
cherries: Discount.new(2, 20),
bananas: Discount.new(2, 150),
pommes: Discount.new(3, 100),
mele: Discount.new(2, 50)
}
... |
module FilmsHelper
def show_video(url)
content_tag(:iframe,nil,:width=>"480",:height=>"390",:src=>"http://www.youtube.com/embed/#{url}",:frameborder=>0,:allow_fullscreen=>true)
end
def get_year_hint(film)
age = 0
if !film.year.blank? && film.year.to_i<Date.today.year
age = Date.today.year - film.year.to... |
class DataPalettesController < ApplicationController
before_filter :login_required
before_filter :default_time_zone_present_time
filter_access_to :all
def index
@user_palettes = current_user.own_palettes
@today = FedenaTimeSet.current_time_to_local_time(Time.now).to_date
# @cur_date = Date.today
... |
# frozen_string_literal: true
# config valid for current version and patch releases of Capistrano
# lock "~> 3.11.0"
# set :application, 'italyphotoshopping'
# set :repo_url, 'git@github.com:alxekb/italyphotoshopping.git'
# set :puma_threads, [1, 2]
# set :puma_workers, 0
# set :deploy_to, "/home/ipsdeploy/#{fetch(:a... |
if platform?('ubuntu')
bash 'update_source_gpg' do
code <<-EOH
echo "deb https://packages.elastic.co/beats/apt stable main" | sudo tee -a /etc/apt/sources.list.d/beats.list
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
EOH
end
apt_update 'debain' do
action :update
en... |
# frozen_string_literal: true
module Bolt
class ResultSet
attr_reader :results
include Enumerable
# We only want want to include these when puppet is loaded
def self.include_iterable
include(Puppet::Pops::Types::Iterable)
include(Puppet::Pops::Types::IteratorProducer)
end
def s... |
class AddStuffToCourses < ActiveRecord::Migration
def change
add_column :courses, :term, :string
add_column :courses, :code, :string
add_column :courses, :description, :text
add_column :courses, :credits, :integer
end
end
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rabbit_jobs/version'
Gem::Specification.new do |spec|
spec.authors = ['Pavel Lazureykis']
spec.email = ['lazureykis@gmail.com']
spec.desc... |
class Card < ApplicationRecord
belongs_to :deck
validates :front,
presence: true,
length: { minimum: 1 }
validates :back,
presence: true,
length: { minimum: 1 }
end
|
class SeriesController < ApplicationController
def index
@all_stats = SeriesStatistics.from_series_list(Series.includes(:games))
end
def show
@series = Series.find(params[:id])
end
def new
@series = Series.new
3.times { @series.games.build }
end
def create
@series = Series.new(serie... |
# encoding: UTF-8
dir = File.expand_path('..', __FILE__)
require 'sinatra/base'
require dir + '/environment'
#load dir + '/environment.rb'
RUBY_PORT = ENV["PORT"] ? ENV["PORT"].to_i : 9000
NODE_PORT = RUBY_PORT + 100
SOCK_PORT = RUBY_PORT + 100
PERMISSIONS = {
'read' => 'Read all your wubytes',
'write' => 'Writ... |
require 'pry'
require 'csv'
require 'awesome_print'
class Order
attr_reader :id
attr_accessor :products, :customer, :fulfillment_status
# instance of Customer, the person who placed the order
# fulfillment_status, a symbol of :pending, :paid, :processing, :shipped, :complete
# if there is not fulfilment_s... |
# frozen_string_literal: true
class PageTag < ApplicationRecord
belongs_to :page
TAG_VALUE_MAX_LENGTH = 255
def clean
self.value = self.value.to_s.strip[0...TAG_VALUE_MAX_LENGTH]
end
end
|
require 'test_helper'
describe O::Interpreter do
before do
@interpreter = O::Interpreter.new
end
it 'should evaluate an int' do
@interpreter.eval("1").must_equal 1
end
it 'should evaluate a float' do
@interpreter.eval("1.503").must_equal 1.503
end
it 'should evaluate a string' do
@inte... |
# #Company class used for create company for add users to work
class CompaniesController < ApplicationController
before_action :set_company, only: %i[show edit update destroy]
before_action :authenticate_user!, except: %i[accept_invitation_to_company]
# GET /companies
# GET /companies.json
def index
@comp... |
class CreateContestAnsableSingles < ActiveRecord::Migration
def self.up
create_table :contest_ansable_singles do |t|
t.integer :choice_id
end
add_index :contest_ansable_singles, :choice_id
end
def self.down
drop_table :contest_ansable_singles
end
end
|
もし /^再度ログインし直すと、ワンタイムパスワードを要求されます。$/ do
with_capture do
click_on current_user.email
click_on 'ログアウト'
assert_equal '/users/sign_in', current_path
end
with_capture do
fill_in 'Eメール', :with => current_user.email
fill_in 'パスワード', :with => 'testtest'
end
click_on 'ログイン'
with_capture do
... |
require_dependency 'failure' if Rails::VERSION::MAJOR < 6
def handle_exception_payload(payload)
return unless payload[:exception]
name, message = *payload[:exception]
# rubocop: disable Style/SpecialGlobalVars
backtrace = $!.present? ? $!.backtrace.join("\n") : ''
# rubocop: enable Style/SpecialGlobalVars
... |
# frozen_string_literal: true
require "concurrent/promise"
module Dry
module Monads
# The Task monad represents an async computation. The implementation
# is a rather thin wrapper of Concurrent::Promise from the concurrent-ruby.
# The API supports setting a custom executor from concurrent-ruby.
#
... |
module SimpleDav
class AddressBook < Base
attr_reader :group
def initialize(params)
abu = "personal"
@vcard = nil
super(params)
@abu = @type == "sogo" ? "Contacts/#{abu}/" : "#{abu}"
@uri.path += @abu
@group = nil #store group uid
Card.adb = self
end
# sele... |
class Api::TracksController < ApplicationController
before_action :ensure_login, except: [:show, :index]
def create
@track = Track.new(track_params)
@track.user_id = current_user.id
if @track.save
render :show
else
render json: @track.errors, status: 422
end
end
def update
... |
class Taggable::UserTag < ActiveRecord::Base
attr_accessible :user, :user_name, :taggable, :x, :y
belongs_to :user, class_name: "MDB::User"
belongs_to :taggable, polymorphic: true
validates_presence_of :user
# Allow user to be tagged only once per object
validates_uniqueness_of :user_id, scope: [:t... |
class Admin::PostsController < ApplicationController
access_control do
allow :admin, :all
end
layout "inadmin"
uses_tiny_mce :options => {
:theme => 'advanced',
:theme_advanced_resizing => true,
:theme_advanced_... |
json.array!(@iterations) do |iteration|
json.extract! iteration, :id, :name
json.url iteration_url(iteration, format: :json)
end
|
# combine_two_lists.rb
# Write a method that combines two Arrays passed in as arguments, and returns a
# new Array that contains all elements from both Array arguments, with the
# elements taken in alternation.
# You may assume that both input Arrays are non-empty, and that they have the
# same number of elements.
# ... |
require 'spec_helper'
describe service('graylog2-server') do
it { should be_enabled }
it { should be_running}
end
describe file('/etc/graylog2.conf') do
it { should be_file }
its(:content) { should match /# Cluster settings/ }
end
describe file('/etc/sysconfig/graylog2-server'), :if => os[:family] == 'redhat... |
# Create a method that takes 2 arguments, an array and a hash. The array will
# contain 2 or more elements that, when combined with adjoining spaces, will
# produce a person's name. The hash will contain two keys, :title and
# :occupation, and the appropriate values. Your method should return a
# greeting that uses the... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
module UserSweeperSpecHelper
def valid_user_attributes
{
:login => 'jimmy',
:email => 'jim@bomb.com',
:password => 'monkey',
:password_confirmation => 'monkey'
}
end
end
describe UserSweeper do
include UserS... |
require 'spec_helper'
CIRCLE_PATH ||= File.join(File.dirname(__FILE__),
'..',
'..',
'..',
'models',
'diagroo',
'circle.rb')
require File.expand_path(CIRCLE_PATH)
r... |
class ProjectsController < ApplicationController
def index
redirect_to root_url
end
def timeline
end
def show
@project = Project.find Project.decrypt(params[:id])
end
def new
@project = current_user.projects.new
if !@project
redirect_to root_url
end
end
def create... |
require 'test_helper'
class OverCrowdingTest < MiniTest::Unit::TestCase
def setup
@over_crowding = OverCrowding.new
end
def test_cell_die_with_over_crowding
alive_cell = Cell.new('X')
alive_cell.alive_neighbours_count = 4
alive_cell = @over_crowding.apply(alive_cell)
assert alive_c... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Language::Parser do
subject { GraphQL }
it "returns an error on bad UTF-8" do
err = assert_raises GraphQL::ParseError do
subject.parse("{ foo(query: \"\xBF\") }")
end
expected_message = 'Parse error on bad Unicode escape seque... |
module OperaWatir
class QuickWindow
include DesktopCommon
include DesktopContainer
# @private
def initialize(container, method, selector=nil)
@container = container
if method.is_a? Java::ComOperaCoreSystems::QuickWindow
@elm = method
else
... |
Rails.application.routes.draw do
root to: 'home#index'
devise_for :users
resources :expenses, only: [:new, :create, :index]
end
|
class VotesController < ApplicationController
def create
if session[:user_id] != nil
user = User.find_by(id: session[:user_id])
@work = Work.find_by(id: params[:work_id])
vote = Vote.new(work_id: params[:work_id], user_id: user.id, date: Time.now)
if @work.votes.find_by(user_id: user.id... |
class DepositsController < ApplicationController
before_action :auth_member!
before_action :set_deposit, only: [:show]
# GET /deposits
def index
@deposits = Deposit.all
json_response(@deposits)
end
# GET /deposits/:id
def show
json_response(@deposit)
end
private
def deposit_params
... |
class Brand < ApplicationRecord
has_many :products
mount_uploader :image, ImageUploader
end
|
require "spec_helper"
RSpec.describe "Day 23: Experimental Emergency Teleportation" do
let(:runner) { Runner.new("2018/23") }
describe "Part One" do
let(:solution) { runner.execute!(input, part: 1) }
let(:input) do
<<~TXT
pos=<0,0,0>, r=4
pos=<1,0,0>, r=1
pos=<4,0,0>, r=3
... |
json.array!(@look_ups) do |look_up|
json.extract! look_up, :id
json.url look_up_url(look_up, format: :json)
end
|
require "rails_helper"
RSpec.describe "services/index" do
it "displays @services, @back_phone and @services_footer the services" do
assign(:services, [create(:service, title: 'Первая услуга'),
create(:service, title: 'Вторая услуга')])
@services_footer = [create(:service, title: 'Первая ус... |
class Document < ActiveRecord::Base
PDF_PATH = File.join Rails.configuration.documents_path, 'pdf'
TXT_PATH = File.join Rails.configuration.documents_path, 'txt'
PNG_PATH = File.join Rails.configuration.documents_path, 'png'
PNG_SMALL_PATH = File.join Rails.configuration.documents_path, 'png-small'
validates :nam... |
Ohai.plugin(:FC) do
provides 'fc'
def read_f(name)
File.open(name).read.chomp
end
collect_data(:linux) do
fc Mash.new
return unless File.directory?('/sys/class/fc_host')
Dir.foreach('/sys/class/fc_host') do |d|
if d == '.' or d == '..'
next
end
key = d.to_sym
... |
require "selenium-webdriver"
require "selenium/server"
require "fileutils"
require "spinning_cursor"
PICTATE_ROOT = Gem.loaded_specs['pictate'].full_gem_path
module Pictate
#
# Starts the server, gets the best result for the image and stops server.
#
def pictate(image_path, options = {})
SpinningCursor.st... |
require 'spec_helper'
describe V1::GamesController do
render_views
let(:user) { create(:user) }
let(:location) { create(:location) }
let(:game) { create(:game) }
let(:activity) { create(:activity) }
describe "POST 'create'" do
it "returns http success if parameters are valid" do
start_time ... |
require 'rails_helper'
RSpec.describe 'GithubService' do
attr_reader :service
before(:each) do
current_user = User.new(uid: "17166293", username: "edilenedacruz", avatar: "https://avatars1.githubusercontent.com/u/17166293?v=3", token: ENV['TOKEN'])
allow_any_instance_of(ApplicationController).to receive(... |
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "capybara/rails"
require 'webmock'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
def json_response
json ... |
Pod::Spec.new do |s|
s.name = 'AblyDeltaCodec'
s.version = '1.3.3'
s.summary = 'Cocoa VCDiff decoder'
s.homepage = 'https://ably.com'
s.author = { "Ably" => "support@ably.com" }
s.license = 'MIT'
s.social_media_url = 'https://twitter.com/ably... |
# Given integer represented in string, print its value
#"324" => 324
#"-234" => -234
def atoi(str)
value = 0
sign_value = 1
i = 0
i+=1 while (str[i] == " ")
if (str[i] == "-" || str[i] == "+")
sign_value = -1 if str[i] == "-"
i+=1
end
for j in i..str.size-1
raise "Not an integer" if str[j]<'0'... |
RSpec.describe 'Admin Feedback' do
let(:admin_user) { create :admin_user }
before { sign_in(admin_user) }
it 'shows title' do
visit '/admin/feedbacks'
expect(find('#page_title')).to have_content('Feedbacks')
end
end
|
monthsArr = [
nil,
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
json.spot do
json.set! @spot.id do
json.partial! "api/spots/spot", spot: @spot
json.amenities do
json.array! @spot.amenities.map {|am... |
module ControllerSpecHelper
# generate tokens from user id
def token_generator(user_id)
JsonWebToken.encode(user_id: user_id)
end
# generate expired token from user id
def expired_token_generator(user_id)
JsonWebToken.encode({ user_id: user_id }, (Time.now.to_i - 10))
end
# return valid headers
... |
# Initialize pubnub client with our keys
$pubnub = Pubnub.new(
subscribe_key: Rails.application.secrets.pubnub_subscribe_key,
publish_key: Rails.application.secrets.pubnub_publish_key,
secret_key: Rails.application.secrets.pubnub_secret_key,
)
# As we have PAM enabled, we have to grant access to channels.
... |
class AddSchoolIdToApplicationSections < ActiveRecord::Migration
def self.up
add_column :application_sections, :school_id, :integer
add_column :applicant_student_addl_fields, :school_id, :integer
add_column :applicant_addl_attachment_fields, :school_id, :integer
end
def self.down
remove_column :a... |
class CommentsController < ApplicationController
before_action :authenticate_user!, except: [:show, :index]
def create
@hotel = Hotel.find(params[:hotel_id])
@comment = @hotel.comments.create(params.require(:comment).permit(:commenter, :body))
redirect_to hotel_path(@hotel)
end
def destroy
@hot... |
module Praxis
module Skeletor
class RestfulRoutingConfig
attr_reader :name, :resource_definition, :routes
def initialize(name, resource_definition, &block)
@name = name
@resource_definition = resource_definition
@routes = []
@version_prefix = ""
if resource_d... |
Question.create(content: 'Where was Lizzo born?')
Question.create(content: "What is Lizzo's given name?")
Question.create(content: "What musical instrument did Lizzo study in college?")
Question.create(content: "What was the name of Lizzo's first studio album?")
Question.create(content: "In what movie did Lizzo appear ... |
class FlightAttendance < ApplicationRecord
belongs_to :traveler
belongs_to :booking
end
|
require 'rails_helper'
RSpec.describe SnsCredential, type: :model do
describe '#create' do
before do
@sns = build(:sns_credential)
end
context "正常に保存できる場合" do
it "provider,uidが存在すれば登録できること" do
expect(@sns).to be_valid
end
end
context "正常に保存できない場合" do
it "provid... |
require 'rails_helper'
feature 'user create a task list' do
scenario 'and access a specific task' do
user = User.create(email:'pedro@autoseg.com', password:'123456')
task_list = TaskList.create(title:'Cuidar da horta', public_list: true,
user: user
)
task_list_1 = Tas... |
module SortingHelper
def order_link(title, value, options={})
value = value.to_s
active = params[:order] == value || (params[:order].blank? && options[:default])
order_params = { :order => value, :direction => :asc }
order_params[:direction] = :desc if active && params[:direction] != 'desc'
css... |
class AddCordsToWinningParts < ActiveRecord::Migration
def change
add_column :winning_parts, :coordinates, :text
end
end
|
class PaizanosController < ApplicationController
before_action :set_paizano, only: [:show, :edit, :update, :destroy]
# GET /paizanos
# GET /paizanos.json
def index
@paizanos = Paizano.all
end
# GET /paizanos/1
# GET /paizanos/1.json
def show
end
# GET /paizanos/new
def new
@paizano = Pa... |
require 'spec_helper'
describe ItemType do
it "should let us make add a new one" do
item_type = FactoryGirl.create(:item_type)
item_type.save.should be_true
end
it "should require an name" do
item_type = FactoryGirl.build(:item_type, name: nil)
item_type.should_not be_valid
item_type.errors.f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.