diff --git a/Gemfile b/Gemfile index 0e4d83d..f6c1340 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "rails", "~> 5.2" +gem "rails", "~> 6.1.7" gem "dotenv" gem "oj", ">= 3.1.0" gem "oj_mimic_json", "~> 1.0", ">= 1.0.1" @@ -22,22 +22,19 @@ gem "rack-cors", "~> 1.0", require: "rack/cors" gem "git", "~> 1.5" gem "sprockets", "~> 3.7", ">= 3.7.2" -group :development do +group :development, :test do gem "better_errors" gem "binding_of_caller" gem "listen", "~> 3.0.5" - gem "rubocop", "~> 0.77.0" + gem "rubocop", "~> 1.3", ">= 1.3.1" gem "rubocop-performance", "~> 1.5", ">= 1.5.1" - gem "rubocop-rails", "~> 2.4" + gem "rubocop-rails", "~> 2.8", ">= 2.8.1" gem "spring" gem "spring-watcher-listen", "~> 2.0.0" gem 'byebug' -end - -group :test do - gem "rspec-rails", "~> 3.5", ">= 3.5.2" + gem "rspec-rails", "~> 3.8", ">= 3.8.2" gem "capybara" gem "webmock", "~> 3.8", ">= 3.8.2" - gem "vcr", "~> 3.0.3" + gem "vcr", "~> 5.1" gem 'simplecov', '~> 0.17.1' end diff --git a/Gemfile.lock b/Gemfile.lock index c440050..d671925 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,50 +1,67 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.6) - actionpack (= 5.2.6) + actioncable (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.6) - actionpack (= 5.2.6) - actionview (= 5.2.6) - activejob (= 5.2.6) + actionmailbox (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) + mail (>= 2.7.1) + actionmailer (6.1.7.6) + actionpack (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.6) - actionview (= 5.2.6) - activesupport (= 5.2.6) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.7.6) + actionview (= 6.1.7.6) + activesupport (= 6.1.7.6) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.6) - activesupport (= 5.2.6) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7.6) + actionpack (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) + nokogiri (>= 1.8.5) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.6) - activesupport (= 5.2.6) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (5.2.6) - activesupport (= 5.2.6) - activerecord (5.2.6) - activemodel (= 5.2.6) - activesupport (= 5.2.6) - arel (>= 9.0) - activestorage (5.2.6) - actionpack (= 5.2.6) - activerecord (= 5.2.6) - marcel (~> 1.0.0) - activesupport (5.2.6) + activemodel (6.1.7.6) + activesupport (= 6.1.7.6) + activerecord (6.1.7.6) + activemodel (= 6.1.7.6) + activesupport (= 6.1.7.6) + activestorage (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activesupport (= 6.1.7.6) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) - arel (9.0.0) ast (2.4.2) benchmark_methods (0.7) better_errors (2.9.1) @@ -107,6 +124,7 @@ GEM csl-styles (1.0.1.11) csl (~> 1.0) dalli (2.7.11) + date (3.3.4) debug_inspector (1.1.0) diff-lcs (1.5.0) docile (1.4.0) @@ -134,14 +152,13 @@ GEM unicode_utils (>= 1.3.0) git (1.10.1) rchardet (~> 1.8) - globalid (1.0.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) hashdiff (1.0.1) htmlentities (4.3.4) i18n (1.14.1) concurrent-ruby (~> 1.0) iso8601 (0.9.1) - jaro_winkler (1.5.4) json (2.6.1) json-canonicalization (0.3.1) json-ld (3.2.4) @@ -173,8 +190,11 @@ GEM loofah (2.21.3) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) maremma (4.9.8) activesupport (>= 4.2.5) @@ -194,15 +214,25 @@ GEM multi_json (1.15.0) multipart-post (2.3.0) namae (1.1.1) - nio4r (2.5.8) + net-imap (0.3.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.7.0) nokogiri (1.13.10-x86_64-darwin) racc (~> 1.4) oj (3.14.2) oj_mimic_json (1.0.1) optimist (3.1.0) - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.23.0) + parser (3.2.2.4) ast (~> 2.4.1) + racc postrank-uri (1.1) addressable (>= 2.4.0) nokogiri (>= 1.8.0) @@ -214,31 +244,33 @@ GEM rack (>= 2.0.0) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.6) - actioncable (= 5.2.6) - actionmailer (= 5.2.6) - actionpack (= 5.2.6) - actionview (= 5.2.6) - activejob (= 5.2.6) - activemodel (= 5.2.6) - activerecord (= 5.2.6) - activestorage (= 5.2.6) - activesupport (= 5.2.6) - bundler (>= 1.3.0) - railties (= 5.2.6) + rails (6.1.7.6) + actioncable (= 6.1.7.6) + actionmailbox (= 6.1.7.6) + actionmailer (= 6.1.7.6) + actionpack (= 6.1.7.6) + actiontext (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activemodel (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) + bundler (>= 1.15.0) + railties (= 6.1.7.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (5.2.6) - actionpack (= 5.2.6) - activesupport (= 5.2.6) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.0) rb-inotify (0.10.1) @@ -278,20 +310,25 @@ GEM rspec-mocks (~> 3.9.0) rspec-support (~> 3.9.0) rspec-support (3.9.4) - rubocop (0.77.0) - jaro_winkler (~> 1.5.1) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) rubocop-performance (1.6.1) rubocop (>= 0.71.0) - rubocop-rails (2.5.2) - activesupport + rubocop-rails (2.19.1) + activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.72.0) - ruby-progressbar (1.11.0) + rubocop (>= 1.33.0, < 2.0) + ruby-progressbar (1.13.0) scanf (1.0.0) sentry-raven (2.13.0) faraday (>= 0.7.6, < 1.0) @@ -315,22 +352,23 @@ GEM matrix (~> 0.4) rdf (~> 3.2) thor (1.2.2) - thread_safe (0.3.6) - tzinfo (1.2.11) - thread_safe (~> 0.1) - unicode-display_width (1.6.1) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) unicode-types (1.9.0) unicode_utils (1.4.0) - vcr (3.0.3) + vcr (5.1.0) webmock (3.14.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.6.12) PLATFORMS x86_64-darwin-20 @@ -359,17 +397,17 @@ DEPENDENCIES oj (>= 3.1.0) oj_mimic_json (~> 1.0, >= 1.0.1) rack-cors (~> 1.0) - rails (~> 5.2) - rspec-rails (~> 3.5, >= 3.5.2) - rubocop (~> 0.77.0) + rails (~> 6.1.7) + rspec-rails (~> 3.8, >= 3.8.2) + rubocop (~> 1.3, >= 1.3.1) rubocop-performance (~> 1.5, >= 1.5.1) - rubocop-rails (~> 2.4) + rubocop-rails (~> 2.8, >= 2.8.1) sentry-raven (~> 2.9) simplecov (~> 0.17.1) spring spring-watcher-listen (~> 2.0.0) sprockets (~> 3.7, >= 3.7.2) - vcr (~> 3.0.3) + vcr (~> 5.1) webmock (~> 3.8, >= 3.8.2) BUNDLED WITH diff --git a/config/application.rb b/config/application.rb index 92e4522..a3c8a00 100644 --- a/config/application.rb +++ b/config/application.rb @@ -38,6 +38,7 @@ module ContentNegotiation class Application < Rails::Application + config.load_defaults 6.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. diff --git a/config/routes.rb b/config/routes.rb index d94f342..3e9cb5e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,7 +17,7 @@ get '/application/x-turtle/:id', :to => 'index#show', constraints: { :id => /.+/ }, defaults: { format: :turtle } get '/text/x-bibliography/:id', :to => 'index#show', constraints: { :id => /.+/ }, defaults: { format: :citation } - resources :index, path: '/', only: [:show, :index], constraints: { id: /.+/, format: false } + resources :index, path: '/', only: [:show, :index], constraints: { id: /.+/ } root :to => 'index#index' # rescue method not allowed errors diff --git a/spec/routing/index_routing_spec.rb b/spec/routing/index_routing_spec.rb new file mode 100644 index 0000000..0483005 --- /dev/null +++ b/spec/routing/index_routing_spec.rb @@ -0,0 +1,35 @@ +require 'rails_helper' + +RSpec.describe 'Index routing', type: :routing do + it 'routes GET / to index#index' do + expect(get: '/').to route_to(controller: 'index', action: 'index') + end + + it 'routes GET /index to index#show' do + expect(get: '/index').to route_to(controller: 'index', action: 'show', id: 'index') + end + + it 'does not route GET /index.xml to index#show' do + expect(get: '/index.xml').not_to route_to(controller: 'index', action: 'show', id: 'index', format: 'xml') + end + + it 'routes GET /custom_id to index#show with custom_id' do + expect(get: '/custom_id').to route_to(controller: 'index', action: 'show', id: 'custom_id') + end + + it 'does not route GET /custom_id.xml to index#show with custom_id and xml format' do + expect(get: '/custom_id.xml').not_to route_to(controller: 'index', action: 'show', id: 'custom_id', format: 'xml') + end + + it 'routes GET / with format: false to index#index' do + expect(get: '/', constraints: { format: false }).to route_to(controller: 'index', action: 'index') + end + + it 'does not route GET /index.xml with format: false to index#show' do + expect(get: '/index.xml', constraints: { format: false }).not_to route_to(controller: 'index', action: 'show', id: 'index', format: 'xml') + end + + it 'does not route GET /custom_id.xml with format: false to index#show with custom_id' do + expect(get: '/custom_id.xml', constraints: { format: false }).not_to route_to(controller: 'index', action: 'show', id: 'custom_id', format: 'xml') + end +end