diff --git a/.gitignore b/.gitignore index 4872cec1..04c62312 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ log dragonfly.log .byebug_history TODO.md +bin/generate_non_regression_with_scope_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 7101d0f5..f9ccd669 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ PATH moneta (~> 1.6.0) morphine (~> 0.1.1) multi_json (~> 1.15.0) - nokogiri (~> 1.15.6) + nokogiri (~> 1.16.7) parser (~> 3.3) pony (~> 1.12) rack-cache (>= 1.7, < 2) @@ -30,16 +30,17 @@ GEM remote: https://rubygems.org/ specs: RedCloth (4.3.4) - activesupport (7.1.3.4) + activesupport (7.2.1) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) @@ -50,12 +51,12 @@ GEM bson (4.15.0) chronic (0.10.2) colorize (1.1.0) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) diff-lcs (1.5.1) - docile (1.4.0) + docile (1.4.1) dragonfly (1.4.0) addressable (~> 2.3) multi_json (~> 1.0) @@ -71,7 +72,7 @@ GEM httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - i18n (1.14.4) + i18n (1.14.6) concurrent-ruby (~> 1.0) i18n-spec (0.6.0) iso @@ -88,19 +89,20 @@ GEM attr_extras (~> 7.1.0) colorize stringex (~> 2.8.5) + logger (1.6.1) mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp - memory_profiler (1.0.1) + memory_profiler (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0604) + mime-types-data (3.2024.1001) mimetype-fu (0.1.2) mini_mime (1.1.5) mini_portile2 (2.8.7) - minitest (5.24.0) + minitest (5.25.1) moneta (1.6.0) mongo (2.18.3) bson (>= 4.14.1, < 5.0.0) @@ -108,8 +110,7 @@ GEM multi_json (1.15.0) multi_xml (0.7.1) bigdecimal (~> 3.1) - mutex_m (0.2.0) - net-imap (0.4.14) + net-imap (0.4.16) date net-protocol net-pop (0.1.2) @@ -118,21 +119,23 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.1) - nokogiri (1.15.6) + nio4r (2.7.3) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) origin (2.3.1) parser (3.3.5.0) ast (~> 2.4.1) racc pony (1.13.1) mail (>= 2.0) - public_suffix (6.0.0) - puma (6.4.2) + public_suffix (6.0.1) + puma (6.4.3) nio4r (~> 2.0) - racc (1.8.0) - rack (3.0.10) + racc (1.8.1) + rack (3.1.7) rack-cache (1.17.0) rack (>= 0.4) rack-mini-profiler (0.10.7) @@ -144,9 +147,8 @@ GEM rack (>= 1.3) rack_csrf (2.6.0) rack (>= 1.1.0) - rake (13.1.0) - rexml (3.3.1) - strscan + rake (13.2.1) + rexml (3.3.8) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) @@ -163,19 +165,19 @@ GEM sanitize (6.0.2) crass (~> 1.0.2) nokogiri (>= 1.12.0) + securerandom (0.3.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) stackprof (0.2.26) stringex (2.8.6) - strscan (3.1.0) temple (0.10.3) - thor (1.3.1) - tilt (2.3.0) - timecop (0.9.8) + thor (1.3.2) + tilt (2.4.0) + timecop (0.9.10) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) diff --git a/lib/locomotive/steam/server.rb b/lib/locomotive/steam/server.rb index bd2b68c9..5bdc1026 100644 --- a/lib/locomotive/steam/server.rb +++ b/lib/locomotive/steam/server.rb @@ -24,7 +24,7 @@ class << self def default_middlewares server, configuration = self, self.configuration - -> (stack) { + -> (stack) { use(Rack::Rewrite) { r301 %r{^/(.*)/$}, '/$1' } use Middlewares::Favicon @@ -38,6 +38,7 @@ def default_middlewares use Dragonfly::Middleware, :steam use Rack::Lint + use Rack::RewindableInput::Middleware use Rack::Session::Moneta, configuration.moneta use Rack::MiniProfiler if ENV['PROFILER'] diff --git a/locomotivecms_steam.gemspec b/locomotivecms_steam.gemspec index 37c82e54..9176443f 100644 --- a/locomotivecms_steam.gemspec +++ b/locomotivecms_steam.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'mongo', '~> 2.18.2' spec.add_development_dependency 'origin', '~> 2.3.1' - spec.add_dependency 'nokogiri', '~> 1.15.6' + spec.add_dependency 'nokogiri', '~> 1.16.7' spec.add_dependency 'sanitize', '~> 6.0.1' spec.add_dependency 'morphine', '~> 0.1.1' spec.add_dependency 'httparty', '~> 0.21.0' diff --git a/spec/integration/server/contact_form_spec.rb b/spec/integration/server/contact_form_spec.rb index 52457faa..9b516d02 100644 --- a/spec/integration/server/contact_form_spec.rb +++ b/spec/integration/server/contact_form_spec.rb @@ -204,7 +204,8 @@ def app def post_contact_form(url, params, json = false, follow_redirect = false, env = {}) if json url += '.json' - params = params.symbolize_keys + params = JSON.generate(params.symbolize_keys) + env['CONTENT_TYPE'] = 'application/json' end post url, params, env diff --git a/spec/unit/middlewares/section_spec.rb b/spec/unit/middlewares/section_spec.rb index bdfd597d..3d7570f3 100644 --- a/spec/unit/middlewares/section_spec.rb +++ b/spec/unit/middlewares/section_spec.rb @@ -27,7 +27,10 @@ locale: 'en') } + let(:body) { '' } + before do + env['rack.input'] = StringIO.new(body) env['steam.page'] = page env['steam.services'] = services env['steam.locale'] = :en @@ -52,11 +55,8 @@ end context "the content of the section is in the request body" do - - before do - allow(env['steam.request']).to receive(:body).and_return(StringIO.new( - %({ "section_content": { "id": "dropzone-42", "settings": { "name": "modified HTML" } } }) - )) + let(:body) do + %({ "section_content": { "id": "dropzone-42", "settings": { "name": "modified HTML" } } }) end it 'renders the HTML code related to the section' do