text stringlengths 10 2.61M |
|---|
# encoding: utf-8
# frozen_string_literal: true
RSpec.describe TTY::Tree::PathWalker do
it "walks path tree and collects nodes" do
walker = TTY::Tree::PathWalker.new
within_dir(fixtures_path) do
walker.traverse('dir1')
end
expect(walker.nodes).to eq([
TTY::Tree::Node.new('dir1', '', '',... |
require_relative 'recipe'
require 'csv'
class Cookbook
def initialize(filepath)
@recipe_file = filepath
@recipes = []
load_csv
end
def all
@recipes = []
load_csv
@recipes
end
def add_recipe(attributes = {})
write_csv(attributes)
end
def remove_recipe(number)
@recipes.de... |
class ChargesController < ApplicationController
def index
@charges_failed = Charge.failed
@charges_successful = Charge.successful
@charges_disputed = Charge.disputed
end
end
|
class Lineup < ActiveRecord::Base
has_many :players, :autosave => true, :dependent => :destroy
belongs_to :team
end
|
include_recipe "partial_search"
# This code iterates through node['admin']['cloud_network']['recipes'] to find
# network information about the location of each recipe. Then, populates the public and private
# IP info for further use throughout the cookbook. Chef environments are used
# to isolate different installatio... |
require 'spec_helper'
describe AuthenticationsController do
let(:user) { create(:user) }
let(:omniauth_callback) { {'provider' => 'twitter', 'uid' => '1234',
'credentials' => {'token' => 'token', 'secret' => 'secret'} } }
before(:each) { controller.stub!(:auth_hash).and_return(omnia... |
require 'rails_helper'
describe 'merchant items show (/merchant/:merchant_id/items/:id)' do
let!(:merchant) { create(:merchant) }
let!(:item1) { create(:item, unit_price: 10, merchant: merchant) }
let!(:item2) { create(:item, unit_price: 8, merchant: merchant) }
let!(:item3) { create(:item, unit_price: 5, m... |
class Meeting < ApplicationRecord
validates :date, :speaker, presence: true
scope :date, -> { order("date ASC") }
end
|
# Copyright 2007-2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
require 'spec_helper'
describe 'using shorthand operators to combine String, Symbol and Regexp parsers' do
it 'should be able to chain a String and a Regexp together' do
# try in one order
sequen... |
require 'rails_helper'
feature 'application header' do
let(:client) { create :user, role: :client }
let(:admin) { create :user, role: :admin }
# describe 'when no user is logged in' do
# before do
# visit root_path
# end
# it 'shows the brand' do
# expect(page).to have_css '.brand'
# ... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UpdateGLYCMembers, type: :service do
let(:pdf) { file_fixture('update_glyc_members/GLYC_Roster.pdf') }
let(:service) { described_class.new(pdf) }
it 'updates the stored members' do
create(:glyc_member)
service.update
expect(GLYCM... |
#!/bin/env ruby
# frozen_string_literal: true
require 'rubygems'
COIN_SIDES = %w[heads tails].freeze
####
# Name: fifty_fifty
# Description: returns true or false
# Arguments: none
# Response: boolean
####
def fifty_fifty
[true, false].sample
end
####
# Name: one_third
# Description: returns true approximately on... |
class PiecesController < ApplicationController
before_action :load_batiment
def index
@pieces = @batiment.pieces.all
end
def new
@batiment = Batiment.find(params[:batiment_id])
@piece = @batiment.pieces.new
end
def create
@piece = @batiment.pieces.new(piece_params)
if @piece.save
flash[:notice] = ... |
class RemoveRegionFromBirds < ActiveRecord::Migration[5.1]
def change
remove_column :birds, :region
end
end
|
class Practice < ApplicationRecord
has_one_attached :eyecatch
attr_accessor :image
def eyecatch=(image)
return unless image.present?
prefix = image[%r{(image|application)(/.*)(?=\;)}]
type = prefix.sub(%r{(image|application)(/)}, '')
data = Base64.decode64(image.sub(/data:#{prefix};base64,/, '')... |
module MessagesController
extend Sinatra::Extension
configure do
set :webhook_token, ENV['PLIVO_WEBHOOK_TOKEN']
end
helpers do
def send_message
to = params['to']
text = params['text']
@contact = Contact.find(phone_number: to,
user_id: @current_user.id)
... |
FactoryGirl.define do
sequence :den_number do |n|
"#{n}"
end
sequence :rank do |r|
["Tiger", "Wolf", "Bear", "Webelo 1", "Webelo 2"][rand(5)]
end
factory :den do
den_number { FactoryGirl.generate(:den_number) }
rank { FactoryGirl.generate(:rank) }
leader... |
class RenameAccessTokenTable < ActiveRecord::Migration[5.2]
def change
rename_column :instagram_access_tokens, :encrypted_message, :encrypted_access_token
rename_column :instagram_access_tokens, :encrypted_message_iv, :encrypted_access_token_iv
end
end
|
module VipUser::VipClient
require "#{Rails.root}/lib/Vip_User/VIPUserServicesDriver.rb"
class VipClient
def initialize(uri_path)
@driver = AuthenticationServicePort.new("https://vipuserservices-auth.verisign.com/" + uri_path)
@driver.loadproperty("#{Rails.root}/config/vip_auth.properties")
end
... |
class ChangeRefereeMatchToRefereeMatchIdForRedCards < ActiveRecord::Migration[5.1]
def change
remove_column :red_cards, :referee_match, :integer
add_column :red_cards, :referee_match_id, :integer
end
end
|
FactoryBot.define do
factory :transfer_marker do
reporting_relationship { create :reporting_relationship }
body { "i am a transfer marker #{SecureRandom.hex(17)}" }
end
end
|
class Activity < ActiveRecord::Base
belongs_to :user
has_many :events
validates :user_id, presence: true
validates :activity_name, presence: true
end
|
require 'rubygems'
require 'gtk3'
load 'Sauvegarde.rb'
load 'Highscore.rb'
# Cette classe gère tout l'aspect graphique du début de l'application, elle utilise le DP singleton
# @param nom_joueur [String] le nom du joueur
# @param window [GTK::Window] la fenetre actuelle
# @param @builder [GTK::Builder] le constructeur... |
# frozen_string_literal: true
# a video model containing youtube urls
class Video < ApplicationRecord
has_many :user_videos
has_many :users, through: :user_videos
belongs_to :tutorial
def default_video?
title == 'Tutorial Has No Videos'
end
validates_presence_of :position
end
|
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Opinions
describe VoteOpinion do
describe "call" do
let(:opinion) { create(:opinion) }
let(:current_user) { create(:user, organization: opinion.component.organization) }
let(:command) { described_class.new(op... |
class Page < ActiveRecord::Base
extend FriendlyId
friendly_id :title, :use => :slugged
validates :title, :presence => true, :uniqueness => true
end
# == Schema Information
#
# Table name: pages
#
# id :integer not null, primary key
# title :string(255)
# content :text
# slug :s... |
require_relative "../../db/chores/populator"
namespace :populate do
namespace :ncr do
desc "Populate the database with identical NCR data"
task uniform: :environment do
Populator.new.uniform_ncr_data
end
desc "Populate the database with random NCR data"
task random: :environment do
P... |
class Api::BookmarksController < Api::ApiController
before_action :set_bookmark, only: [:show, :edit, :update, :destroy]
# /bookmarks?user_id=6
def index
bookmarks = Bookmark.where(user_id: params[:user_id])
if bookmarks.count == 0
bookmarks = Bookmark.all
end
# bookmar... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# frozen_string_literal: true
require 'logging'
require 'bolt/node/errors'
module Bolt
module Transport
class Docker < Base
class Connection
def initialize(target)
raise Bolt::ValidationError, "Target #{target.safe_name} does not have a host" unless target.host
@target = target... |
# Processes have exit codes.
# Every process that exits does so with a numeric exit code (0-255)
# Kernel#exit
exit
# Custom exit code
exit 133
# Invoke block at exit
at_exit { puts 'Exit' }
exit
# Exists with status code 1 (default) and doesn't invoke at_exit
exit!
# Exit a process unsuccessfully
abort "Something... |
require 'sumac'
# make sure it exists
describe Sumac::RemoteEntry do
def build_remote_entry
future = instance_double('QuackConcurrency::Future')
allow(QuackConcurrency::Future).to receive(:new).and_return(future)
remote_entry = Sumac::RemoteEntry.new
end
# ::new
example do
future = instance_d... |
# frozen_string_literal: true
require 'test_helper'
class ViewTest < ActiveSupport::TestCase
setup do
@workspace = workspaces(:one)
@view = views(:one)
end
test "to_s should return name" do
view = View.new(name: "View Foo")
assert_equal "View Foo", view.to_s
end
test "duplicate should ret... |
class Post < ActiveRecord::Base
validates :title, presence: true, length: {minimum: 5}
validates :body, presence: true
has_many :comments, as: :commentable
end
|
class AddReferencesToTaskcomments < ActiveRecord::Migration[6.0]
def change
add_reference :task_comments, :boss, foreign_key: true
add_reference :task_comments, :child_task, foreign_key: true
end
end
|
require 'rails_helper'
RSpec.describe "offers/edit", type: :view do
before(:each) do
@offer = assign(:offer, Offer.create!(
:nombre => "MyText",
:descripción => "MyText",
:imagen => "MyString"
))
end
it "renders the edit offer form" do
render
assert_select "form[action=?][meth... |
class CreateSmoothies < ActiveRecord::Migration[5.2]
def change
create_table :smoothies, :options => 'ENGINE=InnoDB ROW_FORMAT=DYNAMIC' do |t|
t.string :smoothie_name
t.string :smoothie_image
t.text :comment
t.datetime :created_at
t.datetime :updated_at
t.datetime :deleted_at
... |
module CDI
module V1
class SimpleGameItemSerializer < ActiveModel::Serializer
root false
attributes :id, :game_related_item_id, :word, :related_word,
:has_uploaded_image?, :image_url,
:has_uploaded_related_image?, :related_image_url,
:created_at, :u... |
class CreateItems < ActiveRecord::Migration[5.2]
def change
create_table :items do |t|
t.string :name, null: false
t.text :description, null:false
t.integer :price, null:false
t.integer :brand_id
t.integer :condition_id, null:false
t.integer :delivery_fee_id, null:false
t... |
# DashboardManifest tells Administrate which dashboards to display
class DashboardManifest
# `DASHBOARDS`
# a list of dashboards to display in the side navigation menu
#
# These are all of the rails models that we found in your database
# at the time you installed Administrate.
#
# To show or hide dashboa... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserChannel, type: :channel do
let!(:current_user) { create(:user) }
describe 'User' do
it 'should subscribe' do
stub_connection current_user: current_user
expect do
subscribe(id: current_user.id)
end.to have_broadc... |
# terminal: rspec --tag @dropdown
describe 'Dropdown list', :dropdown do
it 'specific simple item' do
visit 'https://training-wheels-protocol.herokuapp.com/dropdown'
select('Loki', from: 'dropdown')
sleep 3
end
it 'specific item by find' do
visit 'https://training-wheels... |
require "application_responder"
class ApplicationController < ActionController::Base
self.responder = ApplicationResponder
respond_to :html
protect_from_forgery
rescue_from CarrierWave::DropBox::Error do |exception|
redirect_to new_dropbox_sessions_url(:return_url => request.referer)
end
def after_s... |
class EventsController < ApplicationController
before_action :set_event, only: [:show, :edit, :update, :destroy]
before_action :logged_in_user, only: [:new, :create, :edit, :update, :destroy]
def search
address = GeocodedAddress.new(params['user_geo'])
# find events within the search radius, and filte... |
# The input array should be sorted. This is when we use binary search. It is much faster than the linear search.
module Kata
module Algorithms
module Searching
class BinarySearch < Struct.new(:array, :value_to_search_for)
def search
return nil if array.nil? || array.empty? || value_to_sear... |
module Jsonapi
class TurnResource < JSONAPI::Resource
attributes :hole_number, :par, :strokes
has_one :scorecard
def self.updatable_fields(_)
super - [:holes_count]
end
def self.creatable_fields(_)
super - [:holes_count]
end
paginator :none
end
end
|
class Admins::PortfoliosController < ApplicationController
before_filter :authenticate_admin!
layout "admins"
def index
@portfolios = Portfolio.all
respond_to do |format|
format.html
end
end
def new
@portfolio = Portfolio.new
@portfolio.photos.build
respond_to do |format|
format.html
end
... |
require 'space'
describe Space do
describe '.all' do
it '.all method exists' do
expect(Space).to respond_to(:all)
end
it 'returns a space' do
add_row_to_places_test_database
connection = PG.connect(dbname: 'makersbnb_test')
expect(Space.all[0].name).to eq "Shed"
expect(Sp... |
class EventType < ActiveRecord::Base
belongs_to :activity
validates_presence_of :name
end
|
class CreateOnlineExamGroupsQuestions < ActiveRecord::Migration
def self.up
create_table :online_exam_groups_questions do |t|
t.references :online_exam_group
t.references :online_exam_question
t.decimal :mark, :precision=>15, :scale=>4
t.text :answer_ids
t.integer :position
t.... |
# GET & HANDLES DATA FROM YELP API
class YelpHandler
def self.get_by_coordinates(lat, long)
client = setup_client
data = client.search_by_coordinates({latitude: lat, longitude: long}, limit: 10, radius_filter: 100, sort: 1)
output = data.businesses.map do |business|
{
name: business.nam... |
#
# Cookbook Name:: redis
# Recipe:: source
#
# Author:: Gerhard Lazu (<gerhard@lazu.co.uk>)
#
# Copyright 2011, Gerhard Lazu
#
# 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://ww... |
class User < ActiveRecord::Base
belongs_to :tribe
has_many :happenings
has_many :rsvps
def name
"#{first_name} #{last_name}"
end
def profile_incomplete?
home_zip.blank? || work_zip.blank?
end
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap d... |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "Assets/css"
sass_dir = "Assets/sass"
images_dir = "Assets/images"
javascripts_dir = "AsiCommon/Scripts"
# You can select your preferred output style here (can be overridden via the command ... |
class Image < ActiveRecord::Base
self.table_name = 'uploads'
has_many :sections, through: :upload_sections
attr_accessible :title, :size, :filetype, :file, :section_id
mount_uploader :file, ImageUploader
def self.is_image
where("filetype LIKE 'image%'")
end
end |
require 'spec_helper'
describe HomeController do
context 'subdomains' do
before { set_subdomain }
context 'GET :index' do
it 'renders the :index template' do
get :index
expect(response).to render_template(:index)
end
end
end
context 'custom domains' do
before { set_c... |
require 'rails_helper'
RSpec.describe 'supply_teachers/suppliers/master_vendors.html.erb' do
let(:suppliers) { [] }
before do
assign(:suppliers, suppliers)
end
it 'displays the number of suppliers' do
render
expect(rendered).to have_text(/0 agencies/)
end
end
|
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
#
# Microsoft Visual Studio Mobile Center API
#
class RepositoryConfigurations
#
# Creates and initializes a ... |
class AddTypeToEvent < ActiveRecord::Migration
def change
add_column :events, :event_type, :integer, :default => 0
add_column :events, :to_do_id, :integer
add_column :events, :request_map_id, :integer
end
end
|
require "base64"
class RootMe < Botpop::Plugin
include Cinch::Plugin
FloatRegexp = "\d+(\.\d+)?"
match(/!ep1 (\w+)/, use_prefix: false, method: :start_ep1)
match(/!ep2 (\w+)/, use_prefix: false, method: :start_ep2)
match(/^(#{FloatRegexp}) ?\/ ?(#{FloatRegexp})$/, use_prefix: false, method: :play_ep1)
mat... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :students, only: [:new, :create, :edit, :update, :show]
resources :school_classes, only: [:new, :create, :edit, :update, :show]
end
# could have done it like this:
# Rail... |
class Preference < ActiveRecord::Base
include Lolita::Configuration
has_and_belongs_to_many :profiles
end
|
class CreateLeaseItems < ActiveRecord::Migration
def change
create_table :leasingx_lease_items do |t|
t.string :name
t.string :description
t.decimal :hourly_rate, :precision => 7, :scale => 2
t.boolean :active, :default => true
t.integer :discount, :default => 0
t.integer :inpu... |
class AddAdminUserIdAndVisibilityToPhoto < ActiveRecord::Migration[5.2]
def change
add_column :photos, :admin_user_id, :integer
add_column :photos, :visibility, :integer
Photo.update_all(admin_user_id: 1)
Photo.find_each do |photo|
if photo.id % 2 == 0
photo.update!(visibility: 0)
... |
class Gag < ActiveRecord::Base
attr_accessible :title, :image, :votes_up, :imagelink, :videolink
#:ratio, :title, :user_id, :votes, :votes_up, :image
has_attached_file :image, dependent: :destroy, :styles => { :medium => "300x300>", :thumb => "100x100>" }
validates_attachment_content_type :image,
:content_t... |
# -*- coding: utf-8 -*-
MindpinSidebar::Base.config do
# example
#
# rule :admin do
# nav :students, :name => '学生', :url => '/admin/students' do
# controller :'admin/students'
# subnav :student_info, :name => '学生信息', :url => '/admin/students/info' do
# controller :'admin/student_i... |
namespace :oai do
desc "Harvest records from OAI providers"
task :harvest => :environment do
if ENV['ID']
provider = Provider.find(ENV['ID'])
if provider.first_consumption
print "Consuming #{provider.endpoint_url} for first time: "
count = provider.first_consume!
print "#{count} rec... |
class ChangeColumnFilms < ActiveRecord::Migration[6.1]
def change
add_column :films, :author, :string
add_column :films, :description, :string
add_column :films, :status, :integer
add_column :films, :time, :integer
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :reservation do
reservation_from "2014-07-17 04:55:37"
reservation_to "2014-07-17 04:55:37"
notes "MyText"
user nil
no_of_people 1
end
end
|
class LogEntriesController < ApplicationController
before_filter :authenticate_user!
before_filter :find_activity_log
before_filter :find_log_entry, only: [:show, :edit, :update, :destroy]
before_filter :build_favorites
def new
# log_entry = @activity_log.log_entries.where(date: params[:date]).first
... |
class ElasticSearch < DebianFormula
url 'https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.1.tar.gz'
homepage 'http://www.elasticsearch.org'
md5 '439002f5f0e7d213d2e27b166fb87d87'
source 'https://github.com/mobz/elasticsearch-head.git'
name 'elasticsearch'
version '0.17.1'
sect... |
# frozen_string_literal: true
class EventsController < ApplicationController
layout false
$adminBOOLEAN = 0
def index
@households = Household.all
@events = Event.order('name ASC')
if $adminBOOLEAN == 1
render('index')
else
redirect_to(controller: 'member_view', action: 'index')
e... |
require "spec_helper"
describe Reflect::Permalink do
describe "when creating a permalink" do
it "should return a permalink" do
slug = Reflect::Permalink.new("my super slug")
slug.should eq("my-super-slug")
end
end
end |
require 'rspec'
require_relative '../lib/node'
describe Attribute do
let(:attr_class) { Attribute.new :class, 'some-class' }
context 'attribute instance' do
it 'return attribute name' do
expect(attr_class.name).to eq :class
end
it 'return attribute value' do
expect(attr_class.value)... |
class EditHashtags < ActiveRecord::Migration[5.2]
def change
remove_column :hashtags, :article_id
end
end
|
require 'rake/testtask'
namespace :test do
namespace :unit do
Rake::TestTask.new :string_calculator do |t|
t.test_files = FileList['test/string_calculator_test.rb']
end
end
namespace :spec do
Rake::TestTask.new :string_calculator do |t|
t.test_files = FileList['spec/string_calculator... |
require 'yaml'
module Env
class << self
attr_accessor :redis
end
module Redis
CONFIG_FILE = "config/redis.yml"
def self.start!
configs = YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', CONFIG_FILE))
redis_configs = configs['redis']
Env.redis = ::Redis.new ... |
class LikesController < ApplicationController
before_action :authenticate_user!
before_action :set_user
before_action :set_likeable
def create
if (liked = current_user.likeable_like(@likeable)).present?
liked.destroy!
end
@like = Like.new()
@like.is_upvote = params[:is_upvote]
@like... |
require 'lita/handlers/enhance/node_index'
module Lita
module Handlers
class Enhance
class IpEnhancer < Enhancer
IP_REGEX = /(?:[0-9]{1,3}\.){3}[0-9]{1,3}/
def initialize(redis)
super
@nodes_by_ip = NodeIndex.new(redis, 'nodes_by_ip')
end
def index(ip, ... |
module Veeqo
class Order < Base
include Veeqo::Actions::Base
def create(channel_id:, customer_id:, delivery_method_id:, **attributes)
required_attributes = {
channel_id: channel_id,
customer_id: customer_id,
delivery_method_id: delivery_method_id,
}
create_resource(... |
require 'rails_helper'
RSpec.describe AddressForm, :address_form do
subject { AddressForm.new(attributes_for(:type_address, :shipping)) }
context 'validation' do
%i(firstname lastname address zipcode phone city country_id).each do |attribute_name|
it { should validate_presence_of(attribute_name) }
... |
class AddColumnsToPublications2 < ActiveRecord::Migration
def change
add_column :publications, :publication_type_id, :integer
add_column :publications, :alt_title, :text
add_column :publications, :publanguage, :text
add_column :publications, :extid, :text
add_column :publications, :links, :text
... |
class MatchesController < ApplicationController
before_action :login_user
# respond_to :json
# GET api/matches
def index
#return JSON of a user's matches profile information
# render :text => "Match index"
#THIS SHOULD PROBABLY BE MOVED TO MODEL
# user = User.find(1)
# ma... |
describe PlayerCharacter, type: :model do
describe 'validations' do
describe 'name' do
it 'is not valid if no name' do
expect(PlayerCharacter.new.valid?).to eq(false)
end
it 'is valid if name' do
expect(PlayerCharacter.new(name: 'foobar').valid?).to eq(true)
end
end
... |
ENV['SINATRA_ENV'] ||= "development"
#we should use the "development" environment for both the shotgun and the testing suite
#we want to make sure that our migrations run on the same environment
require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])
configure :development do
set :database, 'sqlite3:db/... |
module Ripley
module Loggers
class Stdout
# logs to stdout
def fatal(message)
puts "FATAL #{message}"
end
def error(message)
puts "ERROR #{message}"
end
def warn(message)
puts "WARN #{message}"
end
def info(message)
puts "INFO #{... |
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /users
# GET /users.json
def index
@users = User.all
end
# GET /users/1
# GET /users/1.json
def show
end
# GET /users/new
def new
@use... |
module DSLSet
module DSLRestful
require 'rest_client'
require "base64"
require "nori"
require 'json'
class << self
def config cfgs
puts "Calling config: #{cfgs.to_s}"
unless cfgs.keys.include?(:web_host)
puts "parameters you should input are :web_host"
... |
Dir[File.expand_path('face_detect/*.rb', __dir__)].each { |file| require file }
class FaceDetect
attr_reader :file, :adapter_instance
# TODO accept a File or a URL
def initialize(file:, adapter:)
@file = file
@adapter_instance = adapter.new(file)
end
def run
adapter_instance.run
end
end
|
class UserCategory < ApplicationRecord
# Associations
belongs_to :user
belongs_to :category
# ------------
# Validations
validates :user_id, presence: true
validates :category_id, presence: true
validates :total_weightage, presence: true
# ----------------
end
|
require 'test_helper'
require 'tins/find'
require 'fileutils'
require 'tempfile'
module Tins
class FindTest < Test::Unit::TestCase
include Tins::Find
include FileUtils
def setup
mkdir_p @work_dir = File.join(Dir.tmpdir, "test.#$$")
end
def teardown
rm_rf @work_dir
end
def t... |
When("user click in entry button must appears screen of stock controll") do
@m_Object.click "entrada"
temp = @m_Object.get_element "lbl_titulo"
expect(temp.text).to eql("Adicionar estoque")
end
Given("which product stock increase {int} units in amount") do |_Amount|
@m_Object.add_text "txt_qtdentrada",... |
# frozen_string_literal: true
module Enums
class LocaleEnum < BaseEnum
from_enum Locale
end
end
|
class V1::TokensController < ApplicationController
before_action :authenticate!, except: [:create]
def create
jwt_token = AuthToken.encode(id: valid_account.id)
token = valid_account.tokens.create(token: jwt_token)
render json: serialize_model(token), status: 201
end
private
def valid_account
... |
require_relative '../../../../spec_helper'
describe 'collectd::plugin::process', :type => :define do
let(:pre_condition) { 'Collectd::Plugin <||>' }
describe 'when title is valid' do
let(:title) { 'giraffe' }
it {
is_expected.to contain_collectd__plugin('process-giraffe').with_content(<<EOS
<Plug... |
require "zip"
require "json"
require "kartograph"
require "resource_kit"
require "qualtrics/version"
require "active_model"
require "active_support/all"
module Qualtrics
module API
autoload :Client, "qualtrics/client"
# Models
autoload :BaseModel, "qu... |
class Admin::VolunteersController < ApplicationController
before_filter :authenticate_user!
authorize_resource
before_filter :load_model, only: [:edit, :show, :update, :destroy]
def index
scope = Volunteer.joins(:congregation)
@part, @order, @congregation_id, @vacancy = nil, nil, nil, nil
if para... |
require 'spec_helper'
describe PermissionCollection do
before(:each) do
@law_case = build(:law_case)
@permission_collection = PermissionCollection.new
end
describe "#add_case_permission" do
it "should add a case permission" do
@permission_collection.add_case_permission(@law_case, :read_only)
... |
# Lesson 2
# Заполнение массива числами от 10 до 100 с шагом 5
numbers = []
number = 10
while number <= 100
numbers << number
number += 5
end
puts numbers |
class FreeContentsController < ApplicationController
before_action :set_variables, only: :show
def show
raise ActionController::RoutingError.new('Not Found') if !@document.present?
end
private
def set_variables
@courses = Course.joins(:topics => {:subtopics => :documents}).where(documents: {free_c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.