text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'rails_helper'
feature 'User can sign in', %(
As an unauthenticated user
I'd like to be able to sign in
), js: true do
given(:staff) { create(:staff) }
given(:client) { create(:client) }
describe 'Registered' do
scenario 'staff sign in' do
visit new_staff_ses... |
class Team
attr_accessor :name, :motto
attr_reader :heros
@@all = []
def initialize(team_info = {})
team_info.each do |k,v|
send("#{k}=",v)
end
end
def self.create(team_info = {})
team = Team.new(team_info)
team.save
team
end
d... |
# frozen_string_literal: true
class AddLabelToPackages < ActiveRecord::Migration[5.2]
def change
add_column :packages, :label, :string
end
end
|
class Admin::AdminController < ApplicationController
layout 'admin'
before_action :authenticate_admin_admin!
helper_method :current_admin, :is_super_admin?
protected
def check_super_admin
if !is_super_admin?
flash[:error] = "You do not have permission. Contact Super Admin."
redirect_to adm... |
class GamesController < ApplicationController
def options
game = Game.find(params[:id])
game.destroy
respond_to do |format|
ret = game.destroyed? ? {:success => true} : {:success => false}
format.json { render :json => ret }
end
end
def index
games = Game.all
respond_to ... |
class CoursesController < ApplicationController
before_action :owner_only,except: [:show]
def index
@courses = Course.paginate(page:params[:page])
end
def new
@course = Course.new
end
def create
@course = Course.new(course_params)
begin
if @course.save
flash[:success] = "登録完... |
require 'spec_helper'
describe Kata::Algorithms::Searching::LinearSearchOnOrderedArray do
[
[[1, 2, 3], 2, 1],
[[1, 2, 3], 5, nil],
[[1, 2, 3], 1, 0],
[[1, 2, 3], 3, 2],
[[1, 2, 3], -1, nil],
[[1, 20, 30], 10, nil],
[[1, 20, 30], 25, nil],
[[1, 20, 30], 30, 2],
[... |
class RemoveUniqueNameIndexFromSkillCategory < ActiveRecord::Migration
def change
remove_index :skill_categories, :name if index_exists?(:skill_categories, :name)
end
end
|
require "pry"
#def reverse_each_word(sentence)
# array = sentence.split
#binding.pry
#array is ["Hello", "there,", "and", "how", "are", "you?"]
# reverse_arr = []
# array.each do |word|
# reverse_arr << word.reverse
# end
# reverse_arr.join(" ")
#end
def reverse_each_word(sentence)
array = sentence.... |
module EsMapper
# extend ActiveSupport::Concern
include MapperCommon
class << self
def customer_accessible_by_permission(current_user)
return nil if current_user.admin?
permissions = current_user.try(:agent_role).try(:permissions)
if permissions.blank?
{term: {owner_id: current_user.... |
require 'test_helper'
class ItemsTest < ActiveSupport::TestCase
let(:item){ build(:item) }
it 'should be a valid' do
expect(item).to be_valid
end
it 'should have a title' do
item.title = nil
expect(item).not_to be_valid
end
end
|
require 'rubygems'
require 'telegram/bot'
require 'json'
BOT_TOKEN = "649407107:AAHLuz1cZiees71biKqWGOxk8f2y0kcwnIg"
JSON_FILE = "./data.json"
WRITE_MODE = "w+"
def convert_hash_to_story(data)
str = []
data.each do |s|
str.push(s["word"])
end
return str.join(" ")
end
Telegram::Bot::Client.run(BOT_TOKEN) ... |
class HarvestBatchSerializer
include FastJsonapi::ObjectSerializer
attribute :id do |object|
object.id&.to_s
end
attributes :harvest_name, :created_at, :updated_at
attribute :strain_name do |object|
object.facility_strain&.strain_name
end
attribute :total_dry_weight do |object|
"#{object.t... |
#
# Cookbook Name:: ldap
# Recipe:: user
#
# Copyright 2014, oshiire
#
# All rights reserved - Do Not Redistribute
#
accounts = data_bag('users')
accounts.each do |id|
users = data_bag_item('users', id)
execute "add-#{users['uid']}" do
command "ldapadd -H ldapi:/// -f #{Chef::Config[:file_cache_path]}/#{use... |
module GovukPayApiClient
class GetStatus
include GovukPayApiClient::Api
attr_accessor :fee
def initialize(fee = nil)
raise RequiresFeeObject if fee.blank?
@fee = fee
end
def call
get
parsed_response
end
private
def parsed_response
OpenStruct.new(
... |
class AddColumnMobileUrl < ActiveRecord::Migration
def up
add_column :contents, :mobile_url, :text
end
def down
remove_column :contents, :mobile_url
end
end
|
require 'rails_helper'
RSpec.feature "ApprovalWorkflows", type: :feature do
describe "edit" do
it "has a status that can be edited on the form" do
user = create(:user)
post = create(:post, user: user)
login_as(user)
visit edit_post_path(post)
choose "post_status_approved"
... |
class FindAdmin
include Interactor
before do
context.fail! if context.response.blank? || context.user.blank? || (@admin = Admin.find_by_id(context.user[:id])).blank?
end
def call
context.response[:admin] = @admin
end
end |
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class EpisodeSpecTest < ActiveSupport::TestCase
CASES = [
["Law.and.Order.S20E20.HDTV.XviD-LOL.avi", "Law and Order", 20, 20],
["24.S08E03.600PM-700PM.HDTV.XviD-FQM.avi", "24", 8, 3, "600 Pm 700 Pm"],
["The.Good... |
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class DashboardControllerTest < ActionController::TestCase
context "overall dashboard" do
should "show correct number of messages" do
142.times { Message.make }
get :index
assert_equal 142, assigns(:message_count)
end
... |
require 'rails_helper'
RSpec.describe Delivery, type: :model do
let(:supplier) { create(:company, supplier: true) }
let(:warehouse) { create(:address, company_id: supplier.id, t_delivery_address: true) }
subject { build_stubbed(:delivery, warehouse_id: warehouse.id) }
it 'has a proper factor' do
expect(su... |
# Alphabet symmetry
=begin
(Understand the Problem)
Problem:
Given an array of words, return an array of the number of letters that occupy their positions in the alphabet for each word
Inputs: Array of words
Outputs: Array (# of letters that occupy their positions in the alphabet)
Questions:
1.
Expl... |
module Users
class RegistrationsController < Devise::RegistrationsController
layout 'authentication'
before_action :configure_sign_up_params, only: %i(create)
before_action :check_person_existence, only: %i(create)
protected
def build_resource(hash = {})
super(hash)
resource.person ... |
class Category < ActiveRecord::Base
belongs_to :project
has_many :images, :dependent => :destroy
accepts_nested_attributes_for :images
end
|
require 'spec_helper'
require 'crawler/models/safe_insertable'
require 'crawler/models/user_profile'
require 'crawler/models/post'
UserProfile.extend SafeInsertable
UserProfile.unique_id :vk_id
Post.extend SafeInsertable
Post.unique_id [:owner_id, :vk_id]
module Crawler
module Models
describe SafeInsertable ... |
class Rocktrading
include Exchange
def update
@data = {}
@currency_pairs =[
["BTC", "EUR"],
["BTC", "USD"],
["BTC", "XRP"],
["EUR", "XRP"],
["LTC", "BTC"],
["LTC", "EUR"]
]
@currency_pairs.each do |pair|
url = "https://www.therocktrading.com/api/orderbook/#... |
class Seller < ApplicationRecord
has_many :mobiles, through: :cust_mobiles
validates :name, presence: true
end
|
puts '=> Loading Rails...'
require File.dirname(__FILE__) + '/../../../../config/environment'
require File.dirname(__FILE__) + '/../lib/workling/remote'
require File.dirname(__FILE__) + '/../lib/workling/remote/invokers/basic_poller'
require File.dirname(__FILE__) + '/../lib/workling/remote/invokers/threaded_poller'
r... |
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :name_ciphertext, null: false
t.string :name_bidx, null: false
t.string :email_ciphertext, null: false
t.string :email_bidx, null: false
t.string :site_role, default: "site_user"
t.... |
require 'test_helper'
module Radiator
class ApiTest < Radiator::Test
def setup
@api = Radiator::Api.new(logger: LOGGER)
end
def test_hashie_logger
assert Radiator::Api.new(hashie_logger: 'hashie.log')
end
def test_method_missing
assert_raises NoMethodError do
@api.... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class SupplementSerializer < ActiveModel::Serializer
attributes :id, :description, :name
has_many :effects
end
|
require 'rails_helper'
RSpec.describe BookReviewsController, type: :controller do
describe "GET #index" do
it "finds all the book reviews ordered by publish date" do
new_book_review = create(:book_review)
old_book_review = create(:book_review)
old_book_review.published_at = Date.today - 1.day
... |
class HotelsController < ApplicationController
include TenantScopedController
load_and_authorize_resource
before_action :set_model
def detail
render partial:'hotels/detail', locals:{model: @model}
end
def index
@q = Hotel.ransack(params[:q])
@models = @q.result(distinct: true).includes(:bookin... |
#!/usr/bin/env ruby -I ../lib -I lib
require 'em-midori'
require 'json'
require_relative 'controllers/user_controller'
class Server < Midori::API
get '/' do
'Hello World!'
end
get '/user/:id/dump' do |id|
{ header: @request.header,
body: @request.body,
id: id
}.to_json
end
websocket '/websocket/:id... |
module Kss
# Public: The main KSS parser. Takes a directory full of SASS / SCSS / CSS
# files and parses the KSS within them.
class Parser
# Public: Returns a hash of Sections.
attr_accessor :sections
# Public: Initializes a new parser based on a directory of files or kss strings.
# Scans within ... |
class CreateExtraFanClubs < ActiveRecord::Migration[5.1]
def change
create_table :extra_fan_clubs do |t|
t.integer :user_id
t.integer :introductions_id
t.text :comment
t.integer :payment
t.timestamps
end
end
end
|
class Api::AirlinesController < ApplicationController
def index
@airlines = Airline.all
render "index.json.jb"
end
end
|
class TriedRecipe < ActiveRecord::Base
belongs_to :recipe
belongs_to :cook, foreign_key: :recipe_user_id
validates :date_tried, :presence => true
end
|
class GroupCategory < ActiveRecord::Base
validates :category_name, :presence=>true
validates :category_name, :uniqueness=>true
belongs_to :groups
belongs_to :group_nesting
end
|
require 'spec_helper'
describe 'Services Access', reset: false do
serviceable_collection_id = 'C179014698-NSIDC_ECS'
smap_collection_id = 'C1236303848-NSIDC_ECS'
smap_collection_title = "SMAP L1C Radiometer Half-Orbit 36 km EASE-Grid Brightness Temperatures V003"
serviceable_collection_title = 'AMSR-E/Aqua 5-D... |
class Transaction < ActiveRecord::Base
belongs_to :birthday_party
belongs_to :voucher, class_name: 'BirthdayDealVoucher'
monetize :amount_cents
end
|
musicians = [
'David Gilmour',
'Roger Waters',
'Richard Wright',
'Nick Mason'
]
# for musician in musicians
# puts "#{musician} rocked out!"
# end
# puts "=" * 20
musicians.each do |musician|
puts "#{musician} rocked out!"
end
puts "=" * 20
musicians.each_with_index do |musician, index|
puts "#{index... |
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 80, host: 1234
config.vm.network "forwarded_port", guest: 443, host: 444
config.vm.synced_folder ".", "/vagrant"
config.vm.network "private_network", ip: "192... |
require 'mericope'
require 'cli/base'
class Mericope
class CLI
attr_reader :options, :input
ALLOWED_COMMANDS = %w{help normalize parse substitute reverse-substitute usage}
def self.run(command, *args)
if ALLOWED_COMMANDS.member?(command)
command = command.gsub(/-/, '_').to_sym
CLI... |
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, :omniauth_providers => [:twitter]
validates :username, presence: :true, uniqueness: { case_sensitive: false }
validates :authentication_keys, pre... |
class ChangedContestInfosAddedDemo < ActiveRecord::Migration
def self.up
add_column :contest_infos, :demo, :boolean
end
def self.down
remove_column :contest_infos, :demo
end
end
|
class ItemSerializer
include JSONAPI::Serializer
attribute :name
attribute :done
end
|
ENV["ENV"] ||= 'test'
require 'rubygems'
require 'rake'
require 'pry'
require 'timecop'
require 'time'
require 'factory_girl'
require 'webmock/rspec'
require File.expand_path("../../yugioh_x1", __FILE__)
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |file| require file }
Dir.glob('lib/tasks/*.rake').each { |f... |
module API
module Helpers
module V1
module SupportingCoursesHelpers
extend Grape::API::Helpers
params :new_supporting_course do
requires :supportingcourse, type: Hash do
requires :title, :type => String
requires :category_ids
# optional :presen... |
# Controller for Guesses
class GuessesController < ActionController::Base
def create
game = Game.find(params[:game_id])
guess = game.guesses.create!(guess_params)
flash[:errors] = guess.errors.full_messages.to_sentence unless guess.valid?
redirect_to game
end
private
def guess_params
pa... |
Mamashai::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned o... |
class CreateTranscribeLines < ActiveRecord::Migration
def change
create_table :transcribe_lines do |t|
t.references :article, null:false
t.string :content, null:false, default:""
t.string :start_min, null:false, default:"00"
t.string :start_sec, null:false, default:"... |
class UsersController < ApplicationController
before_action :require_no_user, :only => [:new, :create]
before_action :require_user, :only => [:edit, :update]
before_action :require_admin, :only => [:destroy]
def show
@user = User.find_by_slug(params[:id]) or render_404
end
def new
@user = User.new... |
class TimeSpansController < ApplicationController
before_action :set_time_spans
before_action :set_time_span, only: [:show, :destroy]
around_action :set_time_zone
def index
@time_spans = @plan.time_spans
end
def show
end
def new
@time_span = @plan.time_spans.build
end
def create
@tim... |
json.array!(@invoice_ingredients) do |invoice_ingredient|
json.extract! invoice_ingredient, :id, :invoice_id, :ingredient_id, :measure_id, :qty_ordered, :price, :extended, :qty_shipped, :brand, :item_number, :vendor_number, :description, :pack_qty, :pack_size, :unit
json.ingredient invoice_ingredient.ingredient, :i... |
#frozen_literal_string: true
class ApplicationController < ActionController::API
rescue_from UserAuthenticator::AuthenticationError, with: :authentication_error
include JsonapiErrorsHandler
# ErrorMapper.map_errors!(
# 'ActiveRecord::RecordNotFound' =>
# 'JsonapiErrorsHandler::errors::... |
require_relative 'lib/jobless'
Jobless.cv do
name "Filip Defar"
email "dabrorius@gmail.com"
location "Zagreb, Croatia"
homepage "http://dabrorius.github.io"
employment do
entry do
title "Full-stack Rails developer"
company "DirectVest"
technologies "Ruby, Ruby on Rails, Javascript"
... |
class Project < ActiveRecord::Base
mount_uploader :photo, ImageUploader
validates :title, presence: true, uniqueness: true
validates :description, presence: true
acts_as_taggable
scope :visible, -> {where(hidden: false)}
end
|
# write a method that returns true if its integer argument is palindromic
# false if otherwise
# a palindromic number reads the same forwards and backwards
# Examples:
# palindromic_number?(34543) == true
# palindromic_number?(123210) == false
# palindromic_number?(22) == true
# palindromic_number?(5) == true
def p... |
class Publication < ApplicationRecord
belongs_to :user
has_one_attached :image
has_many_attached :documents
has_many :califications, dependent: :destroy
has_many :donations, dependent: :destroy
has_many :payments
validates :image, attached: true, content_type: ['image/png', 'image/jpg', 'image/jpeg']
... |
require "aws-sdk"
require "pry"
sqs_client = Aws::SQS::Client.new(region: "ap-southeast-2") # Sydney
p sqs_client.operation_names # dump operations
# => [:add_permission, :change_message_visibility, :change_message_visibility_batch, :create_queue, :delete_message, :delete_message_batch, :delete_queue, :get_queue_attr... |
class RPS::TerminalClient
def initialize
user_log_in
end
def get_input
puts "Please enter your choice or exit if you wish to leave."
gets.chomp.downcase
end
def user_log_in
puts "Welcome to Rock Paper Scissors!"
puts "[1] Sign in"
puts "[2] Sign up"
answer = get_input
if answ... |
class UserMailer < ApplicationMailer
def new_user_registration(user)
@user = user
@url = '/verify?code=' + user.auth_code
mail(to: user.email, subject: 'Verify Your EMail Account')
end
end
|
class AddIndexToAoKandMoi < ActiveRecord::Migration
def change
add_index :modes_of_inquiries, :abbr, unique: true
add_index :areas_of_knowledges, :abbr, unique: true
end
end
|
require 'rails_helper'
require 'helper_methods'
describe Avatar do
before :each do
populate_users
init_variables
@file1 = File.new('spec/assets/audios/registration.mp3')
@file2 = File.new('spec/assets/images/logo.png')
@file3 = File.new('spec/assets/images/brad.jpg')
@avatar = Avatar.new
en... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username
t.string :password_hash
t.string :email
t.string :session
t.string :first_name
t.string :last_name
t.string :profile_image_url
t.string :height
t.string :weig... |
class FontXits < Formula
version "1.200"
sha256 "039493b95b86d15e451e818e065e6f6719977a31e43504eb6946513ba09c8a72"
url "https://github.com/khaledhosny/xits/archive/v#{version}.zip"
desc "XITS"
homepage "https://github.com/khaledhosny/xits"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEM... |
class CreateUgroups < ActiveRecord::Migration
def self.up
create_table :ugroups do |t|
t.integer :school_id
t.string :name
t.integer :group_type
t.integer :enrollments_count
t.integer :users_count
t.datetime :updated_at
t.datetime :created_at
end
add_index ... |
class Api::ProfilesController < ApplicationController
def index
@profiles = Profile.all
end
def show
@profile = Profile.find_by_user_id(params[:id])
end
def update
@profile = Profile.find_by_user_id(params[:id])
if @profile.update(profile_params)
render json: @profile
else
fl... |
class AddFoodColumnToEnvironments < ActiveRecord::Migration[5.0]
def change
add_column :environments, :food_type, :string
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :info, class: Info do
sequence(:title) {|n| "title#{n}" }
last_modified DateTime.now
sequence(:content) {|n| "content#{n}" }
end
end
|
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/posicion_actors/index.html.erb" do
include PosicionActorsHelper
before(:each) do
posicion_actor_98 = mock_model(PosicionActor)
posicion_actor_98.should_receive(:fecha).and_return(Date.today)
posicion_actor_98.should_receive(:titular).a... |
require 'test_helper'
class V1::UsersControllerTest < ActionDispatch::IntegrationTest
setup do
@user = create(:user)
end
test 'should show user' do
get user_url(@user)
assert_equal json_response['email'], @user.email
assert_response :success
end
test 'should update user' do
patch user_... |
require 'sinatra'
require 'sequel'
require 'sinatra'
require 'json'
#enable sessions in the server (this is not on by default)
enable :sessions
all_majors = Array.new
#connect to the sqlite database
configure do
#connect to the sqlite database
DB = Sequel.connect('sqlite://Degree.db')
def create_tables
... |
class Api::V1::RetailerTypesController < ApplicationController
def index
retailer_types = RetailerType.all
retailer_types = RetailerType.where('name ilike ?', "%#{params[:q]}%") unless params[:q]&.empty?
render_all(datas: retailer_types)
end
def create
retailer_type = RetailerType.new(retailer_ty... |
class Model::Domain::GeneralInfo < Model::Domain::Content
attr_accessor :internal_link
attr_accessor :external_link_title
attr_accessor :external_link_link
attr_accessor :show_hide_title
attr_accessor :show_hide_body
def initialize
@title = "General Info Title #{Time.current.strftime("%T")} #{String.ra... |
class Meetup
include HTTParty
base_uri 'api.meetup.com'
def get_data
self.class.get('/Flatiron-School-Presents/events/')
end
def events
get_data.parsed_response
end
end |
class Oystercard
attr_reader :balance, :entry_station, :station_log
LIMIT = 90
MINFARE = 1
def initialize
@balance = 0
@station_log = []
@journeyclass = Journey.new
end
def top_up(money)
fail "£#{LIMIT} Limit Reached" if @balance+money > LIMIT
@balance += money
end
def touch_in(st... |
class DeliveryAddress < ApplicationRecord
belongs_to :user
has_many :orders
validates :delivery_address_postal_code, presence: true, length: { is: 7}, numericality:{only_integer: true}
validates :delivery_address, presence: true
end
|
class Hash
def keys_of(*args)
select { |k, v| args.include? v }.keys
end
end
|
require 'spec_helper'
describe Purchase do
it { should belong_to :receipt }
it { should belong_to :product }
describe '.receipt_total' do
it 'sums the prices of all products associated with a receipt id' do
product1 = Product.create({:name => 'soup', :price => 25.50})
product2 = Product.create({... |
class AddStartLongitudeToConnections < ActiveRecord::Migration[5.2]
def change
add_column :connections, :start_longitude, :integer
end
end
|
class AddShopIdToShopCategory < ActiveRecord::Migration
def change
add_reference :shop_categories, :shop, index: true
add_foreign_key :shop_categories, :shops
end
end
|
require "chandler/refinements/version_format"
module Chandler
# Responsible for parsing a CHANGELOG into a hash of release notes keyed
# by version number. Release notes for a particular version or tag can be
# accessed using the `fetch` method.
class Changelog
using Chandler::Refinements::VersionFormat
... |
require 'syllable_module'
require 'rhyme_module'
class TweetValidation < ActiveModel::Validator
def validate(tweet)
if tweet.text.include?("@")
tweet.errors[:base] << "This tweet refers to another user"
end
if tweet.text.include?("#")
tweet.errors[:base] << "This tweet includes a hashtag"
end
if... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
rescue_from User::Exception, :with => :show_error
#helper_method :current_user
## override devise
def after_sig... |
ROM::SQL.migration do
change do
create_table(:users) do
primary_key :id
column :state, String, null: false
column :station_code, String
column :messenger_id, String, null: false
index :messenger_id
end
end
end
|
module MarkdownMetrics
class TopElementsParser
attr_reader :elements
def initialize(lines)
@lines = lines
@elements = []
end
def parse
@lines.each_with_index_and_catch do |line, index|
element = initialize_element(line, index)
@elements << {
name: element.... |
class Hotels::SuggestionsService < Hotels::Base
PERSONAL_ROUTE = 'suggestions'
def initialize(params={})
@query = params[:query]
end
def perform!
@api_call = hotels
if @api_call.include?('errors')
error_result
else
ResultObjects::Success.new(@api_call)
end
end
private
de... |
class FileInfo
attr_accessor :name, :size, :ext, :date, :attr, :path, :display_name, :type, :icon
def to_s
@path
end
end |
class Member < ApplicationRecord
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
after_create :set_default_alias
# after_c... |
require 'spec_helper'
describe TweetsController do
let(:valid_attributes) { {} }
let(:valid_session) { {} }
describe "GET index" do
it "assigns all tweets as @tweets" do
tweet = Tweet.create! valid_attributes
get :index, {}, valid_session
assigns(:tweets).should eq([tweet])
end
end
... |
#
# fluent-plugin-map
#
# 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 to in w... |
require 'rails_helper'
RSpec.describe Video, type: :model do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:link) }
end
|
class MicropostsController < ApplicationController
include TagsHelper
before_action :logged_in_user, only: [:create, :destroy, :new]
before_action :get_micropost, only: [:destroy, :edit, :show, :update]
before_action :get_all_tags, only: [:edit, :new]
before_action :valid_micropost_resource, only: [... |
feature "Contract Step 3 - Create" do
context 'Visitor' do
scenario "Access invalid" do
visit new_contract_path
expect(current_path).to eq new_session_path
end
end
context 'Admin' do
let(:user) { create :user}
background do
login user.email, user.password
end
scenario... |
# frozen_string_literal: true
# This will guess the User class
FactoryBot.define do
factory :user do
name { Faker::Name.name.gsub(/'/,'') }
sequence :email do |n|
"person#{n}@example.com"
end
password { 'password' }
password_confirmation { 'password' }
factory :admin do
admin { tr... |
#!/usr/bin/env ruby -rubygems
require "eventmachine"
if ARGV.empty? || !ARGV.first.include?(?() || !ARGV.first.include?(?))
puts "Usage: rollup [regex with a capture group]"
abort
end
$total = 0
$regex = Regexp.new(ARGV.first)
$buckets = Hash.new(0)
class Rollup < EM::Connection
def receive_data(data)
... |
module Roglew
module GL
MAX_DUAL_SOURCE_DRAW_BUFFERS ||= 0x88FC
ONE_MINUS_SRC1_ALPHA ||= 0x88FB
ONE_MINUS_SRC1_COLOR ||= 0x88FA
SRC1_COLOR ||= 0x88F9
end
end
module GL_ARB_blend_func_extended
module RenderHandle
include Roglew::RenderHandleExtension
func... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.