mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Configure Travis, remove spork, add simplecov, add turbo sprokets.
Add travis config (cherry picked from commite3fdb12289) Only build on Ruby 1.9.3 (cherry picked from commit719ef386bf) Exclude pry from CI build (cherry picked from commitd60935c800) Conflicts: Gemfile Attempt 2 (cherry picked from commit2b19253895) Conflicts: Gemfile.lock Configure travis for postgres (cherry picked from commit3a441cd7d9) Fix migrations that fail because of coupling to changed/removed models (cherry picked from commitb030793f15) Set up xvfb for Travis (cherry picked from commitcdc3ab09a1) Add a failing test to test travis (cherry picked from commit72aa8fe5e5) Revert "Add a failing test to test travis" This reverts commit72aa8fe5e5. (cherry picked from commitbd5533e2b1) Add simplecov (cherry picked from commit5089d3bb22) Conflicts: Gemfile.lock Add turbo sprockets for faster asset precompile (cherry picked from commit3e6c56a638) Remove spork (cherry picked from commited7bded642) Conflicts: spec/spec_helper.rb Remove more spork-specific things, remove unused cuc config from zeus (cherry picked from commitfa11ff8982) Ensure order decorator is required, fix test fragility (cherry picked from commit1e94f88c5e)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -29,3 +29,4 @@ public/spree
|
||||
config/abr.yml
|
||||
config/heroku_env.rb
|
||||
NERD_tree*
|
||||
coverage
|
||||
|
||||
14
.travis.yml
Normal file
14
.travis.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
language: ruby
|
||||
bundler_args: --without development
|
||||
rvm:
|
||||
- "1.9.3"
|
||||
services: postgresql
|
||||
before_install:
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
||||
before_script:
|
||||
- cp config/database.travis.yml config/database.yml
|
||||
- psql -c 'create database open_food_web_test;' -U postgres
|
||||
script:
|
||||
- RAILS_ENV=test bundle exec rake db:migrate --trace
|
||||
- export DISPLAY=:99.0 && bundle exec rake spec
|
||||
10
Gemfile
10
Gemfile
@@ -37,6 +37,8 @@ group :assets do
|
||||
gem 'therubyracer'
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
|
||||
gem 'turbo-sprockets-rails3'
|
||||
end
|
||||
|
||||
gem 'jquery-rails'
|
||||
@@ -52,8 +54,7 @@ group :test, :development do
|
||||
gem 'faker'
|
||||
gem 'capybara'
|
||||
gem 'database_cleaner', '0.7.1', :require => false
|
||||
gem 'spork', '~> 1.0rc'
|
||||
gem 'pry-debugger'
|
||||
gem 'simplecov', :require => false
|
||||
gem 'awesome_print'
|
||||
gem 'letter_opener'
|
||||
gem 'timecop'
|
||||
@@ -64,3 +65,8 @@ group :chili do
|
||||
gem 'eaterprises_feature', path: 'lib/chili/eaterprises_feature'
|
||||
gem 'local_organics_feature', path: 'lib/chili/local_organics_feature'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'pry-debugger'
|
||||
gem 'debugger-linecache'
|
||||
end
|
||||
|
||||
12
Gemfile.lock
12
Gemfile.lock
@@ -371,8 +371,11 @@ GEM
|
||||
websocket (~> 1.0.4)
|
||||
shoulda-matchers (1.1.0)
|
||||
activesupport (>= 3.0.0)
|
||||
simplecov (0.7.1)
|
||||
multi_json (~> 1.0)
|
||||
simplecov-html (~> 0.7.1)
|
||||
simplecov-html (0.7.1)
|
||||
slop (3.3.3)
|
||||
spork (1.0.0rc3)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
@@ -389,6 +392,9 @@ GEM
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
truncate_html (0.5.5)
|
||||
turbo-sprockets-rails3 (0.3.6)
|
||||
railties (> 3.2.8, < 4.0.0)
|
||||
sprockets (>= 2.0.0)
|
||||
turn (0.8.3)
|
||||
ansi
|
||||
tzinfo (0.3.37)
|
||||
@@ -420,6 +426,7 @@ DEPENDENCIES
|
||||
comfortable_mexican_sofa
|
||||
database_cleaner (= 0.7.1)
|
||||
db2fog
|
||||
debugger-linecache
|
||||
deface!
|
||||
eaterprises_feature!
|
||||
enterprises_distributor_info_rich_text_feature!
|
||||
@@ -438,7 +445,7 @@ DEPENDENCIES
|
||||
sass-rails (~> 3.2.3)
|
||||
shoulda-matchers
|
||||
simple_form!
|
||||
spork (~> 1.0rc)
|
||||
simplecov
|
||||
spree!
|
||||
spree_i18n!
|
||||
spree_last_address!
|
||||
@@ -446,6 +453,7 @@ DEPENDENCIES
|
||||
therubyracer
|
||||
timecop
|
||||
truncate_html
|
||||
turbo-sprockets-rails3
|
||||
turn (~> 0.8.3)
|
||||
uglifier (>= 1.0.3)
|
||||
unicorn
|
||||
|
||||
@@ -59,15 +59,9 @@ Then the tests can be run with:
|
||||
bundle exec rspec spec
|
||||
|
||||
The site is configured to use
|
||||
[Spork](https://github.com/sporkrb/spork) to reduce the pre-test
|
||||
startup time while Rails loads. To use it, first start up a spork
|
||||
instance:
|
||||
|
||||
bundle exec spork
|
||||
|
||||
When that's ready, you can run RSpec with the --drb flag:
|
||||
|
||||
bundle exec rspec --drb spec
|
||||
[Zeus](https://github.com/burke/zeus) to reduce the pre-test
|
||||
startup time while Rails loads. See the Zeus github page for
|
||||
usage instructions.
|
||||
|
||||
|
||||
## Deployment
|
||||
|
||||
4
config/database.travis.yml
Normal file
4
config/database.travis.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
test:
|
||||
adapter: postgresql
|
||||
database: open_food_web_test
|
||||
username: postgres
|
||||
@@ -1,5 +1,6 @@
|
||||
# Legacy table support
|
||||
class Checkout < ActiveRecord::Base; end;
|
||||
class Spree::Creditcard < ActiveRecord::Base; end;
|
||||
|
||||
class PolymorphicPayments < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
class MoveDistributorFromOrderToProduct < ActiveRecord::Migration
|
||||
class Distributor < ActiveRecord::Base; end
|
||||
class Spree::Product < ActiveRecord::Base; end
|
||||
|
||||
def up
|
||||
remove_column :spree_orders, :distributor_id
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
class ExtractDistributorAndSupplierAddressToSpreeAddress < ActiveRecord::Migration
|
||||
class Supplier < ActiveRecord::Base; end
|
||||
class Distributor < ActiveRecord::Base; end
|
||||
class Spree::Address < ActiveRecord::Base; end
|
||||
|
||||
|
||||
def up
|
||||
# -- Distributors
|
||||
add_column :distributors, :pickup_address_id, :integer
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
class RenameDistributorsProductsToProductDistributions < ActiveRecord::Migration
|
||||
class Spree::ShippingMethod < ActiveRecord::Base; end
|
||||
class ProductDistribution < ActiveRecord::Base; end
|
||||
|
||||
def up
|
||||
# Convert m2m join table into explicit join model, and add a shipping method relation and timestamps
|
||||
rename_table :distributors_products, :product_distributions
|
||||
@@ -9,7 +12,7 @@ class RenameDistributorsProductsToProductDistributions < ActiveRecord::Migration
|
||||
end
|
||||
|
||||
# Set default shipping method on all product distributions
|
||||
sm = Spree::ShippingMethod.first
|
||||
sm = Spree::ShippingMethod.unscoped.first
|
||||
ProductDistribution.update_all(:shipping_method_id => sm.id) if sm
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
||||
|
||||
if ENV['RAILS_ENV'] == 'test'
|
||||
require 'simplecov'
|
||||
SimpleCov.start 'rails'
|
||||
puts "required simplecov"
|
||||
end
|
||||
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'rails/commands'
|
||||
|
||||
@@ -160,7 +160,7 @@ module OpenFoodWeb
|
||||
applicator.send(:update_exchange, sender.id, receiver.id, {:variant_ids => [variant1.id, variant3.id]})
|
||||
|
||||
exchange.reload
|
||||
exchange.variant_ids.should == [variant1.id, variant3.id]
|
||||
exchange.variant_ids.sort.should == [variant1.id, variant3.id].sort
|
||||
applicator.send(:touched_exchanges).should == [exchange]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,68 +1,60 @@
|
||||
require 'simplecov'
|
||||
SimpleCov.start
|
||||
|
||||
require 'rubygems'
|
||||
require 'spork'
|
||||
#uncomment the following line to use spork with the debugger
|
||||
#require 'spork/ext/ruby-debug'
|
||||
|
||||
# By default, test on eaterprises deployment settings
|
||||
# This must be set before rails loads so that it's available in engine initializers
|
||||
ENV['OFW_DEPLOYMENT'] ||= 'eaterprises'
|
||||
|
||||
|
||||
Spork.prefork do
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
require 'capybara'
|
||||
require 'database_cleaner'
|
||||
ENV["RAILS_ENV"] = 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'capybara'
|
||||
require 'database_cleaner'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
require 'spree/core/testing_support/controller_requests'
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
require 'spree/core/testing_support/controller_requests'
|
||||
|
||||
require 'active_record/fixtures'
|
||||
fixtures_dir = File.expand_path('../../db/default', __FILE__)
|
||||
ActiveRecord::Fixtures.create_fixtures(fixtures_dir, ['spree/states', 'spree/countries'])
|
||||
require 'active_record/fixtures'
|
||||
fixtures_dir = File.expand_path('../../db/default', __FILE__)
|
||||
ActiveRecord::Fixtures.create_fixtures(fixtures_dir, ['spree/states', 'spree/countries'])
|
||||
|
||||
|
||||
RSpec.configure do |config|
|
||||
# ## Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
RSpec.configure do |config|
|
||||
# ## Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = false
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = false
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
# ## Filters
|
||||
#
|
||||
config.filter_run_excluding :skip => true
|
||||
# ## Filters
|
||||
#
|
||||
config.filter_run_excluding :skip => true
|
||||
|
||||
config.before(:each) do
|
||||
if example.metadata[:js]
|
||||
DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] }
|
||||
else
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
|
||||
config.after(:each) do
|
||||
DatabaseCleaner.clean
|
||||
config.before(:each) do
|
||||
if example.metadata[:js]
|
||||
DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] }
|
||||
else
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
@@ -74,18 +66,20 @@ Spork.prefork do
|
||||
config.include Spree::UrlHelpers
|
||||
config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
end
|
||||
|
||||
Spork.each_run do
|
||||
Dir["#{File.dirname(__FILE__)}/../app/**/*.rb"].each {|f| load f}
|
||||
Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| load f}
|
||||
config.after(:each) do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
Rails.application.reload_routes!
|
||||
config.include Rails.application.routes.url_helpers
|
||||
config.include Spree::UrlHelpers
|
||||
config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
|
||||
# Factory girl
|
||||
require 'factory_girl_rails'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user