From 6797989ec171f0b5885953020e11f9e04b7df142 Mon Sep 17 00:00:00 2001 From: Jorge Chayan Date: Fri, 11 Sep 2020 23:51:24 -0500 Subject: [PATCH] Adds test --- config/environments/test.rb | 2 -- spec/controllers/ovens_controller_spec.rb | 18 ++++++++++++++++++ spec/spec_helper.rb | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index a1fc360..8e5cbde 100755 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,8 +7,6 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - config.allow_concurrency = 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. diff --git a/spec/controllers/ovens_controller_spec.rb b/spec/controllers/ovens_controller_spec.rb index b275f49..de57fa9 100755 --- a/spec/controllers/ovens_controller_spec.rb +++ b/spec/controllers/ovens_controller_spec.rb @@ -117,4 +117,22 @@ end end + + describe 'GET progress' do + context "when not authenticated" do + before { sign_in nil } + + it "blocks access" do + the_request + expect(response).to redirect_to new_user_session_path + end + end + + context "when authenticated" do + before { get :progress } + it { expect(response.headers['Content-Type']).to eq("text/event-stream") } + after {response.stream.close unless response.stream.closed? } + end + end + end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cfb18dc..bbd7371 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -76,3 +76,23 @@ end =end end + +# Trying to debug what's wrong with RSpec and ActionController::Live +# puts "rspec pid: #{Process.pid}" +# +# trap 'USR1' do +# threads = Thread.list +# +# puts +# puts "=" * 80 +# puts "Received USR1 signal; printing all #{threads.count} thread backtraces." +# +# threads.each do |thr| +# description = thr == Thread.main ? "Main thread" : thr.inspect +# puts +# puts "#{description} backtrace: " +# puts thr.backtrace.join("\n") +# end +# +# puts "=" * 80 +# end