Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stupid ugly and lots of crap but it works consistently nad is easy to…
… customize so f it.
- Loading branch information
1 parent
76de9c5
commit 68ec58e
Showing
305 changed files
with
4,886 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,3 @@ | |||
--color | --color | ||
--require spec_helper | |||
--format=d | --format=d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
2 changes: 1 addition & 1 deletion
2
...ps/active_record/test_data/user_seeder.rb → seed/user_seeder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.