Parcourir la source

Fix bug in relationships API introduced by #6482 (#6527)

It was merge when it needed to be deep_merge. And added some tests
master
Eugen Rochko il y a 6 ans
committed by GitHub
Parent
révision
4bc625166e
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
3 fichiers modifiés avec 24 ajouts et 2 suppressions
  1. +1
    -1
      app/controllers/api/v1/accounts/relationships_controller.rb
  2. +1
    -1
      app/presenters/account_relationships_presenter.rb
  3. +22
    -0
      spec/controllers/api/v1/accounts/relationships_controller_spec.rb

+ 1
- 1
app/controllers/api/v1/accounts/relationships_controller.rb Voir le fichier

@@ -21,6 +21,6 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController
end

def account_ids
@_account_ids ||= Array(params[:id]).map(&:to_i)
Array(params[:id]).map(&:to_i)
end
end

+ 1
- 1
app/presenters/account_relationships_presenter.rb Voir le fichier

@@ -45,7 +45,7 @@ class AccountRelationshipsPresenter
maps_for_account = Rails.cache.read("relationship:#{@current_account_id}:#{account_id}")

if maps_for_account.is_a?(Hash)
@cached.merge!(maps_for_account)
@cached.deep_merge!(maps_for_account)
else
@uncached_account_ids << account_id
end


+ 22
- 0
spec/controllers/api/v1/accounts/relationships_controller_spec.rb Voir le fichier

@@ -66,6 +66,28 @@ describe Api::V1::Accounts::RelationshipsController do
expect(json.second[:requested]).to be false
expect(json.second[:domain_blocking]).to be false
end

it 'returns JSON with correct data on cached requests too' do
get :index, params: { id: [simon.id] }

json = body_as_json

expect(json).to be_a Enumerable
expect(json.first[:following]).to be true
expect(json.first[:showing_reblogs]).to be true
end

it 'returns JSON with correct data after change too' do
user.account.unfollow!(simon)

get :index, params: { id: [simon.id] }

json = body_as_json

expect(json).to be_a Enumerable
expect(json.first[:following]).to be false
expect(json.first[:showing_reblogs]).to be false
end
end
end
end

Chargement…
Annuler
Enregistrer