code
stringlengths
1
1.73M
language
stringclasses
1 value
require 'will_paginate' class ItemsController < ApplicationController before_filter :except => [:item_attributes, :comments, :cap_color, :by_barcode, :bag_contents_by_barcode, :bag_contents, :show, :barcode, :lookup, :update] do |controller| controller.authorize_permissions({:blocked_permissions => ["courier"]}...
Ruby
class ChecklistItemInstancesController < ApplicationController # GET /checklist_item_instances # GET /checklist_item_instances.json def index @checklist_item_instances = ChecklistItemInstance.all respond_to do |format| format.html # index.html.erb format.json { render :json => @checklist_ite...
Ruby
# 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::RequestForgeryP...
Ruby
class StopsController < ApplicationController # GET /stops # GET /stops.json def index @stops = Stop.all respond_to do |format| format.html # index.html.erb format.json { render :json => @stops } end end # GET /stops/1 # GET /stops/1.json def show @stop = Stop.find(params[:i...
Ruby
class ChecklistItemsController < ApplicationController # GET /checklist_items # GET /checklist_items.json def index @checklist_items = ChecklistItem.all respond_to do |format| format.html # index.html.erb format.json { render :json => @checklist_items } end end # GET /checklist_item...
Ruby
class UsersController < ApplicationController before_filter :except => [:edit, :update, :show, :logged_in] do |controller| controller.authorize_permissions({:blocked_permissions => (User::PermissionLevels - ["admin", "supervisor"])}) end def logged_in @courier = @current_user.courier respond_t...
Ruby
class ItemTypesController < ApplicationController # GET /item_types # GET /item_types.json def index @item_types = ItemType.all respond_to do |format| format.html # index.html.erb format.json { render :json => @item_types } end end # GET /item_types/1 # GET /item_types/1.json de...
Ruby
class ChecklistInstancesController < ApplicationController # GET /checklist_instances # GET /checklist_instances.json def index @checklist_instances = ChecklistInstance.all respond_to do |format| format.html # index.html.erb format.json { render :json => @checklist_instances } end end ...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
class CreateAttributeValues < ActiveRecord::Migration def self.up create_table :attribute_values do |t| t.integer :item_id t.string :value t.integer :attribute_id t.timestamps end end def self.down drop_table :attribute_values end end
Ruby
class CreateStops < ActiveRecord::Migration def self.up create_table :stops do |t| t.integer :stop_number t.time :timeframe_low t.time :timeframe_high t.integer :location_id t.string :notes t.integer :route_id t.timestamps end end def self.down drop_table :s...
Ruby
class CreateChecklistItemInstances < ActiveRecord::Migration def self.up create_table :checklist_item_instances do |t| t.boolean :done t.string :task_text t.integer :checklist_item_id t.integer :checklist_instance_id t.int :item_number t.timestamps end end def self.do...
Ruby
class CreateAttributeSets < ActiveRecord::Migration def self.up create_table :attribute_sets do |t| t.boolean :hidden t.boolean :mutually_exclusive t.string :name t.boolean :required t.timestamps end end def self.down drop_table :attribute_sets end end
Ruby
class AddRealNameToUsers < ActiveRecord::Migration def self.up add_column :users, :real_name, :string end def self.down remove_column :users, :real_name end end
Ruby
class ChangeUsersContactInfoFields < ActiveRecord::Migration def self.up change_table :users do |t| t.remove :contact_info t.string :email t.string :phone_number end end def self.down change_table :users do |t| t.string :contact_info t.remove :email t.remove :phone_number end end en...
Ruby
class AddDefaults < ActiveRecord::Migration def self.up change_column_default :check_ins, :hidden, false change_column_default :checklist_item_instances, :done, false change_column_default :checklist_recurrence_rules, :days_ahead, 0 change_column_default :couriers, :active, false ...
Ruby
class AddCarriedByAndRenameParentToItems < ActiveRecord::Migration def self.up add_column :items, :carried_by_id, :integer rename_column :items, :parent_id, :replaced_id end def self.down rename_column :items, :replaced_id, :parent_id remove_column :items, :carried_by_id end end
Ruby
class CreateChecklistInstances < ActiveRecord::Migration def self.up create_table :checklist_instances do |t| t.integer :courier_id t.date :day t.integer :checklist_id t.timestamps end end def self.down drop_table :checklist_instances end end
Ruby
class ChangeUserPermissionLevelToStringEnum < ActiveRecord::Migration def self.up change_column :users, :permission_level, :string end def self.down change_column :users, :permission_level, :int end end
Ruby
class AddDefaultResolvedToFalseForLostItem < ActiveRecord::Migration def self.up change_column_default :lost_items, :resolved, false end def self.down change_column_default :lost_items, :resolved, nil end end
Ruby
class AddPasswordSaltToUsers < ActiveRecord::Migration def self.up add_column :users, :password_salt, :string end def self.down remove_column :users, :password_salt end end
Ruby
class AddHiddenToChecklists < ActiveRecord::Migration def self.up add_column :checklists, :hidden, :boolean, :default => false end def self.down remove_column :checklists, :hidden end end
Ruby
class CreateChecklists < ActiveRecord::Migration def self.up create_table :checklists do |t| t.timestamps end end def self.down drop_table :checklists end end
Ruby
class ChangeDefaultOfRouteNotes < ActiveRecord::Migration def self.up change_column_default :routes, :notes, '' end def self.down change_column_default :routes, :notes, nil end end
Ruby
class AddDisplayColorToItemAttribute < ActiveRecord::Migration def self.up add_column :item_attributes, :display_color, :string end def self.down remove_column :item_attributes, :display_color end end
Ruby
class AddTextToComments < ActiveRecord::Migration def self.up add_column :comments, :text, :string end def self.down remove_column :comments, :text end end
Ruby
class RemoveDaysAheadFromRouteRecurrenceRules < ActiveRecord::Migration def self.up remove_column :route_recurrence_rules, :days_ahead end def self.down add_column :route_recurrence_rules, :days_ahead, :int, :default => 0 end end
Ruby
class FixAllTheBrokenUsers < ActiveRecord::Migration def self.up remove_column :users, :real_name add_column :users, :real_name, :string end def self.down add_column :users, :real_name, :String remove_column :users, :real_name end end
Ruby
class CreateCheckIns < ActiveRecord::Migration def self.up create_table :check_ins do |t| t.boolean :hidden t.integer :item_id t.user :user_id t.integer :location_id t.timestamps end end def self.down drop_table :check_ins end end
Ruby
class RenameAttributesToItemAttributes < ActiveRecord::Migration def self.up rename_table :attributes, :item_attributes rename_table :attribute_values, :item_attribute_values rename_table :attribute_sets, :item_attribute_sets rename_column :item_attributes, :attribute_set_id, :item_attribute_set_...
Ruby
class CreateLocations < ActiveRecord::Migration def self.up create_table :locations do |t| t.string :name t.string :address t.string :details t.boolean :hidden t.timestamps end end def self.down drop_table :locations end end
Ruby
class RemoveDaysAheadFromChecklistRecurrenceRules < ActiveRecord::Migration def self.up remove_column :checklist_recurrence_rules, :days_ahead end def self.down add_column :checklist_recurrence_rules, :days_ahead, :int, :default => 0 end end
Ruby
class CreateRoutes < ActiveRecord::Migration def self.up create_table :routes do |t| t.string :notes t.string :name t.timestamps end end def self.down drop_table :routes end end
Ruby
class CreateItems < ActiveRecord::Migration def self.up create_table :items do |t| t.boolean :is_container t.integer :item_type_id t.boolean :hidden t.integer :parent_id t.integer :destination_id t.integer :user_id t.boolean :locked t.timestamps end end de...
Ruby
class CreateStopInstances < ActiveRecord::Migration def self.up create_table :stop_instances do |t| t.integer :stop_number t.boolean :visited t.time :timeframe_low t.time :timeframe_high t.integer :location_id t.string :notes t.integer :route_instance_id t.integer :...
Ruby
class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.integer :item_id t.integer :user_id t.timestamps end end def self.down drop_table :comments end end
Ruby
class AddItemNumberToChecklistItemInstances < ActiveRecord::Migration def self.up add_column :checklist_item_instances, :item_number, :integer end def self.down remove_column :checklist_item_instances, :item_number end end
Ruby
class CreateChecklistRecurrenceRules < ActiveRecord::Migration def self.up create_table :checklist_recurrence_rules do |t| t.integer :courier_id t.integer :checklist_id t.string :days t.integer :days_ahead t.timestamps end end def self.down drop_table :checklist_recurre...
Ruby
class AddActionsToCheckIns < ActiveRecord::Migration def self.up add_column :check_ins, :action, :string end def self.down remove_column :check_ins, :action end end
Ruby
class CreateChecklistItems < ActiveRecord::Migration def self.up create_table :checklist_items do |t| t.string :task_text t.integer :item_number t.integer :checklist_id t.timestamps end end def self.down drop_table :checklist_items end end
Ruby
class CreateItemTypes < ActiveRecord::Migration def self.up create_table :item_types do |t| t.boolean :hidden t.string :type t.timestamps end end def self.down drop_table :item_types end end
Ruby
class MoveIsContainerFromItemToItemType < ActiveRecord::Migration def self.up remove_column :items, :is_container add_column :item_types, :is_container, :boolean end def self.down remove_column :item_types, :is_container add_column :items, :is_container, :boolean end end
Ruby
class AddDescriptionToItemAttributeSet < ActiveRecord::Migration def self.up add_column :item_attribute_sets, :description, :string end def self.down remove_column :item_attribute_sets, :description end end
Ruby
class ChangeUserIdToClientIdInItems < ActiveRecord::Migration def self.up rename_column :items, :user_id, :client_id end def self.down rename_column :items, :client_id, :user_id end end
Ruby
class AddHiddenToRoutes < ActiveRecord::Migration def self.up add_column :routes, :hidden, :boolean, :default => false end def self.down remove_column :routes, :hidden end end
Ruby
class ChangeLocationHiddenDefaultToFalse < ActiveRecord::Migration def self.up change_column_default :locations, :hidden, false end def self.down change_column_default :locations, :hidden, true end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :account_name t.string :contact_info t.integer :location_id t.string :password_hash t.integer :permission_level t.String :real_name t.timestamps end end def self.down ...
Ruby
class AddInheritsContainerToItemAttributeSet < ActiveRecord::Migration def self.up add_column :item_attribute_sets, :inherits_from_container, :boolean, :default => false end def self.down remove_column :item_attribute_sets, :inherits_from_container end end
Ruby
class CreateRouteInstances < ActiveRecord::Migration def self.up create_table :route_instances do |t| t.date :day t.integer :courier_id t.integer :route_id t.timestamps end end def self.down drop_table :route_instances end end
Ruby
class AddUserIdToCheckIns < ActiveRecord::Migration def self.up add_column :check_ins, :user_id, :integer end def self.down remove_column :check_ins, :user_id end end
Ruby
class AddNameToChecklists < ActiveRecord::Migration def self.up add_column :checklists, :name, :string end def self.down remove_column :checklists, :name end end
Ruby
class CreateLostItems < ActiveRecord::Migration def self.up create_table :lost_items do |t| t.integer :item_id t.string :comment t.boolean :resolved t.timestamps end end def self.down drop_table :lost_items end end
Ruby
class AddContainedByIdToItems < ActiveRecord::Migration def self.up add_column :items, :contained_by_id, :integer end def self.down remove_column :items, :contained_by_id end end
Ruby
class CreateAttributes < ActiveRecord::Migration def self.up create_table :attributes do |t| t.integer :attribute_set_id t.string :display_text t.boolean :hidden t.boolean :verify_on_scan t.timestamps end end def self.down drop_table :attributes end end
Ruby
class RenameItemTypesTypeColumn < ActiveRecord::Migration def self.up rename_column :item_types, :type, :item_type end def self.down rename_column :item_types, :item_type, :type end end
Ruby
class AddInstantiatedByToRouteInstances < ActiveRecord::Migration def self.up add_column :route_instances, :instantiated_by_id, :integer end def self.down remove_column :route_instances, :instantiated_by_id end end
Ruby
class AddSourceIdToItems < ActiveRecord::Migration def self.up add_column :items, :source_id, :integer end def self.down remove_column :items, :source_id end end
Ruby
class CreateIdentifiers < ActiveRecord::Migration def self.up create_table :identifiers do |t| t.string :identifier_type t.string :identifier_value t.integer :item_id t.timestamps end end def self.down drop_table :identifiers end end
Ruby
class CreateRouteRecurrenceRules < ActiveRecord::Migration def self.up create_table :route_recurrence_rules do |t| t.integer :courier_id t.integer :route_id t.string :days t.integer :days_ahead t.timestamps end end def self.down drop_table :route_recurrence_rules end ...
Ruby
class CreateCouriers < ActiveRecord::Migration def self.up create_table :couriers do |t| t.boolean :active t.decimal :latest_lat t.decimal :latest_long t.integer :user_id t.timestamps end end def self.down drop_table :couriers end end
Ruby
class AddChecklistTypeToChecklists < ActiveRecord::Migration def self.up add_column :checklists, :checklist_type, :string end def self.down remove_column :checklists, :checklist_type end end
Ruby
class AddDeliveryStatusFieldsToItems < ActiveRecord::Migration def self.up change_table :items do |t| t.boolean :delivered, :default => false t.boolean :picked_up, :default => false end end def self.down remove_column :items, :delivered remove_column :items, :picked_up end end
Ruby
# 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' }]) # Major.create(:name...
Ruby
# So that we have some realistic data # http://uwmedicine.washington.edu/Patient-Care/Locations/Pages/default.aspx Location.create([ { :name => 'Harborview Medical Center', :address => '325 Ninth Ave., Seattle, WA 98104' }, { :name => 'UW Medical Center at Roosevelt', :address =>...
Ruby
# This contains seed data to load for the system. :defaults is run for each # environment and test loads lots of data that previously was in fixtures. Bootstrapper.for :defaults do |b| b.truncate_tables :locations, :users, :item_attribute_sets, :item_attributes, :item_attribute_values, :item_typ...
Ruby
require 'rcov/rcovtask' Rcov::RcovTask.new do |t| t.test_files = FileList['test/unit/*.rb'] + FileList['test/functional/*.rb'] t.rcov_opts = ['--rails', '-x /var/lib', '--text-report', '--sort coverage'] t.output_dir = 'doc/coverage' t.libs << "test" t.verbose = true end
Ruby
module IntegrationHelper def valid_user_credentials(params = {}) User.new({ :account_name => 'admin', :password => 'password' }.merge(params)) end def setup_user(params = {}) user = User.new({ :account_name => 'roviler', :password => 'pass123', :location_i...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' require 'fixtures_helper' class ActiveSupport::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This en...
Ruby
require 'rubygems' require 'selenium-webdriver' begin driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => :firefox driver.get "http://www.google.com" driver.save_screenshot "/Screenshots/google.png" ensure driver.quit end
Ruby
require 'rubygems' # not required for ruby 1.9 or if you installed without gem require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.manage.timeouts.implicit_wait = 10 # seconds driver.get "http://somedomain/url_that_delays_loading" element = driver.find_element(:id => "some-dynamic-element")
Ruby
require 'rubygems' # not required for ruby 1.9 or if you installed without gem require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.get "http://somedomain/url_that_delays_loading" wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds begin element = wait.until { driver.find_element...
Ruby
require 'rubygems' require 'selenium-webdriver' PROXY = "localhost:8080" proxy = Selenium::WebDriver::Proxy.new( :http => PROXY, :ftp => PROXY, :ssl => PROXY ) caps = Selenium::WebDriver::Remote::Capabilities.ie(:proxy => proxy) # you have to use remote, otherwise you'll have to code it yoursel...
Ruby
require 'rubygems' require 'selenium-webdriver' PROXY = 'localhost:8087' profile = Selenium::WebDriver::Firefox::Profile.new profile.proxy = Selenium::WebDriver::Proxy.new( :http => PROXY, :ftp => PROXY, :ssl => PROXY ) driver = Selenium::WebDriver.for :firefox, :profile => profile
Ruby
driver = Selenium::WebDriver.for :chrome
Ruby
driver = Selenium::WebDriver.for :ie
Ruby
driver = Selenium::WebDriver.for :firefox
Ruby
driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => :htmlunit
Ruby
require 'rubygems' require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.get "http://google.com" element = driver.find_element :name => "q" element.send_keys "Cheese!" element.submit puts "Page title is #{driver.title}" wait = Selenium::WebDriver::Wait.new(:timeout => 10) wait.u...
Ruby
require 'fileutils' commons = Dir.glob("C:/dev/src/RhinoCommons/rhino-commons/Rhino.Commons/bin/Debug/*.dll") + ["C:/dev/src/RhinoCommons/rhino-commons/Rhino.Commons.ActiveRecord/bin/Debug/Castle.ActiveRecord.dll", "C:/dev/src/RhinoCommons/rhino-commons/Rhino.Commons.ActiveRecord/bin/Debug/Castle.Component...
Ruby
class CreateZcjs < ActiveRecord::Migration def self.up create_table :zcjs do |t| t.string :title #注册码标题 t.text :filename #下载文件名 t.integer :filesize,:default=>0 #文件大小 t.string :letter,:limit=>1 #首字母 t.boole...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name,:limit=>20 #名字 t.string :password,:limit=>20 #密码 t.string :email,:limit=>40 #email t.integer :login_num,:default=>0 #登录次数 t.integer :zcm_num,:defa...
Ruby
class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.integer :parent_id #所属评论的id t.text :content #注册码内容 t.integer :floor #楼层 t.integer :comment_type #评论种类 1=>注册码 ...
Ruby
class CreateZcms < ActiveRecord::Migration def self.up create_table :zcms do |t| t.string :title #注册码标题 t.text :content #注册码内容 t.string :letter,:limit=>1 #首字母 t.boolean :islock,:default=>false #是否显示 t.string :ip ,:lim...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!C:/ruby/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!C:/ruby/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby