text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe "equipment/new", type: :view do
before(:each) do
assign(:equipment, Equipment.new())
end
it "renders new equipment form" do
render
assert_select "form[action=?][method=?]", equipment_index_path, "post" do
assert_select "select#equipment_brand_id[name=?]",... |
class VendorDatatable
delegate :current_user, :content_tag, :check_box_tag, :params, :link_to, to: :@view
delegate :url_helpers, to: 'Rails.application.routes'
delegate :session, to: :@view
include ApplicationHelper
def initialize(view)
@view = view
end
def as_json(options = {})
{
draw:... |
class ListsController < ApplicationController
before_action :set_list, only: [:show, :update, :destroy]
def renderError(message, code, description)
render status: code,json: {
message: message,
code: code,
description: description
}
end
def showPendingPaybyUser
if !(Integer(params[:user_id... |
require_relative '../spec_helper'
class SquirrelSpec
describe 'squirrels' do
let(:squirrel) { Squirrel.create(name: 'Rockey', tree_mail: 'tree@mail.com', tail_length: 123)}
before do
squirrel
end
it 'should respond to /squirrels' do
get '/squirrels'
expect(last_response).to be_o... |
class Word
include Mongoid::Document
include Mongoid::Timestamps
field :original, type: String
field :translation, type: String
field :lang, type: String
#key :original
validates_uniqueness_of :original
index :original, unique: true
before_save :set_lang_and_translation
def t... |
class CreateStates < ActiveRecord::Migration
def self.up
create_table :states do |t|
t.column :state, :string
end
[ 'Andhra Pradesh',
'Arunachal Pradesh',
'Assam',
'Bihar',
'Chhattisgarh',
'Goa',
'Gujarat',
'Haryana',
'Himachal Pradesh',
'Jammu and Kashmir',
'Jharkhand',
'Karnataka'... |
class ComponentTemplatesController < ApplicationController
before_action :set_component_template, only: %i(show destroy update edit)
def index
authorize ComponentTemplate
@component_templates = ComponentTemplate.all
end
def new
authorize ComponentTemplate
@component_template = ComponentTemplat... |
module Admin
class JobsController < AdminController
expose(:jobs) { Job.order(created_at: :desc).page(params[:page]).all }
expose(:job)
def index
end
def create
if job.save
JobHandler.new(job, job_params[:uploaded_file]).queue_processing("import_format" => "docx")
end
r... |
module Authentication
include ActiveSupport::Concern
def authenticate
token = request.headers['Authorization'].gsub('Bearer ', '')
data, header = JWT.decode token, hmac_secret, true, { algorithm: 'HS256' }
@current_user = data["data"]
rescue JWT::DecodeError, JWT::VerificationError
render status:... |
class AccountType < ActiveRecord::Base
validates_presence_of :name, :code
validates_uniqueness_of :name, :code
end
|
class AddInsuranceIdOnReturn < ActiveRecord::Migration
def change
add_column :returns, :insurance_id, :integer
end
end
|
# web_server
require 'logger'
require 'socket'
require_relative 'job_classes.rb'
class Server
def initialize (file = 'server.log', port = 8080)
@queue = Queue.new
@server_socket = TCPServer.open("localhost", port)
@log = Logger.new (file)
@log.datetime_format = '%Y-%m-%d %H:%M:%S'
@log.debug("... |
class ApplicationController < ActionController::Base
protected
def after_sign_in_path_for(resource)
posts_path
end
def after_sign_out_path_for(resource)
root_url
end
end
|
# Region クラスのソースファイル
# Author:: maki-tetsu
# Date:: 2011/03/11
# Copyright:: Copyright (c) 2011 maki-tetsu
module PREP # nodoc
module Core # nodoc
# リージョンの幅がマイナスになった場合に発行される例外
class RegionWidthOverflowError < StandardError; end
# リージョンの高さがマイナスになった場合に発行される例外
class RegionHeightOverflowError < Standard... |
class TestimonialsController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
def index
testimonials = Testimonial.all
render json: testimonials
end
def create
testimonial = Testimonial.create(params.permit(:image, :paragraph, ... |
FactoryGirl.define do
factory :rating do
value { Random.rand(4) + 1 }
association :user
association :restaurant
end
end |
require 'rspec'
class FileWriter
def initialize(number_of_lines:, file_path:)
@path = file_path
@n = number_of_lines
end
def write
File.open(@path, 'w+') do |f|
@n.times do |i|
f.puts "Content line #{i + 1}"
end
end
end
end
describe FileWriter do
it 'writes 1k lines to a... |
require "rails_helper"
RSpec.feature "Store Admin", type: :feature do
include LoginHelper
before do
create_roles
end
it "can login" do
create_account
login_as_store_admin
expect(page).to have_content("Company Information")
end
it "shows a 404 with nonregistered user" do
visit compa... |
require 'spec_helper'
module Boilerpipe
describe Document::TextBlock do
subject { Document::TextBlock.new 'hello' }
describe '.new' do
context 'with text input' do
it 'sets text' do
expect(subject.text).to eq 'hello'
end
# used in image extraction / highligher
... |
shared :set_classify do |klass|
describe "#{klass}#classify" do
before(:each) do
@set = klass["one", "two", "three", "four"]
end
it "yields each Object in self" do
res = []
@set.classify { |x| res << x }
res.sort.should == ["one", "two", "three", "four"].sort
end
it "rais... |
class ChangeMaintenanceRecordColumnNAme < ActiveRecord::Migration
def change
rename_column :maintenance_records, :reason_code, :reason_codes
end
end
|
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/plans'
describe 'aggregate::count' do
include BoltSpec::Plans
it 'counts the same value' do
expect_task('test_task').always_return('key1' => 'val', 'key2' => 'val')
result = run_plan('aggregate::count', 'targets' => 'foo,bar', 'task' ... |
class OutboundStatus<ActiveRecord::Base
self.table_name = "outbound_status"
belongs_to :outbound_logs
end
|
require 'rails_helper'
RSpec.describe PlansController, type: :controller do
let(:valid_attributes) {
{
"name": Faker::Book.title,
"planner": Faker::Name.first_name,
"location": Faker::Address.city
}
}
let(:invalid_attributes) {
{
"invalid_attribute": Faker::Name.first_name
... |
require 'spec_helper'
describe Comment do
should_validate_presence_of :body, :commentable
should_validate_presence_of :author_name, :if => Proc.new { |c| c.user.nil? }
end
|
require 'pry'
class Game
attr_accessor :board, :player_1, :player_2
@@WIN_COMBINATIONS = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[6, 4, 2]]
WIN_COMBINATIONS = @@WIN_COMBINATIONS # This is needed to pass a test but violates DRY. Check solution for more comp... |
module EditI18nDatabaseTranslations
module Helper
def text(path)
if are_you_i18n_editor?
text = t(path)
if text.blank?
text = "edit it"
end
content_tag(:span, text,
data: {i18n_path: path},
class: 'i18n-translation js-i18n-tr... |
require_relative 'sliding_piece.rb'
class Rook < SlidingPiece
attr_accessor :moved
def initialize(position, color, board)
super(position, color, board)
@moved = false
end
def valid_move?(target, board)
super(target, board) && straight_move?(target)
end
# this is for castling logic...
def m... |
class Phrase < ActiveRecord::Base
has_many :searches, dependent: :nullify
has_many :synonyms, dependent: :destroy
has_many :synonym_phrases, through: :synonyms
has_many :inverse_synonyms, class_name: 'Synonym', foreign_key: 'synonym_id', dependent: :destroy
has_many :inverse_synonym_phrases, through: :invers... |
class RolesController < ApplicationController
include Hydra::RoleManagement::RolesBehavior
def create
@role = Role.new(role_params)
if @role.save
redirect_to role_management.roles_path, notice: 'Role was successfully created.'
else
render action: "new"
end
end
end
|
class AssuntosController < ApplicationController
def new
@assunto = Assunto.new
end
def edit
@assunto = Assunto.find_by(id: params[:id])
end
def index
if params[:message].present?
@message = params[:message]
end
@assuntos = Assunto.all
render :index
end
def show
@assu... |
# Source: https://launchschool.com/exercises/ff9b13b6
def transpose(matrix)
rows = matrix[0].size
transposed = []
(0..rows-1).each do |idx|
row = []
matrix.each do |arr|
row << arr[idx]
end
transposed << row
end
transposed
end
p transpose([[1, 2, 3, 4]]) == [[1], [2], [3], [4]]
p tran... |
class Contact < ApplicationRecord
has_many :properties, inverse_of: :owner
has_many :deals, inverse_of: :contact
has_many :brokers, through: :deals
accepts_nested_attributes_for :properties,
allow_destroy: true,
reject_if: :all_blank
enum type_... |
class ProjectsController < ApplicationController
def index
process_filter_params
@title = "Projects"
@projects = params[:project_category] == "Recent Projects" ? Project.recent_projects : Project.all
@projects = @pt_id ? @projects.where("type_id = ?", @pt_id) : @projects
@project_types = ProjectTy... |
require "roark/aws"
require "roark/ami"
require "roark/ami_create_workflow"
require "roark/instance"
require "roark/response"
require "roark/stack"
require "roark/version"
require "logger"
module Roark
module_function
def logger(logger=nil)
@logger ||= logger ? logger : Logger.new(STDOUT)
end
end
|
# 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 ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
before_action :current_notifications, if: :signed_in?
def current_notifications
@notifications_count = Notification.where(user_id: current_user.id).whe... |
# frozen_string_literal: true
FactoryBot.define do
factory :user_identity, class: 'UserIdentity' do
uuid 'b2fab2b5-6af0-45e1-a9e2-394347af91ef'
email 'abraham.lincoln@vets.gov'
first_name 'abraham'
last_name 'lincoln'
gender 'M'
birth_date '1809-02-12'
zip '17325'
ssn '796111863'
... |
class ChangeTrainingsTableToEvents < ActiveRecord::Migration
def change
rename_table :gsa18f_trainings, :gsa18f_events
end
end
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'daggregator/configuration'
require 'daggregator/connection'
module Daggregator
class << self
def client
@client ||= Client.new
end
def configuration
@configuration ||= Daggrega... |
# Given an array of elements, return true if any element shows up three times in a row
#
# Examples:
# got_three? [1, 2, 2, 2, 3] # => true
# got_three? ['a', 'a', 'b'] # => false
# got_three? ['a', 'a', 'a'] # => true
# got_three? [1, 2, 1, 1] # => false
def got_three?(element_array)
value = false
element_a... |
require_relative "./shared/intcode"
class Navigator
MOVES = {"^" => [0, -1], ">" => [1, 0], "v" => [0, 1], "<" => [-1, 0]}.freeze
DIRECTIONS = MOVES.keys
TURNS = {"L" => -1, "R" => 1}.freeze
def initialize(map)
@map = map
end
def path
path = []
position, dir = @map.detect { |_, c| MOVES.key?(... |
class AddRankToTrendsTable < ActiveRecord::Migration[5.0]
def change
add_column :trends, :rank, :integer
end
end
|
# Model
model:
rest_name: plan
resource_name: plans
entity_name: Plan
package: vince
group: core/billing
description: Contains the various billing plans available.
get:
description: Retrieves the plan with the given ID.
# Attributes
attributes:
v1:
- name: description
description: Contains th... |
class ExpirationDateValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return if record.status == "pending"
if record.cc_expiration == nil
return record.errors[:cc_expiration] << 'expiration date can\'t be blank'
end
unless value =~ /\A(0[1-9]|1[0-2]|[1-9])\/(2... |
class User < ApplicationRecord
has_many :p_spaces
def to_s
name
end
end
|
# 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... |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryPr... |
class Monthlyinvitem < ActiveRecord::Base
belongs_to :monthlyinv
belongs_to :item
belongs_to :storeloc
belongs_to :price
validates_uniqueness_of :item_id, :scope => [:monthlyinv_id, :storeloc_id]
def <=> (other)
other.item.sort.to_i <=> item.sort.to_i
end
end
|
module HeadersMixin
extend ActiveSupport::Concern
# X-DEVICE-ID : abcd0123 // device unique identifier
# X-MOBILE-PLATFORM : ios // device platform name (ios, android)
# X-APPLICATION-NAME : Astro DJ // name of application
# X-APPLICATION-VERSION : 1.0.0 // version name of the application
# X-DEVI... |
def roll_call_dwarves(dwarves)
dwarves.each_with_index do |dwarf, index|
puts "#{index + 1}. #{dwarf}"
end
end
def summon_captain_planet(calls)
calls.map do |call|
"#{call.capitalize}!"
end
end
def long_planeteer_calls(calls)
if calls.detect {|call| call.length > 4}
true
else false
end
end
... |
require "rails_helper"
feature "User Sign In" do
context "without JavaScript"do
scenario "a User signs in" do
visit root_path
within("nav.app-nav") do
click_on t("modules.navigation.sign_in")
end
fill_in "Email", with: user.email
fill_in "Password", with: user.password
... |
require 'rails_helper'
require 'spec_helper'
feature "Welcome" do
scenario "User sees welcome message" do
visit '/'
expect(page).to have_content "Welcome aboard"
end
end |
class UserAnswersController < ApplicationController
def index
@score = 0
@total = 0
@user = User.find(params[:user_id])
@questions = Question.all
@user.user_answers.all.map do |answer|
if answer.answer.correct == true
@score += 1
end
@total += 1
end
end
def new
@user =... |
require "spec_helper"
RSpec.describe Aruba::Platforms::WindowsCommandString do
let(:command_string) { described_class.new(base_command, *arguments) }
let(:cmd_path) { 'C:\Some Path\cmd.exe' }
let(:arguments) { [] }
before do
allow(Aruba.platform).to receive(:which).with("cmd.exe").and_return(cmd_path)
e... |
require 'spec_helper'
describe AuthorizeNetRecurring do
describe ".create" do
before :each do
@owner = Factory.build :owner
@owner.stub!(:prev_billing_date).and_return(Date.today)
@card = Factory.build :card, :owner => @owner
@owner.confirmed_at = Date.today
@gateway = mock('gateway... |
namespace :n2 do
namespace :data do
desc "Bootstrap and convert existing data"
task :bootstrap => [:environment, :pre_register_users, :delete_floating_content, :delete_floating_ideas, :generate_model_slugs, :generate_widgets, :load_seed_data] do
puts "Finished Bootstrapping and converting existing data... |
class MessagesController < ApplicationController
before_action :find_message, only: [:show, :destroy]
before_action :check_user, only: :index
def new
@user = User.find_by_id(params[:artist_id])
@message = Message.new
end
def create
@message = Message.new(permit_message)
# assign the based o... |
module SessionsHelper
def sign_in(user)
remember_token = User.new_remember_token
cookies.permanent[:remember_token] = remember_token
user.update_attribute(:remember_token, User.encrypt(remember_token))
self.current_user = user
end
def signed_in?
!current_user.nil?
end
#implementi... |
# 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... |
module Cultivation
class DestroyBatch
prepend SimpleCommand
def initialize(current_user, batch_id)
@current_user = current_user,
if batch_id.nil?
raise 'Invalid batch_id'
else
@batch_id = batch_id
end
end
def call
@batch = Cultivation::Batch.find(@batch_... |
require 'rails_helper'
describe "/ticket_kinds/index.html.erb" do
include TicketKindsHelper
before(:each) do
assign(:ticket_kinds, [
create(:ticket_kind, title: "value for title", prefix: "value for prefix", template: "value for template"),
create(:ticket_kind, title: "value for title", prefix: "v... |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def twitter
callback_from :twitter
end
private
def callback_from(provider)
provider = provider.to_s
usersignedin = user_signed_in?
userself = current_user
... |
class StandingTable < ActiveRecord::Base
belongs_to :standing
belongs_to :team
before_validation :set_country_name_if_changed
private
def set_country_name_if_changed
self.team_name = Team.find(team_id).country if team_id_changed?
end
end
|
class CardSerializer < ActiveModel::Serializer
attributes :value, :dir, :location
end |
require 'factory_bot'
FactoryBot.define do
email = Faker::Internet.email
factory :comment do
body { 'Some sample text as comment' }
association :user, factory: :user, email: email
association :post, factory: :post
end
end
|
fastlane_version '2.140.0'
require_relative './common/utils'
platform :android do
desc 'Build the Android application.'
lane :build do
buildAppPath = File.expand_path("~/fl_output/{{OUTPUT_APP_FILENAME}}");
nativescriptCLICommand = ["tns", "build", "android", "--copy-to", buildAppPath];
cliCommandArgs... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :advertisement_list1, class: AdvertisementList do
state 1
sequence(:corp_ad_number){|n|n}
sequence(:pref_ad_number){|n|n}
advertisement {create(:advertisement1)}
trait :corp do
advertisement ... |
require "fog/core"
module Fog
module Brkt
extend Fog::Provider
service(:compute, "Compute")
class Mock
# Generates random id
#
# @return [String] 16 character random hex
def self.id
Fog::Mock.random_hex(16)
end
# Generates random name
#
# @return... |
require_relative('../db/crud.rb')
require_relative('./address.rb')
require_relative('./burger.rb')
require_relative('./deal.rb')
class Restaurant < Crud
attr_reader :id, :name
attr_accessor :address_id
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@address... |
class CreateCustomerDimension < ActiveRecord::Migration
def self.up
fields = {
:name => :string
}
create_table :customer_dimension do |t|
fields.each do |name,type|
t.column name, type
end
end
fields.each do |name,type|
add_index :customer_dimension, name unless ... |
require 'uns_feeder/feed'
module UnsFeeder
class Firehose
def initialize(river_list)
@rivers = river_list
end
def name
'Firehose'
end
def all_rivers
[self].concat(@rivers)
end
def destroy
raise UnsFeeder::InvalidFirehoseAction
end
def refresh
... |
class Tunewiki < Cask
url 'http://www.tunewiki.com/download/desktop/TuneWiki_Installer.dmg'
homepage 'http://www.tunewiki.com/'
version '2.1.0'
sha1 '21285dbe39af0dcc7cb9d688bdedc6786d1b6276'
end
|
class CreateBranches < ActiveRecord::Migration[5.0]
def self.up
create_table :branches do |t|
t.datetime :last_post_at
t.timestamps null: true
end
end
def self.down
drop_table :branches
end
end
|
require 'rails_helper'
RSpec.describe SchoolsController, type: :controller do
let(:valid_attributes) {
{
name: 'Crush',
address: '100 west',
principal: 'bob',
capacity: 100,
private_school: true
}
}
let(:invalid_attributes) {
{
name: '',
address: '100... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'digital_invoices#index'
resources :digital_invoices, only: [:index] do
post :upload, on: :collection
post :download, on: :member
end
end
|
class Event
include DataMapper::Resource
timestamps :at, :on
property :deleted_at, ParanoidDateTime
property :id, Serial
property :name, String, length: 100, required: true
property :start_date, DateTime, required: true
property :end_date, DateTime, required: true
property :street_ids, DecimalArray, req... |
class FavouriteController < ApplicationController
def index
@user = current_user
@favourites = @user.likes
end
end
|
module OCR4R
class BasicSegmenter
CHAR_ROW_AVERAGE = 100
CHAR_COLUMN_AVERAGE = 500
def initialize
FileUtils.mkdir_p(destination_dir)
end
def segment_word(image)
char_images = segment_chars(image)
i = 0
char_images.map do |char_image|
char_file = "#{... |
class Entry
attr_reader :author_username, :posted_at, :image_url, :profile_image_url, :text, :like_count, :url
def initialize(username, posted_at, image_url, profile_image_url, text, like_count, url)
@author_username = username
@posted_at = posted_at
@image_url = image_url
@profile_image_url = prof... |
require 'benchmark/ips'
require_relative '../lib/icmp'
current = (1..20_000).to_a
previous = current.dup
Benchmark.ips do |x|
x.report('interactive_compare') do
Icmp.compare(current, previous) do |event, cur_item, prev_item|
end
end
x.report('binary search') do
current.each do |cur_item|
pr... |
# frozen_string_literal: true
module Vedeu
module Input
# Rudimentary support for mouse interactions.
#
# @api private
#
class Mouse
# Trigger an event depending on which button was pressed.
#
# @param (see #initialize)
# @return [void]
def self.click(input)
... |
require 'spec_helper'
describe 'cacti', type: :class do
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
let :required_params do
{
'database_root_pass' => 'root_password',
'database_pass' => 'cacti_password'
}
... |
class GwordsController < ApplicationController
before_action :set_gword, only: [:show, :edit, :update, :destroy]
# GET /gwords
# GET /gwords.json
def index
@gwords = Gword.all
end
# GET /gwords/1
# GET /gwords/1.json
def show
@comments = @gword.comments.all
@comment = @gword.comments.buil... |
class SyncRequestsWorker
include Sidekiq::Worker
sidekiq_options retry: false
def initialize
end
def perform
redis_connection = RedisConnection.new
new_responses = redis_connection.all
new_responses.each do |response|
if response.url.include?("assets")
else
... |
require 'rails_helper'
RSpec.describe WeatherController, :type => :controller do
let(:client) { double(:savon_client) }
before do
allow(Savon).to receive(:client) { client }
allow(client).to receive(:call).with(:get_city_forecast_by_zip, message: { "ZIP" => "10028" }).and_return(
double(body: { get_c... |
require '../lib/queue_continuum.rb'
require 'minitest/autorun'
class TestQueue < MiniTest::Unit::TestCase
def setup
@register = Queue.new([5, 6, 7, 8])
end
def test_
assert_equal 5, @register.pop
assert_equal 6, @register.pop
assert_equal true, @register.push([4, 2])
assert_equal [7, 8], @re... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MinutesFile do
let(:minutes) do
create(:minutes_file, year: 2017, month: 9, file: File.open(test_image(200, 500), 'r'))
end
it 'has the correct number of issues' do
expect(described_class.issues.count).to be(10)
end
describe 'issu... |
class Users::WineCellar < ActiveRecord::Base
set_table_name "user_wine_cellars"
PRIVATE_TYPE_SECRET = 1
PRIVATE_TYPE_FRIEND = 2
PRIVATE_TYPE_USER = 3
PRIVATE_TYPE_PUBLIC = 4
include Users::UserSupport
belongs_to :user
has_many :items, :class_name => "Users::WineCellarItem", :foreign_key => "user_wine_... |
require 'test_helper'
class SiteTest < ActiveSupport::TestCase
should validate_presence_of :name
should validate_presence_of :author_name
should validate_presence_of :url
should belong_to :owner
should have_many :stories
should allow_mass_assignment_of :name
should allow_mass_assignment_of :auth... |
Rails.application.routes.draw do
root 'static_pages#index'
namespace :api do
defaults format: :json do
end
end
end |
Given(/^You are in the Secondary Marketing page$/) do
visit AutomationHomePage
on(LoginPage).login_yml
on(LandingPage).menus.when_present(10).click
sleep(1)
on(LandingPage).secondaryMarketing.when_present(10).click
end
And(/^you click on TSS$/) do
sleep(3)
expect(on(SecondaryMarketingPage).tSSSecondary.p... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "dsl"
s.version = "0.2.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ryan Scott Lewis"]
s.date = "2012-11-05"
s.description = "Easily create DSLs for use within your ... |
# 变形器将单词从单数转换为复数,将类名转换为表名,将模块化类名转换为不带名,将类名转换为外键。
# 复数形式,单数形式和不可数单词的默认变形会保留在inflections.rb中
require 'active_support/inflector'
require 'pading/actionview/paginator'
module Pading
module HelperMethods
def test_paginate(scope, paginator_class: Pading::Actionview::Paginator, template: nil, **options)
#... |
#
# Ruby For Kids Projects 4: Shapes
# Programmed By: Chris Haupt
# Experiment with drawing ASCII art shapes using code
#
puts "Welcome to Shapes"
print "How big do you want your shape? "
shape_size = gets
shape_size = shape_size.chomp
print "Outside letter: "
outside_letter = gets
outside_letter = outside... |
namespace :services do
desc "Start all services"
task start: :environment do
puts "starting solr"
Rake::Task['sunspot:solr:start'].execute rescue nil
puts 'starting redis'
system('redis-server /usr/local/etc/redis.conf')
port = Rails.env == :production ? 8443 : 8080
puts "starting juggernaut on po... |
require 'factory_girl'
FactoryGirl.define do
# This will guess the User class
factory :user do |u|
u.email "jdoe@stanford.edu"
u.password "foobar"
u.approved true
end
factory :not_approved, :class => User do |u|
u.email "msnotapproved@stanford.edu"
u.password "foobar"
u.approved false
... |
require_relative "../lib/cultivos/cultivo"
include RSpec
RSpec.describe Cultivo do
context Cultivo do
before (:each) do
@c1 = Cultivo.new('Cultivo1', 0.3, 12, 0.7, 0.5)
end
context "Creacion de un cultivo" do
it "Instanciar un cultivo" do
expect(@c1).not_to eq(nil)
end
it "Obtener nombre ... |
module Api
class UsersController < Api::ApplicationController
def me
render json: current_user
end
end
end
|
class Cart < ApplicationRecord
has_many :cartitems
has_many :products, through: :cartitems
validates_presence_of :email, :mailing_address, :name, :cc_number, :cc_expiration, :cc_cvv, :zip, :purchase_datetime, :if => lambda {self.status != "pending"}
validates_length_of :cc_number, minimum: 16, maximum: 16, :i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.