New Upstream Snapshot - ruby-web-console
Ready changes
Summary
Merged new upstream version: 4.2.0+git20221019.1.891c363 (was: 4.2.0).
Resulting package
Built on 2022-10-21T18:21 (took 7m11s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots ruby-web-console
Lintian Result
Diff
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..49ccbfd
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,33 @@
+name: CI
+
+on:
+ - push
+ - pull_request
+
+permissions:
+ contents: read
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ continue-on-error: ${{ matrix.experimental }}
+ strategy:
+ fail-fast: false
+ matrix:
+ ruby: ['2.7', '3.0', '3.1', 'head']
+ script: [test]
+ experimental: [false]
+ include:
+ - ruby: '2.7'
+ script: templates:test
+ experimental: true
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true
+ - name: Run tests
+ run: bundle exec rake ${{ matrix.script }}
diff --git a/.gitignore b/.gitignore
index 2d29fe5..c35bc03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,5 +9,6 @@ test/dummy/tmp/
test/dummy/.sass-cache
Gemfile.lock
node_modules/
+package-lock.json
dist/
tmp/
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 317f34e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-language: ruby
-
-rvm:
- - 2.5.3
- - 2.6.1
- - jruby-9.2.0.0
- - ruby-head
- - jruby-head
-
-before_install:
- - gem update --system
-
-env:
- global:
- - JRUBY_OPTS=--dev
-
-script:
- - bundle exec rake ${TEST_SUITE:-test}
-
-matrix:
- fast_finish: true
- allow_failures:
- - rvm: ruby-head
- - rvm: jruby-head
- - rvm: jruby-9.2.0.0
- - env: TEST_SUITE=templates:test
- include:
- - env: TEST_SUITE=templates:test
- rvm: 2.6.1
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index 10624e3..6121a18 100644
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -5,7 +5,7 @@
## 4.2.0
* [#308](https://github.com/rails/web-console/pull/308) Fix web-console inline templates rendering ([@voxik])
-* [#306](https://github.com/rails/web-console/pull/306) Support Ruby 3.0 and above ([@ruanwood])
+* [#306](https://github.com/rails/web-console/pull/306) Support Ruby 3.0 and above ([@ryanwood])
## 4.1.0
diff --git a/Gemfile b/Gemfile
index bdaaa3e..64445cb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,8 +7,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gemspec
gem "rails", github: "rails/rails"
-gem "arel", github: "rails/arel"
-gem "rack", github: "rack/rack"
+gem "rack"
group :development do
platform :ruby do
diff --git a/README.markdown b/README.markdown
index ae958bc..40ef01e 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,11 +1,11 @@
<p align=right>
- <strong>Current version: 4.1.0</strong> | Documentation for:
+ <strong>Current version: 4.2.0</strong> | Documentation for:
<a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
<a href=https://github.com/rails/web-console/tree/v2.2.1>v2.2.1</a>
<a href=https://github.com/rails/web-console/tree/v3.7.0>v3.7.0</a>
</p>
-# Web Console [![Build Status](https://travis-ci.org/rails/web-console.svg?branch=master)](https://travis-ci.org/rails/web-console)
+# Web Console [![CI](https://github.com/rails/web-console/actions/workflows/ci.yml/badge.svg)](https://github.com/rails/web-console/actions/workflows/ci.yml)
_Web Console_ is a debugging tool for your Ruby on Rails applications.
diff --git a/debian/changelog b/debian/changelog
index 75926ab..0743478 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-web-console (4.2.0+git20221019.1.891c363-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Fri, 21 Oct 2022 18:17:47 -0000
+
ruby-web-console (4.2.0-1) unstable; urgency=medium
* Team upload
diff --git a/extensions/chrome/js/background.js b/extensions/chrome/js/background.js
index 1105424..b7e62a2 100644
--- a/extensions/chrome/js/background.js
+++ b/extensions/chrome/js/background.js
@@ -84,10 +84,10 @@ function initHttpListener() {
function onResponse(details) {
var headers = getHeaders(details);
var sessionId;
- if (sessionId = headers['X-Web-Console-Session-Id']) {
+ if (sessionId = headers['x-web-console-session-id']) {
sessions[details.tabId] = {
sessionId: sessionId,
- mountPoint: headers['X-Web-Console-Mount-Point'],
+ mountPoint: headers['x-web-console-mount-point'],
remoteHost: details.url.match(/([^:]+:\/\/[^\/]+)\/?/)[1]
};
}
diff --git a/lib/web_console.rb b/lib/web_console.rb
index 3f3f88a..3852609 100644
--- a/lib/web_console.rb
+++ b/lib/web_console.rb
@@ -26,7 +26,7 @@ module WebConsole
end
def self.logger
- Rails.logger || (@logger ||= ActiveSupport::Logger.new($stderr))
+ (defined?(Rails.logger) && Rails.logger) || (@logger ||= ActiveSupport::Logger.new($stderr))
end
end
diff --git a/lib/web_console/injector.rb b/lib/web_console/injector.rb
index d3bb325..a82cd05 100644
--- a/lib/web_console/injector.rb
+++ b/lib/web_console/injector.rb
@@ -13,10 +13,10 @@ module WebConsole
end
def inject(content)
- # Set Content-Length header to the size of the current body
+ # Set content-length header to the size of the current body
# + the extra content. Otherwise the response will be truncated.
- if @headers["Content-Length"]
- @headers["Content-Length"] = (@body.bytesize + content.bytesize).to_s
+ if @headers["content-length"]
+ @headers["content-length"] = (@body.bytesize + content.bytesize).to_s
end
[
diff --git a/lib/web_console/interceptor.rb b/lib/web_console/interceptor.rb
index c084153..112577f 100644
--- a/lib/web_console/interceptor.rb
+++ b/lib/web_console/interceptor.rb
@@ -1,8 +1,7 @@
module WebConsole
module Interceptor
- def self.call(request, exception)
+ def self.call(request, error)
backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
- error = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception
# Get the original exception if ExceptionWrapper decides to follow it.
Thread.current[:__web_console_exception] = error
diff --git a/lib/web_console/middleware.rb b/lib/web_console/middleware.rb
index 93320ee..256e151 100644
--- a/lib/web_console/middleware.rb
+++ b/lib/web_console/middleware.rb
@@ -28,8 +28,8 @@ module WebConsole
status, headers, body = call_app(env)
if (session = Session.from(Thread.current)) && acceptable_content_type?(headers)
- headers["X-Web-Console-Session-Id"] = session.id
- headers["X-Web-Console-Mount-Point"] = mount_point
+ headers["x-web-console-session-id"] = session.id
+ headers["x-web-console-mount-point"] = mount_point
template = Template.new(env, session)
body, headers = Injector.new(body, headers).inject(template.render("index"))
@@ -52,12 +52,12 @@ module WebConsole
private
def acceptable_content_type?(headers)
- headers["Content-Type"].to_s.include?("html")
+ headers["content-type"].to_s.include?("html")
end
def json_response(opts = {})
status = opts.fetch(:status, 200)
- headers = { "Content-Type" => "application/json; charset = utf-8" }
+ headers = { "content-type" => "application/json; charset = utf-8" }
body = yield.to_json
[ status, headers, [ body ] ]
diff --git a/lib/web_console/tasks/templates.rake b/lib/web_console/tasks/templates.rake
index f51ae65..9090baa 100644
--- a/lib/web_console/tasks/templates.rake
+++ b/lib/web_console/tasks/templates.rake
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "net/http"
+
namespace :templates do
desc "Run tests for templates"
task test: [ :daemonize, :npm, :rackup, :wait, :mocha, :kill, :exit ]
@@ -10,7 +12,6 @@ namespace :templates do
runner = URI.parse("http://#{ENV['IP'] || '127.0.0.1'}:#{ENV['PORT'] || 29292}/html/test_runner.html")
rackup = "rackup --host #{runner.host} --port #{runner.port}"
result = nil
- browser = "phantomjs"
def need_to_wait?(uri)
Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) }
@@ -22,17 +23,10 @@ namespace :templates do
rackup += " -D --pid #{pid}"
end
- task npm: [ :phantomjs ] do
+ task :npm do
Dir.chdir(workdir) { system "npm install --silent" }
end
- task :phantomjs do
- unless system("which #{browser} >/dev/null")
- browser = "./node_modules/.bin/phantomjs"
- Dir.chdir(workdir) { system("test -f #{browser} || npm install --silent phantomjs-prebuilt") }
- end
- end
-
task :rackup do
Dir.chdir(workdir) { system rackup }
end
@@ -43,7 +37,7 @@ namespace :templates do
end
task :mocha do
- Dir.chdir(workdir) { result = system("#{browser} ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js #{runner} dot") }
+ Dir.chdir(workdir) { result = system("npx mocha-headless-chrome -f #{runner} -r dot") }
end
task :kill do
diff --git a/lib/web_console/templates/console.js.erb b/lib/web_console/templates/console.js.erb
index 108f91f..6b8021b 100644
--- a/lib/web_console/templates/console.js.erb
+++ b/lib/web_console/templates/console.js.erb
@@ -935,8 +935,8 @@ REPLConsole.request = function request(method, url, params, callback) {
var xhr = new REPLConsole.XMLHttpRequest();
xhr.open(method, url, true);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
+ xhr.setRequestHeader("x-requested-with", "XMLHttpRequest");
xhr.send(params);
xhr.onreadystatechange = function() {
diff --git a/lib/web_console/testing/fake_middleware.rb b/lib/web_console/testing/fake_middleware.rb
index 144fc29..9e3488d 100644
--- a/lib/web_console/testing/fake_middleware.rb
+++ b/lib/web_console/testing/fake_middleware.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "action_view"
+require "action_dispatch" # This is needed to use Mime::Type
require "web_console"
require "web_console/testing/helper"
@@ -9,7 +10,7 @@ module WebConsole
class FakeMiddleware
I18n.load_path.concat(Dir[Helper.gem_root.join("lib/web_console/locales/*.yml")])
- DEFAULT_HEADERS = { "Content-Type" => "application/javascript" }
+ DEFAULT_HEADERS = { "content-type" => "application/javascript" }
def initialize(opts)
@headers = opts.fetch(:headers, DEFAULT_HEADERS)
@@ -18,18 +19,21 @@ module WebConsole
end
def call(env)
- [ 200, @headers, [ render(req_path(env)) ] ]
+ body = render(req_path(env))
+ @headers["content-length"] = body.bytesize.to_s
+
+ [ 200, @headers, [ body ] ]
end
def view
- @view = View.new(@view_path)
+ @view = View.with_empty_template_cache.with_view_paths(@view_path)
end
private
# extract target path from REQUEST_PATH
def req_path(env)
- env["REQUEST_PATH"].match(@req_path_regex)[1]
+ File.basename(env["REQUEST_PATH"].match(@req_path_regex)[1], ".*")
end
def render(template)
diff --git a/test/templates/config.ru b/test/templates/config.ru
index 2dc93d1..b89f837 100644
--- a/test/templates/config.ru
+++ b/test/templates/config.ru
@@ -15,18 +15,11 @@ end
map "/html" do
run WebConsole::Testing::FakeMiddleware.new(
req_path_regex: %r{^/html/(.*)},
- headers: {"Content-Type" => "text/html"},
+ headers: {"content-type" => "text/html"},
view_path: TEST_ROOT.join("html"),
)
end
-map "/spec" do
- run WebConsole::Testing::FakeMiddleware.new(
- req_path_regex: %r{^/spec/(.*)},
- view_path: TEST_ROOT.join("spec"),
- )
-end
-
map "/test" do
run WebConsole::Testing::FakeMiddleware.new(
req_path_regex: %r{^/test/(.*)},
@@ -42,19 +35,19 @@ map "/templates" do
end
map "/mock/repl_sessions/result" do
- headers = { 'Content-Type' => 'application/json' }
+ headers = { 'content-type' => 'application/json' }
body = [ { output: '=> "fake-result"\n', context: [ [ :something, :somewhat, :somewhere ] ] }.to_json ]
run lambda { |env| [ 200, headers, body ] }
end
map "/mock/repl_sessions/error" do
- headers = { 'Content-Type' => 'application/json' }
+ headers = { 'content-type' => 'application/json' }
body = [ { output: 'fake-error-message' }.to_json ]
run lambda { |env| [ 400, headers, body ] }
end
map "/mock/repl_sessions/error.txt" do
- headers = { 'Content-Type' => 'plain/text' }
+ headers = { 'content-type' => 'plain/text' }
body = [ 'error message' ]
run lambda { |env| [ 400, headers, body ] }
end
diff --git a/test/templates/html/test_runner.html.erb b/test/templates/html/test_runner.html.erb
index f82809a..a4ccb64 100644
--- a/test/templates/html/test_runner.html.erb
+++ b/test/templates/html/test_runner.html.erb
@@ -12,7 +12,6 @@
<script src="/node_modules/chai/chai.js"></script>
<script>
mocha.setup('tdd');
- mocha.reporter('html');
</script>
<!-- load templates -->
@@ -26,11 +25,7 @@
<!-- run tests -->
<script>
- if (window.mochaPhantomJS) {
- mochaPhantomJS.run();
- } else {
- mocha.run();
- }
+ mocha.run();
</script>
</body>
</html>
diff --git a/test/templates/package.json b/test/templates/package.json
index e6994e9..c68574c 100644
--- a/test/templates/package.json
+++ b/test/templates/package.json
@@ -6,8 +6,8 @@
"url": "https://github.com/rails/web-console"
},
"devDependencies": {
- "chai": "^3.0.0",
- "mocha": "^2.2.5",
- "mocha-phantomjs-core": "^1.3.1"
+ "chai": "^4.3.6",
+ "mocha": "^10.0.0",
+ "mocha-headless-chrome": "^4.0.0"
}
}
diff --git a/test/templates/test/repl_console_test.js b/test/templates/test/repl_console_test.js
index 0a0c33e..4d56f9e 100644
--- a/test/templates/test/repl_console_test.js
+++ b/test/templates/test/repl_console_test.js
@@ -1,4 +1,4 @@
-suite('REPLCosnole', function() {
+suite('REPLConsole', function() {
suiteSetup(function() {
this.stage = document.createElement('div');
document.body.appendChild(this.stage);
@@ -179,13 +179,14 @@ suite('REPLCosnole', function() {
}, 100);
});
- test('inserts the current word if tab key is pressed', function() {
+ test('inserts the current word if tab key is pressed', function(done) {
var c = this.console;
c.setInput('some');
setTimeout(function() {
- c.onKeyDown(TestHelper.KeyDown(TestHelper.KEY_TAB));
+ c.onKeyDown(TestHelper.keyDown(TestHelper.KEY_TAB));
assert.equal('something', c._input);
+ done();
}, 100);
});
});
diff --git a/test/web_console/exception_mapper_test.rb b/test/web_console/exception_mapper_test.rb
index 7e7947c..f088fd2 100644
--- a/test/web_console/exception_mapper_test.rb
+++ b/test/web_console/exception_mapper_test.rb
@@ -3,7 +3,7 @@
require "test_helper"
module WebConsole
- class ExcetionMapperTest < ActiveSupport::TestCase
+ class ExceptionMapperTest < ActiveSupport::TestCase
test "#first tries to find the first application binding" do
Rails.stubs(:root).returns Pathname(__FILE__).parent
diff --git a/test/web_console/helper_test.rb b/test/web_console/helper_test.rb
index 0a4cf1f..ad901ba 100644
--- a/test/web_console/helper_test.rb
+++ b/test/web_console/helper_test.rb
@@ -20,7 +20,7 @@ module WebConsole
end
def headers
- { "Content-Type" => "text/html; charset=utf-8" }
+ { "content-type" => "text/html; charset=utf-8" }
end
def body
diff --git a/test/web_console/injector_test.rb b/test/web_console/injector_test.rb
index 277fa97..c522be0 100644
--- a/test/web_console/injector_test.rb
+++ b/test/web_console/injector_test.rb
@@ -28,11 +28,11 @@ module WebConsole
assert_equal [ [ "foobar" ], {} ], Injector.new(body, {}).inject("bar")
end
- test "updates the Content-Length header" do
+ test "updates the content-length header" do
body = [ "foo" ]
- headers = { "Content-Length" => 3 }
+ headers = { "content-length" => 3 }
- assert_equal [ [ "foobar" ], { "Content-Length" => "6" } ], Injector.new(body, headers).inject("bar")
+ assert_equal [ [ "foobar" ], { "content-length" => "6" } ], Injector.new(body, headers).inject("bar")
end
end
end
diff --git a/test/web_console/middleware_test.rb b/test/web_console/middleware_test.rb
index b545e78..c03774c 100644
--- a/test/web_console/middleware_test.rb
+++ b/test/web_console/middleware_test.rb
@@ -35,8 +35,8 @@ module WebConsole
def headers
Hash.new.tap do |header_hash|
- header_hash["Content-Type"] = "#{@response_content_type}; charset=utf-8" unless @response_content_type.nil?
- header_hash["Content-Length"] = @response_content_length unless @response_content_length.nil?
+ header_hash["content-type"] = "#{@response_content_type}; charset=utf-8" unless @response_content_type.nil?
+ header_hash["content-length"] = @response_content_length unless @response_content_length.nil?
end
end
end
@@ -84,13 +84,13 @@ module WebConsole
assert_select "#console"
end
- test "sets correct Content-Length header" do
+ test "sets correct content-length header" do
Thread.current[:__web_console_binding] = binding
@app = Middleware.new(Application.new(response_content_length: 7))
get "/", params: nil
- assert_equal(response.body.size, response.headers["Content-Length"].to_i)
+ assert_equal(response.body.size, response.headers["content-length"].to_i)
end
test "it closes original body if rendering console" do
@@ -121,12 +121,12 @@ module WebConsole
assert_select "#console", 0
end
- test "returns X-Web-Console-Session-Id as response header" do
+ test "returns x-web-console-session-id as response header" do
Thread.current[:__web_console_binding] = binding
get "/", params: nil
- session_id = response.headers["X-Web-Console-Session-Id"]
+ session_id = response.headers["x-web-console-session-id"]
assert_not Session.find(session_id).nil?
end
Debdiff
File lists identical (after any substitutions)
Control files: lines which differ (wdiff format)
Ruby-Versions: all