diff --git a/.rspec b/.rspec index 1bc9984..b6d0b2a 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --color +--require spec_helper --format=d diff --git a/Gemfile b/Gemfile index 88050e5..b4e2a20 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Rakefile b/Rakefile index 57fd423..b6041c9 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 41a2622..3118e27 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/gemfiles/active_record_32.gemfile b/gemfiles/active_record_32.gemfile index 3234c79..9a6e21a 100644 --- a/gemfiles/active_record_32.gemfile +++ b/gemfiles/active_record_32.gemfile @@ -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' diff --git a/gemfiles/active_record_40.gemfile b/gemfiles/active_record_40.gemfile index 53ef30d..aae97ff 100644 --- a/gemfiles/active_record_40.gemfile +++ b/gemfiles/active_record_40.gemfile @@ -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 => '../' diff --git a/gemfiles/active_record_41.gemfile b/gemfiles/active_record_41.gemfile index 81b0467..7c8cf89 100644 --- a/gemfiles/active_record_41.gemfile +++ b/gemfiles/active_record_41.gemfile @@ -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" diff --git a/gemfiles/active_record_42.gemfile b/gemfiles/active_record_42.gemfile index 9f0b63e..b10e462 100644 --- a/gemfiles/active_record_42.gemfile +++ b/gemfiles/active_record_42.gemfile @@ -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" diff --git a/gemfiles/will_paginate.gemfile b/gemfiles/will_paginate.gemfile index 73687ef..e8f7bfa 100644 --- a/gemfiles/will_paginate.gemfile +++ b/gemfiles/will_paginate.gemfile @@ -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 => '../' diff --git a/lib/upmin/admin.rb b/lib/upmin/admin.rb index 5044a7b..59591fc 100644 --- a/lib/upmin/admin.rb +++ b/lib/upmin/admin.rb @@ -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 diff --git a/spec/setups/active_record/test_data/names.json b/seed/names.json similarity index 100% rename from spec/setups/active_record/test_data/names.json rename to seed/names.json diff --git a/seed/order_seeder.rb b/seed/order_seeder.rb new file mode 100644 index 0000000..eb60720 --- /dev/null +++ b/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 diff --git a/seed/product_seeder.rb b/seed/product_seeder.rb new file mode 100644 index 0000000..a19dc9b --- /dev/null +++ b/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 diff --git a/spec/setups/active_record/test_data/products.json b/seed/products.json similarity index 100% rename from spec/setups/active_record/test_data/products.json rename to seed/products.json diff --git a/spec/setups/active_record/test_data/seeder.rb b/seed/seeder.rb similarity index 100% rename from spec/setups/active_record/test_data/seeder.rb rename to seed/seeder.rb diff --git a/spec/setups/active_record/test_data/user_seeder.rb b/seed/user_seeder.rb similarity index 93% rename from spec/setups/active_record/test_data/user_seeder.rb rename to seed/user_seeder.rb index c13b243..49807d1 100644 --- a/spec/setups/active_record/test_data/user_seeder.rb +++ b/seed/user_seeder.rb @@ -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 diff --git a/spec/dummy/config/boot.rb b/spec/dummy/config/boot.rb deleted file mode 100644 index eba0681..0000000 --- a/spec/dummy/config/boot.rb +++ /dev/null @@ -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__) \ No newline at end of file diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml deleted file mode 100644 index 339fa04..0000000 --- a/spec/dummy/config/database.yml +++ /dev/null @@ -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 diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb deleted file mode 100644 index a70ba99..0000000 --- a/spec/dummy/config/environments/development.rb +++ /dev/null @@ -1,3 +0,0 @@ -Dummy::Application.configure do - -end diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb deleted file mode 100644 index 1d96880..0000000 --- a/spec/dummy/config/environments/test.rb +++ /dev/null @@ -1,3 +0,0 @@ -Dummy::Application.configure do - config.eager_load = false -end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb deleted file mode 100644 index 4dfbb16..0000000 --- a/spec/dummy/db/schema.rb +++ /dev/null @@ -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 diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb new file mode 100644 index 0000000..3ef32ef --- /dev/null +++ b/spec/features/search_spec.rb @@ -0,0 +1,79 @@ +# encoding: UTF-8 +require 'spec_helper' + +feature('Search') do + background do + # Setup BG Stuff + end + + scenario("pagination") do + visit('/upmin/m/User') + + page.save_and_open_page + + # Make sure some basic pagination exits + within('.pagination') do + within('.current') do + expect(page).to(have_content('1')) + end + + expect(page).to(have_content('Next')) + click_link('Next') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('2')) + end + + expect(page).to(have_content('Next')) + expect(page).to(have_content('Prev')) + + click_link('3') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('3')) + end + end + end + + scenario("Search via integer") do + visit('/upmin/m/Order') + + expect(page).to(have_selector('a.search-result-link', count: 30)) + + fill_in("q_id_gteq", with: 1) + fill_in("q_id_lteq", with: 5) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', count: 5)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + +end diff --git a/spec/setups/active_record/migrate/all_tables.rb b/spec/setups/active_record/migrate/all_tables.rb deleted file mode 100644 index 475a5e7..0000000 --- a/spec/setups/active_record/migrate/all_tables.rb +++ /dev/null @@ -1,113 +0,0 @@ -class CreateProducts < ActiveRecord::Migration - def self.up - create_table :products do |t| - t.string :name - t.text :short_desc - t.integer :best_selling_rank - t.string :thumbnail - t.decimal :price - t.string :manufacturer - t.string :url - t.string :product_type - t.string :image - t.string :category - t.boolean :free_shipping - - t.timestamps - end - end - - def self.down - drop_table :products - end -end - -class CreateUsers < ActiveRecord::Migration - def self.up - create_table :users do |t| - t.string :name - t.string :email - t.string :stripe_card_id - t.boolean :stripe_card_id - - t.timestamps - end - end - - def self.down - drop_table :users - end -end - -class CreateOrders < ActiveRecord::Migration - def self.up - create_table :orders do |t| - t.integer :user_id - t.string :stripe_charge_id - t.string :stripe_refund_id - - t.timestamps - end - end - - def self.down - drop_table :orders - end -end - -class CreateProductOrders < ActiveRecord::Migration - def self.up - create_table :product_orders do |t| - t.integer :product_id - t.integer :order_id - t.integer :quantity - t.decimal :purchase_price - - t.timestamps - end - end - - def self.down - drop_table :product_orders - end -end - -class CreateShipments < ActiveRecord::Migration - def self.up - create_table :shipments do |t| - t.integer :order_id - t.decimal :price - t.string :carrier - t.string :tracking_code - t.boolean :delivered - t.datetime :est_delivery_date - - t.timestamps - end - end - - def self.down - drop_table :shipments - end -end - -class AllTables - def self.up - CreateProducts.up - CreateUsers.up - CreateOrders.up - CreateProductOrders.up - CreateShipments.up - end - - def self.down - CreateProducts.down - CreateUsers.down - CreateOrders.down - CreateProductOrders.down - CreateShipments.down - end - -end - -ActiveRecord::Migration.verbose = false diff --git a/spec/setups/active_record/models/order.rb b/spec/setups/active_record/models/order.rb deleted file mode 100644 index 218a5db..0000000 --- a/spec/setups/active_record/models/order.rb +++ /dev/null @@ -1,42 +0,0 @@ -# == Schema Information -# -# Table name: orders -# -# id :integer not null, primary key -# user_id :integer -# stripe_charge_id :string(255) -# created_at :datetime -# updated_at :datetime -# - -class Order < ActiveRecord::Base - has_many :product_orders - has_many :products, through: :product_orders - has_one :shipment - belongs_to :user - - upmin_attribute :total_cost - - def total_cost - return @total_cost if @total_cost - - @total_cost = 0.0 - product_orders.each do |product_order| - @total_cost += product_order.quantity * product_order.purchase_price - end - @total_cost += shipment.price if shipment - return @total_cost - end - - def issue_refund(amount = total_cost) - amount = BigDecimal.new(amount) if amount.is_a?(String) - amount_cents = (amount * 100).to_i - return amount - end - - def create_return_shipping_label - # Do some work to create a return label - return "http://assets.geteasypost.com/postage_labels/labels/lUoagDx.png" - end - -end diff --git a/spec/setups/active_record/models/product.rb b/spec/setups/active_record/models/product.rb deleted file mode 100644 index 0d7bd4c..0000000 --- a/spec/setups/active_record/models/product.rb +++ /dev/null @@ -1,26 +0,0 @@ -# == Schema Information -# -# Table name: products -# -# id :integer not null, primary key -# name :string(255) -# short_desc :text -# best_selling_rank :integer -# thumbnail :string(255) -# price :decimal(, ) -# manufacturer :string(255) -# url :string(255) -# product_type :string(255) -# image :string(255) -# category :string(255) -# free_shipping :boolean -# created_at :datetime -# updated_at :datetime -# - -class Product < ActiveRecord::Base - has_many :product_orders - has_many :orders, through: :product_orders - - upmin_attributes :name, :short_desc, :price, :manufacturer, :free_shipping -end diff --git a/spec/setups/active_record/models/product_order.rb b/spec/setups/active_record/models/product_order.rb deleted file mode 100644 index 5569f2b..0000000 --- a/spec/setups/active_record/models/product_order.rb +++ /dev/null @@ -1,17 +0,0 @@ -# == Schema Information -# -# Table name: product_orders -# -# id :integer not null, primary key -# product_id :integer -# order_id :integer -# quantity :integer -# purchase_price :decimal(, ) -# created_at :datetime -# updated_at :datetime -# - -class ProductOrder < ActiveRecord::Base - belongs_to :order - belongs_to :product -end diff --git a/spec/setups/active_record/models/shipment.rb b/spec/setups/active_record/models/shipment.rb deleted file mode 100644 index c622b54..0000000 --- a/spec/setups/active_record/models/shipment.rb +++ /dev/null @@ -1,39 +0,0 @@ -# == Schema Information -# -# Table name: shipments -# -# id :integer not null, primary key -# order_id :integer -# price :decimal(, ) -# carrier :string(255) -# tracking_code :string(255) -# delivered :boolean -# est_delivery_date :datetime -# created_at :datetime -# updated_at :datetime -# - -class Shipment < ActiveRecord::Base - belongs_to :order - - upmin_attributes :status, :price, :carrier, :est_delivery_date - - def status - # Using a random value to pretend that we are looking up unique values. - return tracking_states[rand(tracking_states.length)] - end - - def tracking_states - return [:preparing, :awaiting_pickup, :in_transit, :out_for_delivery, :delivered] - end - - def cancel - return true - end - - def update_shipment(length, width, height, weight, perishable = false) - # Do some work - this is a demo so no work is done. - return "Shipment successfully updated with the following: length=#{length}, width=#{width}, height=#{height}, weight=#{weight}, perishable=#{perishable}" - end - -end diff --git a/spec/setups/active_record/models/user.rb b/spec/setups/active_record/models/user.rb deleted file mode 100644 index de752f7..0000000 --- a/spec/setups/active_record/models/user.rb +++ /dev/null @@ -1,49 +0,0 @@ -# == Schema Information -# -# Table name: users -# -# id :integer not null, primary key -# name :string(255) -# email :string(255) -# stripe_card_id :string(255) -# admin :boolean -# created_at :datetime -# updated_at :datetime -# -require 'digest/md5' - -class User < ActiveRecord::Base - has_many :orders - - validates :email, format: { with: /.+@.+(.).+/, message: "not a valid email" } - - before_save :downcase_email - - upmin_actions :reset_password, :issue_coupon, :issue_free_shipping_coupon - - def avatar_url - hash = Digest::MD5.hexdigest(email) - return "http://www.gravatar.com/avatar/#{hash}" - end - - def reset_password - # Email the user with a password reset link - return "#{name} has been emailed at #{email} with a password reset link." - end - - def issue_coupon(percent = 20) - if percent == 20 - return "CPN_FJALDKF01Z1" - else - return "CPN_12838501ADN" - end - end - - def issue_free_shipping_coupon - return "CPN_AJDOCKA81A0" - end - - def downcase_email - self.email = email.downcase - end -end diff --git a/spec/setups/active_record/test_data/order_seeder.rb b/spec/setups/active_record/test_data/order_seeder.rb deleted file mode 100644 index 839e42f..0000000 --- a/spec/setups/active_record/test_data/order_seeder.rb +++ /dev/null @@ -1,36 +0,0 @@ -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.create!(user: user) - 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( - order: order, - product: product, - quantity: quantity, - purchase_price: product.price - ) - po.save! - end - - order.build_shipment( - price: (rand(1000) / 100.0) + 10.0, - carrier: [:ups, :usps, :fedex, :dhl][rand(4)], - delivered: [true, true, false][rand(3)], - est_delivery_date: random_date - ).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 diff --git a/spec/setups/active_record/test_data/product_seeder.rb b/spec/setups/active_record/test_data/product_seeder.rb deleted file mode 100644 index 31d1de8..0000000 --- a/spec/setups/active_record/test_data/product_seeder.rb +++ /dev/null @@ -1,26 +0,0 @@ -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.create!( - name: json_product["name"], - short_desc: json_product["shortDescription"], - best_selling_rank: json_product["bestSellingRank"], - thumbnail: json_product["thumbnailImage"], - price: json_product["salePrice"], - manufacturer: json_product["manufacturer"], - url: json_product["url"], - product_type: json_product["type"], - image: json_product["image"], - category: json_product["category"], - free_shipping: !json_product["shipping"].nil? - ) - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c27c14f..3eed3d8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,50 +1,41 @@ -ENV['RAILS_ENV'] ||= 'test' - -require File.expand_path("../dummy/config/environment.rb", __FILE__) +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' -# require 'rspec/autorun' -require 'factory_girl_rails' -require 'database_cleaner' require 'capybara/rspec' +require 'capybara/rails' +require 'database_cleaner' -# Active Record Models, Table, and Seeder -if defined?(ActiveRecord) || true - require 'setups/active_record/migrate/all_tables' - require 'setups/active_record/test_data/seeder' - Dir["#{File.dirname(__FILE__)}/setups/models/**/*.rb"].each { |f| require f } -end - - -Rails.backtrace_cleaner.remove_silencers! - - -# Load support files -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } +if defined?(ActiveRecord) + require File.expand_path('../../../../seed/seeder', __FILE__) +end RSpec.configure do |config| - config.mock_with :rspec + config.fixture_path = "#{::Rails.root}/spec/fixtures" config.use_transactional_fixtures = true - config.infer_base_class_for_anonymous_controllers = false + config.infer_spec_type_from_file_location! config.order = "random" + config.expect_with(:rspec) do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with(:rspec) do |mocks| + mocks.verify_partial_doubles = true + end + config.before(:suite) do - AllTables.up - DatabaseCleaner.strategy = :transaction - DatabaseCleaner.clean_with(:truncation) Seeder.seed end config.after(:suite) do - AllTables.down end config.before(:each) do - DatabaseCleaner.start end config.after(:each) do - DatabaseCleaner.clean end config.after do |example| diff --git a/test_apps/active_record_32/.gitignore b/test_apps/active_record_32/.gitignore new file mode 100644 index 0000000..eb3489a --- /dev/null +++ b/test_apps/active_record_32/.gitignore @@ -0,0 +1,15 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile ~/.gitignore_global + +# Ignore bundler config +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp diff --git a/test_apps/active_record_32/.rspec b/test_apps/active_record_32/.rspec new file mode 100644 index 0000000..b6d0b2a --- /dev/null +++ b/test_apps/active_record_32/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format=d diff --git a/test_apps/active_record_32/Gemfile b/test_apps/active_record_32/Gemfile new file mode 100644 index 0000000..81e0350 --- /dev/null +++ b/test_apps/active_record_32/Gemfile @@ -0,0 +1,24 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.19' + +gem 'sqlite3' + +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + gem 'uglifier', '>= 1.0.3' +end + +gem 'jquery-rails' + + +# Used for testing +gem 'capybara' +gem 'rspec-rails' +gem 'launchy' +gem 'database_cleaner' + +gem 'test_models', git: "git://github.com/upmin/test_models.git" + +gemspec :path => '../../' diff --git a/test_apps/active_record_32/README.rdoc b/test_apps/active_record_32/README.rdoc new file mode 100644 index 0000000..3e1c15c --- /dev/null +++ b/test_apps/active_record_32/README.rdoc @@ -0,0 +1,261 @@ +== Welcome to Rails + +Rails is a web-application framework that includes everything needed to create +database-backed web applications according to the Model-View-Control pattern. + +This pattern splits the view (also called the presentation) into "dumb" +templates that are primarily responsible for inserting pre-built data in between +HTML tags. The model contains the "smart" domain objects (such as Account, +Product, Person, Post) that holds all the business logic and knows how to +persist themselves to a database. The controller handles the incoming requests +(such as Save New Account, Update Product, Show Post) by manipulating the model +and directing data to the view. + +In Rails, the model is handled by what's called an object-relational mapping +layer entitled Active Record. This layer allows you to present the data from +database rows as objects and embellish these data objects with business logic +methods. You can read more about Active Record in +link:files/vendor/rails/activerecord/README.html. + +The controller and view are handled by the Action Pack, which handles both +layers by its two parts: Action View and Action Controller. These two layers +are bundled in a single package due to their heavy interdependence. This is +unlike the relationship between the Active Record and Action Pack that is much +more separate. Each of these packages can be used independently outside of +Rails. You can read more about Action Pack in +link:files/vendor/rails/actionpack/README.html. + + +== Getting Started + +1. At the command prompt, create a new Rails application: + rails new myapp (where myapp is the application name) + +2. Change directory to myapp and start the web server: + cd myapp; rails server (run with --help for options) + +3. Go to http://localhost:3000/ and you'll see: + "Welcome aboard: You're riding Ruby on Rails!" + +4. Follow the guidelines to start developing your application. You can find +the following resources handy: + +* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html +* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ + + +== Debugging Rails + +Sometimes your application goes wrong. Fortunately there are a lot of tools that +will help you debug it and get it back on the rails. + +First area to check is the application log files. Have "tail -f" commands +running on the server.log and development.log. Rails will automatically display +debugging and runtime information to these files. Debugging info will also be +shown in the browser on requests from 127.0.0.1. + +You can also log your own messages directly into the log file from your code +using the Ruby logger class from inside your controllers. Example: + + class WeblogController < ActionController::Base + def destroy + @weblog = Weblog.find(params[:id]) + @weblog.destroy + logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") + end + end + +The result will be a message in your log file along the lines of: + + Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! + +More information on how to use the logger is at http://www.ruby-doc.org/core/ + +Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are +several books available online as well: + +* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) +* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) + +These two books will bring you up to speed on the Ruby language and also on +programming in general. + + +== Debugger + +Debugger support is available through the debugger command when you start your +Mongrel or WEBrick server with --debugger. This means that you can break out of +execution at any point in the code, investigate and change the model, and then, +resume execution! You need to install ruby-debug to run the server in debugging +mode. With gems, use sudo gem install ruby-debug. Example: + + class WeblogController < ActionController::Base + def index + @posts = Post.all + debugger + end + end + +So the controller will accept the action, run the first line, then present you +with a IRB prompt in the server window. Here you can do things like: + + >> @posts.inspect + => "[#nil, "body"=>nil, "id"=>"1"}>, + #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" + >> @posts.first.title = "hello from a debugger" + => "hello from a debugger" + +...and even better, you can examine how your runtime objects actually work: + + >> f = @posts.first + => #nil, "body"=>nil, "id"=>"1"}> + >> f. + Display all 152 possibilities? (y or n) + +Finally, when you're ready to resume execution, you can enter "cont". + + +== Console + +The console is a Ruby shell, which allows you to interact with your +application's domain model. Here you'll have all parts of the application +configured, just like it is when the application is running. You can inspect +domain models, change values, and save to the database. Starting the script +without arguments will launch it in the development environment. + +To start the console, run rails console from the application +directory. + +Options: + +* Passing the -s, --sandbox argument will rollback any modifications + made to the database. +* Passing an environment name as an argument will load the corresponding + environment. Example: rails console production. + +To reload your controllers and models after launching the console run +reload! + +More information about irb can be found at: +link:http://www.rubycentral.org/pickaxe/irb.html + + +== dbconsole + +You can go to the command line of your database directly through rails +dbconsole. You would be connected to the database with the credentials +defined in database.yml. Starting the script without arguments will connect you +to the development database. Passing an argument will connect you to a different +database, like rails dbconsole production. Currently works for MySQL, +PostgreSQL and SQLite 3. + +== Description of Contents + +The default directory structure of a generated Ruby on Rails application: + + |-- app + | |-- assets + | | |-- images + | | |-- javascripts + | | `-- stylesheets + | |-- controllers + | |-- helpers + | |-- mailers + | |-- models + | `-- views + | `-- layouts + |-- config + | |-- environments + | |-- initializers + | `-- locales + |-- db + |-- doc + |-- lib + | |-- assets + | `-- tasks + |-- log + |-- public + |-- script + |-- test + | |-- fixtures + | |-- functional + | |-- integration + | |-- performance + | `-- unit + |-- tmp + | `-- cache + | `-- assets + `-- vendor + |-- assets + | |-- javascripts + | `-- stylesheets + `-- plugins + +app + Holds all the code that's specific to this particular application. + +app/assets + Contains subdirectories for images, stylesheets, and JavaScript files. + +app/controllers + Holds controllers that should be named like weblogs_controller.rb for + automated URL mapping. All controllers should descend from + ApplicationController which itself descends from ActionController::Base. + +app/models + Holds models that should be named like post.rb. Models descend from + ActiveRecord::Base by default. + +app/views + Holds the template files for the view that should be named like + weblogs/index.html.erb for the WeblogsController#index action. All views use + eRuby syntax by default. + +app/views/layouts + Holds the template files for layouts to be used with views. This models the + common header/footer method of wrapping views. In your views, define a layout + using the layout :default and create a file named default.html.erb. + Inside default.html.erb, call <% yield %> to render the view using this + layout. + +app/helpers + Holds view helpers that should be named like weblogs_helper.rb. These are + generated for you automatically when using generators for controllers. + Helpers can be used to wrap functionality for your views into methods. + +config + Configuration files for the Rails environment, the routing map, the database, + and other dependencies. + +db + Contains the database schema in schema.rb. db/migrate contains all the + sequence of Migrations for your schema. + +doc + This directory is where your application documentation will be stored when + generated using rake doc:app + +lib + Application specific libraries. Basically, any kind of custom code that + doesn't belong under controllers, models, or helpers. This directory is in + the load path. + +public + The directory available for the web server. Also contains the dispatchers and the + default HTML files. This should be set as the DOCUMENT_ROOT of your web + server. + +script + Helper scripts for automation and generation. + +test + Unit and functional tests along with fixtures. When using the rails generate + command, template test files will be generated for you and placed in this + directory. + +vendor + External libraries that the application depends on. Also includes the plugins + subdirectory. If the app has frozen rails, those gems also go here, under + vendor/rails/. This directory is in the load path. diff --git a/spec/dummy/Rakefile b/test_apps/active_record_32/Rakefile similarity index 86% rename from spec/dummy/Rakefile rename to test_apps/active_record_32/Rakefile index 3645852..2572d91 100644 --- a/spec/dummy/Rakefile +++ b/test_apps/active_record_32/Rakefile @@ -4,4 +4,4 @@ require File.expand_path('../config/application', __FILE__) -Dummy::Application.load_tasks +ActiveRecord32::Application.load_tasks diff --git a/test_apps/active_record_32/app/assets/images/rails.png b/test_apps/active_record_32/app/assets/images/rails.png new file mode 100644 index 0000000..d5edc04 Binary files /dev/null and b/test_apps/active_record_32/app/assets/images/rails.png differ diff --git a/spec/dummy/app/assets/javascripts/application.js b/test_apps/active_record_32/app/assets/javascripts/application.js similarity index 100% rename from spec/dummy/app/assets/javascripts/application.js rename to test_apps/active_record_32/app/assets/javascripts/application.js diff --git a/spec/dummy/app/assets/stylesheets/application.css b/test_apps/active_record_32/app/assets/stylesheets/application.css similarity index 100% rename from spec/dummy/app/assets/stylesheets/application.css rename to test_apps/active_record_32/app/assets/stylesheets/application.css diff --git a/spec/dummy/app/controllers/application_controller.rb b/test_apps/active_record_32/app/controllers/application_controller.rb similarity index 100% rename from spec/dummy/app/controllers/application_controller.rb rename to test_apps/active_record_32/app/controllers/application_controller.rb diff --git a/spec/dummy/app/helpers/application_helper.rb b/test_apps/active_record_32/app/helpers/application_helper.rb similarity index 100% rename from spec/dummy/app/helpers/application_helper.rb rename to test_apps/active_record_32/app/helpers/application_helper.rb diff --git a/spec/dummy/app/mailers/.gitkeep b/test_apps/active_record_32/app/mailers/.gitkeep similarity index 100% rename from spec/dummy/app/mailers/.gitkeep rename to test_apps/active_record_32/app/mailers/.gitkeep diff --git a/spec/dummy/app/models/.gitkeep b/test_apps/active_record_32/app/models/.gitkeep similarity index 100% rename from spec/dummy/app/models/.gitkeep rename to test_apps/active_record_32/app/models/.gitkeep diff --git a/spec/dummy/app/views/layouts/application.html.erb b/test_apps/active_record_32/app/views/layouts/application.html.erb similarity index 86% rename from spec/dummy/app/views/layouts/application.html.erb rename to test_apps/active_record_32/app/views/layouts/application.html.erb index 4cab268..0c1d812 100644 --- a/spec/dummy/app/views/layouts/application.html.erb +++ b/test_apps/active_record_32/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - Dummy + ActiveRecord32 <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> diff --git a/test_apps/active_record_32/config.ru b/test_apps/active_record_32/config.ru new file mode 100644 index 0000000..64771d3 --- /dev/null +++ b/test_apps/active_record_32/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run ActiveRecord32::Application diff --git a/spec/dummy/config/application.rb b/test_apps/active_record_32/config/application.rb similarity index 85% rename from spec/dummy/config/application.rb rename to test_apps/active_record_32/config/application.rb index 16078c3..1ae71cf 100644 --- a/spec/dummy/config/application.rb +++ b/test_apps/active_record_32/config/application.rb @@ -3,15 +3,19 @@ # Pick the frameworks you want: require "active_record/railtie" require "action_controller/railtie" -# require "action_mailer/railtie" -# require "active_resource/railtie" +require "action_mailer/railtie" +require "active_resource/railtie" require "sprockets/railtie" # require "rails/test_unit/railtie" -Bundler.require(*Rails.groups) -require "upmin" +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end -module Dummy +module ActiveRecord32 class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -53,7 +57,7 @@ class Application < Rails::Application # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true + config.active_record.whitelist_attributes = true # Enable the asset pipeline config.assets.enabled = true @@ -62,4 +66,3 @@ class Application < Rails::Application config.assets.version = '1.0' end end - diff --git a/test_apps/active_record_32/config/boot.rb b/test_apps/active_record_32/config/boot.rb new file mode 100644 index 0000000..4489e58 --- /dev/null +++ b/test_apps/active_record_32/config/boot.rb @@ -0,0 +1,6 @@ +require 'rubygems' + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/test_apps/active_record_32/config/database.yml b/test_apps/active_record_32/config/database.yml new file mode 100644 index 0000000..51a4dd4 --- /dev/null +++ b/test_apps/active_record_32/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/spec/dummy/config/environment.rb b/test_apps/active_record_32/config/environment.rb similarity index 74% rename from spec/dummy/config/environment.rb rename to test_apps/active_record_32/config/environment.rb index 3da5eb9..b9f46a5 100644 --- a/spec/dummy/config/environment.rb +++ b/test_apps/active_record_32/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the rails application -Dummy::Application.initialize! +ActiveRecord32::Application.initialize! diff --git a/test_apps/active_record_32/config/environments/development.rb b/test_apps/active_record_32/config/environments/development.rb new file mode 100644 index 0000000..b945bfd --- /dev/null +++ b/test_apps/active_record_32/config/environments/development.rb @@ -0,0 +1,37 @@ +ActiveRecord32::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/test_apps/active_record_32/config/environments/production.rb b/test_apps/active_record_32/config/environments/production.rb new file mode 100644 index 0000000..3b3ebb1 --- /dev/null +++ b/test_apps/active_record_32/config/environments/production.rb @@ -0,0 +1,67 @@ +ActiveRecord32::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end diff --git a/test_apps/active_record_32/config/environments/test.rb b/test_apps/active_record_32/config/environments/test.rb new file mode 100644 index 0000000..baa784b --- /dev/null +++ b/test_apps/active_record_32/config/environments/test.rb @@ -0,0 +1,36 @@ +ActiveRecord32::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + config.cache_classes = false + + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr + + + config.i18n.enforce_available_locales = false +end diff --git a/spec/dummy/config/initializers/backtrace_silencers.rb b/test_apps/active_record_32/config/initializers/backtrace_silencers.rb similarity index 100% rename from spec/dummy/config/initializers/backtrace_silencers.rb rename to test_apps/active_record_32/config/initializers/backtrace_silencers.rb diff --git a/spec/dummy/config/initializers/inflections.rb b/test_apps/active_record_32/config/initializers/inflections.rb similarity index 100% rename from spec/dummy/config/initializers/inflections.rb rename to test_apps/active_record_32/config/initializers/inflections.rb diff --git a/spec/dummy/config/initializers/mime_types.rb b/test_apps/active_record_32/config/initializers/mime_types.rb similarity index 100% rename from spec/dummy/config/initializers/mime_types.rb rename to test_apps/active_record_32/config/initializers/mime_types.rb diff --git a/spec/dummy/config/initializers/secret_token.rb b/test_apps/active_record_32/config/initializers/secret_token.rb similarity index 64% rename from spec/dummy/config/initializers/secret_token.rb rename to test_apps/active_record_32/config/initializers/secret_token.rb index 1020eda..49568ad 100644 --- a/spec/dummy/config/initializers/secret_token.rb +++ b/test_apps/active_record_32/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -Dummy::Application.config.secret_token = 'b5b0b53c3816e9d16de521f0ade8b404c2d98a1fb391528b442ab40e0a11a88ad2d9ab5683097defad27474daafbb1cdf8f8ca5839ab118366a488e0650468bd' +ActiveRecord32::Application.config.secret_token = '38b7ab6e74f9740d6f029f49b84177a58c07cbbbda6a2f5e702f1c09aa1291b59faa038f6297bd911cae1f22ee4e7ef7425e0063006ccb63d35cf24a30cc89ed' diff --git a/spec/dummy/config/initializers/session_store.rb b/test_apps/active_record_32/config/initializers/session_store.rb similarity index 61% rename from spec/dummy/config/initializers/session_store.rb rename to test_apps/active_record_32/config/initializers/session_store.rb index a5f5499..32a96b9 100644 --- a/spec/dummy/config/initializers/session_store.rb +++ b/test_apps/active_record_32/config/initializers/session_store.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -Dummy::Application.config.session_store :cookie_store, key: '_dummy_upmin_admin_session' +ActiveRecord32::Application.config.session_store :cookie_store, key: '_active_record_32_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") -# Dummy::Application.config.session_store :active_record_store +# ActiveRecord32::Application.config.session_store :active_record_store diff --git a/spec/dummy/config/initializers/wrap_parameters.rb b/test_apps/active_record_32/config/initializers/wrap_parameters.rb similarity index 100% rename from spec/dummy/config/initializers/wrap_parameters.rb rename to test_apps/active_record_32/config/initializers/wrap_parameters.rb diff --git a/spec/dummy/config/locales/en.yml b/test_apps/active_record_32/config/locales/en.yml similarity index 100% rename from spec/dummy/config/locales/en.yml rename to test_apps/active_record_32/config/locales/en.yml diff --git a/test_apps/active_record_32/config/routes.rb b/test_apps/active_record_32/config/routes.rb new file mode 100644 index 0000000..843d8ac --- /dev/null +++ b/test_apps/active_record_32/config/routes.rb @@ -0,0 +1,3 @@ +ActiveRecord32::Application.routes.draw do + mount Upmin::Engine => "/upmin" +end diff --git a/test_apps/active_record_32/db/migrate/20140920222337_create_products.test_models.rb b/test_apps/active_record_32/db/migrate/20140920222337_create_products.test_models.rb new file mode 100644 index 0000000..3cdd485 --- /dev/null +++ b/test_apps/active_record_32/db/migrate/20140920222337_create_products.test_models.rb @@ -0,0 +1,20 @@ +# This migration comes from test_models (originally 20140807182135) +class CreateProducts < ActiveRecord::Migration + def change + create_table :products do |t| + t.string :name + t.string :short_desc + t.integer :best_selling_rank + t.string :thumbnail + t.decimal :price + t.string :manufacturer + t.string :url + t.string :product_type + t.string :image + t.string :category + t.boolean :free_shipping + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_32/db/migrate/20140920222338_create_users.test_models.rb b/test_apps/active_record_32/db/migrate/20140920222338_create_users.test_models.rb new file mode 100644 index 0000000..cbd65e8 --- /dev/null +++ b/test_apps/active_record_32/db/migrate/20140920222338_create_users.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807182247) +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :stripe_card_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_32/db/migrate/20140920222339_create_orders.test_models.rb b/test_apps/active_record_32/db/migrate/20140920222339_create_orders.test_models.rb new file mode 100644 index 0000000..5cd78b5 --- /dev/null +++ b/test_apps/active_record_32/db/migrate/20140920222339_create_orders.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807183757) +class CreateOrders < ActiveRecord::Migration + def change + create_table :orders do |t| + t.integer :user_id + t.string :stripe_charge_id + t.string :stripe_refund_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_32/db/migrate/20140920222340_create_product_orders.test_models.rb b/test_apps/active_record_32/db/migrate/20140920222340_create_product_orders.test_models.rb new file mode 100644 index 0000000..037a3c1 --- /dev/null +++ b/test_apps/active_record_32/db/migrate/20140920222340_create_product_orders.test_models.rb @@ -0,0 +1,13 @@ +# This migration comes from test_models (originally 20140807183823) +class CreateProductOrders < ActiveRecord::Migration + def change + create_table :product_orders do |t| + t.integer :product_id + t.integer :order_id + t.integer :quantity + t.decimal :purchase_price + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_32/db/migrate/20140920222341_create_shipments.test_models.rb b/test_apps/active_record_32/db/migrate/20140920222341_create_shipments.test_models.rb new file mode 100644 index 0000000..1c590b4 --- /dev/null +++ b/test_apps/active_record_32/db/migrate/20140920222341_create_shipments.test_models.rb @@ -0,0 +1,15 @@ +# This migration comes from test_models (originally 20140807184427) +class CreateShipments < ActiveRecord::Migration + def change + create_table :shipments do |t| + t.integer :order_id + t.decimal :price + t.string :carrier + t.string :tracking_code + t.boolean :delivered + t.datetime :est_delivery_date + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_32/db/schema.rb b/test_apps/active_record_32/db/schema.rb new file mode 100644 index 0000000..2d9ba2f --- /dev/null +++ b/test_apps/active_record_32/db/schema.rb @@ -0,0 +1,68 @@ +# 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 to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20140920222341) do + + create_table "orders", :force => true do |t| + t.integer "user_id" + t.string "stripe_charge_id" + t.string "stripe_refund_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "product_orders", :force => true do |t| + t.integer "product_id" + t.integer "order_id" + t.integer "quantity" + t.decimal "purchase_price" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "products", :force => true do |t| + t.string "name" + t.string "short_desc" + t.integer "best_selling_rank" + t.string "thumbnail" + t.decimal "price" + t.string "manufacturer" + t.string "url" + t.string "product_type" + t.string "image" + t.string "category" + t.boolean "free_shipping" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "shipments", :force => true do |t| + t.integer "order_id" + t.decimal "price" + t.string "carrier" + t.string "tracking_code" + t.boolean "delivered" + t.datetime "est_delivery_date" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "users", :force => true do |t| + t.string "name" + t.string "email" + t.string "stripe_card_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/test_apps/active_record_32/db/seeds.rb b/test_apps/active_record_32/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/test_apps/active_record_32/db/seeds.rb @@ -0,0 +1,7 @@ +# 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', city: cities.first) diff --git a/spec/dummy/lib/assets/.gitkeep b/test_apps/active_record_32/lib/assets/.gitkeep similarity index 100% rename from spec/dummy/lib/assets/.gitkeep rename to test_apps/active_record_32/lib/assets/.gitkeep diff --git a/spec/dummy/log/.gitkeep b/test_apps/active_record_32/lib/tasks/.gitkeep similarity index 100% rename from spec/dummy/log/.gitkeep rename to test_apps/active_record_32/lib/tasks/.gitkeep diff --git a/spec/dummy/public/favicon.ico b/test_apps/active_record_32/log/.gitkeep similarity index 100% rename from spec/dummy/public/favicon.ico rename to test_apps/active_record_32/log/.gitkeep diff --git a/spec/dummy/public/404.html b/test_apps/active_record_32/public/404.html similarity index 100% rename from spec/dummy/public/404.html rename to test_apps/active_record_32/public/404.html diff --git a/spec/dummy/public/422.html b/test_apps/active_record_32/public/422.html similarity index 100% rename from spec/dummy/public/422.html rename to test_apps/active_record_32/public/422.html diff --git a/spec/dummy/public/500.html b/test_apps/active_record_32/public/500.html similarity index 100% rename from spec/dummy/public/500.html rename to test_apps/active_record_32/public/500.html diff --git a/test_apps/active_record_32/public/favicon.ico b/test_apps/active_record_32/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_32/public/index.html b/test_apps/active_record_32/public/index.html new file mode 100644 index 0000000..a1d5099 --- /dev/null +++ b/test_apps/active_record_32/public/index.html @@ -0,0 +1,241 @@ + + + + Ruby on Rails: Welcome aboard + + + + +
+ + +
+ + + + +
+

Getting started

+

Here’s how to get rolling:

+ +
    +
  1. +

    Use rails generate to create your models and controllers

    +

    To see all available options, run it without parameters.

    +
  2. + +
  3. +

    Set up a default route and remove public/index.html

    +

    Routes are set up in config/routes.rb.

    +
  4. + +
  5. +

    Create your database

    +

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    +
  6. +
+
+
+ + +
+ + diff --git a/test_apps/active_record_32/public/robots.txt b/test_apps/active_record_32/public/robots.txt new file mode 100644 index 0000000..085187f --- /dev/null +++ b/test_apps/active_record_32/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-Agent: * +# Disallow: / diff --git a/spec/dummy/script/rails b/test_apps/active_record_32/script/rails similarity index 100% rename from spec/dummy/script/rails rename to test_apps/active_record_32/script/rails diff --git a/spec/requests/search_spec.rb b/test_apps/active_record_32/spec/features/search_spec.rb similarity index 100% rename from spec/requests/search_spec.rb rename to test_apps/active_record_32/spec/features/search_spec.rb diff --git a/test_apps/active_record_32/spec/spec_helper.rb b/test_apps/active_record_32/spec/spec_helper.rb new file mode 100644 index 0000000..ad0022f --- /dev/null +++ b/test_apps/active_record_32/spec/spec_helper.rb @@ -0,0 +1,46 @@ +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/rails' +require 'database_cleaner' + + +if defined?(ActiveRecord) + require File.expand_path('../../../seed/seeder', __FILE__) +end + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.order = "random" + + config.expect_with(:rspec) do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with(:rspec) do |mocks| + mocks.verify_partial_doubles = true + end + + config.before(:suite) do + Seeder.seed + end + + config.after(:suite) do + end + + config.before(:each) do + end + + config.after(:each) do + end + + config.after do |example| + if example.metadata[:type] == :feature && example.exception.present? + save_and_open_page + end + end +end diff --git a/test_apps/active_record_32/vendor/assets/javascripts/.gitkeep b/test_apps/active_record_32/vendor/assets/javascripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_32/vendor/assets/stylesheets/.gitkeep b/test_apps/active_record_32/vendor/assets/stylesheets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_32/vendor/plugins/.gitkeep b/test_apps/active_record_32/vendor/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/.gitignore b/test_apps/active_record_40/.gitignore new file mode 100644 index 0000000..6a502e9 --- /dev/null +++ b/test_apps/active_record_40/.gitignore @@ -0,0 +1,16 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp diff --git a/test_apps/active_record_40/.rspec b/test_apps/active_record_40/.rspec new file mode 100644 index 0000000..b6d0b2a --- /dev/null +++ b/test_apps/active_record_40/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format=d diff --git a/test_apps/active_record_40/Gemfile b/test_apps/active_record_40/Gemfile new file mode 100644 index 0000000..ffa3db8 --- /dev/null +++ b/test_apps/active_record_40/Gemfile @@ -0,0 +1,20 @@ +source 'https://rubygems.org' + +gem 'rails', '4.0.10' +gem 'sqlite3' +gem 'sass-rails', '~> 4.0.2' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails' +gem 'turbolinks' +gem 'jbuilder', '~> 1.2' + + +# Used for testing +gem 'capybara' +gem 'rspec-rails' +gem 'launchy' +gem 'database_cleaner' +gem 'test_models', git: "git://github.com/upmin/test_models.git" + +gemspec :path => '../../' diff --git a/test_apps/active_record_40/README.rdoc b/test_apps/active_record_40/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test_apps/active_record_40/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test_apps/active_record_40/Rakefile b/test_apps/active_record_40/Rakefile new file mode 100644 index 0000000..992a980 --- /dev/null +++ b/test_apps/active_record_40/Rakefile @@ -0,0 +1,6 @@ +# 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.expand_path('../config/application', __FILE__) + +ActiveRecord40::Application.load_tasks diff --git a/test_apps/active_record_40/app/assets/images/.keep b/test_apps/active_record_40/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/app/assets/javascripts/application.js b/test_apps/active_record_40/app/assets/javascripts/application.js new file mode 100644 index 0000000..d6925fa --- /dev/null +++ b/test_apps/active_record_40/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/test_apps/active_record_40/app/assets/stylesheets/application.css b/test_apps/active_record_40/app/assets/stylesheets/application.css new file mode 100644 index 0000000..3192ec8 --- /dev/null +++ b/test_apps/active_record_40/app/assets/stylesheets/application.css @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . + */ diff --git a/test_apps/active_record_40/app/controllers/application_controller.rb b/test_apps/active_record_40/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test_apps/active_record_40/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test_apps/active_record_40/app/controllers/concerns/.keep b/test_apps/active_record_40/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/app/helpers/application_helper.rb b/test_apps/active_record_40/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test_apps/active_record_40/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test_apps/active_record_40/app/mailers/.keep b/test_apps/active_record_40/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/app/models/.keep b/test_apps/active_record_40/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/app/models/concerns/.keep b/test_apps/active_record_40/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/app/views/layouts/application.html.erb b/test_apps/active_record_40/app/views/layouts/application.html.erb new file mode 100644 index 0000000..e668886 --- /dev/null +++ b/test_apps/active_record_40/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + ActiveRecord40 + <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> + <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test_apps/active_record_40/bin/bundle b/test_apps/active_record_40/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/test_apps/active_record_40/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test_apps/active_record_40/bin/rails b/test_apps/active_record_40/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/test_apps/active_record_40/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test_apps/active_record_40/bin/rake b/test_apps/active_record_40/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test_apps/active_record_40/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/spec/dummy/config.ru b/test_apps/active_record_40/config.ru similarity index 85% rename from spec/dummy/config.ru rename to test_apps/active_record_40/config.ru index 1989ed8..5bc2a61 100644 --- a/spec/dummy/config.ru +++ b/test_apps/active_record_40/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run Dummy::Application +run Rails.application diff --git a/test_apps/active_record_40/config/application.rb b/test_apps/active_record_40/config/application.rb new file mode 100644 index 0000000..8c3c72b --- /dev/null +++ b/test_apps/active_record_40/config/application.rb @@ -0,0 +1,28 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ActiveRecord40 + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/test_apps/active_record_40/config/boot.rb b/test_apps/active_record_40/config/boot.rb new file mode 100644 index 0000000..5e5f0c1 --- /dev/null +++ b/test_apps/active_record_40/config/boot.rb @@ -0,0 +1,4 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/test_apps/active_record_40/config/database.yml b/test_apps/active_record_40/config/database.yml new file mode 100644 index 0000000..51a4dd4 --- /dev/null +++ b/test_apps/active_record_40/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/test_apps/active_record_40/config/environment.rb b/test_apps/active_record_40/config/environment.rb new file mode 100644 index 0000000..59c0330 --- /dev/null +++ b/test_apps/active_record_40/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +ActiveRecord40::Application.initialize! diff --git a/test_apps/active_record_40/config/environments/development.rb b/test_apps/active_record_40/config/environments/development.rb new file mode 100644 index 0000000..07dd969 --- /dev/null +++ b/test_apps/active_record_40/config/environments/development.rb @@ -0,0 +1,32 @@ +ActiveRecord40::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/active_record_40/config/environments/production.rb b/test_apps/active_record_40/config/environments/production.rb new file mode 100644 index 0000000..49897b5 --- /dev/null +++ b/test_apps/active_record_40/config/environments/production.rb @@ -0,0 +1,80 @@ +ActiveRecord40::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/test_apps/active_record_40/config/environments/test.rb b/test_apps/active_record_40/config/environments/test.rb new file mode 100644 index 0000000..016ac61 --- /dev/null +++ b/test_apps/active_record_40/config/environments/test.rb @@ -0,0 +1,39 @@ +ActiveRecord40::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/active_record_40/config/initializers/backtrace_silencers.rb b/test_apps/active_record_40/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test_apps/active_record_40/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test_apps/active_record_40/config/initializers/filter_parameter_logging.rb b/test_apps/active_record_40/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test_apps/active_record_40/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test_apps/active_record_40/config/initializers/inflections.rb b/test_apps/active_record_40/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test_apps/active_record_40/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test_apps/active_record_40/config/initializers/mime_types.rb b/test_apps/active_record_40/config/initializers/mime_types.rb new file mode 100644 index 0000000..72aca7e --- /dev/null +++ b/test_apps/active_record_40/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/test_apps/active_record_40/config/initializers/secret_token.rb b/test_apps/active_record_40/config/initializers/secret_token.rb new file mode 100644 index 0000000..d7d26e9 --- /dev/null +++ b/test_apps/active_record_40/config/initializers/secret_token.rb @@ -0,0 +1,12 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure your secret_key_base is kept private +# if you're sharing your code publicly. +ActiveRecord40::Application.config.secret_key_base = '71cbc8ff2c8f396c5fd327d32ece1d2ced7024f3f2dfc50c1e678d6c84b57c034117dcfaa79baf31f8c71933d7c286d2aa3e3037052456adf09ebe2402dca2c7' diff --git a/test_apps/active_record_40/config/initializers/session_store.rb b/test_apps/active_record_40/config/initializers/session_store.rb new file mode 100644 index 0000000..dd9984e --- /dev/null +++ b/test_apps/active_record_40/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +ActiveRecord40::Application.config.session_store :cookie_store, key: '_active_record_40_session' diff --git a/test_apps/active_record_40/config/initializers/wrap_parameters.rb b/test_apps/active_record_40/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test_apps/active_record_40/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test_apps/active_record_40/config/locales/en.yml b/test_apps/active_record_40/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test_apps/active_record_40/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test_apps/active_record_40/config/routes.rb b/test_apps/active_record_40/config/routes.rb new file mode 100644 index 0000000..51d7567 --- /dev/null +++ b/test_apps/active_record_40/config/routes.rb @@ -0,0 +1,3 @@ +ActiveRecord40::Application.routes.draw do + mount Upmin::Engine => "/upmin" +end diff --git a/test_apps/active_record_40/db/migrate/20140920222405_create_products.test_models.rb b/test_apps/active_record_40/db/migrate/20140920222405_create_products.test_models.rb new file mode 100644 index 0000000..3cdd485 --- /dev/null +++ b/test_apps/active_record_40/db/migrate/20140920222405_create_products.test_models.rb @@ -0,0 +1,20 @@ +# This migration comes from test_models (originally 20140807182135) +class CreateProducts < ActiveRecord::Migration + def change + create_table :products do |t| + t.string :name + t.string :short_desc + t.integer :best_selling_rank + t.string :thumbnail + t.decimal :price + t.string :manufacturer + t.string :url + t.string :product_type + t.string :image + t.string :category + t.boolean :free_shipping + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_40/db/migrate/20140920222406_create_users.test_models.rb b/test_apps/active_record_40/db/migrate/20140920222406_create_users.test_models.rb new file mode 100644 index 0000000..cbd65e8 --- /dev/null +++ b/test_apps/active_record_40/db/migrate/20140920222406_create_users.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807182247) +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :stripe_card_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_40/db/migrate/20140920222407_create_orders.test_models.rb b/test_apps/active_record_40/db/migrate/20140920222407_create_orders.test_models.rb new file mode 100644 index 0000000..5cd78b5 --- /dev/null +++ b/test_apps/active_record_40/db/migrate/20140920222407_create_orders.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807183757) +class CreateOrders < ActiveRecord::Migration + def change + create_table :orders do |t| + t.integer :user_id + t.string :stripe_charge_id + t.string :stripe_refund_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_40/db/migrate/20140920222408_create_product_orders.test_models.rb b/test_apps/active_record_40/db/migrate/20140920222408_create_product_orders.test_models.rb new file mode 100644 index 0000000..037a3c1 --- /dev/null +++ b/test_apps/active_record_40/db/migrate/20140920222408_create_product_orders.test_models.rb @@ -0,0 +1,13 @@ +# This migration comes from test_models (originally 20140807183823) +class CreateProductOrders < ActiveRecord::Migration + def change + create_table :product_orders do |t| + t.integer :product_id + t.integer :order_id + t.integer :quantity + t.decimal :purchase_price + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_40/db/migrate/20140920222409_create_shipments.test_models.rb b/test_apps/active_record_40/db/migrate/20140920222409_create_shipments.test_models.rb new file mode 100644 index 0000000..1c590b4 --- /dev/null +++ b/test_apps/active_record_40/db/migrate/20140920222409_create_shipments.test_models.rb @@ -0,0 +1,15 @@ +# This migration comes from test_models (originally 20140807184427) +class CreateShipments < ActiveRecord::Migration + def change + create_table :shipments do |t| + t.integer :order_id + t.decimal :price + t.string :carrier + t.string :tracking_code + t.boolean :delivered + t.datetime :est_delivery_date + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_40/db/schema.rb b/test_apps/active_record_40/db/schema.rb new file mode 100644 index 0000000..538fcbb --- /dev/null +++ b/test_apps/active_record_40/db/schema.rb @@ -0,0 +1,68 @@ +# 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: 20140920222409) do + + create_table "orders", force: true do |t| + t.integer "user_id" + t.string "stripe_charge_id" + t.string "stripe_refund_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "product_orders", force: true do |t| + t.integer "product_id" + t.integer "order_id" + t.integer "quantity" + t.decimal "purchase_price" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "products", force: true do |t| + t.string "name" + t.string "short_desc" + t.integer "best_selling_rank" + t.string "thumbnail" + t.decimal "price" + t.string "manufacturer" + t.string "url" + t.string "product_type" + t.string "image" + t.string "category" + t.boolean "free_shipping" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "shipments", force: true do |t| + t.integer "order_id" + t.decimal "price" + t.string "carrier" + t.string "tracking_code" + t.boolean "delivered" + t.datetime "est_delivery_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: true do |t| + t.string "name" + t.string "email" + t.string "stripe_card_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test_apps/active_record_40/db/seeds.rb b/test_apps/active_record_40/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/test_apps/active_record_40/db/seeds.rb @@ -0,0 +1,7 @@ +# 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', city: cities.first) diff --git a/test_apps/active_record_40/lib/assets/.keep b/test_apps/active_record_40/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/lib/tasks/.keep b/test_apps/active_record_40/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/log/.keep b/test_apps/active_record_40/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/public/404.html b/test_apps/active_record_40/public/404.html new file mode 100644 index 0000000..a0daa0c --- /dev/null +++ b/test_apps/active_record_40/public/404.html @@ -0,0 +1,58 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/test_apps/active_record_40/public/422.html b/test_apps/active_record_40/public/422.html new file mode 100644 index 0000000..fbb4b84 --- /dev/null +++ b/test_apps/active_record_40/public/422.html @@ -0,0 +1,58 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/test_apps/active_record_40/public/500.html b/test_apps/active_record_40/public/500.html new file mode 100644 index 0000000..e9052d3 --- /dev/null +++ b/test_apps/active_record_40/public/500.html @@ -0,0 +1,57 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/test_apps/active_record_40/public/favicon.ico b/test_apps/active_record_40/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/public/robots.txt b/test_apps/active_record_40/public/robots.txt new file mode 100644 index 0000000..3c9c7c0 --- /dev/null +++ b/test_apps/active_record_40/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/test_apps/active_record_40/spec/features/search_spec.rb b/test_apps/active_record_40/spec/features/search_spec.rb new file mode 100644 index 0000000..50109e5 --- /dev/null +++ b/test_apps/active_record_40/spec/features/search_spec.rb @@ -0,0 +1,77 @@ +# encoding: UTF-8 +require 'spec_helper' + +feature('Search') do + background do + # Setup BG Stuff + end + + scenario("pagination") do + visit('/upmin/m/User') + + # Make sure some basic pagination exits + within('.pagination') do + within('.current') do + expect(page).to(have_content('1')) + end + + expect(page).to(have_content('Next')) + click_link('Next') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('2')) + end + + expect(page).to(have_content('Next')) + expect(page).to(have_content('Prev')) + + click_link('3') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('3')) + end + end + end + + scenario("Search via integer") do + visit('/upmin/m/Order') + + expect(page).to(have_selector('a.search-result-link', count: 30)) + + fill_in("q_id_gteq", with: 1) + fill_in("q_id_lteq", with: 5) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', count: 5)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + +end diff --git a/test_apps/active_record_40/spec/spec_helper.rb b/test_apps/active_record_40/spec/spec_helper.rb new file mode 100644 index 0000000..3eed3d8 --- /dev/null +++ b/test_apps/active_record_40/spec/spec_helper.rb @@ -0,0 +1,46 @@ +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/rails' +require 'database_cleaner' + + +if defined?(ActiveRecord) + require File.expand_path('../../../../seed/seeder', __FILE__) +end + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.order = "random" + + config.expect_with(:rspec) do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with(:rspec) do |mocks| + mocks.verify_partial_doubles = true + end + + config.before(:suite) do + Seeder.seed + end + + config.after(:suite) do + end + + config.before(:each) do + end + + config.after(:each) do + end + + config.after do |example| + if example.metadata[:type] == :feature && example.exception.present? + save_and_open_page + end + end +end diff --git a/test_apps/active_record_40/vendor/assets/javascripts/.keep b/test_apps/active_record_40/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_40/vendor/assets/stylesheets/.keep b/test_apps/active_record_40/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/.gitignore b/test_apps/active_record_41/.gitignore new file mode 100644 index 0000000..6a502e9 --- /dev/null +++ b/test_apps/active_record_41/.gitignore @@ -0,0 +1,16 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp diff --git a/test_apps/active_record_41/.rspec b/test_apps/active_record_41/.rspec new file mode 100644 index 0000000..b6d0b2a --- /dev/null +++ b/test_apps/active_record_41/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format=d diff --git a/test_apps/active_record_41/Gemfile b/test_apps/active_record_41/Gemfile new file mode 100644 index 0000000..8698236 --- /dev/null +++ b/test_apps/active_record_41/Gemfile @@ -0,0 +1,23 @@ +source 'https://rubygems.org' + + +gem 'rails', '4.1.6' +gem 'sqlite3' +gem 'sass-rails', '~> 4.0.3' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails' +gem 'turbolinks' +gem 'jbuilder', '~> 2.0' +gem 'spring', group: :development + + +# Used for testing +gem 'capybara' +gem 'rspec-rails' +gem 'launchy' +gem 'database_cleaner' +gem 'test_models', git: "git://github.com/upmin/test_models.git" + +gemspec :path => '../../' + diff --git a/test_apps/active_record_41/README.rdoc b/test_apps/active_record_41/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test_apps/active_record_41/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test_apps/active_record_41/Rakefile b/test_apps/active_record_41/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/test_apps/active_record_41/Rakefile @@ -0,0 +1,6 @@ +# 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.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test_apps/active_record_41/app/assets/images/.keep b/test_apps/active_record_41/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/app/assets/javascripts/application.js b/test_apps/active_record_41/app/assets/javascripts/application.js new file mode 100644 index 0000000..d6925fa --- /dev/null +++ b/test_apps/active_record_41/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/test_apps/active_record_41/app/assets/stylesheets/application.css b/test_apps/active_record_41/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/test_apps/active_record_41/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test_apps/active_record_41/app/controllers/application_controller.rb b/test_apps/active_record_41/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test_apps/active_record_41/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test_apps/active_record_41/app/controllers/concerns/.keep b/test_apps/active_record_41/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/app/helpers/application_helper.rb b/test_apps/active_record_41/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test_apps/active_record_41/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test_apps/active_record_41/app/mailers/.keep b/test_apps/active_record_41/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/app/models/.keep b/test_apps/active_record_41/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/app/models/concerns/.keep b/test_apps/active_record_41/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/app/views/layouts/application.html.erb b/test_apps/active_record_41/app/views/layouts/application.html.erb new file mode 100644 index 0000000..9f4f0c4 --- /dev/null +++ b/test_apps/active_record_41/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + ActiveRecord41 + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test_apps/active_record_41/bin/bundle b/test_apps/active_record_41/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/test_apps/active_record_41/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test_apps/active_record_41/bin/rails b/test_apps/active_record_41/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/test_apps/active_record_41/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test_apps/active_record_41/bin/rake b/test_apps/active_record_41/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test_apps/active_record_41/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test_apps/active_record_41/config.ru b/test_apps/active_record_41/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test_apps/active_record_41/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test_apps/active_record_41/config/application.rb b/test_apps/active_record_41/config/application.rb new file mode 100644 index 0000000..ce66cd8 --- /dev/null +++ b/test_apps/active_record_41/config/application.rb @@ -0,0 +1,30 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +require "active_model/railtie" +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ActiveRecord41 + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/test_apps/active_record_41/config/boot.rb b/test_apps/active_record_41/config/boot.rb new file mode 100644 index 0000000..5e5f0c1 --- /dev/null +++ b/test_apps/active_record_41/config/boot.rb @@ -0,0 +1,4 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/test_apps/active_record_41/config/database.yml b/test_apps/active_record_41/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/test_apps/active_record_41/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test_apps/active_record_41/config/environment.rb b/test_apps/active_record_41/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/test_apps/active_record_41/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test_apps/active_record_41/config/environments/development.rb b/test_apps/active_record_41/config/environments/development.rb new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/test_apps/active_record_41/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/active_record_41/config/environments/production.rb b/test_apps/active_record_41/config/environments/production.rb new file mode 100644 index 0000000..b93a877 --- /dev/null +++ b/test_apps/active_record_41/config/environments/production.rb @@ -0,0 +1,78 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test_apps/active_record_41/config/environments/test.rb b/test_apps/active_record_41/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/test_apps/active_record_41/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/active_record_41/config/initializers/assets.rb b/test_apps/active_record_41/config/initializers/assets.rb new file mode 100644 index 0000000..d2f4ec3 --- /dev/null +++ b/test_apps/active_record_41/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/test_apps/active_record_41/config/initializers/backtrace_silencers.rb b/test_apps/active_record_41/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test_apps/active_record_41/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test_apps/active_record_41/config/initializers/cookies_serializer.rb b/test_apps/active_record_41/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/test_apps/active_record_41/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/test_apps/active_record_41/config/initializers/filter_parameter_logging.rb b/test_apps/active_record_41/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test_apps/active_record_41/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test_apps/active_record_41/config/initializers/inflections.rb b/test_apps/active_record_41/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test_apps/active_record_41/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test_apps/active_record_41/config/initializers/mime_types.rb b/test_apps/active_record_41/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test_apps/active_record_41/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test_apps/active_record_41/config/initializers/session_store.rb b/test_apps/active_record_41/config/initializers/session_store.rb new file mode 100644 index 0000000..2bec4d9 --- /dev/null +++ b/test_apps/active_record_41/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_active_record_41_session' diff --git a/test_apps/active_record_41/config/initializers/wrap_parameters.rb b/test_apps/active_record_41/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test_apps/active_record_41/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test_apps/active_record_41/config/locales/en.yml b/test_apps/active_record_41/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test_apps/active_record_41/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/spec/dummy/config/routes.rb b/test_apps/active_record_41/config/routes.rb similarity index 100% rename from spec/dummy/config/routes.rb rename to test_apps/active_record_41/config/routes.rb diff --git a/test_apps/active_record_41/config/secrets.yml b/test_apps/active_record_41/config/secrets.yml new file mode 100644 index 0000000..9d977b2 --- /dev/null +++ b/test_apps/active_record_41/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 93401a424e6bf0a7ba926c578a6f8fc4c83d0117cbaec0e83c4a7ce31f15e8ad0f61d5b4b59db044ee0ae0f297c59a50ed6b64b5cb0a727eb18ff0c74badadd5 + +test: + secret_key_base: 76bdda95128265b91446e35034c2a431e5d54321ca085403a70bb888bc6b64e2fc6c86c13614f66c0acab7dbf9a2b63926df625a3395e2e752f49a81a80ad308 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test_apps/active_record_41/db/migrate/20140920222429_create_products.test_models.rb b/test_apps/active_record_41/db/migrate/20140920222429_create_products.test_models.rb new file mode 100644 index 0000000..3cdd485 --- /dev/null +++ b/test_apps/active_record_41/db/migrate/20140920222429_create_products.test_models.rb @@ -0,0 +1,20 @@ +# This migration comes from test_models (originally 20140807182135) +class CreateProducts < ActiveRecord::Migration + def change + create_table :products do |t| + t.string :name + t.string :short_desc + t.integer :best_selling_rank + t.string :thumbnail + t.decimal :price + t.string :manufacturer + t.string :url + t.string :product_type + t.string :image + t.string :category + t.boolean :free_shipping + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_41/db/migrate/20140920222430_create_users.test_models.rb b/test_apps/active_record_41/db/migrate/20140920222430_create_users.test_models.rb new file mode 100644 index 0000000..cbd65e8 --- /dev/null +++ b/test_apps/active_record_41/db/migrate/20140920222430_create_users.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807182247) +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :stripe_card_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_41/db/migrate/20140920222431_create_orders.test_models.rb b/test_apps/active_record_41/db/migrate/20140920222431_create_orders.test_models.rb new file mode 100644 index 0000000..5cd78b5 --- /dev/null +++ b/test_apps/active_record_41/db/migrate/20140920222431_create_orders.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807183757) +class CreateOrders < ActiveRecord::Migration + def change + create_table :orders do |t| + t.integer :user_id + t.string :stripe_charge_id + t.string :stripe_refund_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_41/db/migrate/20140920222432_create_product_orders.test_models.rb b/test_apps/active_record_41/db/migrate/20140920222432_create_product_orders.test_models.rb new file mode 100644 index 0000000..037a3c1 --- /dev/null +++ b/test_apps/active_record_41/db/migrate/20140920222432_create_product_orders.test_models.rb @@ -0,0 +1,13 @@ +# This migration comes from test_models (originally 20140807183823) +class CreateProductOrders < ActiveRecord::Migration + def change + create_table :product_orders do |t| + t.integer :product_id + t.integer :order_id + t.integer :quantity + t.decimal :purchase_price + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_41/db/migrate/20140920222433_create_shipments.test_models.rb b/test_apps/active_record_41/db/migrate/20140920222433_create_shipments.test_models.rb new file mode 100644 index 0000000..1c590b4 --- /dev/null +++ b/test_apps/active_record_41/db/migrate/20140920222433_create_shipments.test_models.rb @@ -0,0 +1,15 @@ +# This migration comes from test_models (originally 20140807184427) +class CreateShipments < ActiveRecord::Migration + def change + create_table :shipments do |t| + t.integer :order_id + t.decimal :price + t.string :carrier + t.string :tracking_code + t.boolean :delivered + t.datetime :est_delivery_date + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_41/db/schema.rb b/test_apps/active_record_41/db/schema.rb new file mode 100644 index 0000000..1ec8260 --- /dev/null +++ b/test_apps/active_record_41/db/schema.rb @@ -0,0 +1,68 @@ +# 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: 20140920222433) do + + create_table "orders", force: true do |t| + t.integer "user_id" + t.string "stripe_charge_id" + t.string "stripe_refund_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "product_orders", force: true do |t| + t.integer "product_id" + t.integer "order_id" + t.integer "quantity" + t.decimal "purchase_price" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "products", force: true do |t| + t.string "name" + t.string "short_desc" + t.integer "best_selling_rank" + t.string "thumbnail" + t.decimal "price" + t.string "manufacturer" + t.string "url" + t.string "product_type" + t.string "image" + t.string "category" + t.boolean "free_shipping" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "shipments", force: true do |t| + t.integer "order_id" + t.decimal "price" + t.string "carrier" + t.string "tracking_code" + t.boolean "delivered" + t.datetime "est_delivery_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: true do |t| + t.string "name" + t.string "email" + t.string "stripe_card_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test_apps/active_record_41/db/seeds.rb b/test_apps/active_record_41/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/test_apps/active_record_41/db/seeds.rb @@ -0,0 +1,7 @@ +# 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', city: cities.first) diff --git a/test_apps/active_record_41/lib/assets/.keep b/test_apps/active_record_41/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/lib/tasks/.keep b/test_apps/active_record_41/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/log/.keep b/test_apps/active_record_41/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/public/404.html b/test_apps/active_record_41/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/test_apps/active_record_41/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_apps/active_record_41/public/422.html b/test_apps/active_record_41/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/test_apps/active_record_41/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_apps/active_record_41/public/500.html b/test_apps/active_record_41/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/test_apps/active_record_41/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_apps/active_record_41/public/favicon.ico b/test_apps/active_record_41/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/public/robots.txt b/test_apps/active_record_41/public/robots.txt new file mode 100644 index 0000000..3c9c7c0 --- /dev/null +++ b/test_apps/active_record_41/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/test_apps/active_record_41/spec/features/search_spec.rb b/test_apps/active_record_41/spec/features/search_spec.rb new file mode 100644 index 0000000..50109e5 --- /dev/null +++ b/test_apps/active_record_41/spec/features/search_spec.rb @@ -0,0 +1,77 @@ +# encoding: UTF-8 +require 'spec_helper' + +feature('Search') do + background do + # Setup BG Stuff + end + + scenario("pagination") do + visit('/upmin/m/User') + + # Make sure some basic pagination exits + within('.pagination') do + within('.current') do + expect(page).to(have_content('1')) + end + + expect(page).to(have_content('Next')) + click_link('Next') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('2')) + end + + expect(page).to(have_content('Next')) + expect(page).to(have_content('Prev')) + + click_link('3') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('3')) + end + end + end + + scenario("Search via integer") do + visit('/upmin/m/Order') + + expect(page).to(have_selector('a.search-result-link', count: 30)) + + fill_in("q_id_gteq", with: 1) + fill_in("q_id_lteq", with: 5) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', count: 5)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + +end diff --git a/test_apps/active_record_41/spec/spec_helper.rb b/test_apps/active_record_41/spec/spec_helper.rb new file mode 100644 index 0000000..ad0022f --- /dev/null +++ b/test_apps/active_record_41/spec/spec_helper.rb @@ -0,0 +1,46 @@ +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/rails' +require 'database_cleaner' + + +if defined?(ActiveRecord) + require File.expand_path('../../../seed/seeder', __FILE__) +end + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.order = "random" + + config.expect_with(:rspec) do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with(:rspec) do |mocks| + mocks.verify_partial_doubles = true + end + + config.before(:suite) do + Seeder.seed + end + + config.after(:suite) do + end + + config.before(:each) do + end + + config.after(:each) do + end + + config.after do |example| + if example.metadata[:type] == :feature && example.exception.present? + save_and_open_page + end + end +end diff --git a/test_apps/active_record_41/vendor/assets/javascripts/.keep b/test_apps/active_record_41/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_41/vendor/assets/stylesheets/.keep b/test_apps/active_record_41/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/.gitignore b/test_apps/active_record_42/.gitignore new file mode 100644 index 0000000..6a502e9 --- /dev/null +++ b/test_apps/active_record_42/.gitignore @@ -0,0 +1,16 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp diff --git a/test_apps/active_record_42/.rspec b/test_apps/active_record_42/.rspec new file mode 100644 index 0000000..b6d0b2a --- /dev/null +++ b/test_apps/active_record_42/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format=d diff --git a/test_apps/active_record_42/Gemfile b/test_apps/active_record_42/Gemfile new file mode 100644 index 0000000..6c6857a --- /dev/null +++ b/test_apps/active_record_42/Gemfile @@ -0,0 +1,37 @@ +source 'https://rubygems.org' + + +gem 'rails', '4.2.0.beta1' +gem 'sqlite3' +gem 'sass-rails', '~> 5.0.0.beta1' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails' +gem 'turbolinks' +gem 'jbuilder', '~> 2.0' +gem 'sdoc', '~> 0.4.0', group: :doc + +gem 'rails-html-sanitizer', '~> 1.0' + + +group :development, :test do + gem 'byebug' + gem 'web-console', '~> 2.0.0.beta2' + gem 'spring' +end + + +# Specific to 4.2.0.beta1 & upmin-admin +gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails-4.2' + +# Used for testing +gem 'capybara' +gem 'rspec-rails' +gem 'launchy' +gem 'database_cleaner' +gem 'test_models', git: "git://github.com/upmin/test_models.git" + +gemspec :path => '../../' + + + diff --git a/test_apps/active_record_42/README.rdoc b/test_apps/active_record_42/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test_apps/active_record_42/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test_apps/active_record_42/Rakefile b/test_apps/active_record_42/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/test_apps/active_record_42/Rakefile @@ -0,0 +1,6 @@ +# 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.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test_apps/active_record_42/app/assets/images/.keep b/test_apps/active_record_42/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/app/assets/javascripts/application.js b/test_apps/active_record_42/app/assets/javascripts/application.js new file mode 100644 index 0000000..d6925fa --- /dev/null +++ b/test_apps/active_record_42/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/test_apps/active_record_42/app/assets/stylesheets/application.css b/test_apps/active_record_42/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/test_apps/active_record_42/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test_apps/active_record_42/app/controllers/application_controller.rb b/test_apps/active_record_42/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test_apps/active_record_42/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test_apps/active_record_42/app/controllers/concerns/.keep b/test_apps/active_record_42/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/app/helpers/application_helper.rb b/test_apps/active_record_42/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test_apps/active_record_42/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test_apps/active_record_42/app/mailers/.keep b/test_apps/active_record_42/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/app/models/.keep b/test_apps/active_record_42/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/app/models/concerns/.keep b/test_apps/active_record_42/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/app/views/layouts/application.html.erb b/test_apps/active_record_42/app/views/layouts/application.html.erb new file mode 100644 index 0000000..013fad3 --- /dev/null +++ b/test_apps/active_record_42/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + ActiveRecord42 + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test_apps/active_record_42/bin/bundle b/test_apps/active_record_42/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/test_apps/active_record_42/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test_apps/active_record_42/bin/rails b/test_apps/active_record_42/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/test_apps/active_record_42/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test_apps/active_record_42/bin/rake b/test_apps/active_record_42/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test_apps/active_record_42/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test_apps/active_record_42/bin/setup b/test_apps/active_record_42/bin/setup new file mode 100755 index 0000000..acdb2c1 --- /dev/null +++ b/test_apps/active_record_42/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/test_apps/active_record_42/config.ru b/test_apps/active_record_42/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test_apps/active_record_42/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test_apps/active_record_42/config/application.rb b/test_apps/active_record_42/config/application.rb new file mode 100644 index 0000000..425cd8c --- /dev/null +++ b/test_apps/active_record_42/config/application.rb @@ -0,0 +1,33 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +require "active_model/railtie" +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ActiveRecord42 + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # For not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true + end +end diff --git a/test_apps/active_record_42/config/boot.rb b/test_apps/active_record_42/config/boot.rb new file mode 100644 index 0000000..6b750f0 --- /dev/null +++ b/test_apps/active_record_42/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/test_apps/active_record_42/config/database.yml b/test_apps/active_record_42/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/test_apps/active_record_42/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test_apps/active_record_42/config/environment.rb b/test_apps/active_record_42/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/test_apps/active_record_42/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test_apps/active_record_42/config/environments/development.rb b/test_apps/active_record_42/config/environments/development.rb new file mode 100644 index 0000000..ddef61b --- /dev/null +++ b/test_apps/active_record_42/config/environments/development.rb @@ -0,0 +1,41 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/active_record_42/config/environments/production.rb b/test_apps/active_record_42/config/environments/production.rb new file mode 100644 index 0000000..0d15891 --- /dev/null +++ b/test_apps/active_record_42/config/environments/production.rb @@ -0,0 +1,76 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like NGINX, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or NGINX will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :info to decrease the log volume. + config.log_level = :debug + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test_apps/active_record_42/config/environments/test.rb b/test_apps/active_record_42/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/test_apps/active_record_42/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/active_record_42/config/initializers/assets.rb b/test_apps/active_record_42/config/initializers/assets.rb new file mode 100644 index 0000000..01ef3e6 --- /dev/null +++ b/test_apps/active_record_42/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/test_apps/active_record_42/config/initializers/backtrace_silencers.rb b/test_apps/active_record_42/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test_apps/active_record_42/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test_apps/active_record_42/config/initializers/cookies_serializer.rb b/test_apps/active_record_42/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7f70458 --- /dev/null +++ b/test_apps/active_record_42/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/test_apps/active_record_42/config/initializers/filter_parameter_logging.rb b/test_apps/active_record_42/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test_apps/active_record_42/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test_apps/active_record_42/config/initializers/inflections.rb b/test_apps/active_record_42/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test_apps/active_record_42/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test_apps/active_record_42/config/initializers/mime_types.rb b/test_apps/active_record_42/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test_apps/active_record_42/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test_apps/active_record_42/config/initializers/session_store.rb b/test_apps/active_record_42/config/initializers/session_store.rb new file mode 100644 index 0000000..bedb176 --- /dev/null +++ b/test_apps/active_record_42/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_active_record_42_session' diff --git a/test_apps/active_record_42/config/initializers/wrap_parameters.rb b/test_apps/active_record_42/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test_apps/active_record_42/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test_apps/active_record_42/config/locales/en.yml b/test_apps/active_record_42/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test_apps/active_record_42/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test_apps/active_record_42/config/routes.rb b/test_apps/active_record_42/config/routes.rb new file mode 100644 index 0000000..452fe12 --- /dev/null +++ b/test_apps/active_record_42/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + mount Upmin::Engine => "/upmin" +end diff --git a/test_apps/active_record_42/config/secrets.yml b/test_apps/active_record_42/config/secrets.yml new file mode 100644 index 0000000..6e7028d --- /dev/null +++ b/test_apps/active_record_42/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 155ab53702ca62fd590f34b7310e392a1c81514870436c39ea5d3883937b3fbe543a06eef407a4bc3d2c959aaf84cf7c8f11dce7d5ac3fdd758fb3b91f24fab7 + +test: + secret_key_base: efc4f644c6b335db4681da4b1d7df9bf6e047d0ac6191d9d200b0487ebb20fef8d23a4b60972e0f4ec7cdb7be96c7382c54ef052c05e9365a31139ad1bd65bd5 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test_apps/active_record_42/db/migrate/20140920222455_create_products.test_models.rb b/test_apps/active_record_42/db/migrate/20140920222455_create_products.test_models.rb new file mode 100644 index 0000000..3cdd485 --- /dev/null +++ b/test_apps/active_record_42/db/migrate/20140920222455_create_products.test_models.rb @@ -0,0 +1,20 @@ +# This migration comes from test_models (originally 20140807182135) +class CreateProducts < ActiveRecord::Migration + def change + create_table :products do |t| + t.string :name + t.string :short_desc + t.integer :best_selling_rank + t.string :thumbnail + t.decimal :price + t.string :manufacturer + t.string :url + t.string :product_type + t.string :image + t.string :category + t.boolean :free_shipping + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_42/db/migrate/20140920222456_create_users.test_models.rb b/test_apps/active_record_42/db/migrate/20140920222456_create_users.test_models.rb new file mode 100644 index 0000000..cbd65e8 --- /dev/null +++ b/test_apps/active_record_42/db/migrate/20140920222456_create_users.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807182247) +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :stripe_card_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_42/db/migrate/20140920222457_create_orders.test_models.rb b/test_apps/active_record_42/db/migrate/20140920222457_create_orders.test_models.rb new file mode 100644 index 0000000..5cd78b5 --- /dev/null +++ b/test_apps/active_record_42/db/migrate/20140920222457_create_orders.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807183757) +class CreateOrders < ActiveRecord::Migration + def change + create_table :orders do |t| + t.integer :user_id + t.string :stripe_charge_id + t.string :stripe_refund_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_42/db/migrate/20140920222458_create_product_orders.test_models.rb b/test_apps/active_record_42/db/migrate/20140920222458_create_product_orders.test_models.rb new file mode 100644 index 0000000..037a3c1 --- /dev/null +++ b/test_apps/active_record_42/db/migrate/20140920222458_create_product_orders.test_models.rb @@ -0,0 +1,13 @@ +# This migration comes from test_models (originally 20140807183823) +class CreateProductOrders < ActiveRecord::Migration + def change + create_table :product_orders do |t| + t.integer :product_id + t.integer :order_id + t.integer :quantity + t.decimal :purchase_price + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_42/db/migrate/20140920222459_create_shipments.test_models.rb b/test_apps/active_record_42/db/migrate/20140920222459_create_shipments.test_models.rb new file mode 100644 index 0000000..1c590b4 --- /dev/null +++ b/test_apps/active_record_42/db/migrate/20140920222459_create_shipments.test_models.rb @@ -0,0 +1,15 @@ +# This migration comes from test_models (originally 20140807184427) +class CreateShipments < ActiveRecord::Migration + def change + create_table :shipments do |t| + t.integer :order_id + t.decimal :price + t.string :carrier + t.string :tracking_code + t.boolean :delivered + t.datetime :est_delivery_date + + t.timestamps null: false + end + end +end diff --git a/test_apps/active_record_42/db/schema.rb b/test_apps/active_record_42/db/schema.rb new file mode 100644 index 0000000..a888bb4 --- /dev/null +++ b/test_apps/active_record_42/db/schema.rb @@ -0,0 +1,68 @@ +# 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: 20140920222459) do + + create_table "orders", force: true do |t| + t.integer "user_id" + t.string "stripe_charge_id" + t.string "stripe_refund_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "product_orders", force: true do |t| + t.integer "product_id" + t.integer "order_id" + t.integer "quantity" + t.decimal "purchase_price" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "products", force: true do |t| + t.string "name" + t.string "short_desc" + t.integer "best_selling_rank" + t.string "thumbnail" + t.decimal "price" + t.string "manufacturer" + t.string "url" + t.string "product_type" + t.string "image" + t.string "category" + t.boolean "free_shipping" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "shipments", force: true do |t| + t.integer "order_id" + t.decimal "price" + t.string "carrier" + t.string "tracking_code" + t.boolean "delivered" + t.datetime "est_delivery_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: true do |t| + t.string "name" + t.string "email" + t.string "stripe_card_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test_apps/active_record_42/db/seeds.rb b/test_apps/active_record_42/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/test_apps/active_record_42/db/seeds.rb @@ -0,0 +1,7 @@ +# 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', city: cities.first) diff --git a/test_apps/active_record_42/lib/assets/.keep b/test_apps/active_record_42/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/lib/tasks/.keep b/test_apps/active_record_42/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/log/.keep b/test_apps/active_record_42/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/public/404.html b/test_apps/active_record_42/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/test_apps/active_record_42/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_apps/active_record_42/public/422.html b/test_apps/active_record_42/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/test_apps/active_record_42/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_apps/active_record_42/public/500.html b/test_apps/active_record_42/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/test_apps/active_record_42/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_apps/active_record_42/public/favicon.ico b/test_apps/active_record_42/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/public/robots.txt b/test_apps/active_record_42/public/robots.txt new file mode 100644 index 0000000..3c9c7c0 --- /dev/null +++ b/test_apps/active_record_42/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/test_apps/active_record_42/spec/features/search_spec.rb b/test_apps/active_record_42/spec/features/search_spec.rb new file mode 100644 index 0000000..50109e5 --- /dev/null +++ b/test_apps/active_record_42/spec/features/search_spec.rb @@ -0,0 +1,77 @@ +# encoding: UTF-8 +require 'spec_helper' + +feature('Search') do + background do + # Setup BG Stuff + end + + scenario("pagination") do + visit('/upmin/m/User') + + # Make sure some basic pagination exits + within('.pagination') do + within('.current') do + expect(page).to(have_content('1')) + end + + expect(page).to(have_content('Next')) + click_link('Next') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('2')) + end + + expect(page).to(have_content('Next')) + expect(page).to(have_content('Prev')) + + click_link('3') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('3')) + end + end + end + + scenario("Search via integer") do + visit('/upmin/m/Order') + + expect(page).to(have_selector('a.search-result-link', count: 30)) + + fill_in("q_id_gteq", with: 1) + fill_in("q_id_lteq", with: 5) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', count: 5)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + +end diff --git a/test_apps/active_record_42/spec/spec_helper.rb b/test_apps/active_record_42/spec/spec_helper.rb new file mode 100644 index 0000000..ad0022f --- /dev/null +++ b/test_apps/active_record_42/spec/spec_helper.rb @@ -0,0 +1,46 @@ +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/rails' +require 'database_cleaner' + + +if defined?(ActiveRecord) + require File.expand_path('../../../seed/seeder', __FILE__) +end + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.order = "random" + + config.expect_with(:rspec) do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with(:rspec) do |mocks| + mocks.verify_partial_doubles = true + end + + config.before(:suite) do + Seeder.seed + end + + config.after(:suite) do + end + + config.before(:each) do + end + + config.after(:each) do + end + + config.after do |example| + if example.metadata[:type] == :feature && example.exception.present? + save_and_open_page + end + end +end diff --git a/test_apps/active_record_42/vendor/assets/javascripts/.keep b/test_apps/active_record_42/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/active_record_42/vendor/assets/stylesheets/.keep b/test_apps/active_record_42/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/.gitignore b/test_apps/will_paginate/.gitignore new file mode 100644 index 0000000..6a502e9 --- /dev/null +++ b/test_apps/will_paginate/.gitignore @@ -0,0 +1,16 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp diff --git a/test_apps/will_paginate/.rspec b/test_apps/will_paginate/.rspec new file mode 100644 index 0000000..b6d0b2a --- /dev/null +++ b/test_apps/will_paginate/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format=d diff --git a/test_apps/will_paginate/Gemfile b/test_apps/will_paginate/Gemfile new file mode 100644 index 0000000..f65f374 --- /dev/null +++ b/test_apps/will_paginate/Gemfile @@ -0,0 +1,22 @@ +source 'https://rubygems.org' + +gem 'rails', '4.0.10' +gem 'sqlite3' +gem 'sass-rails', '~> 4.0.2' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails' +gem 'turbolinks' +gem 'jbuilder', '~> 1.2' + +# Specific gem we are testing: +gem 'will_paginate' + +# Used for testing +gem 'capybara' +gem 'rspec-rails' +gem 'launchy' +gem 'database_cleaner' +gem 'test_models', git: "git://github.com/upmin/test_models.git" + +gemspec :path => '../../' diff --git a/test_apps/will_paginate/README.rdoc b/test_apps/will_paginate/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test_apps/will_paginate/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test_apps/will_paginate/Rakefile b/test_apps/will_paginate/Rakefile new file mode 100644 index 0000000..992a980 --- /dev/null +++ b/test_apps/will_paginate/Rakefile @@ -0,0 +1,6 @@ +# 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.expand_path('../config/application', __FILE__) + +ActiveRecord40::Application.load_tasks diff --git a/test_apps/will_paginate/app/assets/images/.keep b/test_apps/will_paginate/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/app/assets/javascripts/application.js b/test_apps/will_paginate/app/assets/javascripts/application.js new file mode 100644 index 0000000..d6925fa --- /dev/null +++ b/test_apps/will_paginate/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/test_apps/will_paginate/app/assets/stylesheets/application.css b/test_apps/will_paginate/app/assets/stylesheets/application.css new file mode 100644 index 0000000..3192ec8 --- /dev/null +++ b/test_apps/will_paginate/app/assets/stylesheets/application.css @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . + */ diff --git a/test_apps/will_paginate/app/controllers/application_controller.rb b/test_apps/will_paginate/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test_apps/will_paginate/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test_apps/will_paginate/app/controllers/concerns/.keep b/test_apps/will_paginate/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/app/helpers/application_helper.rb b/test_apps/will_paginate/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test_apps/will_paginate/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test_apps/will_paginate/app/mailers/.keep b/test_apps/will_paginate/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/app/models/.keep b/test_apps/will_paginate/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/app/models/concerns/.keep b/test_apps/will_paginate/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/app/views/layouts/application.html.erb b/test_apps/will_paginate/app/views/layouts/application.html.erb new file mode 100644 index 0000000..e668886 --- /dev/null +++ b/test_apps/will_paginate/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + ActiveRecord40 + <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> + <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test_apps/will_paginate/bin/bundle b/test_apps/will_paginate/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/test_apps/will_paginate/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test_apps/will_paginate/bin/rails b/test_apps/will_paginate/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/test_apps/will_paginate/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test_apps/will_paginate/bin/rake b/test_apps/will_paginate/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test_apps/will_paginate/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test_apps/will_paginate/config.ru b/test_apps/will_paginate/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test_apps/will_paginate/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test_apps/will_paginate/config/application.rb b/test_apps/will_paginate/config/application.rb new file mode 100644 index 0000000..8c3c72b --- /dev/null +++ b/test_apps/will_paginate/config/application.rb @@ -0,0 +1,28 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ActiveRecord40 + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/test_apps/will_paginate/config/boot.rb b/test_apps/will_paginate/config/boot.rb new file mode 100644 index 0000000..5e5f0c1 --- /dev/null +++ b/test_apps/will_paginate/config/boot.rb @@ -0,0 +1,4 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/test_apps/will_paginate/config/database.yml b/test_apps/will_paginate/config/database.yml new file mode 100644 index 0000000..51a4dd4 --- /dev/null +++ b/test_apps/will_paginate/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/test_apps/will_paginate/config/environment.rb b/test_apps/will_paginate/config/environment.rb new file mode 100644 index 0000000..59c0330 --- /dev/null +++ b/test_apps/will_paginate/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +ActiveRecord40::Application.initialize! diff --git a/test_apps/will_paginate/config/environments/development.rb b/test_apps/will_paginate/config/environments/development.rb new file mode 100644 index 0000000..07dd969 --- /dev/null +++ b/test_apps/will_paginate/config/environments/development.rb @@ -0,0 +1,32 @@ +ActiveRecord40::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/will_paginate/config/environments/production.rb b/test_apps/will_paginate/config/environments/production.rb new file mode 100644 index 0000000..49897b5 --- /dev/null +++ b/test_apps/will_paginate/config/environments/production.rb @@ -0,0 +1,80 @@ +ActiveRecord40::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/test_apps/will_paginate/config/environments/test.rb b/test_apps/will_paginate/config/environments/test.rb new file mode 100644 index 0000000..016ac61 --- /dev/null +++ b/test_apps/will_paginate/config/environments/test.rb @@ -0,0 +1,39 @@ +ActiveRecord40::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test_apps/will_paginate/config/initializers/backtrace_silencers.rb b/test_apps/will_paginate/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test_apps/will_paginate/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test_apps/will_paginate/config/initializers/filter_parameter_logging.rb b/test_apps/will_paginate/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test_apps/will_paginate/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test_apps/will_paginate/config/initializers/inflections.rb b/test_apps/will_paginate/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test_apps/will_paginate/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test_apps/will_paginate/config/initializers/mime_types.rb b/test_apps/will_paginate/config/initializers/mime_types.rb new file mode 100644 index 0000000..72aca7e --- /dev/null +++ b/test_apps/will_paginate/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/test_apps/will_paginate/config/initializers/secret_token.rb b/test_apps/will_paginate/config/initializers/secret_token.rb new file mode 100644 index 0000000..d7d26e9 --- /dev/null +++ b/test_apps/will_paginate/config/initializers/secret_token.rb @@ -0,0 +1,12 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure your secret_key_base is kept private +# if you're sharing your code publicly. +ActiveRecord40::Application.config.secret_key_base = '71cbc8ff2c8f396c5fd327d32ece1d2ced7024f3f2dfc50c1e678d6c84b57c034117dcfaa79baf31f8c71933d7c286d2aa3e3037052456adf09ebe2402dca2c7' diff --git a/test_apps/will_paginate/config/initializers/session_store.rb b/test_apps/will_paginate/config/initializers/session_store.rb new file mode 100644 index 0000000..dd9984e --- /dev/null +++ b/test_apps/will_paginate/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +ActiveRecord40::Application.config.session_store :cookie_store, key: '_active_record_40_session' diff --git a/test_apps/will_paginate/config/initializers/wrap_parameters.rb b/test_apps/will_paginate/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test_apps/will_paginate/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test_apps/will_paginate/config/locales/en.yml b/test_apps/will_paginate/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test_apps/will_paginate/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test_apps/will_paginate/config/routes.rb b/test_apps/will_paginate/config/routes.rb new file mode 100644 index 0000000..51d7567 --- /dev/null +++ b/test_apps/will_paginate/config/routes.rb @@ -0,0 +1,3 @@ +ActiveRecord40::Application.routes.draw do + mount Upmin::Engine => "/upmin" +end diff --git a/test_apps/will_paginate/db/migrate/20140920222929_create_products.test_models.rb b/test_apps/will_paginate/db/migrate/20140920222929_create_products.test_models.rb new file mode 100644 index 0000000..3cdd485 --- /dev/null +++ b/test_apps/will_paginate/db/migrate/20140920222929_create_products.test_models.rb @@ -0,0 +1,20 @@ +# This migration comes from test_models (originally 20140807182135) +class CreateProducts < ActiveRecord::Migration + def change + create_table :products do |t| + t.string :name + t.string :short_desc + t.integer :best_selling_rank + t.string :thumbnail + t.decimal :price + t.string :manufacturer + t.string :url + t.string :product_type + t.string :image + t.string :category + t.boolean :free_shipping + + t.timestamps null: false + end + end +end diff --git a/test_apps/will_paginate/db/migrate/20140920222930_create_users.test_models.rb b/test_apps/will_paginate/db/migrate/20140920222930_create_users.test_models.rb new file mode 100644 index 0000000..cbd65e8 --- /dev/null +++ b/test_apps/will_paginate/db/migrate/20140920222930_create_users.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807182247) +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :stripe_card_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/will_paginate/db/migrate/20140920222931_create_orders.test_models.rb b/test_apps/will_paginate/db/migrate/20140920222931_create_orders.test_models.rb new file mode 100644 index 0000000..5cd78b5 --- /dev/null +++ b/test_apps/will_paginate/db/migrate/20140920222931_create_orders.test_models.rb @@ -0,0 +1,12 @@ +# This migration comes from test_models (originally 20140807183757) +class CreateOrders < ActiveRecord::Migration + def change + create_table :orders do |t| + t.integer :user_id + t.string :stripe_charge_id + t.string :stripe_refund_id + + t.timestamps null: false + end + end +end diff --git a/test_apps/will_paginate/db/migrate/20140920222932_create_product_orders.test_models.rb b/test_apps/will_paginate/db/migrate/20140920222932_create_product_orders.test_models.rb new file mode 100644 index 0000000..037a3c1 --- /dev/null +++ b/test_apps/will_paginate/db/migrate/20140920222932_create_product_orders.test_models.rb @@ -0,0 +1,13 @@ +# This migration comes from test_models (originally 20140807183823) +class CreateProductOrders < ActiveRecord::Migration + def change + create_table :product_orders do |t| + t.integer :product_id + t.integer :order_id + t.integer :quantity + t.decimal :purchase_price + + t.timestamps null: false + end + end +end diff --git a/test_apps/will_paginate/db/migrate/20140920222933_create_shipments.test_models.rb b/test_apps/will_paginate/db/migrate/20140920222933_create_shipments.test_models.rb new file mode 100644 index 0000000..1c590b4 --- /dev/null +++ b/test_apps/will_paginate/db/migrate/20140920222933_create_shipments.test_models.rb @@ -0,0 +1,15 @@ +# This migration comes from test_models (originally 20140807184427) +class CreateShipments < ActiveRecord::Migration + def change + create_table :shipments do |t| + t.integer :order_id + t.decimal :price + t.string :carrier + t.string :tracking_code + t.boolean :delivered + t.datetime :est_delivery_date + + t.timestamps null: false + end + end +end diff --git a/test_apps/will_paginate/db/schema.rb b/test_apps/will_paginate/db/schema.rb new file mode 100644 index 0000000..2bcee85 --- /dev/null +++ b/test_apps/will_paginate/db/schema.rb @@ -0,0 +1,68 @@ +# 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: 20140920222933) do + + create_table "orders", force: true do |t| + t.integer "user_id" + t.string "stripe_charge_id" + t.string "stripe_refund_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "product_orders", force: true do |t| + t.integer "product_id" + t.integer "order_id" + t.integer "quantity" + t.decimal "purchase_price" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "products", force: true do |t| + t.string "name" + t.string "short_desc" + t.integer "best_selling_rank" + t.string "thumbnail" + t.decimal "price" + t.string "manufacturer" + t.string "url" + t.string "product_type" + t.string "image" + t.string "category" + t.boolean "free_shipping" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "shipments", force: true do |t| + t.integer "order_id" + t.decimal "price" + t.string "carrier" + t.string "tracking_code" + t.boolean "delivered" + t.datetime "est_delivery_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: true do |t| + t.string "name" + t.string "email" + t.string "stripe_card_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test_apps/will_paginate/db/seeds.rb b/test_apps/will_paginate/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/test_apps/will_paginate/db/seeds.rb @@ -0,0 +1,7 @@ +# 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', city: cities.first) diff --git a/test_apps/will_paginate/lib/assets/.keep b/test_apps/will_paginate/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/lib/tasks/.keep b/test_apps/will_paginate/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/log/.keep b/test_apps/will_paginate/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/public/404.html b/test_apps/will_paginate/public/404.html new file mode 100644 index 0000000..a0daa0c --- /dev/null +++ b/test_apps/will_paginate/public/404.html @@ -0,0 +1,58 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/test_apps/will_paginate/public/422.html b/test_apps/will_paginate/public/422.html new file mode 100644 index 0000000..fbb4b84 --- /dev/null +++ b/test_apps/will_paginate/public/422.html @@ -0,0 +1,58 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/test_apps/will_paginate/public/500.html b/test_apps/will_paginate/public/500.html new file mode 100644 index 0000000..e9052d3 --- /dev/null +++ b/test_apps/will_paginate/public/500.html @@ -0,0 +1,57 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/test_apps/will_paginate/public/favicon.ico b/test_apps/will_paginate/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/public/robots.txt b/test_apps/will_paginate/public/robots.txt new file mode 100644 index 0000000..3c9c7c0 --- /dev/null +++ b/test_apps/will_paginate/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/test_apps/will_paginate/spec/features/search_spec.rb b/test_apps/will_paginate/spec/features/search_spec.rb new file mode 100644 index 0000000..3ef32ef --- /dev/null +++ b/test_apps/will_paginate/spec/features/search_spec.rb @@ -0,0 +1,79 @@ +# encoding: UTF-8 +require 'spec_helper' + +feature('Search') do + background do + # Setup BG Stuff + end + + scenario("pagination") do + visit('/upmin/m/User') + + page.save_and_open_page + + # Make sure some basic pagination exits + within('.pagination') do + within('.current') do + expect(page).to(have_content('1')) + end + + expect(page).to(have_content('Next')) + click_link('Next') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('2')) + end + + expect(page).to(have_content('Next')) + expect(page).to(have_content('Prev')) + + click_link('3') + end + + within('.pagination') do + within('.current') do + expect(page).to(have_content('3')) + end + end + end + + scenario("Search via integer") do + visit('/upmin/m/Order') + + expect(page).to(have_selector('a.search-result-link', count: 30)) + + fill_in("q_id_gteq", with: 1) + fill_in("q_id_lteq", with: 5) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', count: 5)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + scenario("Search via string") do + expected_user = User.first + + visit('/upmin/m/User') + + fill_in("q_name_cont", with: expected_user.name) + click_button("Search") + + expect(page).to(have_selector('a.search-result-link', minimum: 1)) + expect(page).to(have_content(expected_user.name)) + end + + +end diff --git a/test_apps/will_paginate/spec/spec_helper.rb b/test_apps/will_paginate/spec/spec_helper.rb new file mode 100644 index 0000000..3eed3d8 --- /dev/null +++ b/test_apps/will_paginate/spec/spec_helper.rb @@ -0,0 +1,46 @@ +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/rails' +require 'database_cleaner' + + +if defined?(ActiveRecord) + require File.expand_path('../../../../seed/seeder', __FILE__) +end + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.order = "random" + + config.expect_with(:rspec) do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with(:rspec) do |mocks| + mocks.verify_partial_doubles = true + end + + config.before(:suite) do + Seeder.seed + end + + config.after(:suite) do + end + + config.before(:each) do + end + + config.after(:each) do + end + + config.after do |example| + if example.metadata[:type] == :feature && example.exception.present? + save_and_open_page + end + end +end diff --git a/test_apps/will_paginate/vendor/assets/javascripts/.keep b/test_apps/will_paginate/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_apps/will_paginate/vendor/assets/stylesheets/.keep b/test_apps/will_paginate/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/upmin-admin.gemspec b/upmin-admin.gemspec index 2acd6cf..99d8681 100644 --- a/upmin-admin.gemspec +++ b/upmin-admin.gemspec @@ -23,17 +23,8 @@ Gem::Specification.new do |s| s.add_dependency "rails" s.add_dependency "haml", [">= 3.0.0"] - s.add_dependency "jquery-rails", [">= 0"] - s.add_dependency "sass-rails", [">= 0"] - s.add_dependency "kaminari", [">= 0"] - s.add_dependency "ransack", [">= 0"] - - s.add_development_dependency "bundler", [">= 0"] - s.add_development_dependency "rake", [">= 0"] - s.add_development_dependency "sqlite3", [">= 0"] - s.add_development_dependency "rspec-rails", [">= 0"] - s.add_development_dependency "capybara", [">= 0"] - s.add_development_dependency "factory_girl_rails", [">= 0"] - s.add_development_dependency "database_cleaner", [">= 0"] - s.add_development_dependency "launchy", [">= 0"] + s.add_dependency "jquery-rails" + s.add_dependency "sass-rails" + s.add_dependency "kaminari" + s.add_dependency "ransack" end diff --git a/upmin-rails.sublime-project b/upmin-rails.sublime-project index 9cbd597..1066df0 100644 --- a/upmin-rails.sublime-project +++ b/upmin-rails.sublime-project @@ -3,7 +3,8 @@ [ { "follow_symlinks": true, - "path": "." + "path": ".", + "folder_exclude_patterns": ["test_apps/*"] } ] }