From 1255088ff0f9e75f40a0cb4b415c50e8e0ae8f8b Mon Sep 17 00:00:00 2001 From: Siddhant Bajaj Date: Mon, 20 Feb 2017 23:43:02 +0530 Subject: [PATCH 1/2] fixed travis issues --- .travis.yml | 1 + INSTALL.md | 1 - dotenv.example | 4 ---- lib/tasks/factory_girl.rake | 1 + lib/tasks/migrate_config.rake | 1 - spec/support/database_cleaner.rb | 12 +++++++++++- spec/support/factory_girl.rb | 12 ------------ 7 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 spec/support/factory_girl.rb diff --git a/.travis.yml b/.travis.yml index ae8030b0..1bf2c028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,5 @@ before_script: - RAILS_ENV=test bundle exec rake db:migrate --trace script: - 'bundle exec rubocop -Dc .rubocop.yml' + - "bundle exec rake factory_girl:lint RAILS_ENV='test'" - 'bundle exec rspec --color --format documentation' diff --git a/INSTALL.md b/INSTALL.md index 7bc85350..608b3508 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -36,7 +36,6 @@ There are a couple of environment variables you can set to configure OSEM. | OSEM_TRANSIFEX_APIKEY | *string* | Use this api key for [transifex](https://www.transifex.com/). See TRANSLATION.md for details. | | OSEM_ERRBIT_HOST | errbit.opensuse.org | The [errbit](https://github.com/errbit/errbit) host to post exceptions to | | OSEM_ERRBIT_APIKEY | *string* | The api key for the errbit host | -| OSEM_FACTORY_LINT | *boolean* (true/false) | Setting this to false will disable linting of factories before running spec | OSEM_GOOGLE_KEY | *string* | OMNIAUTH Developer Key for GOOGLE | OSEM_GOOGLE_SECRET | *string* | OMNIAUTH Developer Secret for GOOGLE | OSEM_FACEBOOK_KEY | *string* | OMNIAUTH Developer Key for Facebook diff --git a/dotenv.example b/dotenv.example index b9c2a668..358fe094 100644 --- a/dotenv.example +++ b/dotenv.example @@ -42,10 +42,6 @@ OSEM_GITHUB_SECRET='' STRIPE_PUBLISHABLE_KEY='' STRIPE_SECRET_KEY='' -# Disable linting of factories in the test suite. -# Speeds up turn around times of tests -OSEM_FACTORY_LINT="false" - # The smtp configuration. See the rails guides for more # http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration OSEM_SMTP_ADDRESS="" diff --git a/lib/tasks/factory_girl.rake b/lib/tasks/factory_girl.rake index bccc1b66..a55103d8 100644 --- a/lib/tasks/factory_girl.rake +++ b/lib/tasks/factory_girl.rake @@ -1,3 +1,4 @@ +require_relative '../../spec/support/external_request' namespace :factory_girl do desc "Verify that all FactoryGirl factories are valid" task lint: :environment do diff --git a/lib/tasks/migrate_config.rake b/lib/tasks/migrate_config.rake index 452a061f..5f22f358 100644 --- a/lib/tasks/migrate_config.rake +++ b/lib/tasks/migrate_config.rake @@ -26,7 +26,6 @@ namespace :data do dot_env.puts "OSEM_ICHAIN_ENABLED=\"#{CONFIG['authentication']['ichain']['enabled']}\"" if CONFIG.has_key?(:authentication) dot_env.puts "OSEM_TRANSIFEX_APIKEY=\"#{CONFIG['transifex_live_api_key']}\"" dot_env.puts "OSEM_ERRBIT_HOST=\"#{CONFIG['errbit_host']}\"" - dot_env.puts "OSEM_FACTORY_LINT=\"#{CONFIG['factory_girl_lint']}\"" dot_env.puts "OSEM_SMTP_ADDRESS=\"#{CONFIG['mail_address']}\"" dot_env.puts "OSEM_SMTP_PORT=\"#{CONFIG['mail_port']}\"" dot_env.puts "OSEM_SMTP_USERNAME=\"#{CONFIG['mail_username']}\"" diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 3e6c8404..fc2fcea3 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,6 +1,16 @@ RSpec.configure do |config| - config.before(:each) do + config.before(:suite) do DatabaseCleaner.clean_with(:truncation) Rails.application.load_seed end + + config.before(:each) do |example| + DatabaseCleaner.strategy = (example.metadata[:js] == true) ? :truncation : :transaction + DatabaseCleaner.start + end + + config.after(:each) do |example| + DatabaseCleaner.clean + Rails.application.load_seed if example.metadata[:js] == true + end end diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb deleted file mode 100644 index c46a5105..00000000 --- a/spec/support/factory_girl.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative 'external_request' - -RSpec.configure do |config| - - config.before(:suite) do - if ENV['OSEM_FACTORY_LINT'] != 'false' - mock_commercial_request - FactoryGirl.lint - end - end - -end From 0295850f201ddcd07b6a34862cebe7a33493e908 Mon Sep 17 00:00:00 2001 From: Siddhant Bajaj Date: Mon, 20 Feb 2017 23:45:13 +0530 Subject: [PATCH 2/2] Mock request to fix factory girl rake --- lib/tasks/factory_girl.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/factory_girl.rake b/lib/tasks/factory_girl.rake index a55103d8..1799dccf 100644 --- a/lib/tasks/factory_girl.rake +++ b/lib/tasks/factory_girl.rake @@ -5,6 +5,7 @@ namespace :factory_girl do if Rails.env.test? begin DatabaseCleaner.start + mock_commercial_request FactoryGirl.lint ensure DatabaseCleaner.clean