You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

Optional notification muting (#5087) * Add a hide_notifications column to mutes * Add muting_notifications? and a notifications argument to mute! * block notifications in notify_service from hard muted accounts * Add specs for how mute! interacts with muting_notifications? * specs testing that hide_notifications in mutes actually hides notifications * Add support for muting notifications in MuteService * API support for muting notifications (and specs) * Less gross passing of notifications flag * Break out a separate mute modal with a hide-notifications checkbox. * Convert profile header mute to use mute modal * Satisfy eslint. * specs for MuteService notifications params * add trailing newlines to files for Pork :) * Put the label for the hide notifications checkbox in a label element. * Add a /api/v1/mutes/details route that just returns the array of mutes. * Define a serializer for /api/v1/mutes/details * Add more specs for the /api/v1/mutes/details endpoint * Expose whether a mute hides notifications in the api/v1/relationships endpoint * Show whether muted users' notifications are muted in account lists * Allow modifying the hide_notifications of a mute with the /api/v1/accounts/:id/mute endpoint * make the hide/unhide notifications buttons work * satisfy eslint * In probably dead code, replace a dispatch of muteAccount that was skipping the modal with launching the mute modal. * fix a missing import * add an explanatory comment to AccountInteractions * Refactor handling of default params for muting to make code cleaner * minor code style fixes oops * Fixed a typo that was breaking the account mute API endpoint * Apply white-space: nowrap to account relationships icons * Fix code style issues * Remove superfluous blank line * Rename /api/v1/mutes/details -> /api/v2/mutes * Don't serialize "account" in MuteSerializer Doing so is somewhat unnecessary since it's always the current user's account. * Fix wrong variable name in api/v2/mutes * Use Toggle in place of checkbox in the mute modal. * Make the Toggle in the mute modal look better * Code style changes in specs and removed an extra space * Code review suggestions from akihikodaki Also fixed a syntax error in tests for AccountInteractions. * Make AddHideNotificationsToMute Concurrent It's not clear how much this will benefit instances in practice, as the number of mutes tends to be pretty small, but this should prevent any blocking migrations nonetheless. * Fix up migration things * Remove /api/v2/mutes
7 years ago
  1. require 'rails_helper'
  2. RSpec.describe MuteService, type: :service do
  3. subject do
  4. -> { described_class.new.call(account, target_account) }
  5. end
  6. let(:account) { Fabricate(:account) }
  7. let(:target_account) { Fabricate(:account) }
  8. describe 'home timeline' do
  9. let(:status) { Fabricate(:status, account: target_account) }
  10. let(:other_account_status) { Fabricate(:status) }
  11. let(:home_timeline_key) { FeedManager.instance.key(:home, account.id) }
  12. before do
  13. Redis.current.del(home_timeline_key)
  14. end
  15. it "clears account's statuses" do
  16. FeedManager.instance.push_to_home(account, status)
  17. FeedManager.instance.push_to_home(account, other_account_status)
  18. is_expected.to change {
  19. Redis.current.zrange(home_timeline_key, 0, -1)
  20. }.from([status.id.to_s, other_account_status.id.to_s]).to([other_account_status.id.to_s])
  21. end
  22. end
  23. it 'mutes account' do
  24. is_expected.to change {
  25. account.muting?(target_account)
  26. }.from(false).to(true)
  27. end
  28. context 'without specifying a notifications parameter' do
  29. it 'mutes notifications from the account' do
  30. is_expected.to change {
  31. account.muting_notifications?(target_account)
  32. }.from(false).to(true)
  33. end
  34. end
  35. context 'with a true notifications parameter' do
  36. subject do
  37. -> { described_class.new.call(account, target_account, notifications: true) }
  38. end
  39. it 'mutes notifications from the account' do
  40. is_expected.to change {
  41. account.muting_notifications?(target_account)
  42. }.from(false).to(true)
  43. end
  44. end
  45. context 'with a false notifications parameter' do
  46. subject do
  47. -> { described_class.new.call(account, target_account, notifications: false) }
  48. end
  49. it 'does not mute notifications from the account' do
  50. is_expected.to_not change {
  51. account.muting_notifications?(target_account)
  52. }.from(false)
  53. end
  54. end
  55. end