text stringlengths 10 2.61M |
|---|
require 'addressable'
require_relative 'config/capybara'
require_relative 'config/facebook'
class Scraper
include Capybara::DSL
class PageDoesNotExist < StandardError; end
FB_SITE = 'https://www.facebook.com'
MAX_ELEMS = 400
ABOUT_ATTRIBUTES = {
'Facebook' => :facebook,
'Pohlaví' => :gender,
'... |
class RemoveTitleFromActivities < ActiveRecord::Migration[5.0]
def change
remove_column :activities, :title
end
end
|
class CTF3::Docker::Manager
include Chalk::Log
def initialize
@initial = []
@attempted = []
@booted = []
end
def attempt(*args)
container = CTF3::Docker::Container.new(*args)
container.start
@attempted << container
container
end
# Spin these up here so that you get backtraces ... |
class Contract < ApplicationRecord
belongs_to :profile
belongs_to :job
has_many :timeslots
has_many :reviews
validates :accept_status, presence: true #0: waiting; 1: reject; 2: accept
end |
require 'spec_helper'
require 'cancan/matchers'
describe FabricHandler do
describe "normally" do
before do
user = double('user', :username => 'joel')
fabric = double('fabric', :prices => double('array', :each => double('sss')))
amount = '1.99'... |
class Locker < ApplicationRecord
belongs_to :account
validates :locker_key, presence: true, length: { minimum: 4, maximum: 4 }
end
|
# frozen_string_literal: true
require 'bank_deposits/display_investment_growth'
require 'bank_deposits/deposit'
RSpec.describe BankDeposits::DisplayInvestmentGrowth, '#call' do
subject do
display_investment_growth.call(deposit, years, annual_addition)
end
let(:display_investment_growth) do
described_cl... |
class Sale < ApplicationRecord
validates :order_id, :shoe_id, :sex, :size, :date, :price, :active, null: false
belongs_to :order,
foreign_key: :order_id,
class_name: :Order
belongs_to :shoe
end
|
require 'test_helper'
class Regaliator::BillerTest < Minitest::Test
def setup
Regaliator.configure do |config|
config.api_key = 'api-key'
config.secret_key = 'secret-key'
config.host = 'api.regalii.dev'
config.use_ssl = false
end
end
def test_list_credentials
VCR.... |
class AddIsBusytoVirtualMachines2 < ActiveRecord::Migration
def up
end
def change
add_column :virtual_machines, :is_busy, :boolean
end
def down
end
end
|
# encoding: utf-8
require 'minitest/autorun'
require_relative '../lib/regexp_m17n'
class RegexpTest < MiniTest::Unit::TestCase
# Ruby does not implement converters for these:
IGNORE_LIST = ['ISO-2022-JP-2', 'UTF-7']
TEST_ENC_LIST = Encoding.list.reject{|x| IGNORE_LIST.include? x.name}
def test_non_empty_stri... |
class AddHolidayToIndoors < ActiveRecord::Migration
def change
add_column :indoors, :holiday, :string
end
end
|
# frozen_string_literal: true
require 'shared/file'
require './lib/log_processor/formatter/base'
require './lib/log_processor/formatter/uniq'
RSpec.describe LogProcessor::Formatter::Uniq do
describe 'formatter value' do
it 'returns the formatter value to unique views' do
expect(described_class::FORMATTER)... |
# coding: utf-8
require 'spec_helper'
describe Apress::Videos::OembedValidator do
shared_context 'check field for absense' do |key|
let(:video) do
build :'apress/videos/video', oembed_data: JSON.parse('{"html": "Test_HTML",
"thumbnail_url": "tes... |
class CreateVotingSessions < ActiveRecord::Migration
def change
create_table :voting_sessions do |t|
t.integer :agenda_id
t.boolean :passed
t.boolean :quorum
t.integer :result1, :default => 0
t.integer :result3, :default => 0
t.integer :result5, :default => 0
t.string :re... |
FactoryGirl.define do
factory :transfer_in do
source_id { Faker::PhoneNumber.phone_number }
source_name { Faker::StarWars.character }
source_code { Faker::Lorem.word }
transfer_type { Faker::StarWars.character }
amount { Faker::Number.number(10) }
currency { Faker::StarWars.character }
res... |
require 'open3'
require 'sequel'
Sequel.single_threaded = true
class Project
attr_accessor :name, :account
attr_writer :password
def initialize(name, account, password=nil)
@name = name
@account = account
@password = password
end
def bulk_server_command
begin
rows = @db[:parameter]
.select(:value_... |
module Campaigns
class ComputeDailyReportsDataService
private
attr_reader :campaign
public
def initialize(campaign)
@campaign = campaign
end
def call
last_daily_report = campaign.daily_reports.last
return {
total_backers_count: last_daily_report.backers_count,
... |
class MinPathMatrix
def initialize(matrix)
@matrix = matrix
@total_length = @matrix.length * 2
end
def min_sum
diagonals.each do |diag|
diag.each do |coord|
x = coord[0]
y = coord[1]
if x + 1 < @matrix.length && y + 1 < @matrix.length
@matrix[x][y] += if @matri... |
require 'tinny'
require 'tinny/calculators/distance_utils'
module Tinny::Calculators
attr_reader :gprmc_str, :data_map
class GPRMCData
def initialize(gprmc_str, **settings)
@gprmc_str = gprmc_str
@settings = settings
@data_map = nil
end
def lat_long
extract if @data_map.nil?
... |
# -*- coding: utf-8 -*-
module RakutenSearchHelper
def create_rakuten_search_stub(title="長嶋茂雄", count=1)
response = <<EOS
{
"count": 1,
"page": 1,
"first": 1,
"last": 1,
"hits": 1,
"carrier": 0,
"pageCount": 1,
"Items": [
{
"Item": {
"title": "長嶋茂雄",
"titleKana": "ナガシマ シゲオ... |
class FontSeoulHangangCondensed < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/seoulhangangcondensed"
desc "Seoul Hangang Condensed"
homepage "http://english.seoul.go.kr/seoul-views/seoul-symbols/5-fonts/"
def install
(share/"fonts"... |
class Series < ActiveRecord::Base
validates :title, :year, :mpaa_rating, :description, :thumbnail_url,
presence: true
has_many :categorizations, :as => :media
has_many :genres, :through => :categorizations, :as => :media
has_many :videos
has_many :follows
has_many :users, :through => :follows... |
puts 'Creating restaurants...'
restaurants_attributes = [
{
name: 'XYZ',
address: '7 Boundary St, London E2 7JE',
phone_number: '02 06 78 87 87',
category: 'chinese'
},
{
name: 'Sushi Samba',
address: 'The city',
phone_number: '02 06 78 87 87',
categ... |
class Contract < ActiveRecord::Base
belongs_to :company
has_many :payments, dependent: :destroy
validates :contract_no, :contract_start, :contract_end, :company_code, :company_id, presence: true
validates :contract_no, uniqueness: true
def self.search( search )
if search
where('contract_no LIKE ?', "%#{sea... |
class JobsController < ApplicationController
before_action :set_job, only: [:show, :edit, :update, :destroy]
# GET /jobs
# GET /jobs.json
def index
@jobs = Job.order(id: :desc)
if @jobs.empty?
flash[:notice] = 'There are no jobs !'
redirect_to root_path
end
end
# GET /jobs/1
# G... |
require File.expand_path('spec/support/support.rb', File.dirname(__FILE__))
Vagrant.configure("2") do |config|
config.vm.box = 'dummy'
# see https://github.com/cloudbau/vagrant-openstack-plugin
# or run:
# vagrant box add dummy https://github.com/cloudbau/vagrant-openstack-plugin/raw/master/dummy.box
config.... |
class CreateIdeaTagsRebuilded < ActiveRecord::Migration
def self.up
create_table :idea_tags do |t|
t.integer :tag_id, :idea_id, :user_id
end
remove_column :tag_sharings, :idea_id
end
def self.down
drop_table :idea_tags
add_column :tag_sharings, :idea_id, :int
end
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Presentation
describe Style do
let(:described) { Vedeu::Presentation::Style }
let(:instance) { described.new(_value) }
let(:_value) { 'bold' }
describe '#initialize' do
it { instance.must_be_instance_... |
require 'rspec'
require "rake"
require_relative 'rakefile.rb'
RSpec.describe "scrape_image: To get all images from a web page", type: :rake do
after(:each) do
Rake::Task["scrape_image"].reenable
end
it "No url present" do
expect do
Rake::Task["scrape_image"].invoke()
end.to output("Please pro... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "vagrant-fedora18"
config.vm.box_url = "http://static.stasiak.at/fedora-18-x86-2.box"
... |
Pod::Spec.new do |s|
s.name = 'TPPDF'
s.version = '2.4.1'
s.summary = 'TPPDF is a simple-to-use PDF builder for iOS'
s.description = <<-DESC
TPPDF is an object-based PDF builder, completely built in Swift.
You create a document by defining, adding and positioning diffe... |
class CashRegister
attr_accessor :total, :discount, :items, :trans_total
def initialize(discount = 0)
@total = 0
@discount = discount
end
def add_item (item, price, quantity = 1)
@trans_total = (price*quantity)
@total += @trans_total
while quantity > 0
(@items||=[]) << item
quant... |
# frozen_string_literal: true
module BPS
module PDF
class EducationCertificate
# Dynamically handle seminar completions, certification statuses, and supplementary courses.
#
module Seminars
def seminars(user, **_)
@user = user
@completions = @user.completions
... |
require File.expand_path("../lib/6to5/version.rb", __FILE__)
Gem::Specification.new do |s|
s.name = '6to5'
s.version = ES6to5::VERSION
s.homepage = "https://github.com/6to5/ruby-6to5"
s.summary = "Ruby 6to5 Compiler"
s.description = <<-EOS
Ruby 6to5 is a bridge to the JS 6to5 compiler.
EOS
... |
class AdminController < ApplicationController
before_action :authorize_admin!
def authorize_admin!
if current_user.nil? || !current_user.admin?
flash[:notice] = "You are not authorized to view this resource."
redirect_to root_path
end
end
end
|
require 'spec_helper'
require 'rails_helper'
feature 'the signup process' do
before :each do
create(:user)
create_user(User.last)
end
scenario 'has a new user page' do
visit new_user_url
expect(page).to have_content ('new user alert!')
end
feature 'signing up a user' do
scena... |
module Praxis
class RestfulDocGenerator
class << self
attr_reader :inspected_types
end
@inspected_types = Set.new
API_DOCS_DIRNAME = 'api_docs'
EXCLUDED_TYPES_FROM_TOP_LEVEL = Set.new([
Attributor::Boolean,
Attributor::CSV,
Attributor::DateTime,
Attributor::Float,
... |
require 'spec_helper'
require 'debugger'
describe "screenshot functionality actions" do
before(:each) {
# controls
(1..5).each do |i|
create_screenshot({:id => i, :is_control => true, :is_test => false})
end
# tests
(6..10).each do |i|
create_screenshot({:id => i, :is_control => fals... |
class ChargesController < ApplicationController
Stripe.api_key = "sk_test_gp9PsCjvj6MyLYVhdxW93qCs"
def new
end
# creating a Stripe::Charge object with various POST parameters
def create
# Get the credit card details submitted by the form
token = params[:stripeToken]
# Amount in cents
@amount = 500
... |
class LexemeMembershipRename < ActiveRecord::Migration
def self.up
rename_table 'lexeme_memberships', 'lexeme_phrases'
end
def self.down
rename_table 'lexeme_phrases', 'lexeme_memberships'
end
end
|
ActiveAdmin.register Post do
permit_params :title, :content, :photo
form partial: 'form'
show do |t|
attributes_table do
row :title
row :content
row :photo do |ad|
image_tag url_for(ad.photo) if ad.photo.attached?
end
end
end
form :html => { :enctype => "multipart/fo... |
module Bluesky
module DOMHelper
extend self
protected
# Delays execution to the main event loop
#
# == Parameters:
# block
# A block to execute on the main event loop
#
# == Returns:
# A promise that resolves after block has completed
def defer(&block)
timeout(0,... |
#Fedena
#Copyright 2011 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#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 ... |
class LocationsController < ApplicationController
def index
@locations = Location.last_created(10)
end
def show
@location = Location.find(params[:id])
rescue ActiveRecord::RecordNotFound
render status: 404,
file: "#{Rails.root}/public/404"
end
end
|
class Location < ApplicationRecord
belongs_to :country
belongs_to :sight
end
|
class TweetsController < ApplicationController
before_action :set_tweet, only: [:edit, :update, :destroy, :show]
before_action :login, only: [:new, :show, :edit]
def index
@tweets = Tweet.all
end
def new
if params[:back]
@tweet = Tweet.new(tweet_params)##下記のコメントNo.1に定義されてる。
else
@t... |
#!/usr/bin/env ruby
# frozen_string_literal: true
# Will run one robot as specified, either for a druid a file containing one druid per line
#
# To run With Options
# Options must be placed AFTER workflow and robot name
# robot_root$ ./bin/run_robot Accession::Publish -e test -d druid:aa12bb1234
require 'bundler/setup... |
class Signup
include Mongoid::Document
field :email_address
end
|
# frozen_string_literal: true
# Challenge
# You will be given a positive integer number . Fill in the method sum so that it adds up all the positive integers up to number and returns the sum.
# For example, when given 4 it should return 10 (4+3+2+1).
# While there are other ways to solve this challenge, you should u... |
class Loanable < ApplicationRecord
belongs_to :user
has_many :loan_contracts
end
|
require 'test/unit'
require_relative './driver'
include Test::Unit::Assertions
include ::Driver
step 'Show a message <message>' do |message|
flash_notice = driver.find_element(:xpath, "//div[@id = 'flash_notice' and text() = '"+message+"']")
assert_true flash_notice.displayed?
end
|
class SmsClientsController < ApplicationController
require 'net/http'
def create
stringUrl = "http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=pyau&password=pyau123&sendername=PYAUSR&mobileno=917899767851&message=hello"
url = URI.parse(stringUrl)
req = Net::HTTP::Get.new(url.to_s)
r... |
class BeefCategory < ApplicationRecord
belongs_to :beef, optional: true
belongs_to :category
end
|
require 'spec_helper'
describe 'validate_re' do
describe 'signature validation' do
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong... |
class CreateLocations < ActiveRecord::Migration[5.0]
def change
create_table :locations do |t|
t.string :name, null: false
t.string :slug, null: false
t.integer :district_id, null: false
t.timestamps null: false
end
add_index :locations, :district_id
end
end
|
module Stereotype
module PageExtensions
def self.included(base)
base.extend ClassMethods
base.class_eval do
class <<self
alias_method_chain :new_with_defaults, :stereotype
end
after_save :update_custom_fields
include InstanceMethods
end
end
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Sign Up', type: :system do
scenario 'visitor sign up successfuly' do
visit '/'
click_link t('landing.navigation.sign_up')
within 'form#user' do
fill_in 'Email', with: 'some@email.com'
fill_in 'Password', with: '1q2w3e4r'
... |
class Crawler::Admin < CrawlerRefactor
def initialize(args)
super(args)
@supplier = Supplier.find_by_url_main(args[:url])
end
def load_documents
self.run if @html_documents.empty?
end
def html
load_documents
html = @html_documents.map{|page| page.inner_html}
end
def links
load_d... |
class CreateAlerts < ActiveRecord::Migration[5.1]
def change
create_table :alerts do |t|
t.integer :social_watcher_id
t.string :data_id
t.text :text
t.text :data
t.timestamps
end
add_index :alerts, :social_watcher_id
add_index :alerts, :data_id
end
end
|
class AccountsController < ApplicationController
def index
@accounts = Account.all.order(:id)
end
def transfer
raise "User was not logged in" unless current_user
account = current_user.account
transfer_credits = [params[:credits].to_i, account.balance].min # this is a really terrible bank!
... |
class TransactionBuilder
def self.build_transactions(cashflow_item)
#Create instance variables
@cashflow_item = cashflow_item
@cashflow_type = cashflow_item.class.to_s
@recur_frequency = @cashflow_item.recur_frequency
#Get rid of any old transactions associated with this cashflow item
cl... |
class Blog < ActiveRecord::Base
has_many :blog_comments, -> { where(publish: 1) }, as: :commentable
end
|
# -*- encoding : utf-8 -*-
# The model of the translatee resource.
#
# This code is part of the Stoffi Music Player Project.
# Visit our website at: stoffiplayer.com
#
# Author:: Christoffer Brodd-Reijer (christoffer@stoffiplayer.com)
# Copyright:: Copyright (c) 2013 Simplare
# License:: GNU General Public License (s... |
class RemoveContentFromProject < ActiveRecord::Migration
def change
remove_column :projects, :content
end
end
|
class Refrigerator
attr_reader :name #Note 1
attr_accessor :top_shelf, :middle_shelf, :bottom_shelf #Note 2
def initialize(name)
@name = name
@top_shelf = Hash.new(0) # Note 3
@middle_shelf = Hash.new(0)
@bottom_shelf = Hash.new(0)
end # this is to close initialization
end # this is to close my class
# I... |
############################################################
#
# Name: Sean Kanaley
# Assignment: Rock Paper Scissors
# Date: 1/30/2017
# Class: CIS 282
# Description: Create a game of rock, paper, scissors, lizard, Spock. Where the computer randomly picks and the player chooses.
# Outputs the resu... |
require "spec_helper"
module Tephue
module Repository
module Query
describe Contains do
let(:instance) { Contains.new(:a, [1,2,3]) }
it "has the right type" do
expect(instance.type).to eql(:contains)
end
it "has a #field" do
expect(instance.field).to eql... |
require 'rails_helper'
RSpec.describe Api::V1::NewsController, type: :request do
let!(:news) { create(:news, title: 'My trip to Aspen', content: 'Aspen is great', all_tags: 'aspen') }
describe 'sessions' do
it 'signs in user' do
user = User.create!(email: "fuck@tfz.com", password: "very-secret")
s... |
class Item < ApplicationRecord
belongs_to :auction
has_many :bids, dependent: :destroy
end
|
require 'sidekiq/debounce/version'
require 'sidekiq/api'
module Sidekiq
class Debounce
def call(worker, msg, _queue, redis_pool)
@worker = worker.is_a?(String) ? worker.constantize : worker
@msg = msg
return yield unless debounce?
redis_pool.with do |conn|
# Get JID of the alrea... |
class AddFieldsToFunds < ActiveRecord::Migration
def change
add_column :funds, :firstname, :string
add_column :funds, :lastname, :string
add_column :funds, :email, :string
end
end
|
require 'nokogiri'
require 'pry'
require 'csv'
# return Array
def file_parser(file:)
videos = []
File.open(file).each_line do |line|
video = {}
split_line = line.split('|')
video['title'], video['url'] = split_line[0], split_line[1]
videos << video
end
videos
end
# return hash
def line_parser(... |
FactoryBot.define do
factory :merged_with_marker do
reporting_relationship { create :reporting_relationship }
body { "i am a 'merged with' marker #{SecureRandom.hex(17)}" }
end
end
|
#!/usr/bin/env jruby
require 'java'
require 'tempfile'
import 'org.jfree.chart.ChartFactory'
import 'org.jfree.chart.ChartUtilities'
import 'org.jfree.chart.JFreeChart'
import 'org.jfree.chart.encoders.ImageFormat'
import 'org.jfree.chart.plot.PlotOrientation'
import 'org.jfree.data.xy.XYSeries'
import 'org.jfree.dat... |
require 'rails_helper'
RSpec.describe "authentications/index", :type => :view do
before(:each) do
assign(:authentications, [
Authentication.create!(
:user_id => 1,
:provider => "Provider",
:uid => "12",
# :access_token => "Access Token",
# :access_token_secret => "Ac... |
require_relative "test_helper"
class ClickTest < ActionDispatch::IntegrationTest
def test_default
message = ClickMailer.welcome.deliver_now
refute_body "click", message
end
def test_basic
message = ClickMailer.basic.deliver_now
assert_body "click", message
click_link(message)
assert_red... |
# encoding: utf-8
# 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 applic... |
class AddVisitDateToClinicRecord < ActiveRecord::Migration
def change
add_column :clinic_records, :visit_date, :date
end
end
|
require_relative "errors"
class Piece
attr_reader :color, :board
attr_accessor :pos
def initialize(color, board, pos, kinged = false)
@color = color
@board = board
@pos = pos
@kinged = kinged
end
###############################
# Attribute Info + Adjustment #
###########################... |
class AddDstaccountToTransactionLogs < ActiveRecord::Migration
def change
add_column :transaction_logs, :dst_account, :string
end
end
|
# == Schema Information
#
# Table name: purchase_orders
#
# id :integer not null, primary key
# provider_id :integer
# price :decimal(10, 2)
# quantity :integer
# created_at :datetime
# updated_at :datetime
# des... |
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :name
t.text :description
t.datetime :event_from
t.datetime :event_to
t.references :branch, index: true
t.timestamps
end
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
if Vagrant.ha... |
require 'set'
def my_uniq(arr)
seen = Set.new
result = []
arr.each do |el|
result << el unless seen.include?(el)
seen << el
end
result
end
def two_sum(arr, target)
arr.combination(2).any?{|el| el.reduce(:+) == target}
end
def my_transpose(arr)
result = Array.new(arr[0].length) {Array.new}
idx = 0
while i... |
class CommentsController < ApplicationController
def create
lesson = Lesson.find(params[:lesson_id])
lesson.comments.create(comment_params.merge(user: current_user))
# comment = lesson.comments.new(comment_params)
# comment.user = current_user
# comment.save
redirect_to lesson
end
privat... |
class FakeVoter
include ActiveModel::Model
attr_accessor :id
def self.random_vote_for votable, range
vote_for votable, rand(range)
end
def self.vote_for votable, weight = 1
votable.vote_by voter: self.new, vote_weight: weight
votable.update_score if votable.respond_to? :update_score
end
def... |
require 'time'
require 'forwardable'
module VCR
module Normalizers
module Body
def initialize(*args)
super
# Ensure that the body is a raw string, in case the string instance
# has been subclassed or extended with additional instance variables
# or attributes, so that it is ... |
class FormsController < ApplicationController
before_action :set_form, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource except: [:create]
# GET /forms
# GET /forms.json
def index
@forms = @current_website.forms
authorize! :edit, @current_website
end
# GET /forms/1
# GET /for... |
# == Schema Information
#
# Table name: props
#
# id :integer not null, primary key
# propable_id :integer
# propable_type :string(255) default(""), not null
# name :string(255) default(""), not null
# value :string(255) default(""), not null
# created_at :... |
FactoryBot.define do
factory :temp_document, class: Document do
name "#{FFaker::Name.unique.name}.csv"
display_name "#{FFaker::Name.name}.csv"
folder 'public/uploads/temp/'
file_type '.csv'
processed false
end
end
|
# coding: utf-8
require 'spec_helper'
feature 'About BigCo modal' do
# aboutのモーダル表示を切り替える
scenario 'toggles display of the modal about display' , js: true do
visit root_path
expect(page).not_to match_about_bigco
click_link 'About Us'
expect(page).to match_about_bigco
within '#about_us' do
... |
class DeviceProblemsController < ApplicationController
load_and_authorize_resource
# GET /device_problems
# GET /device_problems.json
def index
@device_problems = DeviceProblem.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @device_problems }
end
e... |
require 'spec_helper'
describe "Merchant pages" do
subject { page }
describe "merchant signup page" do
before { visit new_merchant_registration_path }
it { should have_content('註冊') }
end
describe "merchant signup" do
before { visit new_merchant_registration_path }
describe "with invali... |
# When done, submit this entire file to the autograder.
# Part 1
def sum arr
# YOUR CODE HERE
arr.sum
end
def max_2_sum arr
sum(arr.sort.last(2))
end
def sum_to_n? arr, n
!! arr.uniq.combination(2).detect {|a,b| a+b == n}
end
# Part 2
def hello(name)
return "Hello, #{name}"
end
def starts_with_consona... |
class CanonicalTemperature < ApplicationRecord
def self.get_hourly_reading(zip_code)
datetime = DateTime.now
canonical_temp = find_by({
zip_code: zip_code,
record_time: datetime.beginning_of_hour
})
if !canonical_temp
temp = WeatherMan.current_outdoor_temp(zip_code)
canonical_... |
feature "Official Diaries - List" do
context 'Visitor' do
scenario "Access invalid" do
visit official_diaries_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
scen... |
class Coupon < ActiveRecord::Base
belongs_to :variant
validates :code, presence: true
end
|
# see link_examples.md
When (/^(?:|I )follow "([^"]*)"$/) do |link|
click_link(link)
end
When(/^I click "(.*?)" within "(.*?)"$/) do |link, scope_selector|
page.should have_css(scope_selector)
within(scope_selector) do
click_link(link)
end
end
When(/^I click the "(.*?)" within (\d+)(?:st|nd|rd|th) (.*?)$... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# uid :string(255) not null
# name :string(255)
# username :string(255)
# token :string(255) not null
# secret :string(255) not null
# created_at :datet... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.