diff --git a/.rubocop.yml b/.rubocop.yml index 2564b28..592217c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -207,8 +207,3 @@ Layout/IndentHeredoc: Enabled: false Layout/ClosingHeredocIndentation: Enabled: false - -# for rails 4 and ruby < 2.2.2 -Rails/HttpPositionalArguments: - Exclude: - - "spec/controllers/diaspora_federation/rails4_spec.rb" diff --git a/.travis.yml b/.travis.yml index 6622592..a805249 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ rvm: - 2.1 gemfile: - Gemfile - - test/gemfiles/rails4.Gemfile - test/gemfiles/no-rails.Gemfile matrix: diff --git a/Gemfile.lock b/Gemfile.lock index 9ebdd4b..8ea0d9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ PATH valid (~> 1.0) diaspora_federation-json_schema (0.2.6) diaspora_federation-rails (0.2.6) - actionpack (>= 4.2, < 6) + actionpack (>= 5, < 6) diaspora_federation (= 0.2.6) diaspora_federation-test (0.2.6) diaspora_federation (= 0.2.6) diff --git a/diaspora_federation-rails.gemspec b/diaspora_federation-rails.gemspec index edc4fba..66e08f3 100644 --- a/diaspora_federation-rails.gemspec +++ b/diaspora_federation-rails.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.required_ruby_version = "~> 2.1" - s.add_dependency "actionpack", ">= 4.2", "< 6" + s.add_dependency "actionpack", ">= 5", "< 6" s.add_dependency "diaspora_federation", DiasporaFederation::VERSION end diff --git a/lib/tasks/gemfiles.rake b/lib/tasks/gemfiles.rake index 124f386..f50bf8f 100644 --- a/lib/tasks/gemfiles.rake +++ b/lib/tasks/gemfiles.rake @@ -1,5 +1,5 @@ namespace :gemfiles do - desc "Generates rails4.Gemfile and no-rails.Gemfile" + desc "Generates no-rails.Gemfile" task :generate do FileUtils.mkdir_p("test/gemfiles") FileUtils.rm(Dir["test/gemfiles/*.Gemfile.lock"]) @@ -10,11 +10,6 @@ namespace :gemfiles do original_gemfile.sub!(/^group :development do$.*?^end$\n\n/m, "") original_gemfile << "\n gem \"fabrication\", \"< 2.17.0\"\n" # new versions are not compatible with ruby 2.1 - rails4_version = "4.2.8" - rails4_gemfile = "#{original_gemfile}\ngem \"actionpack\", \"#{rails4_version}\"\n" - rails4_path = "test/gemfiles/rails4.Gemfile" - File.write(rails4_path, rails4_gemfile) - no_rails_gemfile = original_gemfile.dup no_rails_gemfile.sub!(/(gemspec\(name:.*)/) { "#{Regexp.last_match[1]} unless plugin == \"rails\"" } no_rails_gemfile.sub!(/^.*rspec-rails.*$\n/, "") @@ -22,7 +17,6 @@ namespace :gemfiles do File.write(no_rails_path, no_rails_gemfile) Bundler.with_clean_env do - system("BUNDLE_GEMFILE=#{rails4_path} bundle install") system("BUNDLE_GEMFILE=#{no_rails_path} bundle install") end end diff --git a/spec/controllers/diaspora_federation/fetch_controller_spec.rb b/spec/controllers/diaspora_federation/fetch_controller_spec.rb index 235783b..22916e9 100644 --- a/spec/controllers/diaspora_federation/fetch_controller_spec.rb +++ b/spec/controllers/diaspora_federation/fetch_controller_spec.rb @@ -1,5 +1,5 @@ module DiasporaFederation - describe FetchController, type: :controller, rails: 5 do + describe FetchController, type: :controller do routes { DiasporaFederation::Engine.routes } let(:guid) { "12345678901234567890" } diff --git a/spec/controllers/diaspora_federation/h_card_controller_spec.rb b/spec/controllers/diaspora_federation/h_card_controller_spec.rb index 9ebbfd9..4bb4529 100644 --- a/spec/controllers/diaspora_federation/h_card_controller_spec.rb +++ b/spec/controllers/diaspora_federation/h_card_controller_spec.rb @@ -1,5 +1,5 @@ module DiasporaFederation - describe HCardController, type: :controller, rails: 5 do + describe HCardController, type: :controller do routes { DiasporaFederation::Engine.routes } describe "GET #hcard" do diff --git a/spec/controllers/diaspora_federation/rails4_spec.rb b/spec/controllers/diaspora_federation/rails4_spec.rb deleted file mode 100644 index 7225c9a..0000000 --- a/spec/controllers/diaspora_federation/rails4_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -# only some basic controller tests for rails 4 -module DiasporaFederation - describe WebfingerController, type: :controller, rails: 4 do - routes { DiasporaFederation::Engine.routes } - - it "contains the webfinger result" do - webfinger_xrd = DiasporaFederation::Discovery::WebFinger.new( - acct_uri: "acct:#{alice.diaspora_id}", - alias_url: alice.alias_url, - hcard_url: alice.hcard_url, - seed_url: alice.url, - profile_url: alice.profile_url, - atom_url: alice.atom_url, - salmon_url: alice.salmon_url, - subscribe_url: alice.subscribe_url, - guid: alice.guid, - public_key: alice.serialized_public_key - ).to_xml - - get :webfinger, format: :xml, resource: alice.diaspora_id - expect(response).to be_success - expect(response.body).to eq(webfinger_xrd) - end - - it "404s when the person does not exist" do - get :webfinger, format: :xml, resource: "me@mydiaspora.pod.com" - expect(response).to be_not_found - end - end - - describe HCardController, type: :controller, rails: 4 do - routes { DiasporaFederation::Engine.routes } - - it "contains the hcard result" do - hcard_html = DiasporaFederation::Discovery::HCard.new( - guid: alice.guid, - nickname: alice.nickname, - full_name: alice.full_name, - url: alice.url, - photo_large_url: alice.photo_default_url, - photo_medium_url: alice.photo_default_url, - photo_small_url: alice.photo_default_url, - public_key: alice.serialized_public_key, - searchable: alice.searchable, - first_name: alice.first_name, - last_name: alice.last_name - ).to_html - - get :hcard, guid: alice.guid - expect(response).to be_success - expect(response.body).to eq(hcard_html) - end - - it "404s when the person does not exist" do - get :hcard, guid: "unknown_guid" - expect(response).to be_not_found - end - end - - describe ReceiveController, type: :controller, rails: 4 do - routes { DiasporaFederation::Engine.routes } - - describe "POST #public" do - it "returns a 202 if queued correctly" do - expect_callback(:queue_public_receive, "", true) - - post :public, xml: "" - expect(response.code).to eq("202") - end - end - - describe "POST #private" do - it "returns a 202 if the callback returned true" do - expect_callback(:queue_private_receive, "any-guid", "", true).and_return(true) - - post :private, guid: "any-guid", xml: "" - expect(response.code).to eq("202") - end - end - end -end diff --git a/spec/controllers/diaspora_federation/receive_controller_spec.rb b/spec/controllers/diaspora_federation/receive_controller_spec.rb index b480f48..281319e 100644 --- a/spec/controllers/diaspora_federation/receive_controller_spec.rb +++ b/spec/controllers/diaspora_federation/receive_controller_spec.rb @@ -15,21 +15,21 @@ module DiasporaFederation expect(response.code).to eq("422") end - it "returns a 202 if queued correctly", rails: 5 do + it "returns a 202 if queued correctly" do expect_callback(:queue_public_receive, "", true) post :public, params: {xml: ""} expect(response.code).to eq("202") end - it "unescapes the xml before sending it to the callback", rails: 5 do + it "unescapes the xml before sending it to the callback" do expect_callback(:queue_public_receive, "", true) post :public, params: {xml: CGI.escape("")} end end - context "magic envelope", rails: 5 do + context "magic envelope" do before do Mime::Type.register("application/magic-envelope+xml", :magic_envelope) @request.env["CONTENT_TYPE"] = "application/magic-envelope+xml" @@ -44,7 +44,7 @@ module DiasporaFederation end end - describe "POST #private", rails: 5 do + describe "POST #private" do context "legacy salmon slap" do it "return a 404 if not queued successfully (unknown user guid)" do expect_callback(:queue_private_receive, "any-guid", "", true).and_return(false) diff --git a/spec/controllers/diaspora_federation/webfinger_controller_spec.rb b/spec/controllers/diaspora_federation/webfinger_controller_spec.rb index b1796c6..335c19e 100644 --- a/spec/controllers/diaspora_federation/webfinger_controller_spec.rb +++ b/spec/controllers/diaspora_federation/webfinger_controller_spec.rb @@ -35,7 +35,7 @@ module DiasporaFederation end end - describe "GET #webfinger", rails: 5 do + describe "GET #webfinger" do it "uses the JRD format as default" do get :webfinger, params: {resource: alice.diaspora_id} expect(response).to be_successful diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b4f4ce2..f7d6477 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -52,9 +52,7 @@ RSpec.configure do |config| expect_config.syntax = :expect end - if defined?(::Rails) - config.filter_run_excluding rails: (::Rails::VERSION::MAJOR == 5 ? 4 : 5) - else + unless defined?(::Rails) config.exclude_pattern = "**/controllers/**/*_spec.rb, **/routing/**/*_spec.rb" config.filter_run_excluding rails: true end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index e7fbf43..6eee539 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -13,13 +13,8 @@ Rails.application.configure do config.eager_load = false # Configure static file server for tests with Cache-Control for performance. - if Rails::VERSION::MAJOR == 5 - config.public_file_server.enable = true - config.public_file_server.headers = {"Cache-Control" => "public, max-age=3600"} - else - config.serve_static_files = true - config.static_cache_control = "public, max-age=3600" - end + config.public_file_server.enable = true + config.public_file_server.headers = {"Cache-Control" => "public, max-age=3600"} # Show full error reports and disable caching. config.consider_all_requests_local = true diff --git a/test/gemfiles/rails4.Gemfile b/test/gemfiles/rails4.Gemfile deleted file mode 100644 index 8de5931..0000000 --- a/test/gemfiles/rails4.Gemfile +++ /dev/null @@ -1,44 +0,0 @@ -source "https://rubygems.org" - -# Declare your gem's dependencies in diaspora_federation.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. -gemspec name: "diaspora_federation", path: "../../" - -Dir["diaspora_federation-*.gemspec"].each do |gemspec| - plugin = gemspec.scan(/diaspora_federation-(.*)\.gemspec/).flatten.first - gemspec(name: "diaspora_federation-#{plugin}", development_group: plugin, path: "../../") -end - -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. - -group :test do - # rspec formatter - gem "fuubar", "2.3.2", require: false - gem "nyan-cat-formatter", require: false - - # test coverage - gem "simplecov", "0.16.1", require: false - gem "simplecov-rcov", "0.2.3", require: false - - # test helpers - gem "json-schema-rspec", "0.0.4" - gem "rspec-collection_matchers", "~> 1.1.2" - gem "rspec-json_expectations", "~> 2.1" - gem "webmock", "~> 3.0" -end - -group :development, :test do - gem "rake" - - # unit tests - gem "rspec", "~> 3.8.0" - gem "rspec-rails", "~> 3.8.0" -end - - gem "fabrication", "< 2.17.0" - -gem "actionpack", "4.2.8" diff --git a/test/gemfiles/rails4.Gemfile.lock b/test/gemfiles/rails4.Gemfile.lock deleted file mode 100644 index 917f535..0000000 --- a/test/gemfiles/rails4.Gemfile.lock +++ /dev/null @@ -1,171 +0,0 @@ -PATH - remote: ../.. - specs: - diaspora_federation (0.2.6) - faraday (>= 0.9.0, < 0.16.0) - faraday_middleware (>= 0.10.0, < 0.14.0) - nokogiri (~> 1.6, >= 1.6.8) - typhoeus (~> 1.0) - valid (~> 1.0) - diaspora_federation-json_schema (0.2.6) - diaspora_federation-rails (0.2.6) - actionpack (>= 4.2, < 6) - diaspora_federation (= 0.2.6) - diaspora_federation-test (0.2.6) - diaspora_federation (= 0.2.6) - fabrication (~> 2.16) - uuid (~> 2.3, >= 2.3.8) - -GEM - remote: https://rubygems.org/ - specs: - actionpack (4.2.8) - actionview (= 4.2.8) - activesupport (= 4.2.8) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.8) - activesupport (= 4.2.8) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activesupport (4.2.8) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) - builder (3.2.3) - concurrent-ruby (1.1.5) - crack (0.4.3) - safe_yaml (~> 1.0.0) - crass (1.0.4) - diff-lcs (1.3) - docile (1.3.1) - erubis (2.7.0) - ethon (0.12.0) - ffi (>= 1.3.0) - fabrication (2.16.3) - faraday (0.15.4) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.13.1) - faraday (>= 0.7.4, < 1.0) - ffi (1.10.0) - fuubar (2.3.2) - rspec-core (~> 3.0) - ruby-progressbar (~> 1.4) - hashdiff (0.3.8) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - json (2.2.0) - json-schema (2.8.1) - addressable (>= 2.4) - json-schema-rspec (0.0.4) - json-schema (~> 2.5) - rspec - loofah (2.2.3) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - macaddr (1.7.1) - systemu (~> 2.6.2) - mini_portile2 (2.4.0) - minitest (5.11.3) - multipart-post (2.0.0) - nokogiri (1.9.1) - mini_portile2 (~> 2.4.0) - nyan-cat-formatter (0.12.0) - rspec (>= 2.99, >= 2.14.2, < 4) - public_suffix (3.0.3) - rack (1.6.11) - rack-test (0.6.3) - rack (>= 1.0) - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - railties (4.2.8) - actionpack (= 4.2.8) - activesupport (= 4.2.8) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (12.3.2) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-collection_matchers (1.1.3) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-json_expectations (2.1.0) - rspec-mocks (3.8.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - ruby-progressbar (1.10.0) - safe_yaml (1.0.5) - simplecov (0.16.1) - docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - simplecov-rcov (0.2.3) - simplecov (>= 0.4.1) - systemu (2.6.5) - thor (0.20.3) - thread_safe (0.3.6) - typhoeus (1.3.1) - ethon (>= 0.9.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) - uuid (2.3.9) - macaddr (~> 1.0) - valid (1.2.0) - webmock (3.5.1) - addressable (>= 2.3.6) - crack (>= 0.3.2) - hashdiff - -PLATFORMS - ruby - -DEPENDENCIES - actionpack (= 4.2.8) - diaspora_federation! - diaspora_federation-json_schema! - diaspora_federation-rails! - diaspora_federation-test! - fabrication (< 2.17.0) - fuubar (= 2.3.2) - json-schema-rspec (= 0.0.4) - nyan-cat-formatter - rake - rspec (~> 3.8.0) - rspec-collection_matchers (~> 1.1.2) - rspec-json_expectations (~> 2.1) - rspec-rails (~> 3.8.0) - simplecov (= 0.16.1) - simplecov-rcov (= 0.2.3) - webmock (~> 3.0) - -BUNDLED WITH - 1.17.3