text stringlengths 10 2.61M |
|---|
class CreateBookings < ActiveRecord::Migration
def change
create_join_table :vacations, :events, table_name: :bookings do |t|
t.index :vacation_id
t.index :event_id
end
end
end
|
require 'test_helper'
class BackLinkTest < ActionDispatch::IntegrationTest
def setup
@user = users(:user_with_locale_pl)
end
test "that back link is working" do
allow_google_login_as(@user)
visit '/pl'
log_in_pl
click_on I18n.t('header.wallets', locale: 'pl')
click_on I18n.t('add_wallet... |
require 'pessoa'
describe 'Atributos de Classe' do
it 'have_attributes' do
p = Pessoa.new
p.name = "John"
p.age = 30
expect(p).to have_attributes(name: "John", age: 30)
expect(p).to have_attributes(name: starting_with('J'), age: (be >= 30))
end
end |
class ProgrammingLanguage
attr_accessor :name, :age, :type
def initialize(name, age, type)
@name = name
@age = age
@type = type
end
end
ruby = ProgrammingLanguage.new("Ruby", 21, "Dynamic")
python = ProgrammingLanguage.new("Python", 24, "Dynamic")
javascript = ProgrammingLanguage.new("JavaScrip... |
class PostControllerTest < BaseIntegrationTest
test 'an authenticated user should be able to navigate to post/list successfully' do
# Arrange
setup_session('access token', true)
PostImageManager.instance.expects(:clear).once
GithubService.expects(:check_sse_github_org_membership).with('access token')... |
FactoryBot.define do
factory :user do
name "testdata"
email { Faker::Internet.email }
password "abcdef"
end
end
|
require 'rails_helper'
RSpec.describe "user_friendlies/new", type: :view do
before(:each) do
assign(:user_friendly, UserFriendly.new(
:name => "MyString",
:slug => "MyString"
))
end
it "renders new user_friendly form" do
render
assert_select "form[action=?][method=?]", user_friendli... |
class SearchesController < ApplicationController
before_action :set_search, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@searches = Search.all
respond_with(@searches)
end
def show
respond_with(@search)
end
def new
@search = Search.new
respond_with(@search)... |
class Comment < ApplicationRecord
validates :author_id, :expense_id, :body, presence: true
belongs_to :user,
class_name: "User",
primary_key: :id,
foreign_key: :author_id
belongs_to :expense,
inverse_of: :comments,
class_name: "Expense",
primary_key: :id,
foreign_key: :expense_id
en... |
require 'rails_helper'
RSpec.feature "タスク管理機能", type: :feature do
background do
@label1 = FactoryBot.create(:label)
@label2 = FactoryBot.create(:label2)
@label3 = FactoryBot.create(:label3)
@user = FactoryBot.create(:user)
@user2 = FactoryBot.create(:user2)
@task = FactoryBot.create(:task, us... |
class CreateWebimages < ActiveRecord::Migration
def change
create_table :webimages do |t|
t.references :recording, index: true
t.references :user, index: true
t.references :comment, index: true
t.timestamps null: false
t.string :wi_type
t.string :wi_name
end
end
end
|
require 'rspec'
describe RenderingContext do
describe "#render_document" do
describe "when passed a string" do
it "wraps the string in a div" do
@html= RenderingContext.new(
HtmlView.new({}),
'content_name',
"content",
0).render_document
@html... |
################################################################################
# Cipher Challenge
# I worked on this challenge by myself.
# I spent 1.5 hours on this challenge.
# 1. Solution
# Write your comments on what each thing is doing.
# If you have difficulty, go into IRB and play with the methods.
#######... |
module PivotalPlanningPoker
class User
attr_accessor :username, :password, :token, :user_id
def initialize(params = {})
@username = params[:username]
@password = params[:password]
@token = params[:token]
@user_id = params[:user_id]
end
def projects
Project.for_user... |
module StaticPagesHelper
require 'open-uri'
require 'nokogiri'
# returns parsed Nokogiri HTML string
def pdf_to_html(url)
end
# searches HTML doc for all <P>'s with a parent div
def find_all_ps(docurl)
doc = Nokogiri::HTML(open(docurl))
doc.xpath('//div/p').each do |node|
puts node.text
end
end
... |
module Bowline::Generators
class MigrationGenerator < Generator
desc <<-DESC
Generates a new database migration.
DESC
option :model, :as => :boolean, :desc => 'Specify this option to generate a migration which creates a table for the provided model'
first_argument :name, :required => t... |
require 'spec_helper'
require 'money-rails/test_helpers'
RSpec.describe ManageIQ::Consumption::ShowbackCharge, :type => :model do
let(:charge) { FactoryGirl.build(:showback_charge) }
it 'has a valid factory' do
expect(charge).to be_valid
end
it 'monetizes cost' do
expect(ManageIQ::Consumption::Showba... |
require 'cell'
require 'live_cell'
require 'dead_cell'
class CellGenerator
def next_generation(cell)
if (cell.alive? and cell.sustainable?) or (!cell.alive? and cell.fertile?)
LiveCell.new
else
DeadCell.new
end
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
helper_method :current_user
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
added_attrs = [:title, :first_name, :l... |
Antcc::Application.routes.draw do
resources :geosmarkers
resources :seasub_functions
resources :seasurf_functions
resources :ground_functions
resources :air_functions
resources :sub_classes
resources :aircraft_classes
resources :ship_classes
resources :vehicle_models
ro... |
class ClassWorkout < ApplicationRecord
belongs_to :workout_plan
belongs_to :gym_class
validates :workout_plan_id, uniqueness: {scope: [:gym_class_id], message: "workout already in this class"}
end
# validates :group_id, uniqueness: { scope: [:user_id], message: "can't join the same group twice" }
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
describe Plugins do
let(:described) { Vedeu::Plugins }
let(:instance) { described.new }
describe '#initialize' do
it { instance.must_be_instance_of(described) }
it { instance.instance_variable_get('@plugins').must_equal([])... |
class MembersController < ApiController
before_action :set_member, only: [:show, :update, :destroy]
def login
member = Member.find_by(email: params[:email])
if member && member.authenticate(params[:password])
puts "Logged in"
puts Member_logged_in?
else
puts "Username or Password Inc... |
#Extra Enemy Drops v1.0
#----------#
#Features: Let's you set, via notes, more than just three item drops
# from an enemy. Yay!
#
#Usage: Plug and play, customize as needed
#
# Enemy Notetags:
# <DROP type id rate>
# type is 1 for item, 2 for weapon, 3 for armor
# ... |
class Discussion < ActiveRecord::Base
attr_accessible :title, :content, :user_id
belongs_to :user
belongs_to :discussable, :polymorphic => true
has_many :discussions, :as => :discussable
has_many :interests
has_many :interested_users, through: :interests
def super_answer
discussable_type == "Answer... |
require 'result'
require 'json'
module Alfred3
class Workflow
def initialize
@results = []
end
public
def result
result = Result.new
@results << result
result
end
public
def sort_results(direction = 'asc', property = 'title')
@results.sort! { |r1, r2|
... |
class AddSubtitleTypeToWorkingArticle < ActiveRecord::Migration[5.2]
def change
add_column :working_articles, :subtitle_type, :string
end
end
|
class Profile < ActiveRecord::Base
belongs_to :user
validates :city, :country, :age, :address, presence: true
has_attached_file :avatar, styles: { medium: '100x100', thumb: '150x150#'}
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
end
|
module Seed::IssueTypes
issue_types = {
flat_tire: { name: 'Flat Tire', component_type: Seed::ComponentTypes.get(:tire), bill_of_material: Seed::BillOfMaterials.get(:flat_tire), priority: 3},
chipped_windshield: { name: 'Chipped Windshield', component_type: Seed::ComponentTypes.get(:windshield), bill_of... |
require 'spec_helper'
describe WordSearchTest do
let(:english) { Language.create!(:name => 'English') }
let(:user) { User.create!(:email => 'milan@milandobrota.com', :password => 'foobar') }
let(:content) { Content.create!(:name => 'Abc', :body => 'body', :language => english)}
it 'should know how to setup f... |
# 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... |
# frozen_string_literal: true
@mechanize = Mechanize.new
@mechanize.verify_mode = 0
SCRAPE_FROM_ID = (ENV['LEGACY_CRAWL_FIRST_PLAYER'] || 1).to_i
BATCH_SIZE = 100
BASE_PATH = 'https://database.dystopiarisingnetwork.com'
def get(path)
@mechanize.get(BASE_PATH + path)
end
def load_characters(id)
puts "Scraping us... |
module Headjack
module Cypher
include DefaultAdapter
def self.auto_filter result
if result["columns"]
if result["columns"].count == 1
result["data"].map{|row| parse_column(row.first)}
else
result["data"].map{|row| row.map{|c| parse_column(c)}}
end
else
... |
# -*- coding: utf-8 -*-
require "spec_helper"
describe Friendship do
# let(:user) { Factory(:user)}
before(:each) do
@user = create(:user, :with_profile)
@follower = create(:user)
end
context "receive email" do
before(:each) do
@user.profile.config.share.wine_cellar = '1'
@user.profile.config.share.... |
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
$:.unshift(File.dirname(__FILE__))
require 'TestSetup'
require 'RandomThings'
class PgCircleTest < Test
include SqlPostgres
include RandomThings
def test_ctor_defaults
assertEquals(PgCircle.new, PgCircle.new(0, 0, 0))
end
def test_ctor_an... |
FactoryBot.define do
sequence :name do |n|
"MyString#{n}"
end
factory :item do
name { "MyString" }
course_type { 1 }
price { "9.99" }
photo { "MyString" }
end
factory :generate_items, class: "Item" do
name { generate(:name) }
course_type { 1 }
price { "9.99" }
photo { "My... |
class Firm < ActiveRecord::Base
has_many :bankbooks
set_primary_key "code"
end
|
class PostsController < ApplicationController
def new
@post = Post.new
end
def create
@post = Post.new(params.require(:post).permit(:title, :post))
@post.user = current_user
if @post.save
flash[:notice] = "Post successfully created"
redirect_to post_path(@post)
else
render... |
class UploadDbFilesTableGenerator < Rails::Generator::NamedBase
def initialize(runtime_args, runtime_options = {})
runtime_args << 'add_upload_db_files_table' if runtime_args.empty?
super
end
def manifest
record do |m|
m.migration_template 'migration.rb', 'db/migrate', :assigns => { :upload_db_... |
require 'net/http'
module SCC
# Given a URL, return an array of responses.
class CollectResponseTimes
def initialize(url:, interval:, duration:)
@url = url
@interval = interval
@duration = duration
@response_times = []
end
attr_reader :url, :interval, :duration, :response_times... |
require_relative("../lib/lexi.rb")
RSpec.describe Lexiconomitron do
describe "#eat_t" do
it "removes every letter t from the input" do
@lexi = Lexiconomitron.new
expect(@lexi.eat_t("great scott!")).to eq("grea sco!")
end
end
it "reverse this array." do
@lexi = Lexiconomitron.new
e... |
require 'rails_helper'
RSpec.describe "pessoa2s/edit", type: :view do
before(:each) do
@pessoa2 = assign(:pessoa2, Pessoa2.create!(
:nome => "MyString",
:telefone => "MyString"
))
end
it "renders the edit pessoa2 form" do
render
assert_select "form[action=?][method=?]", pessoa2_path... |
# THIS IS FOR RAILS 2.x COMPATIBILITY ONLY
#
# This module, when included into ActionController::Base
# makes sure that no superfluous log entries are generated during request
# handling. Instead, only the configured Lograge output is generated
module Rackstash
module RailsExt
module ActionController
def s... |
# frozen_string_literal: true
# Reponsibilities
# - Top level namespace that contains all AsciiPngfy
# sub-namespaces and general constants
# - Requires all files needed to use the AsciiPngfy Gem
module AsciiPngfy
MAX_RESULT_PNG_IMAGE_WIDTH = 3840
MAX_RESULT_PNG_IMAGE_HEIGHT = 2160
GLYPH_DESIGN_WIDTH = 5... |
class Weather
attr_reader :id, :temperature, :humidity, :description, :daily
def initialize(data)
@id = nil
@temperature = data[:current][:temp]
@humidity = data[:current][:humidity]
@description = data[:current][:weather][0][:description]
@daily = seven_day_forecast(data[:daily])
end
def s... |
# frozen_string_literal: true
module StringCheese
module Options
module Digs
def debug?
fetch(:debug, false)
end
def labels?
fetch(:labels, false)
end
def linter?
fetch(:linter, false)
end
end
module_function
def default_options
{ ... |
class RespondersController < ApplicationController
before_action :set_responder, only: [:update, :show]
def index
@responders = Responder.all
if @responders.blank?
render :status => 200, :text => {:responders => @responders}.to_json
else
if params[:show] == 'capacity'
capacity = {}... |
class V1List < Worklists1
hobo_model # Don't put anything above this
fields do
name :string
comments :text
kbss :text
parameters :text
total :integer
untouched :integer
pending :integer
completed :integer
deleted :boolean
inactive :boolean
... |
require "splitsound/version"
require "splitsound/video_file"
require "splitsound/audio_file"
require "streamio-ffmpeg"
require "fileutils"
module Splitsound
# Your code goes here...
def self.run(path_to_file)
@video_file = VideoFile.new(path_to_file)
if @video_file.configured?
puts "Processing video"... |
FactoryGirl.define do
factory :GateType do
gate_price 1.5
width 1
style "MyString"
material
end
end
|
class Event < ApplicationRecord
belongs_to :user
belongs_to :theme, optional: true
belongs_to :destination, optional: true
has_many :guests
has_many :polls
validates :name, presence: true
validates :description, presence: true
def initialize_hash_choices(choice_type)
hash = {}
poll_id = Poll.f... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :add_temp_order, :set_order
after_action :stored_location
rescue_from CanCan::AccessDenied, Wicked::Wizard::InvalidStepError, with: :generate_route
def stored_location
session[:previous_url] = req... |
require "spec_helper"
describe "Edit user", :type => :request do
let!(:user) { create(:user, :paul) }
let!(:other_user) { create(:user, :billy) }
context "with valid data" do
before do
login_as user
visit root_path
click_link "Meus dados"
fill_in "Seu primeiro e último nome", :with ... |
class Generation < ApplicationRecord
serialize :debuting_pokemon
serialize :game
has_many :games, dependent: :destroy
has_many :pokemons, dependent: :destroy
validates :gen_name, :region_name, :debuting_pokemon
presence: true,
end
|
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
let(:valid_session) {
{} # this controller doesn't need any session stuff yet
}
let(:rbody) { JSON.parse(response.body) }
describe "GET #index" do
it "returns all users" do
users = create_list(:user, 5)
# stub t... |
# encoding: UTF-8
module API
module Helpers
module V1
module SearchesHelpers
extend Grape::API::Helpers
include EducationalInstitutionsHelpers
include LearningDynamicsHelpers
include LearningTracksHelpers
def profile_types_for_search(params)
profile_type... |
class Project < ApplicationRecord
has_many :students_project_memberships, dependent: :destroy
has_many :students, through: :students_project_memberships
has_many :teachers_project_memberships, dependent: :destroy
has_many :teachers, through: :teachers_project_memberships
end
|
if @user.pics.length == 0
json.user_since @user.created_at.strftime("%b %d, %Y")
json.user_id @user.id
json.username @user.username
else
json.array! @user.pics.sort.reverse do |pic|
json.user_since pic.user.created_at.strftime("%b %d, %Y")
json.partial! 'api/pics/pic', pic: pic
end... |
class Report < ActiveRecord::Base
def self.current
today = Date.today
report = Report.first || Report.create(:year => today.year, :month => today.month, :week => today.cweek)
report.year = today.year
report.month = today.month
report.week = today.cweek
report
end
def year=(year)
if re... |
# greeting.rb
def greeting(name)
return "Hi #{name}"
end
puts greeting('Jose')
|
package "squid"
service "squid" do
action :enable
end
template "/etc/squid/squid.conf" do
source "squid.conf.erb"
owner "root"
group "root"
mode "600"
notifies :reload, resources(:service => "squid"), :immediately
end
|
Pod::Spec.new do |s|
s.name = "AVToolkit"
s.version = "0.0.1"
s.summary = "A simple set of classes making it easier to deal with audio/video on iOS 6+."
s.homepage = "https://github.com/spookd/AVToolkit"
s.author = { "Nicolai Persson" => "recognize@me.com" }
s.source =... |
require("minitest/autorun")
require_relative("../single_class_hm")
class StudentTest < MiniTest::Test
def test_get_name()
student = Student.new("Shaun", "E22", "Ruby")
assert_equal("Shaun", student.get_name())
end
def test_get_cohort()
student = Student.new("Shaun", "E22", "Ruby")
assert_equal("E22",... |
json.array!(@leave_types) do |leave_type|
json.extract! leave_type, :id, :name
json.url leave_type_url(leave_type, format: :json)
end
|
class Manager::Contest::TaskSerializer < ActiveModel::Serializer
root false
attributes :id, :tid, :title, :year, :rating
def year
object.created_at.year
end
def rating
object[:vote_weight]
end
end
|
require "json"
class Amazon::Iap2::Result
attr_accessor :product_type, :product_id, :parent_product_id,
:purchase_date, :purchase_time,
:cancel_date, :cancel_time,
:receipt_id,
:quantity,
:test_transaction,
:beta_product,... |
class RemoveUpdatedFromFlights < ActiveRecord::Migration[5.0]
def change
remove_column :flights, :updated_at
end
end
|
class StatusProgress < ActiveRecord::Base
attr_accessible :name
def self.all_order_asc_by_id
all :order => "id ASC"
end
end
|
# == Schema Information
#
# Table name: reviews
#
# id :integer not null, primary key
# reviewable_id :integer
# reviewable_type :string
# text :text
# user_id :integer
# verified :boolean
# created_at :datetime not null
# updated_at :datetime ... |
require "application_system_test_case"
class PLotsTest < ApplicationSystemTestCase
setup do
@p_lot = p_lots(:one)
end
test "visiting the index" do
visit p_lots_url
assert_selector "h1", text: "P Lots"
end
test "creating a P lot" do
visit p_lots_url
click_on "New P Lot"
fill_in "Nam... |
# The base class for all background tasks which implements the Java Runnable interface.
module JBackground
class Task
include java.lang.Runnable
attr_accessor :logger
def initialize
self.logger = JBackground::Base.logger
end
def run
logger.debug "Background Thread #{Thread.current.ob... |
# frozen_string_literal: true
total_record = Character.count
invalids = {}
puts 'Recalculating attendances...'
Character.all.each_with_index do |character, i|
character.recalculate_attendances
puts "#{i}/#{total_record} records processed" if i.positive? && (i % 100).zero?
rescue StandardError => e
branch = cha... |
require 'rails_helper'
RSpec. describe ProductsController, type: :controller do
describe "new action" do
it "" do
get :new
expect(response).to have_http_status(:success)
end
end
describe "create action" do
it "redirect to products list if product save" do
post :create, product: { ... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :master do
who "Individual"
about "about master"
work_desc "master work desc"
icq "icq_here"
skype "skype_here"
phone "phone_here"
website "website_here"
full_address "Moscow, pokrovka 1... |
require 'rails_helper'
RSpec.feature "Fill in Additional Information Page", js: true do
include ET3::Test::I18n
let(:confirmation_of_supplied_details_page) { ET3::Test::ConfirmationOfSuppliedDetailsPage.new }
before do
stub_presigned_url_api_for_s3
end
scenario "correctly will enable user to continue to... |
class JobsController < ApplicationController
def index
@jobs = Job.all
@my_jobs = @jobs.where(user_id: current_user)
@my_bookings = @jobs.where(student: current_user)
end
def destroy
@job = Job.find(params[:id])
if @job.destroy
redirect_to jobs_path
end
end
def update
... |
class Kyaru::Heartbeat
def initialize
baby = Kyaru::Baby.instance
@bot = baby.bot
@db = baby.db
@money = baby.money
@stress = baby.stress
end
def apply
heartbeat
end
def heartbeat
#
# 定期的な処理の実装
#
room = '613223157423276053'
# Heroku上のTimeはUTCなので+9時間する
one_ho... |
# Copyright (c) 2009-2011 VMware, Inc.
$:.unshift(File.dirname(__FILE__))
require 'do'
require 'spec_helper'
require 'service_broker/async_gateway'
class ServiceBrokerHelper
CC_PORT = 34567
GW_PORT = 15000
LOCALHOST = "127.0.0.1"
def get_config
config = load_config
db_conf = config[:local_db]
... |
class Api::V1::BaseController < ApplicationController
respond_to :json
resource_description do
short 'API documentation'
api_version "1"
end
end
|
require 'shanty/plugin'
require 'shanty/project'
module Shanty
module Plugins
# Public: Rspec plugin for testing ruby projects.
class RspecPlugin < Plugin
# By default, we'll detect RSpec in a project if has a dependency on it in a Gemfile or *.gemspec file. If you
# don't use these files, you'll... |
class Card
attr_reader :suit, :name, :value
def initialize(suit, name, value)
@suit, @name, @value = suit, name, value
end
end
class Deck
attr_reader :playable_cards
SUITS = [:hearts, :diamonds, :spades, :clubs]
NAME_VALUES = {
:two => 2,
:three => 3,
:four => 4,
:five => 5,
... |
require 'rails_helper'
RSpec.describe PasswordResetsController, type: :controller do
describe 'GET #new' do
before :each do
get :new
end
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'renders new password reset template' do
expect(response).t... |
# Old-school Roman numerals. In the early days of Roman numerals, the Romans didn’t bother with any of this new-fangled subtraction “IX” nonsense. No sir, it was straight addition, biggest to littlest—so 9 was written “VIIII,” and so on. Write a method that when passed an integer between 1 and 3000 (or so) returns a st... |
require_relative '../../lib/mince_dynamo_db/data_store'
describe MinceDynamoDb::DataStore do
let(:db) { mock 'db connection', tables: collections }
let(:collections) { { collection_name => collection } }
let(:collection) { mock 'some collection', items: items, schema_loaded?: true }
let(:collection_name) { 's... |
class AddColumnsToUsers < ActiveRecord::Migration
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :phone, :string
add_column :users, :admin, :boolean, default: false
add_column :users, :shipping_add1, :string
add_column :users, :ship... |
class Admin::OrdersController < ApplicationController
def index
if admin_signed_in?
@q = Order.ransack(params[:q])
@order_results = @q.result(distinct: true).page(params[:page]).per(30)
@total_quantity = 0
else
redirect_to root_path
end
end
def update
@order = Order.find(params[:id]... |
class AddBodyToRecipes < ActiveRecord::Migration
def change
add_column :recipes, :body, :text
add_column :recipes, :source, :string
add_column :recipes, :description, :string
end
end
|
require "rails_helper"
feature "Authenticated user can vote" do
scenario "User Likes and inreases the votes by 1" do
review = FactoryGirl.create(:review)
sign_in_as(review.user)
visit site_path(review.site)
click_on "Like"
expect(page).to have_content "Likes: 1"
end
scenario "User DisLike an... |
require 'test_helper'
class RequestTest < ActiveSupport::TestCase
def setup
@lunch = requests(:lunch_request)
@nil_requestor = requests(:nil_requestor)
@nil_event = requests(:nil_event)
end
test "requestor must be present" do
assert_equal 'Jk Rowling', @lunch.requestor.name, 'The requestor name... |
require_relative '../../../spec_helper'
require_relative '../../../../apps/admin/controllers/dashboard/index'
describe Admin::Controllers::Dashboard::Index do
let(:action) { Admin::Controllers::Dashboard::Index.new }
let(:params) { Hash[] }
it 'redirects unauthorized user' do
response = action.call(params)
... |
class MembershipsController < ApplicationController
include ApplicationHelper
before_action :log_ip, :require_nationbuilder_slug, :require_api_key
def check
email = params[:email].to_s.strip.downcase
if check_membership(email)
render json: { status: :found }, status: :ok
else
render jso... |
require 'rails_helper'
RSpec.describe "promotions/new", type: :view do
before(:each) do
assign(:promotion, Promotion.new(
:movie => nil,
:whatsapp => "MyText",
:facebook => "MyText",
:twitter => "MyText",
:link => "MyString",
:is_deleted => false
))
end
it "renders ne... |
class Geocodize::Queue
require "redis"
class << self
attr_accessor :redis
attr_accessor :queue_name
end
def self.initialize!(options = {})
options = options || {}
self.redis = options[:redis] ? Redis.new(options[:redis]) : Redis.new
self.queue_name = options[:queue] || "geocodize:queue... |
Rails.application.routes.draw do
devise_for :users, skip: [:passwords, :sessions]
as :user do
post 'sign_in', to: 'sessions#create', as: :user_session
delete 'sign_out', to: 'sessions#destroy', as: :destroy_user_session
get 'settings', to: 'users#settings'
get 'update_password', to: 'users#settings'... |
class ChangeMusics9 < ActiveRecord::Migration[4.2]
def self.up
change_table :musics do |t|
t.string :csv_id
end
add_index :musics, :csv_id, unique: true
end
def self.down
remove_column :musics, :csv_id
remove_index :musics, :csv_id
end
end
|
class PhoneticWordReader
def self.read_words filename
words = []
file = File.new(filename,"r")
while (line = file.gets)
line.downcase!
next unless line[%r/^[a-z]/]
line = line.chomp.split(" ")
word = line[0].sub(%r/\((.*?)\)/,"")
next if word[%r/[0-9]/]
phonemes = line[... |
class AddColumnGistidToGist < ActiveRecord::Migration[5.2]
def change
add_column :gists, :gistid, :string
end
end
|
class CreateChallengeRequests < ActiveRecord::Migration
def change
create_table :challenge_requests do |t|
t.integer :challenge_id
t.integer :source_id
t.integer :destination_id
t.integer :status_id
t.string :comment
t.timestamps null: false
end
end
end
|
require 'rails_helper'
RSpec.feature "User views all playlists" do
scenario "they see each playlist's name with links" do
playlist_one, playlist_two = create_list(:playlist, 2)
visit playlists_path
expect(page).to have_link playlist_one.name, href: playlist_path(playlist_one)
expect(page).to have_... |
class Player
def getHealth()
if @health == nil
return 20
else
return @health
end
end
def moveWarrior(warrior)
if warrior.health < getHealth
if warrior.health <= 10
warrior.walk!(:backward)
else
if warrior.feel.empty?
warrior.walk!
elsif... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.