Permalink
Browse files

stupid ugly and lots of crap but it works consistently nad is easy to…

… customize so f it.
  • Loading branch information...
joncalhoun committed Sep 20, 2014
1 parent 76de9c5 commit 68ec58efeedce9bb9b3e9afc5ec00cb6506a8739
Showing 305 changed files with 4,886 additions and 510 deletions.
View
1 .rspec
@@ -1,2 +1,3 @@
--color
--require spec_helper
--format=d
View
@@ -1,7 +1,3 @@
source "https://rubygems.org"
# This can be commented out if you aren't testing the postgresql version. No idea
# why it is required when i have the gem in the postgresql.gemfile.. so annoyed.
gem 'pg'
gemspec
View
@@ -1,50 +1,77 @@
#!/usr/bin/env rake
# encoding: utf-8
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
require 'bundler'
Bundler::GemHelper.install_tasks
Dir[File.join(File.dirname(__FILE__), "tasks/**/*.rake")].each {|f| load f }
require 'rspec/core'
require 'rspec/core/rake_task'
require "rspec/core"
require "rspec/core/rake_task"
desc "Run all specs in spec directory (excluding plugin specs)"
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => "spec:all"
namespace :spec do
%w(active_record_42 active_record_41 active_record_40 active_record_32 will_paginate).each do |gemfile|
# Full bundle install & test.
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate).each do |gemfile|
desc "Run Tests against #{gemfile}"
task gemfile do
prefix = "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' RAILS_ENV=test"
sh "#{prefix} bundle install --quiet"
sh "#{prefix} bundle exec rake spec"
task "#{gemfile}" do
Dir.chdir("test_apps/#{gemfile}")
puts "Testing in #{`pwd`}"
sh "bundle install --quiet"
sh "bundle update --quiet"
# Drop migrations and recreate
sh "rm -rf db/migrate/*"
sh "bundle exec rake railties:install:migrations --quiet"
if gemfile == "active_record_32"
sh "bundle exec rake db:drop db:create db:migrate --quiet"
end
sh "RAILS_ENV=test bundle exec rake db:drop db:create db:migrate --quiet"
# Drop and reload spec files
sh "rm -rf spec/"
sh "cp -R ../../spec spec"
sh "cp ../../.rspec .rspec"
# Run tests
sh "bundle exec rake"
end
end
desc "Run Tests against Postgresql"
task :postgresql do
prefix = "TEST_DB=postgresql BUNDLE_GEMFILE='gemfiles/postgresql.gemfile' RAILS_ENV=test"
sh "#{prefix} bundle install --quiet"
sh "#{prefix} bundle exec rake db:drop db:create"
sh "#{prefix} bundle exec rake spec"
sh "#{prefix} bundle exec rake db:drop"
# Use existing models & install and just rake.
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate).each do |gemfile|
desc "Run Tests against #{gemfile}"
task "#{gemfile}_quick" do
Dir.chdir("test_apps/#{gemfile}")
puts "Re-testing in #{`pwd`}. Bundle install and migration updates will NOT happen!"
# Drop and reload spec files
sh "rm -rf spec/"
sh "cp -R ../../spec spec"
sh "cp ../../.rspec .rspec"
# Run tests
sh "bundle exec rake"
end
end
desc "Run Tests against all ORMs"
task :all do
%w(active_record_42 active_record_41 active_record_40 active_record_32 will_paginate postgresql).each do |gemfile|
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate).each do |gemfile|
sh "rake spec:#{gemfile}"
end
end
desc "Run Tests against all ORMs"
task :all_quick do
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate).each do |gemfile|
sh "rake spec:#{gemfile}_quick"
end
end
end
View
@@ -5,7 +5,7 @@
# TODO(jon): Move dashboards to an appropriate controller
get "/", as: :upmin_dashboard, controller: :models, action: :dashboard
scope :m do
scope "m" do
scope "/:klass" do
match "/", as: :upmin_search, controller: :models, action: :search, via: [:get, :post]
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
gem 'railties', '~> 3.2.3'
gem 'activerecord', '~> 3.2.3', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1'
gem 'rails', '~> 3.2.3'
# Stick To Versions That Work Under Ruby 1.8 For Now
gem 'capybara', '< 2.1'
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
gem 'railties', '~> 4.0.0'
gem 'activerecord', '~> 4.0.0', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1'
gem 'rails', '~> 4.0.0'
platforms :ruby do
if RUBY_VERSION > "2.1.0"
@@ -12,5 +11,14 @@ platforms :ruby do
gem 'sqlite3', '1.3.8'
end
end
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
end
platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'racc'
gem 'rubysl-test-unit'
gem 'rubinius-developer_tools'
end
gemspec :path => '../'
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
gem 'railties', '~> 4.1.0'
gem 'activerecord', '~> 4.1.0', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1'
gem 'rails', '~> 4.1.0'
platforms :ruby do
if RUBY_VERSION > "2.1.0"
@@ -4,7 +4,9 @@ gem 'railties', '~> 4.2.0.beta1'
gem 'activerecord', '~> 4.2.0.beta1', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1'
gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails-4.2'
gem 'rails', '~> 4.2.0.beta1'
gem 'sprockets-rails', '~> 3.0.0.beta1'
gem 'sass-rails', '~> 5.0.0.beta1'
platforms :ruby do
if RUBY_VERSION > "2.1.0"
@@ -12,16 +12,5 @@ platforms :ruby do
gem 'sqlite3', '1.3.8'
end
end
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
end
platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'racc'
gem 'minitest'
gem 'rubinius-developer_tools'
end
gemspec :path => '../'
View
@@ -22,6 +22,8 @@
# If WillPaginate is present we just use it, but by default upmin-admin uses Kaminari
require "kaminari" unless defined?(WillPaginate)
require 'rails'
module Upmin
module Admin
end
File renamed without changes.
View
@@ -0,0 +1,41 @@
# Dir["#{File.dirname(__FILE__)}/../models/*.rb"].each { |f| require f }
class OrderSeeder
def OrderSeeder.seed
(1..200).each do |i|
user = User.find(rand(User.count) + 1)
order = Order.new
order.user = user
order.save!
num_products = rand(4) + 1
(1..num_products).each do |k|
quantity = rand(4) + 1
product = Product.find(rand(Product.count) + 1)
po = ProductOrder.new
po.order = order
po.product = product
po.quantity = quantity
po.purchase_price = product.price
po.save!
end
shipment = Shipment.new
shipment.order = order
shipment.price = (rand(1000) / 100.0) + 10.0
shipment.carrier = [:ups, :usps, :fedex, :dhl][rand(4)]
shipment.delivered = [true, true, false][rand(3)]
shipment.est_delivery_date = random_date
shipment.save!
end
end
def OrderSeeder.random_date(ago = 60, from_now = 20)
ago = (0..ago).to_a.map{|i| i.days.ago}
from_now = (1..from_now).to_a.map{|i| i.days.ago}
all = ago + from_now
return all[rand(all.length)]
end
end
View
@@ -0,0 +1,26 @@
# Dir["#{File.dirname(__FILE__)}/../models/*.rb"].each { |f| require f }
class ProductSeeder
def ProductSeeder.seed
file = File.new("#{File.dirname(__FILE__)}/products.json")
json_array = JSON.parse(File.read(file))
json_array.each_with_index do |json_product, index|
break if index >= 100
product = Product.new
product.name = json_product["name"]
product.short_desc = json_product["shortDescription"]
product.best_selling_rank = json_product["bestSellingRank"]
product.thumbnail = json_product["thumbnailImage"]
product.price = json_product["salePrice"]
product.manufacturer = json_product["manufacturer"]
product.url = json_product["url"]
product.product_type = json_product["type"]
product.image = json_product["image"]
product.category = json_product["category"]
product.free_shipping = !json_product["shipping"].nil?
product.save
end
end
end
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
Dir["#{File.dirname(__FILE__)}/../models/*.rb"].each { |f| require f }
# Dir["#{File.dirname(__FILE__)}/../models/*.rb"].each { |f| require f }
class UserSeeder
def UserSeeder.seed
View
@@ -1,10 +0,0 @@
require 'rubygems'
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
end
$:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,28 +0,0 @@
sqlite: &sqlite
adapter: sqlite3
database: db/<%= Rails.env %>.sqlite3
mysql: &mysql
adapter: mysql2
username: root
password:
database: upmin_admin_<%= Rails.env %>
postgresql: &postgresql
adapter: postgresql
username: <%= `whoami`.strip %>
password:
database: upmin_admin_<%= Rails.env %>
encoding: unicode
defaults: &defaults
pool: 5
timeout: 5000
host: localhost
<<: *<%= ENV['TEST_DB'] || "sqlite" %>
development:
<<: *defaults
test:
<<: *defaults
@@ -1,3 +0,0 @@
Dummy::Application.configure do
end
@@ -1,3 +0,0 @@
Dummy::Application.configure do
config.eager_load = false
end
View
@@ -1,16 +0,0 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 0) do
end
Oops, something went wrong.

0 comments on commit 68ec58e

Please sign in to comment.