├── .rspec ├── config ├── spree.yml ├── routes.rb ├── locales │ └── en.yml └── initializers │ └── spree.rb ├── SPREE_TRAVEL_VERSIONS ├── lib ├── spree_travel.rb ├── spree_travel │ ├── support.rb │ ├── factories.rb │ └── engine.rb └── generators │ └── spree_travel │ └── install │ └── install_generator.rb ├── app └── assets │ ├── javascripts │ ├── admin │ │ ├── spree_travel.js │ │ └── all.js │ └── store │ │ ├── spree_travel.js │ │ └── all.js │ └── stylesheets │ ├── admin │ ├── spree_travel.css │ └── all.css │ └── store │ ├── spree_travel.css │ └── all.css ├── .gitignore ├── script └── rails ├── Rakefile ├── Versionfile ├── Gemfile ├── README.md.alternate ├── LICENSE ├── spree_travel.gemspec ├── README.md └── spec └── spec_helper.rb /.rspec: -------------------------------------------------------------------------------- 1 | --color -------------------------------------------------------------------------------- /config/spree.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2.1.1 3 | -------------------------------------------------------------------------------- /SPREE_TRAVEL_VERSIONS: -------------------------------------------------------------------------------- 1 | gems: 2 | spree: 2.3.3 3 | spree_travel: 2.3.3 4 | -------------------------------------------------------------------------------- /lib/spree_travel.rb: -------------------------------------------------------------------------------- 1 | require 'spree_core' 2 | require 'spree_travel/engine' 3 | -------------------------------------------------------------------------------- /app/assets/javascripts/admin/spree_travel.js: -------------------------------------------------------------------------------- 1 | //= require admin/spree_backend 2 | -------------------------------------------------------------------------------- /app/assets/javascripts/store/spree_travel.js: -------------------------------------------------------------------------------- 1 | //= require store/spree_frontend 2 | -------------------------------------------------------------------------------- /app/assets/stylesheets/admin/spree_travel.css: -------------------------------------------------------------------------------- 1 | /* 2 | *= require admin/spree_backend 3 | */ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/store/spree_travel.css: -------------------------------------------------------------------------------- 1 | /* 2 | *= require store/spree_frontend 3 | */ 4 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Spree::Core::Engine.routes.draw do 2 | # Add your extension routes here 3 | end 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | \#* 2 | *~ 3 | .#* 4 | .DS_Store 5 | .idea 6 | .project 7 | .sass-cache 8 | coverage 9 | Gemfile.lock 10 | tmp 11 | nbproject 12 | pkg 13 | *.swp 14 | spec/dummy 15 | -------------------------------------------------------------------------------- /lib/spree_travel/support.rb: -------------------------------------------------------------------------------- 1 | def silent_run(command) 2 | 3 | if RUBY_PLATFORM =~ /mswin/ #windows 4 | command += " >nul" 5 | else 6 | command += " >/dev/null" 7 | end 8 | system(command) 9 | end -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /lib/spree_travel/factories.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them. 3 | # 4 | # Example adding this to your spec_helper will load these Factories for use: 5 | # require 'spree_travel/factories' 6 | end 7 | -------------------------------------------------------------------------------- /script/rails: -------------------------------------------------------------------------------- 1 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 2 | 3 | ENGINE_ROOT = File.expand_path('../..', __FILE__) 4 | ENGINE_PATH = File.expand_path('../../lib/spree_travel/engine', __FILE__) 5 | 6 | require 'rails/all' 7 | require 'rails/engine/commands' 8 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler' 2 | Bundler::GemHelper.install_tasks 3 | 4 | require 'rspec/core/rake_task' 5 | require 'spree/testing_support/extension_rake' 6 | 7 | RSpec::Core::RakeTask.new 8 | 9 | task :default => [:spec] 10 | 11 | desc 'Generates a dummy app for testing' 12 | task :test_app do 13 | ENV['LIB_NAME'] = 'spree_travel' 14 | Rake::Task['extension:test_app'].invoke 15 | end 16 | -------------------------------------------------------------------------------- /Versionfile: -------------------------------------------------------------------------------- 1 | # This file is used to designate compatibilty with different versions of Spree 2 | # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details 3 | 4 | # Examples 5 | # 6 | # '1.2.x' => { :branch => 'master' } 7 | # '1.1.x' => { :branch => '1-1-stable' } 8 | # '1.0.x' => { :branch => '1-0-stable' } 9 | # '0.70.x' => { :branch => '0-70-stable' } 10 | # '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' } 11 | 12 | -------------------------------------------------------------------------------- /app/assets/stylesheets/admin/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | 7 | *= require admin/spree_backend 8 | 9 | *= require_self 10 | *= require_tree . 11 | */ 12 | -------------------------------------------------------------------------------- /app/assets/stylesheets/store/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | 7 | *= require store/spree_frontend 8 | 9 | *= require_self 10 | *= require_tree . 11 | */ 12 | -------------------------------------------------------------------------------- /app/assets/javascripts/admin/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | 10 | //= require admin/spree_backend 11 | 12 | //= require_tree . 13 | -------------------------------------------------------------------------------- /app/assets/javascripts/store/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | 10 | //= require store/spree_frontend 11 | 12 | //= require_tree . 13 | -------------------------------------------------------------------------------- /config/initializers/spree.rb: -------------------------------------------------------------------------------- 1 | # Configure Spree Preferences 2 | # 3 | # Note: Initializing preferences available within the Admin will overwrite any changes that were made through the user interface when you restart. 4 | # If you would like users to be able to update a setting with the Admin it should NOT be set here. 5 | # 6 | # In order to initialize a setting do: 7 | # config.setting_name = 'new value' 8 | Spree.config do |config| 9 | # Example: 10 | # Uncomment to override the default site name. 11 | # config.site_name = "Spree Demo Site" 12 | end 13 | 14 | Spree.user_class = "Spree::LegacyUser" 15 | -------------------------------------------------------------------------------- /lib/spree_travel/engine.rb: -------------------------------------------------------------------------------- 1 | module SpreeTravel 2 | class Engine < Rails::Engine 3 | require 'spree/core' 4 | isolate_namespace Spree 5 | engine_name 'spree_travel' 6 | 7 | config.autoload_paths += %W(#{config.root}/lib) 8 | 9 | # use rspec for tests 10 | config.generators do |g| 11 | g.test_framework :rspec 12 | end 13 | 14 | def self.activate 15 | Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c| 16 | Rails.configuration.cache_classes ? require(c) : load(c) 17 | end 18 | end 19 | 20 | config.to_prepare &method(:activate).to_proc 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # source 'http://rubygems.org' 2 | source 'file:///Users/dustet/rubygems' 3 | 4 | gem 'spree_auth_devise', :git => 'file:///Volumes/Data/Important/spree_travel/spree/spree_auth_devise', :branch => '2-3-stable' 5 | # gem 'spree_auth_devise', :git => "https://github.com/openjaf/spree_auth_devise", :branch => '2-3-stable' 6 | 7 | gem 'spree_travel_core', :git => 'file:///Volumes/Data/Important/spree_travel/openjaf/spree_travel_core', :branch => '2-3-stable' 8 | # gem 'spree_travel_core', :git => "https://github.com/openjaf/spree_travel_core" , :branch => '2-3-stable' 9 | 10 | # gem 'spree_travel_hotel', :git => 'file:///Volumes/Data/Important/spree_travel/openjaf/spree_travel_hotel', :branch => '2-3-stable' 11 | gem 'spree_travel_hotel', :path => "../spree_travel_hotel" 12 | 13 | # gem 'spree_travel_sample', :git => 'file:///Volumes/Data/Important/spree_travel/openjaf/spree_travel_sample', :branch => '2-3-stable' 14 | 15 | # gem 'spree_travel_flight', :git => 'file:///Volumes/Data/Important/spree_travel/openjaf/spree_travel_flight', :branch => '2-3-stable' 16 | gem 'spree_travel_flight', :path => "../spree_travel_flight" 17 | 18 | gemspec 19 | -------------------------------------------------------------------------------- /README.md.alternate: -------------------------------------------------------------------------------- 1 | Add to your Gemfile 2 | =================== 3 | 4 | gem 'spree', :git => 'https://github.com/spree/spree', :branch => '2-4-stable' 5 | gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise', :branch => '2-4-stable' 6 | 7 | gem 'spree_travel_core', :path => 'https://github.com/openjaf/spree_travel_core', :branch => '2-4-stable' 8 | gem 'spree_travel_hotel', :path => 'https://github.com/openjaf/spree_travel_hotel', :branch => '2-4-stable' 9 | gem 'spree_travel_flight', :path => 'https://github.com/openjaf/spree_travel_flight', :branch => '2-4-stable' 10 | gem 'spree_travel_package', :path => 'https://github.com/openjaf/spree_travel_package', :branch => '2-4-stable' 11 | gem 'spree_travel_sample', :path => 'https://github.com/openjaf/spree_travel_sample', :branch => '2-4-stable' 12 | 13 | Execute the following in your console 14 | ===================================== 15 | bundle install 16 | 17 | rails generate spree:install 18 | 19 | rails generate spree_travel_core:install 20 | rails generate spree_travel_hotel:install 21 | rails generate spree_travel_flight:install 22 | rails generate spree_travel_package:install 23 | 24 | rake spree_travel_sample:load 25 | rake spree_travel_hotel:load 26 | rake spree_travel_flight:load 27 | rake spree_travel_package:load 28 | 29 | rake spree_travel_sample:load 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 [name of plugin creator] 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name Spree nor the names of its contributors may be used to 13 | endorse or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /spree_travel.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | 3 | require 'yaml' 4 | yaml = YAML.load(File.read('SPREE_TRAVEL_VERSIONS')) 5 | versions = yaml['gems'] 6 | 7 | Gem::Specification.new do |s| 8 | s.platform = Gem::Platform::RUBY 9 | s.name = 'spree_travel' 10 | s.version = '2.4.2' 11 | s.summary = 'Meta package for spree travel platform' 12 | s.description = 'Meta package dependencies for spree travel installation' 13 | s.required_ruby_version = '>= 1.9.3' 14 | 15 | # s.author = 'You' 16 | # s.email = 'you@example.com' 17 | # s.homepage = 'http://www.spreecommerce.com' 18 | 19 | #s.files = `git ls-files`.split("\n") 20 | #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 21 | s.require_path = 'lib' 22 | s.requirements << 'none' 23 | 24 | s.add_dependency 'spree_core', '~> ' + versions['spree'] 25 | s.add_dependency 'colored' 26 | # s.add_dependency 'spree_travel_core', '~> ' + versions['spree'] 27 | # s.add_dependency 'spree_travel_sample', '~> ' + versions['spree'] 28 | # s.add_dependency 'spree_travel_hotel', '~> ' + versions['spree'] 29 | # s.add_dependency 'spree_travel_flight', '~> ' + versions['spree'] 30 | 31 | s.add_development_dependency 'capybara', '~> 2.1' 32 | s.add_development_dependency 'coffee-rails' 33 | s.add_development_dependency 'database_cleaner' 34 | s.add_development_dependency 'factory_girl', '~> 4.2' 35 | s.add_development_dependency 'ffaker' 36 | s.add_development_dependency 'rspec-rails', '~> 2.13' 37 | s.add_development_dependency 'sass-rails' 38 | s.add_development_dependency 'selenium-webdriver' 39 | s.add_development_dependency 'simplecov' 40 | s.add_development_dependency 'sqlite3' 41 | end 42 | -------------------------------------------------------------------------------- /lib/generators/spree_travel/install/install_generator.rb: -------------------------------------------------------------------------------- 1 | module SpreeTravel 2 | module Generators 3 | class InstallGenerator < Rails::Generators::Base 4 | require 'spree_travel_core' 5 | require 'spree_travel/support' 6 | require 'colored' 7 | class_option :auto_run_migrations, :type => :boolean, :default => false 8 | class_option :full_install, :type => :boolean, :default => false 9 | class_option :without_sample, :type => :boolean, :default => false 10 | class_option :with_libs, :type => :array, :default => [] 11 | 12 | def add_other_extensions 13 | 14 | extensions = options[:with_libs] 15 | all_extensions = ['hotel', 'flight'] 16 | 17 | puts "Installing core library...".green 18 | 19 | silent_run("rails generate spree_travel_core:install --auto_run_migrations=true") 20 | 21 | puts "." * 20 22 | 23 | puts "Successfully installed core library".green 24 | 25 | if extensions == [] 26 | extensions = all_extensions 27 | else 28 | extensions.each do |extension| 29 | unless all_extensions.include?(extension) 30 | puts "Invalid extension name, #{extension}, it wont be installed ...".red.bold 31 | end 32 | end 33 | end 34 | 35 | extensions.each do |extension| 36 | 37 | install_extension = options[extension] 38 | 39 | unless install_extension 40 | install_extension = options[:full_install] || ['', 'y', 'Y'].include?(ask "Would you like to add the #{extension} product type features? [Y/n]".yellow) 41 | end 42 | 43 | if install_extension 44 | puts "Installing #{extension} features...".green 45 | silent_run("rails generate spree_travel_#{extension}:install --auto_run_migrations=true") 46 | 47 | load_sample = options[:full_install] || ['', 'y', 'Y'].include?(ask "Would you like to add the #{extension} sample data? [Y/n]".yellow) 48 | 49 | if load_sample 50 | puts "Installing #{extension} sample data...".green 51 | else 52 | puts "Skipping installation of #{extension} sample data..." 53 | end 54 | else 55 | puts "Skipping installation of #{extension} features you can install it later using --with_libs = [#{extension}] attribute".yellow 56 | end 57 | end 58 | end 59 | 60 | def run_migrations 61 | run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]') 62 | if run_migrations || options[:full_install] 63 | run 'bundle exec rake db:migrate' 64 | else 65 | puts 'Skipping rake db:migrate, don\'t forget to run it!' 66 | end 67 | end 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SpreeTravel 2 | =========== 3 | Spree Travel is an extension for rails e-commerce platform [spree](https://github.com/spree/spree).The goal of Spree Travel is to provide spree with the essential functionalities to behave as a travel agency management platform. Meaning that this extension will add new models, behaviors, views, etc… to spree, and will modify some of the definitions it holds. Spree Travel consists in a group of gems that modularizes all the behaviors intended to create with the extension: 4 | 5 | - [Spree Travel Core](https://github.com/openjaf/spree_travel_core), holds the logic under the hole group of extensions. 6 | - [Spree Travel Hotel](https://github.com/openjaf/spree_travel_hotel), holds the definitions to model hotels product_types. 7 | - [Spree Travel Flight](https://github.com/openjaf/spree_travel_flight), holds the definitions to model flight product_types. 8 | - [Spree Travel Sample](https://github.com/openjaf/spree_travel_sample), encapsulates the seeded data needed to understand and watch the behaivor of the entire pack. 9 | 10 | 11 | ###Important Note 12 | The Spree Travel project is a work in progress, and will suffer major changes. Please use it and keep a live feedback with the team by opening a [GitHub issue](https://github.com/openjaf/spree_travel/issues/new). 13 | 14 | Requirements 15 | ------------ 16 | ### Rails and Spree 17 | Spree Travel now requires Rails version **>= 4.0** and a Spree version **>=2.4**. 18 | 19 | Installation 20 | ------------ 21 | 22 | Spree Travel is not yet distributed as a gem, so it should be used in your app with a git reference or you can download the source and build the gem on your own. 23 | 24 | 1. Add the following to your Gemfile 25 | 26 | ```ruby 27 | gem 'spree_travel’, :git => 'https://github.com/openjaf/spree_travel.git', :branch => '2-4-stable' 28 | ``` 29 | 30 | 2. Run `bundle install` 31 | 32 | 3. To copy and apply migrations and features of all the gems on the package run: 33 | 34 | ``` 35 | rails g spree_travel:install 36 | ``` 37 | 38 | If you wish to install some independent and not all of them features run it with the attribute **--with_libs** wich is an array holding the libraries that will be installed, the options are **[hotel, flight]**. 39 | 40 | 41 | Features 42 | ------------ 43 | 44 | - Encapsultes the behavior of the spree_travel pack to extend spree into a travel agency manager site. 45 | 46 | Future Work 47 | ------------ 48 | 49 | 50 | Contributing 51 | ------------ 52 | 53 | If you'd like to contribute a feature or bugfix: Thanks! To make sure your 54 | fix/feature has a high chance of being included, please read the following 55 | guidelines: 56 | 57 | 1. Post a [pull request](https://github.com/openjaf/spree_travel/compare/). 58 | 2. Or open a [GitHub issue](https://github.com/openjaf/spree_travel/issues/new). 59 | 60 | License 61 | ------- 62 | Copyright © 2013 OpenJAF, released under the New BSD License. 63 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # Run Coverage report 2 | require 'simplecov' 3 | SimpleCov.start do 4 | add_group 'Controllers', 'app/controllers' 5 | add_group 'Helpers', 'app/helpers' 6 | add_group 'Mailers', 'app/mailers' 7 | add_group 'Models', 'app/models' 8 | add_group 'Views', 'app/views' 9 | add_group 'Libraries', 'lib' 10 | end 11 | 12 | # Configure Rails Environment 13 | ENV['RAILS_ENV'] = 'test' 14 | 15 | require File.expand_path('../dummy/config/environment.rb', __FILE__) 16 | 17 | require 'rspec/rails' 18 | require 'database_cleaner' 19 | require 'ffaker' 20 | 21 | # Requires supporting ruby files with custom matchers and macros, etc, 22 | # in spec/support/ and its subdirectories. 23 | Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } 24 | 25 | # Requires factories defined in spree_core 26 | require 'spree/testing_support/factories' 27 | require 'spree/testing_support/controller_requests' 28 | require 'spree/testing_support/authorization_helpers' 29 | require 'spree/testing_support/url_helpers' 30 | 31 | # Requires factories defined in lib/spree_travel/factories.rb 32 | require 'spree_travel/factories' 33 | 34 | RSpec.configure do |config| 35 | config.include FactoryGirl::Syntax::Methods 36 | 37 | # == URL Helpers 38 | # 39 | # Allows access to Spree's routes in specs: 40 | # 41 | # visit spree.admin_path 42 | # current_path.should eql(spree.products_path) 43 | config.include Spree::TestingSupport::UrlHelpers 44 | 45 | # == Mock Framework 46 | # 47 | # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: 48 | # 49 | # config.mock_with :mocha 50 | # config.mock_with :flexmock 51 | # config.mock_with :rr 52 | config.mock_with :rspec 53 | config.color = true 54 | 55 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 56 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 57 | 58 | # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner 59 | # to cleanup after each test instead. Without transactional fixtures set to false the records created 60 | # to setup a test will be unavailable to the browser, which runs under a seperate server instance. 61 | config.use_transactional_fixtures = false 62 | 63 | # Ensure Suite is set to use transactions for speed. 64 | config.before :suite do 65 | DatabaseCleaner.strategy = :transaction 66 | DatabaseCleaner.clean_with :truncation 67 | end 68 | 69 | # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary. 70 | config.before :each do 71 | DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction 72 | DatabaseCleaner.start 73 | end 74 | 75 | # After each spec clean the database. 76 | config.after :each do 77 | DatabaseCleaner.clean 78 | end 79 | 80 | config.fail_fast = ENV['FAIL_FAST'] || false 81 | end 82 | --------------------------------------------------------------------------------