Skip to content

Commit

Permalink
stupid ugly and lots of crap but it works consistently nad is easy to…
Browse files Browse the repository at this point in the history
… customize so f it.
  • Loading branch information
joncalhoun committed Sep 20, 2014
1 parent 76de9c5 commit 68ec58e
Show file tree
Hide file tree
Showing 305 changed files with 4,886 additions and 510 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -1,2 +1,3 @@
--color --color
--require spec_helper
--format=d --format=d
4 changes: 0 additions & 4 deletions Gemfile
@@ -1,7 +1,3 @@
source "https://rubygems.org" 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 gemspec
83 changes: 55 additions & 28 deletions Rakefile
@@ -1,50 +1,77 @@
#!/usr/bin/env rake #!/usr/bin/env rake
# encoding: utf-8 # encoding: utf-8


begin require 'bundler'
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'

Bundler::GemHelper.install_tasks 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" RSpec::Core::RakeTask.new(:spec) do |spec|
require "rspec/core/rake_task" spec.pattern = FileList['spec/**/*_spec.rb']

end
desc "Run all specs in spec directory (excluding plugin specs)"
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')


task :default => "spec:all" task :default => "spec:all"


namespace :spec do 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}" desc "Run Tests against #{gemfile}"
task gemfile do task "#{gemfile}" do
prefix = "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' RAILS_ENV=test" Dir.chdir("test_apps/#{gemfile}")
sh "#{prefix} bundle install --quiet" puts "Testing in #{`pwd`}"
sh "#{prefix} bundle exec rake spec" 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
end end


desc "Run Tests against Postgresql" # Use existing models & install and just rake.
task :postgresql do %w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate).each do |gemfile|
prefix = "TEST_DB=postgresql BUNDLE_GEMFILE='gemfiles/postgresql.gemfile' RAILS_ENV=test" desc "Run Tests against #{gemfile}"
sh "#{prefix} bundle install --quiet" task "#{gemfile}_quick" do
sh "#{prefix} bundle exec rake db:drop db:create" Dir.chdir("test_apps/#{gemfile}")
sh "#{prefix} bundle exec rake spec" puts "Re-testing in #{`pwd`}. Bundle install and migration updates will NOT happen!"
sh "#{prefix} bundle exec rake db:drop"
# 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 end


desc "Run Tests against all ORMs" desc "Run Tests against all ORMs"
task :all do 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}" sh "rake spec:#{gemfile}"
end end
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 end
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -5,7 +5,7 @@
# TODO(jon): Move dashboards to an appropriate controller # TODO(jon): Move dashboards to an appropriate controller
get "/", as: :upmin_dashboard, controller: :models, action: :dashboard get "/", as: :upmin_dashboard, controller: :models, action: :dashboard


scope :m do scope "m" do
scope "/:klass" do scope "/:klass" do
match "/", as: :upmin_search, controller: :models, action: :search, via: [:get, :post] match "/", as: :upmin_search, controller: :models, action: :search, via: [:get, :post]


Expand Down
1 change: 1 addition & 0 deletions gemfiles/active_record_32.gemfile
Expand Up @@ -3,6 +3,7 @@ source 'https://rubygems.org'
gem 'railties', '~> 3.2.3' gem 'railties', '~> 3.2.3'
gem 'activerecord', '~> 3.2.3', :require => 'active_record' gem 'activerecord', '~> 3.2.3', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1' gem 'rspec-rails', '~> 2.14.1'
gem 'rails', '~> 3.2.3'


# Stick To Versions That Work Under Ruby 1.8 For Now # Stick To Versions That Work Under Ruby 1.8 For Now
gem 'capybara', '< 2.1' gem 'capybara', '< 2.1'
Expand Down
10 changes: 9 additions & 1 deletion gemfiles/active_record_40.gemfile
Expand Up @@ -3,7 +3,6 @@ source 'https://rubygems.org'
gem 'railties', '~> 4.0.0' gem 'railties', '~> 4.0.0'
gem 'activerecord', '~> 4.0.0', :require => 'active_record' gem 'activerecord', '~> 4.0.0', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1' gem 'rspec-rails', '~> 2.14.1'
gem 'rails', '~> 4.0.0'


platforms :ruby do platforms :ruby do
if RUBY_VERSION > "2.1.0" if RUBY_VERSION > "2.1.0"
Expand All @@ -12,5 +11,14 @@ platforms :ruby do
gem 'sqlite3', '1.3.8' gem 'sqlite3', '1.3.8'
end end
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 => '../' gemspec :path => '../'
1 change: 1 addition & 0 deletions gemfiles/active_record_41.gemfile
Expand Up @@ -3,6 +3,7 @@ source 'https://rubygems.org'
gem 'railties', '~> 4.1.0' gem 'railties', '~> 4.1.0'
gem 'activerecord', '~> 4.1.0', :require => 'active_record' gem 'activerecord', '~> 4.1.0', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1' gem 'rspec-rails', '~> 2.14.1'
gem 'rails', '~> 4.1.0'


platforms :ruby do platforms :ruby do
if RUBY_VERSION > "2.1.0" if RUBY_VERSION > "2.1.0"
Expand Down
4 changes: 3 additions & 1 deletion gemfiles/active_record_42.gemfile
Expand Up @@ -4,7 +4,9 @@ gem 'railties', '~> 4.2.0.beta1'
gem 'activerecord', '~> 4.2.0.beta1', :require => 'active_record' gem 'activerecord', '~> 4.2.0.beta1', :require => 'active_record'
gem 'rspec-rails', '~> 2.14.1' gem 'rspec-rails', '~> 2.14.1'
gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails-4.2' 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 platforms :ruby do
if RUBY_VERSION > "2.1.0" if RUBY_VERSION > "2.1.0"
Expand Down
11 changes: 0 additions & 11 deletions gemfiles/will_paginate.gemfile
Expand Up @@ -12,16 +12,5 @@ platforms :ruby do
gem 'sqlite3', '1.3.8' gem 'sqlite3', '1.3.8'
end end
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 => '../' gemspec :path => '../'
2 changes: 2 additions & 0 deletions lib/upmin/admin.rb
Expand Up @@ -22,6 +22,8 @@
# If WillPaginate is present we just use it, but by default upmin-admin uses Kaminari # If WillPaginate is present we just use it, but by default upmin-admin uses Kaminari
require "kaminari" unless defined?(WillPaginate) require "kaminari" unless defined?(WillPaginate)


require 'rails'

module Upmin module Upmin
module Admin module Admin
end end
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions seed/order_seeder.rb
@@ -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
26 changes: 26 additions & 0 deletions seed/product_seeder.rb
@@ -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 class UserSeeder
def UserSeeder.seed def UserSeeder.seed
Expand Down
10 changes: 0 additions & 10 deletions spec/dummy/config/boot.rb

This file was deleted.

28 changes: 0 additions & 28 deletions spec/dummy/config/database.yml

This file was deleted.

3 changes: 0 additions & 3 deletions spec/dummy/config/environments/development.rb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/dummy/config/environments/test.rb

This file was deleted.

16 changes: 0 additions & 16 deletions spec/dummy/db/schema.rb

This file was deleted.

0 comments on commit 68ec58e

Please sign in to comment.