text stringlengths 10 2.61M |
|---|
require 'spec_helper'
RSpec::Matchers.define :allow do |*args|
match do |permission|
permission.allow?(*args).should be_true
end
end
describe Permission do
describe 'student' do
before do
@user = User.new(name: "Example User", email: "user@example.com",
password: "foobar", teacher:... |
class BusStopsController < ApplicationController
# GET /api/bus_stops
def index
@bus_stops = BusStop.all
render json: @bus_stops
end
end |
require "spec_helper"
RSpec.describe "Day 4: Security Through Obscurity" do
let(:runner) { Runner.new("2016/04") }
let(:input) do
<<~TXT
aaaaa-bbb-z-y-x-123[abxyz]
a-b-c-d-e-f-g-h-987[abcde]
not-a-real-room-404[oarel]
totally-real-room-200[decoy]
TXT
end
describe "Part One" do
... |
class TransactionsController < ApplicationController
def new
@transaction = Transaction.new
end
def create
@transaction = Transaction.new(transaction_params)
@transaction.sender_id = current_user.id
if @transaction.save
redirect_to current_user
else
render 'new'
end
end
... |
require 'net-snmp'
class WalkRaportsController < ApplicationController
before_action :set_walk_raport, only: [:show, :edit, :update, :destroy]
before_action :check_auth
attr_reader :device, :device_id, :snmpwalk_request, :snmpwalk_type_request, :result
attr_reader :errors
# GET /walk_raports
# GET /walk_r... |
module Requests
module StreamGet
def test_stream_get
server.run do |req, rep|
rep.stream do |streamio|
streamio.emit_data("bang", false)
sleep 0.5
streamio.emit_data("bang2")
end
end
sleep 1
response = client.request(:get,"#{server_uri}/", ... |
class AddGravatarToTopics < ActiveRecord::Migration
def change
add_column :topics, :gravatar_id, :string
end
end
|
require 'rails_helper'
describe Todo, '#completed?' do
it 'return true if completed_at is not nil' do
todo = Todo.new completed_at: Time.current
expect(todo).to be_completed
end
it 'returns false if completed_at is not set' do
todo = Todo.new completed_at: nil
expect(todo).not_to be_completed
... |
# A number 233 in base 10 notation can be understood as a linear combination of powers of 10:
# The rightmost digit gets multiplied by 10**0 = 1
# The next number gets multiplied by 10**1 = 10
# ...
# The n*th number gets multiplied by 10n-1*.
# All these values are summed.
# ex. 233 - n = 3
# reverse the number and ... |
class AddColumnToReports < ActiveRecord::Migration
def change
add_column :reports, :disclose, :boolean, default: false, null: false
end
end
|
=begin
(Understand the Problem)
Problem:
In the modern era under the Gregorian Calendar, leap years occur in every year that is evenly divisible by 4,
unless the year is also divisible by 100. If the year is evenly divisible by 100,
then it is not a leap year unless the year is evenly divisible by 400.
... |
class EvaluableCompetenciesController < ApplicationController
# GET /evaluable_competencies
# GET /evaluable_competencies.json
def index
@evaluable_competencies = EvaluableCompetency.all(:order => 'category')
respond_to do |format|
format.html # index.html.erb
format.json { render json: @eval... |
require "rails_helper"
RSpec.feature "user sees all ideas" do
scenario "when they visit the home page", js: true do
idea1 = create(:idea)
idea2 = create(:idea, quality: "genius")
visit "/"
within("#full-#{idea1.id}") do
expect(page).to have_content idea1.title
expect(page).to have_conte... |
#!/usr/bin/env ruby
# encoding: utf-8
# Credits: Joanna Kamrowska & Sebastian Szwac
class Translate
def translate_conditions(phrase)
conditions_table = {
'Overcast' => 'Zachmurzenie',
'Clear' => 'Czyste niebo',
'Partly Cloudy' => 'Częściowe zachmurzenie',
'Mostly Cloudy' => 'Duże zachmurzenie',
'S... |
class UketsukePdf < ActiveRecord::Base
belongs_to( :kyujin_uketsuke)
validates_presence_of :pdf_name, :uketsuke_bango
end
|
class WeeksController < ApplicationController
before_action :set_week, only: [:show, :edit, :update, :destroy]
before_action :set_employee
def create
number = Week.where(employee_id: @employee.id).count + 1
week = Week.new(employee_id: @employee.id, number: number)
if week.save
redirect_to @emp... |
module FinanceReportsHelper
def error_message_box(error_msg)
"<div class='wrapper'><div class='error-icon'></div><div class='error-msg'>#{error_msg}</div></div>" if error_msg.present?
end
# course options in reporting filters
def courses_options args = {}
options = []
options << ["#{t('select_a_cou... |
class School::ParameterSanitizer < Devise::ParameterSanitizer
def sign_up
default_params.permit(*profile_attributes)
end
def account_update
attributes = profile_attributes + [
:current_password,
]
default_params.permit(*attributes)
end
private
def profile_attributes
[
:na... |
# HelloTxt Ruby Client
require 'net/http'
require 'rexml/document'
module HelloTxt
# MUST NOT end with a trailing slash, as this string is interpolated like this:
# "#{API_URL}/user.services"
API_URL = 'http://hellotxt.com/api/v1'
class Client
def initialize(api_key, user_key)
@api_key = api_key
... |
class ServicesController < ApplicationController
before_action :set_service, only: [:show, :edit, :update, :destroy]
def index
@services = Service.all
end
def show
end
def new
@services = Service.new
end
def edit
@service = Service.find(params[:id])
end
... |
# Add support for simple query methods such as where, find, all, and first.
# Where clauses are chainable and are simply appended to the search param.
# Ex:
# Geotab::Device.with_connection(conn).
# where({"serialNumber" => "G7B020D3E1A4"}).
# where({"name" => "07 BMW 335i"}).
# all
module Geotab
module... |
class CreateHosts < ActiveRecord::Migration[5.0]
def change
create_table :hosts do |t|
t.string :description, null: false
t.integer :user_id, null: false
t.timestamps
end
add_index :hosts, :user_id, unique: true
end
end
|
module Web::Controllers::Documents
class SetSearchType
include Web::Action
def call(params)
data = request.env['rack.request.form_vars']
search_scope_matcher = data.match(/search_scope=(.*?)&/)
search_scope = search_scope_matcher[1] if search_scope_matcher
search_mode_matcher = d... |
Rails.application.routes.draw do
constraints Clearance::Constraints::SignedIn.new do
root to: 'dashboard#index', as: :dashboard
end
constraints Clearance::Constraints::SignedOut.new do
root to: 'home#index'
end
end
|
class DropUserRelationshipTable < CamaManager.migration_class
def change
drop_table "#{PluginRoutes.static_system_info["db_prefix"]}user_relationships"
end
end
|
if Rails.env.development? || Rails.env.test?
require "factory_girl"
namespace :dev do
desc "Sample data for local development environment"
task :prime, [:email] => ["db:setup"] do |_task, args|
include FactoryGirl::Syntax::Methods
email = args[:email]
user = User.find_or_create_by!(email... |
class Bismark < Formula
homepage "http://www.bioinformatics.babraham.ac.uk/projects/bismark/"
# tag "bioinformatics"
url "http://www.bioinformatics.babraham.ac.uk/projects/bismark/bismark_v0.14.2.tar.gz"
sha256 "19560979bf3d060dd48079696b595cedd5bd4e8685da95a5024365e071cee58b"
def install
bin.install Di... |
require 'rails_helper'
require 'launchy'
describe 'writing reviews' do
before { Restaurant.create name: 'KFC', cuisine: 'Chicken'}
context 'logged out' do
it 'should not display the review form' do
visit '/restaurants'
expect(page).not_to have_field 'Thoughts'
end
end
context 'logged in' do
before do... |
#
# This is test for [ruby-Bugs#3237]
#
begin
require 'win32ole'
rescue LoadError
end
require "test/unit"
if defined?(WIN32OLE)
class TestWIN32OLE_WITH_WORD < Test::Unit::TestCase
def setup
begin
@obj = WIN32OLE.new('Word.Application')
rescue WIN32OLERuntimeError
@obj = nil
... |
class Patient < ApplicationRecord
has_many :appt_infos
has_many :doctors, through: :appt_infos
end
|
require './levels'
require './PokemonClass'
include Levels
class Game
def initialize(start)
@quips = [
"You died. Noob.",
"Nice job, you lost.",
"Looooooserrrrr."
]
@start = start
end
def play
next_room = @start
while true
puts "---------"
room = method(next_room)
next_room = room.call... |
require_relative "./resource"
require_relative "./metadata"
# Wrapper for {https://m2x.att.com/developer/documentation/v2/collections M2X Collections} API
class M2X::Client::Collection < M2X::Client::Resource
include M2X::Client::Metadata
PATH = "/collections"
class << self
#
# Method for {https://m2x.... |
# frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to specifically reject values that respond to `.blank?` and respond truthy for that method.
#
# @example Require a non-empty string for an argument
# argument :name, String, required: true, validate: { ... |
class CreateMemberships < ActiveRecord::Migration[5.2]
def change
create_table :memberships, id: :uuid do |t|
t.references :user, foreign_key: true, type: :uuid
t.references :organization, foreign_key: true, type: :uuid
t.references :approver, foreign_key: {to_table: :users}, type: :uuid
t... |
class ReleasesController < ApplicationController
def new
@project = Project.find(params[:project_id])
@release = @project.releases.build
@title = "New Release"
end
def index
@project = Project.find(params[:project_id])
@releases = @project.releases
@title = "#{@project.name} Releases... |
json.quantity_available @deal.quantity_available
json.quantity_sold @deal.sold_quantity
json.sold_out @deal.sold_out?
json.expired @deal.expired? |
class Command::Deploy
attr_reader :ref, :env, :app, :user, :payload
def initialize(payload)
fail ::Command::Error, "The /deploy command uses the syntax [app]@[branch]@[env]" unless payload.key?('text')
@app, @ref, @env = payload['text'].split('@')
@user = payload['user_name']
@payload = payload
... |
module Rhouse::Models::Media
class Attribute < ActiveRecord::Base
set_table_name 'Attribute'
set_primary_key "PK_#{Attribute.table_name}"
# relationships...
belongs_to :attribute_type,
:foreign_key => "FK_AttributeType",
:class_name => "Rhouse::Models::Media::AttributeType"
has... |
class ApplicationController < ActionController::Base
# protect_from_forgery with: :null_session
helper_method :current_user, :logged_in?
before_action :set_cart
include SessionsHelper
include CurrentCart
protected
def authorize
unless current_user.admin?
flash[:error] = "unauthorized access"
... |
class Auth::Token
attr_reader :token
alias_method :to_s, :token
def initialize
@hex = ActiveSupport::SecureRandom.hex(64)
# base64 url, see RFC4648
@token = SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
end
end
|
class AddRelationshipTable < ActiveRecord::Migration
def self.up
create_table :relationships do |t|
t.integer :user_id1
t.integer :user_id2
t.string :relationship_type
t.integer :requesting_user_id
t.datetime :requested_at
t.integer :confirming_user_id
t.datetime :confirm... |
# Copyright 2014 Square Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
require "active_record"
module Ag
module Adapters
class ActiveRecordPull
# Private: Do not use outside of this adapter.
class Connection < ::ActiveRecord::Base
self.table_name = [
::ActiveRecord::Base.table_name_prefix,
"ag_connections",
::ActiveRecord::Base.tabl... |
=begin
#===============================================================================
Title: Event Trigger Direction
Author: Hime
Date: Oct 2, 2013
--------------------------------------------------------------------------------
** Change log
Oct 2, 2013
- Initial release
-------------------------------------... |
class CreateMemberships < ActiveRecord::Migration[5.0]
def change
create_table :memberships do |t|
t.string :title, null: false
t.string :description, null: false
t.float :price, null: false
end
end
end
|
Gem::Specification.new do |s|
s.name = 'rufus-json'
s.version = File.read(
File.expand_path('../lib/rufus/json.rb', __FILE__)
).match(/ VERSION *= *['"]([^'"]+)/)[1]
s.platform = Gem::Platform::RUBY
s.authors = [ 'John Mettraux', 'Torsten Schoenebaum' ]
s.email = [ 'jmettraux@gmail.com' ]
s.homepa... |
class TicketTypesController < ApplicationController
def index
@ticket_types = TicketType.all
render json: @ticket_types
end
def create
@ticket_type = TicketType.create!(tickettype_params)
render json: @ticket_type
end
def destroy
@ticket_type = TicketType.find(params[:id])
@ti... |
require "rubygems"
gem "hpdf"
require "hpdf"
require File.join(File.dirname(__FILE__), "core", "prep")
# require "rubygems"
# gem "hpdf"
# require "hpdf"
# require "yaml"
# require "nkf"
# module PREP
# class Report
# def initialize(config_file_path)
# @config = YAML.load_file(config_file_path)
# r... |
# It starts with 139 different bonuses, need to filter them down to manageable levels
class BonusScoring
def initialize
@ht = Hash.new(0)
end
def round!
@ht.each do |k,v|
@ht[k] = v.round(6) if v.is_a?(Float)
end
end
def to_h
round!
@ht.dup
end
def keys
@ht.keys
end
d... |
require 'rails_helper'
describe "Categories" do
describe "Manage categories" do
context 'with according rights' do
before :each do
@role = FactoryGirl.create(:role, name: 'Team')
@user = FactoryGirl.create(:user, :donald, roles: Role.where(name: 'Team'))
end
it "Adds a new ca... |
# # "102012"
# 1 0 2 0 1 2 # the number
# 1*3^5 + 0*3^4 + 2*3^3 + 0*3^2 + 1*3^1 + 2*3^0 # the value
# 243 + 0 + 54 + 0 + 3 + 2 = 302
# input: a trinary number string
# output: a decimal equivalent
class Trinary
INVALID_TRINARY= /\D|[4-9]/
def initiali... |
class Searcher::Configuration
attr_accessor :searcher, :scopes
attr_accessor :facets
attr_writer :models
delegate :search_object, :to => :searcher
def initialize(searcher, &block)
self.searcher = searcher
self.scopes = {}
self.facets = {}
self.models = []
scope :runtime
scope :defa... |
# -*- coding: utf-8; -*-
#
# routes/init.rb : initialize routes
#
# Copyright (C) 2013 TADA Tadashi <t@tdtds.jp>
# You can modify and distribue this under GPL.
#
module PayMemo
class App < Sinatra::Base
before do
if request.path !~ %r|^/auth/| && !session[:user]
redirect '/auth/twitter'
end
end
get '/... |
class CommentDecorator < Draper::Decorator
delegate_all
def added_date
created_at.strftime("%d-%m-%Y, %H:%M")
end
end
|
class RaceTrait < ActiveRecord::Base
belongs_to :character_race
end
|
class Venue < ActiveRecord::Base
has_many :event_venues
has_many :events, through: :event_venues
validates :name, presence: true, length: { minimum: 5, maximum: 100 }
validates_uniqueness_of :name
def self.options_for_select
order(Arel.sql("LOWER(name)")).map { |e| [e.name, e.id] }
end
end |
require 'rails_helper'
RSpec.describe List, type: :model do
let(:my_user) { create(:user) }
let(:my_list) { create(:list, user: my_user) }
it { should belong_to(:user) }
it { should have_many(:items) }
it { should validate_presence_of(:name) }
it { should validate_length_of(:name).is_at_least(1) }
it { should... |
#
# test_rest_post.rb : REST GET client for debug
# v0.1 2016/02 : developped for REST getting
#
# usage:
# ruby test_rest_get.rb www.sample.org 80
#
require 'uri'
require 'net/http'
#####
uri = URI.parse(ARGV[0])
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Get.new(uri.request_uri)
res = http.reque... |
def run_config(expires: 20.years, expiration_time: 2.hours)
JumpIn.configure do |config|
config.expires = expires
config.expiration_time = expiration_time
end
end
# module Authentication
def set_session(object)
session[:jump_in_class] = object.class.to_s
session[:jump_in_id] = object.id
end
def set_... |
web_app "testsite" do
server_name "testsite.dev"
server_aliases ["my-site.testsite.dev"]
docroot "/vagrant/web"
application_name "testsite_log"
allow_override "all"
enabled "true"
end |
require "application_system_test_case"
class IcTypesTest < ApplicationSystemTestCase
setup do
@ic_type = ic_types(:one)
end
test "visiting the index" do
visit ic_types_url
assert_selector "h1", text: "Ic Types"
end
test "creating a Ic type" do
visit ic_types_url
click_on "New Ic Type"
... |
class AddOrderToDrafterms < ActiveRecord::Migration[5.0]
def change
add_column :draftterms, :section_order_no, :integer
add_column :draftterms, :order_no, :integer
end
end
|
require 'beaker-rspec/spec_helper'
require 'beaker/module_install_helper'
require 'beaker/puppet_install_helper'
RSpec.configure do |config|
config.default_formatter = :documentation
# Limits the available syntax to the non-monkey patched syntax that is
# recommended.
config.disable_monkey_patching!
config... |
class CounterReflex < StimulusReflex::Reflex
def increment(step = 1)
session[:count] = session[:count].to_i + step
end
end
|
require 'test_helper'
require 'rackstash'
if Rackstash.framework == "rails3"
require 'rackstash/log_subscriber'
require 'active_support/notifications'
describe Rackstash::LogSubscriber do
let(:log_output){ StringIO.new }
let(:base_logger){ Logger.new(log_output) }
let(:logger){ Rackstash::BufferedLo... |
class Table
def initialize(n)
@places = Array.new(n, 1)
@quant = 1
end
def state
[@places.dup, @quant]
end
def step
pass_penny
alt_quant
end
private
def pass_penny
current = @places.shift - @quant
@places << current if current > 0 || @places.size < 1
@places[0] += @... |
Rails.application.routes.draw do
devise_for :users, path: '', path_names: { sign_in: 'login', sign_out: 'logout', sign_up: 'register'}
resources :portafolios
get 'angular-items', to: 'portafolios#angular'
#get 'portafolio/:id', to: 'portafolio#show', as:'portafolio_show'
# Home Page
#get 'pages/home'
... |
class CreateInterns < ActiveRecord::Migration[5.0]
def up
create_table :interns do |t|
t.string :job_title
t.string :company
t.string :location
t.text :requirements
t.text :responsibilities
t.timestamps
end
end
def down
drop_table :interns
end
end
|
require 'packetfu'
require 'pry'
require 'bindata'
iface = ARGV[0] || PacketFu::Utils.default_int
cap = PacketFu::Capture.new(:iface => iface, :start => true, :filter => "ip")
def is_kafka_tcp? (p)
(p.peek[0] == "T") and ([9092,9093,9094].member?(p.tcp_dport)) and (p.payload.size > 0)
end
PROTOCOL_MAPPING = { pr... |
class Journey
attr_reader :history, :entry_station, :exit_station
def initialize
@history = []
end
def in_journey?
!!@entry_station
end
def save
@history << {:entry_station => @entry_station, :exit_station => @exit_station}
end
end
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'azericard/version'
Gem::Specification.new do |spec|
spec.name = "azericard"
spec.version = Azericard::VERSION
spec.authors = ["Nihad Abbasov"]
spec.email = ["... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Tokenizers
class TokenRecognizer
attr_reader :token_type, :regex, :content, :cleaner
def initialize(token_type, regex, content = nil, &block)
@token_type = token_type
... |
class ApplicationController < ActionController::Base
http_basic_authenticate_with name: ENV['BASIC_AUTH_USERNAME'], password: ENV['BASIC_AUTH_PASSWORD'] if Rails.env.staging?
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :except... |
module Tablette
class Element
class << self
protected
# Defines DSL method for configuring nested element.
# If no args/block passed - returns currently defined elements as array.
#
# Example:
# class Table < Element
# nest :body, Body
# end
#
# ... |
# This class holds a single string called answer that is accessable from outside the class
class Answer
attr_reader :answer
def initialize(answer)
@answer = answer
end
end |
RSpec.describe SphynxGrape::Api do
include Rack::Test::Methods
def app
SphynxGrape::Api
end
describe 'GET /' do
it 'should return a 204 response' do
get('/')
expect(last_response).to be_successful
expect(last_response.status).to be(204)
end
end
describe 'GET /protected' do
... |
class Song < ApplicationRecord
belongs_to :artist
def self.order_by_title
order(:title)
end
end
|
location = attribute('location')
resource_group = attribute('network_resource_group')
name = attribute('subnet_name')
vnet = attribute('vnet_name')
address_prefix = attribute('subnet_address_prefix')
nsg = attribute('subnet_nsg')
control 'check-if-resource-group-exists' do
... |
class Question < ActiveRecord::Base
belongs_to :lesson
has_many :answers
accepts_nested_attributes_for :answers, :reject_if => lambda { |a| a['data'].blank? }, :allow_destroy => true
end |
require 'rails_helper'
describe Feedback do
it 'has a valid factory' do
expect(FactoryGirl.create(:feedback)).to be_valid
end
it 'invaild without name' do
expect(FactoryGirl.build(:feedback, name: nil)).to be_invalid
end
it 'invaild without email' do
expect(FactoryGirl.build(:feedback, email: nil)).to be... |
class UsersController < ApplicationController
skip_before_action :authorized, only: [:new, :create]
before_action :get_user, only: [:edit, :update, :show]
def index
@users = User.all
end
def new
@user = User.new
@errors = flash[:errors]
end
def create
@user = User.create(user_params)
... |
class AddSlugsToArticlesAndRubrics < ActiveRecord::Migration
def change
add_column :articles, :slug, :string
add_index :articles, :slug
add_column :rubrics, :slug, :string
add_index :rubrics, :slug
end
end
|
require 'rails_helper'
describe Examination do
it 'sets the status to scheduled when last_date exists' do
examination = build(:examination, last_date: 10.days.from_now)
examination.save
expect(examination.str_status).to eq("scheduled")
end
describe "#str_status" do
it 'convert the status code to... |
require_relative '../helpers/rake_helper_template'
class LinkProductsToGalleries < RakeHelperTemplate
def main
template do |logger|
products = Refinery::Caststone::Product.all
gallery_pages = Refinery::Page.i18n.where(parent: Refinery::Page.i18n.where(menu_title: 'Galleries'))
products.each d... |
source 'https://rubygems.org'
# Lock rails to version 3.2.8
gem 'rails', '3.2.8'
# Load JQuery for UJS
gem 'jquery-rails'
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
# Use SQLite3 to store data during development
gem 'sqlite3'
# Only load these gems in the development environme... |
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
require './lib/boat'
class BoatTest < Minitest::Test
def test_boat_exists
kayak = Boat.new(:kayak, 20)
assert_instance_of Boat, kayak
end
def test_boat_has_type
boat_1 = Boat.new(:kayak, 20)
assert_equal :kayak, boat_1.type
end... |
class TitleReviewsController < ApplicationController
layout 'default'
before_filter :authorize_admins_only, :only => ['destroy']
before_filter :authorize_users_only, :only => ['new', 'create']
before_filter :authorize_originating_user_only, :only => ['edit', 'update', '_add_title_comment', '_create_title_comment']
... |
class Flight < ApplicationRecord
has_many :user_flights
has_many :users, through: :user_flights
end
|
class User < ApplicationRecord
validates :username, presence: true, length: {minimum: 3, maximum: 15}, uniqueness: true
has_many :messages
has_secure_password
scope :online, -> { where(status: true) }
end
|
class Api::ApplicantsController < ApiController
def index
@xml = Builder::XmlMarkup.new
@applicants = Applicant.search(params[:search])
respond_to do |format|
unless params[:search].present?
render "single_access_tokens/500.xml" and return
else
format.xml { render :applican... |
require "fog/xml/version"
require "nokogiri"
module Fog
autoload :ToHashDocument, "fog/to_hash_document"
module XML
autoload :SAXParserConnection, "fog/xml/sax_parser_connection"
autoload :Connection, "fog/xml/connection"
end
module Parsers
autoload :Base, "fog/parsers/base"
end
end
|
require_relative '../../lib/mince_dynamo_db/config'
describe MinceDynamoDb::Config do
let(:secret_access_key) { mock }
let(:access_key_id) { mock }
before do
AWS.config(access_key_id: access_key_id, secret_access_key: secret_access_key)
end
it 'uses "id" as the primary key for the database' do
desc... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V1::Transactions', type: :request do
within_subdomain :api do
let(:current_user) { FactoryGirl.create(:user) }
let(:transaction) do
FactoryGirl.create(:transaction, user: current_user)
end
context 'with authentication token... |
class ProductsController < ApplicationController
def index
@products = Product.all
end
def show
@product = Product.find(params[:id])
@reviews = @product.reviews.recent.paginate(:page => params[:page], :per_page => 5)
@product.increment
if @reviews.blank?
@avg_experience = 0
... |
class Restaurant < ApplicationRecord
validates :name, presence: true
has_many :restaurant_dishes
has_many :dishes, through: :restaurant_dishes
end
|
require 'spec_helper'
describe UsersController do
let(:user) { FactoryGirl.create(:user)}
let(:invalid_user) { FactoryGirl.create(:invalid_user)}
describe "GET #new" do
it "renders the new template" do
get :new
response.should render_template(:new)
end
end
describe "POST #create" do
it 'should cr... |
class Menu
#Listar os clientes que estão ‘ligados’ e a sua respetiva localização.
#Listar os valores lidos de um determinado sensor, sendo fornecido como parâmetro um identificador único do cliente.
attr_reader :optionListarOnline, :optionListarSensor, :optionSair
@@optionListarOnline = 1
@@optionLista... |
def turn_count(board)
counter = 0
board.each do |space|
if space == "X" || space == "O"
counter += 1
end
end
return counter
end
def current_player(board)
if turn_count(board) == 0 || turn_count(board).even?
return "X"
elsif turn_count(board).odd?
return "O"
end
end
|
require 'rubygems'
# support many method for selenium
class Support
# docs https://www.rubydoc.info/gems/selenium-webdriver/3.141.0/Selenium/WebDriver/Driver
@browser = nil
@url = nil
@wait = nil
# setter @browser
def browser=(browser)
@browser = browser
end
# getter @browser... |
class Purchase < ApplicationRecord
belongs_to :purchaser
belongs_to :item
belongs_to :merchant
validates :purchaser_id, :merchant_id, :item_id, :quantity, :total, presence: true
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.