fix specs for rails 5
This commit is contained in:
parent
82ea57ef34
commit
373540f4cf
8 changed files with 39 additions and 32 deletions
|
|
@ -183,6 +183,3 @@ Style/NumericPredicate:
|
|||
|
||||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
||||
|
||||
Rails/HttpPositionalArguments:
|
||||
Enabled: false
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module DiasporaFederation
|
|||
expect_callback(:fetch_public_entity, "StatusMessage", guid).and_return(post)
|
||||
expect_callback(:fetch_private_key, alice.diaspora_id).and_return(alice.private_key)
|
||||
|
||||
get :fetch, type: "status_message", guid: guid
|
||||
get :fetch, params: {type: "status_message", guid: guid}
|
||||
|
||||
expect_callback(:fetch_public_key, alice.diaspora_id).and_return(alice.public_key)
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ module DiasporaFederation
|
|||
expect_callback(:fetch_public_entity, "Post", guid).and_return(post)
|
||||
expect_callback(:fetch_private_key, alice.diaspora_id).and_return(alice.private_key)
|
||||
|
||||
get :fetch, type: "post", guid: guid
|
||||
get :fetch, params: {type: "post", guid: guid}
|
||||
|
||||
expect_callback(:fetch_public_key, alice.diaspora_id).and_return(alice.public_key)
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ module DiasporaFederation
|
|||
expect_callback(:fetch_person_url_to, alice.diaspora_id, "/fetch/post/#{guid}")
|
||||
.and_return("http://example.org/fetch/post/#{guid}")
|
||||
|
||||
get :fetch, type: "post", guid: guid
|
||||
get :fetch, params: {type: "post", guid: guid}
|
||||
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to "http://example.org/fetch/post/#{guid}"
|
||||
|
|
@ -59,7 +59,7 @@ module DiasporaFederation
|
|||
it "404s when the post does not exist" do
|
||||
expect_callback(:fetch_public_entity, "Post", guid).and_return(nil)
|
||||
|
||||
get :fetch, type: "post", guid: guid
|
||||
get :fetch, params: {type: "post", guid: guid}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,30 +4,30 @@ module DiasporaFederation
|
|||
|
||||
describe "GET #hcard" do
|
||||
it "succeeds when the person exists", fixture: true do
|
||||
get :hcard, "guid" => alice.guid
|
||||
get :hcard, params: {guid: alice.guid}
|
||||
expect(response).to be_success
|
||||
save_fixture(response.body, "hcard")
|
||||
end
|
||||
|
||||
it "contains the guid" do
|
||||
get :hcard, "guid" => alice.guid
|
||||
get :hcard, params: {guid: alice.guid}
|
||||
expect(response.body).to include "<span class=\"uid\">#{alice.guid}</span>"
|
||||
end
|
||||
|
||||
it "contains the username" do
|
||||
get :hcard, "guid" => alice.guid
|
||||
get :hcard, params: {guid: alice.guid}
|
||||
expect(response.body).to include "<span class=\"nickname\">alice</span>"
|
||||
end
|
||||
|
||||
it "404s when the person does not exist" do
|
||||
get :hcard, "guid" => "unknown_guid"
|
||||
get :hcard, params: {guid: "unknown_guid"}
|
||||
expect(response).to be_not_found
|
||||
end
|
||||
|
||||
it "calls the fetch_person_for_hcard callback" do
|
||||
expect_callback(:fetch_person_for_hcard, alice.guid).and_call_original
|
||||
|
||||
get :hcard, "guid" => alice.guid
|
||||
get :hcard, params: {guid: alice.guid}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,26 +18,27 @@ module DiasporaFederation
|
|||
it "returns a 202 if queued correctly" do
|
||||
expect_callback(:queue_public_receive, "<diaspora/>", true)
|
||||
|
||||
post :public, xml: "<diaspora/>"
|
||||
post :public, params: {xml: "<diaspora/>"}
|
||||
expect(response.code).to eq("202")
|
||||
end
|
||||
|
||||
it "unescapes the xml before sending it to the callback" do
|
||||
expect_callback(:queue_public_receive, "<diaspora/>", true)
|
||||
|
||||
post :public, xml: CGI.escape("<diaspora/>")
|
||||
post :public, params: {xml: CGI.escape("<diaspora/>")}
|
||||
end
|
||||
end
|
||||
|
||||
context "magic envelope" do
|
||||
before do
|
||||
Mime::Type.register("application/magic-envelope+xml", :magic_envelope)
|
||||
@request.env["CONTENT_TYPE"] = "application/magic-envelope+xml"
|
||||
end
|
||||
|
||||
it "returns a 202 if queued correctly" do
|
||||
expect_callback(:queue_public_receive, "<me:env/>", false)
|
||||
|
||||
post :public, "<me:env/>"
|
||||
post :public, body: "<me:env/>"
|
||||
expect(response.code).to eq("202")
|
||||
end
|
||||
end
|
||||
|
|
@ -48,32 +49,32 @@ module DiasporaFederation
|
|||
it "return a 404 if not queued successfully (unknown user guid)" do
|
||||
expect_callback(:queue_private_receive, "any-guid", "<diaspora/>", true).and_return(false)
|
||||
|
||||
post :private, guid: "any-guid", xml: "<diaspora/>"
|
||||
post :private, params: {guid: "any-guid", xml: "<diaspora/>"}
|
||||
expect(response.code).to eq("404")
|
||||
end
|
||||
|
||||
it "returns a 422 if no xml is passed" do
|
||||
post :private, guid: "any-guid"
|
||||
post :private, params: {guid: "any-guid"}
|
||||
expect(response.code).to eq("422")
|
||||
end
|
||||
|
||||
it "returns a 422 if no xml is passed with content-type application/x-www-form-urlencoded" do
|
||||
@request.env["CONTENT_TYPE"] = "application/x-www-form-urlencoded"
|
||||
post :private, guid: "any-guid"
|
||||
post :private, params: {guid: "any-guid"}
|
||||
expect(response.code).to eq("422")
|
||||
end
|
||||
|
||||
it "returns a 202 if the callback returned true" do
|
||||
expect_callback(:queue_private_receive, "any-guid", "<diaspora/>", true).and_return(true)
|
||||
|
||||
post :private, guid: "any-guid", xml: "<diaspora/>"
|
||||
post :private, params: {guid: "any-guid", xml: "<diaspora/>"}
|
||||
expect(response.code).to eq("202")
|
||||
end
|
||||
|
||||
it "unescapes the xml before sending it to the callback" do
|
||||
expect_callback(:queue_private_receive, "any-guid", "<diaspora/>", true).and_return(true)
|
||||
|
||||
post :private, guid: "any-guid", xml: CGI.escape("<diaspora/>")
|
||||
post :private, params: {guid: "any-guid", xml: CGI.escape("<diaspora/>")}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -87,7 +88,9 @@ module DiasporaFederation
|
|||
:queue_private_receive, "any-guid", "{\"aes_key\": \"key\", \"encrypted_magic_envelope\": \"env\"}", false
|
||||
).and_return(false)
|
||||
|
||||
post :private, "{\"aes_key\": \"key\", \"encrypted_magic_envelope\": \"env\"}", guid: "any-guid"
|
||||
post :private,
|
||||
body: "{\"aes_key\": \"key\", \"encrypted_magic_envelope\": \"env\"}",
|
||||
params: {guid: "any-guid"}
|
||||
expect(response.code).to eq("404")
|
||||
end
|
||||
|
||||
|
|
@ -96,7 +99,9 @@ module DiasporaFederation
|
|||
:queue_private_receive, "any-guid", "{\"aes_key\": \"key\", \"encrypted_magic_envelope\": \"env\"}", false
|
||||
).and_return(true)
|
||||
|
||||
post :private, "{\"aes_key\": \"key\", \"encrypted_magic_envelope\": \"env\"}", guid: "any-guid"
|
||||
post :private,
|
||||
body: "{\"aes_key\": \"key\", \"encrypted_magic_envelope\": \"env\"}",
|
||||
params: {guid: "any-guid"}
|
||||
expect(response.code).to eq("202")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,30 +38,30 @@ module DiasporaFederation
|
|||
|
||||
describe "GET #legacy_webfinger" do
|
||||
it "succeeds when the person exists", fixture: true do
|
||||
get :legacy_webfinger, "q" => "alice@localhost:3000"
|
||||
get :legacy_webfinger, params: {q: "alice@localhost:3000"}
|
||||
expect(response).to be_success
|
||||
save_fixture(response.body, "legacy-webfinger")
|
||||
end
|
||||
|
||||
it "succeeds with 'acct:' in the query when the person exists" do
|
||||
get :legacy_webfinger, "q" => "acct:alice@localhost:3000"
|
||||
get :legacy_webfinger, params: {q: "acct:alice@localhost:3000"}
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "contains the diaspora* ID" do
|
||||
get :legacy_webfinger, "q" => "acct:alice@localhost:3000"
|
||||
get :legacy_webfinger, params: {q: "acct:alice@localhost:3000"}
|
||||
expect(response.body).to include "<Subject>acct:alice@localhost:3000</Subject>"
|
||||
end
|
||||
|
||||
it "404s when the person does not exist" do
|
||||
get :legacy_webfinger, "q" => "me@mydiaspora.pod.com"
|
||||
get :legacy_webfinger, params: {q: "me@mydiaspora.pod.com"}
|
||||
expect(response).to be_not_found
|
||||
end
|
||||
|
||||
it "calls the fetch_person_for_webfinger callback" do
|
||||
expect_callback(:fetch_person_for_webfinger, "alice@localhost:3000").and_call_original
|
||||
|
||||
get :legacy_webfinger, "q" => "acct:alice@localhost:3000"
|
||||
get :legacy_webfinger, params: {q: "acct:alice@localhost:3000"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@ module Dummy
|
|||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = "1.0"
|
||||
|
||||
# Do not swallow errors in after_commit/after_rollback callbacks.
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
|
||||
# autoload files from test/dummy/lib
|
||||
config.autoload_once_paths += %W(#{config.root}/lib)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ Rails.application.configure do
|
|||
config.eager_load = false
|
||||
|
||||
# Configure static file server for tests with Cache-Control for performance.
|
||||
config.serve_static_files = true
|
||||
config.static_cache_control = "public, max-age=3600"
|
||||
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
|
||||
|
|
|
|||
|
|
@ -79,3 +79,11 @@ Logging::Rails.configure do |config|
|
|||
Logging.logger[ActiveRecord::Base].level = :debug
|
||||
Logging.logger["XMLLogger"].level = :debug
|
||||
end
|
||||
|
||||
module ActiveSupport
|
||||
module Dependencies
|
||||
def self.logger=(_)
|
||||
# This was remove in rails 5: https://github.com/rails/rails/commit/798dc5a92537ba4202a1a8e127a5ebdae87bc78d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue