From 63d89be698ed3785cca3e00581c93e4262bc9e1d Mon Sep 17 00:00:00 2001 From: Mackenzie Date: Mon, 20 Jun 2016 10:34:11 -0400 Subject: [PATCH 1/7] lets encrypt challenge page --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index b8fee2796..5401ed568 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,6 +83,8 @@ Growstuff::Application.routes.draw do get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter get '/admin/:action' => 'admin#:action' + get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' + # CMS stuff -- must remain LAST comfy_route :cms, path: '/', sitemap: false From 5bc6af87c58bc8c3b2df18dc6c854f2433ee0ba2 Mon Sep 17 00:00:00 2001 From: Mackenzie Date: Mon, 20 Jun 2016 10:46:40 -0400 Subject: [PATCH 2/7] challenge code --- app/controllers/pages_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/controllers/pages_controller.rb diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb new file mode 100644 index 000000000..1c3f8f92e --- /dev/null +++ b/app/controllers/pages_controller.rb @@ -0,0 +1,6 @@ +class PagesController < ApplicationController + def letsencrypt + # use your code here, not mine + render text: "B4-cHp8zD8RDI8ihZYvqzb2mV6RPSmrQ-clntqc-5Is.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU" + end +end From 628ebd6841cd528124681153a2c1c4150fb6a8a2 Mon Sep 17 00:00:00 2001 From: Cesy Date: Tue, 21 Jun 2016 15:05:45 +0100 Subject: [PATCH 3/7] Revert "lets encrypt challenge page" --- config/routes.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 5401ed568..b8fee2796 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,8 +83,6 @@ Growstuff::Application.routes.draw do get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter get '/admin/:action' => 'admin#:action' - get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' - # CMS stuff -- must remain LAST comfy_route :cms, path: '/', sitemap: false From 7261fae9f26ce6052851855cfafa796dddd8061d Mon Sep 17 00:00:00 2001 From: Cesy Date: Tue, 21 Jun 2016 15:06:02 +0100 Subject: [PATCH 4/7] Revert "challenge code" --- app/controllers/pages_controller.rb | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 app/controllers/pages_controller.rb diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb deleted file mode 100644 index 1c3f8f92e..000000000 --- a/app/controllers/pages_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class PagesController < ApplicationController - def letsencrypt - # use your code here, not mine - render text: "B4-cHp8zD8RDI8ihZYvqzb2mV6RPSmrQ-clntqc-5Is.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU" - end -end From 900e7361c6e3c5ba51d69ce70ad86725e51e25ee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 30 Nov 2016 09:00:10 +1300 Subject: [PATCH 5/7] Check we have a planted_at ts before doing maths with it --- app/helpers/plantings_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index fb6e2e7dc..898a0272f 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -5,7 +5,7 @@ module PlantingsHelper 0 elsif !planting.finished_at.nil? ((p = planting.finished_at - DateTime.now).to_i) <= 0 ? 0 : p.to_i - elsif planting.days_before_maturity.nil? + elsif planting.planted_at.nil? || planting.days_before_maturity.nil? "unknown" else ((p = (planting.planted_at + planting.days_before_maturity) - DateTime.now).to_i <= 0) ? 0 : p.to_i From 184154893607123c7829127b4a2e7e3e42abde21 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Wed, 30 Nov 2016 11:01:25 +0000 Subject: [PATCH 6/7] Precompile assets in test According to https://github.com/teampoltergeist/poltergeist/issues/677#issuecomment-222919584, a possible cause of the "Request failed to reach server" problem (#901) is that assets are being compiled on-demand, causing enough of a slowdown for PhantomJS to think the connection has failed. This turns off lazy asset compilation in the test environment and precompiles assets before testing on Travis. We should also turn off lazy asset compilation in production - see http://stackoverflow.com/questions/8821864/config-assets-compile-true-in-rails-production-why-not Our Heroku deployments already run `rake assets:precompile`. --- .travis.yml | 1 + config/environments/test.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3aefec912..5f2219acd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ before_install: - phantomjs --version before_script: - bundle exec rake db:create db:migrate db:test:prepare + - bundle exec rake assets:precompile script: - bundle exec rubocop --display-cop-names --rails - script/gemfile_check diff --git a/config/environments/test.rb b/config/environments/test.rb index 35836c90b..dd3a3816c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -6,6 +6,10 @@ Growstuff::Application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false + # Do not compile assets on-demand. On-demand compilation slows down the test + # suite and causes random test failures. + config.assets.compile = false + # 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 From 6be96406254ce678c9da0255b3854e607264f44a Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Wed, 30 Nov 2016 11:35:35 +0000 Subject: [PATCH 7/7] Run tests with `rake` when DB does not yet exist Previously, `rake spec` ran the tests whether or not the `growstuff_test` database existed or not, but `rake` crashed unless it had already been created. The problem was that `rake` was trying to load the environment, which required the presence of a DB; `rake spec` was running this with the `dev` environment, so succeeded if `growstuff_dev` existed, but `rake` was running everything with the `test` environment, so would fail if `growstuff_test` did not exist. This patch adds `db:create` to the dependencies of the `spec` task, forcing an unadorned `rake` to create all necessary databases first. --- lib/tasks/testing.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index a7908d590..b41172efb 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -2,7 +2,7 @@ require 'rake' begin require 'rspec/core/rake_task' task(:spec).clear - RSpec::Core::RakeTask.new(spec: 'db:test:prepare') do |t| + RSpec::Core::RakeTask.new(spec: ['db:create', 'db:test:prepare']) do |t| t.verbose = false end rescue LoadError