Skip to content
Extraits de code Groupes Projets
Valider b155e6cc rédigé par Matt Jankowski's avatar Matt Jankowski Validation de Eugen
Parcourir les fichiers

Fix issue with intermittent api/v1/notifications failure (#1606)

The spec was checking the activity_id of the activities held in notifications
within the controller.

Because the activities are different models, it is possible that they are
created with the same database IDs, and when they are this spec fails because an
activity which should not count as a match is counted as one.
parent f16b9a49
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -13,11 +13,12 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do ...@@ -13,11 +13,12 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
describe 'GET #index' do describe 'GET #index' do
before do before do
status = PostStatusService.new.call(user.account, 'Test') first_status = PostStatusService.new.call(user.account, 'Test')
@reblog = ReblogService.new.call(other.account, status) @reblog_of_first_status = ReblogService.new.call(other.account, first_status)
@mention = PostStatusService.new.call(other.account, 'Hello @alice') mentioning_status = PostStatusService.new.call(other.account, 'Hello @alice')
@favourite = FavouriteService.new.call(other.account, status) @mention_from_status = mentioning_status.mentions.first
@follow = FollowService.new.call(other.account, 'alice') @favourite = FavouriteService.new.call(other.account, first_status)
@follow = FollowService.new.call(other.account, 'alice')
end end
describe 'with no options' do describe 'with no options' do
...@@ -30,19 +31,19 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do ...@@ -30,19 +31,19 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
end end
it 'includes reblog' do it 'includes reblog' do
expect(assigns(:notifications).map(&:activity_id)).to include(@reblog.id) expect(assigns(:notifications).map(&:activity)).to include(@reblog_of_first_status)
end end
it 'includes mention' do it 'includes mention' do
expect(assigns(:notifications).map(&:activity_id)).to include(@mention.mentions.first.id) expect(assigns(:notifications).map(&:activity)).to include(@mention_from_status)
end end
it 'includes favourite' do it 'includes favourite' do
expect(assigns(:notifications).map(&:activity_id)).to include(@favourite.id) expect(assigns(:notifications).map(&:activity)).to include(@favourite)
end end
it 'includes follow' do it 'includes follow' do
expect(assigns(:notifications).map(&:activity_id)).to include(@follow.id) expect(assigns(:notifications).map(&:activity)).to include(@follow)
end end
end end
...@@ -56,19 +57,19 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do ...@@ -56,19 +57,19 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
end end
it 'includes reblog' do it 'includes reblog' do
expect(assigns(:notifications).map(&:activity_id)).to include(@reblog.id) expect(assigns(:notifications).map(&:activity)).to include(@reblog_of_first_status)
end end
it 'excludes mention' do it 'excludes mention' do
expect(assigns(:notifications).map(&:activity_id)).to_not include(@mention.mentions.first.id) expect(assigns(:notifications).map(&:activity)).to_not include(@mention_from_status)
end end
it 'includes favourite' do it 'includes favourite' do
expect(assigns(:notifications).map(&:activity_id)).to include(@favourite.id) expect(assigns(:notifications).map(&:activity)).to include(@favourite)
end end
it 'includes follow' do it 'includes follow' do
expect(assigns(:notifications).map(&:activity_id)).to include(@follow.id) expect(assigns(:notifications).map(&:activity)).to include(@follow)
end end
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter