From 4a0d1e82b1afce50f9b8428500f4aec008553c3b Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Thu, 15 Sep 2016 07:19:46 -0700 Subject: [PATCH] Add adapter for old syntax, fixes #3139 --- lib/sidekiq/web.rb | 5 +++++ test/test_web.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/sidekiq/web.rb b/lib/sidekiq/web.rb index d1ba2f84..5933ea1e 100644 --- a/lib/sidekiq/web.rb +++ b/lib/sidekiq/web.rb @@ -63,6 +63,11 @@ module Sidekiq @views ||= VIEWS end + # Helper for the Sinatra syntax: Sidekiq::Web.set(:session_secret, Rails.application.secrets...) + def set(attribute, value) + send(:"#{attribute}=", value) + end + attr_accessor :app_url, :session_secret, :redis_pool attr_writer :locales, :views end diff --git a/test/test_web.rb b/test/test_web.rb index ed2f03a2..bc0dcf2e 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -28,6 +28,11 @@ class TestWeb < Sidekiq::Test end end + it 'can configure via set() syntax' do + app.set(:session_secret, "foo") + assert_equal "foo", app.session_secret + end + it 'can show text with any locales' do rackenv = {'HTTP_ACCEPT_LANGUAGE' => 'ru,en'} get '/', {}, rackenv