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.

657 lines
17 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
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
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
Allow hiding of reblogs from followed users (#5762) * Allow hiding of reblogs from followed users This adds a new entry to the account menu to allow users to hide future reblogs from a user (and then if they've done that, to show future reblogs instead). This does not remove or add historical reblogs from/to the user's timeline; it only affects new statuses. The API for this operates by sending a "reblogs" key to the follow endpoint. If this is sent when starting a new follow, it will be respected from the beginning of the follow relationship (even if the follow request must be approved by the followee). If this is sent when a follow relationship already exists, it will simply update the existing follow relationship. As with the notification muting, this will now return an object ({reblogs: [true|false]}) or false for each follow relationship when requesting relationship information for an account. This should cause few issues due to an object being truthy in many languages, but some modifications may need to be made in pickier languages. Database changes: adds a show_reblogs column (default true, non-nullable) to the follows and follow_requests tables. Because these are non-nullable, we use the existing MigrationHelpers to perform this change without locking those tables, although the tables are likely to be small anyway. Tests included. See also <https://github.com/glitch-soc/mastodon/pull/212>. * Rubocop fixes * Code review changes * Test fixes This patchset closes #648 and resolves #3271. * Rubocop fix * Revert reblogs defaulting in argument, fix tests It turns out we needed this for the same reason we needed it in muting: if nil gets passed in somehow (most usually by an API client not passing any value), we need to detect and handle it. We could specify a default in the parameter and then also catch nil, but there's no great reason to duplicate the default value.
7 years ago
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. describe AccountInteractions do
  3. let(:account) { Fabricate(:account, username: 'account') }
  4. let(:account_id) { account.id }
  5. let(:account_ids) { [account_id] }
  6. let(:target_account) { Fabricate(:account, username: 'target') }
  7. let(:target_account_id) { target_account.id }
  8. let(:target_account_ids) { [target_account_id] }
  9. describe '.following_map' do
  10. subject { Account.following_map(target_account_ids, account_id) }
  11. context 'account with Follow' do
  12. it 'returns { target_account_id => { reblogs: true } }' do
  13. Fabricate(:follow, account: account, target_account: target_account)
  14. is_expected.to eq(target_account_id => { reblogs: true })
  15. end
  16. end
  17. context 'account with Follow but with reblogs disabled' do
  18. it 'returns { target_account_id => { reblogs: false } }' do
  19. Fabricate(:follow, account: account, target_account: target_account, show_reblogs: false)
  20. is_expected.to eq(target_account_id => { reblogs: false })
  21. end
  22. end
  23. context 'account without Follow' do
  24. it 'returns {}' do
  25. is_expected.to eq({})
  26. end
  27. end
  28. end
  29. describe '.followed_by_map' do
  30. subject { Account.followed_by_map(target_account_ids, account_id) }
  31. context 'account with Follow' do
  32. it 'returns { target_account_id => true }' do
  33. Fabricate(:follow, account: target_account, target_account: account)
  34. is_expected.to eq(target_account_id => true)
  35. end
  36. end
  37. context 'account without Follow' do
  38. it 'returns {}' do
  39. is_expected.to eq({})
  40. end
  41. end
  42. end
  43. describe '.blocking_map' do
  44. subject { Account.blocking_map(target_account_ids, account_id) }
  45. context 'account with Block' do
  46. it 'returns { target_account_id => true }' do
  47. Fabricate(:block, account: account, target_account: target_account)
  48. is_expected.to eq(target_account_id => true)
  49. end
  50. end
  51. context 'account without Block' do
  52. it 'returns {}' do
  53. is_expected.to eq({})
  54. end
  55. end
  56. end
  57. describe '.muting_map' do
  58. subject { Account.muting_map(target_account_ids, account_id) }
  59. context 'account with Mute' do
  60. before do
  61. Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
  62. end
  63. context 'if Mute#hide_notifications?' do
  64. let(:hide) { true }
  65. it 'returns { target_account_id => { notifications: true } }' do
  66. is_expected.to eq(target_account_id => { notifications: true })
  67. end
  68. end
  69. context 'unless Mute#hide_notifications?' do
  70. let(:hide) { false }
  71. it 'returns { target_account_id => { notifications: false } }' do
  72. is_expected.to eq(target_account_id => { notifications: false })
  73. end
  74. end
  75. end
  76. context 'account without Mute' do
  77. it 'returns {}' do
  78. is_expected.to eq({})
  79. end
  80. end
  81. end
  82. describe '#follow!' do
  83. it 'creates and returns Follow' do
  84. expect do
  85. expect(account.follow!(target_account)).to be_kind_of Follow
  86. end.to change { account.following.count }.by 1
  87. end
  88. end
  89. describe '#block' do
  90. it 'creates and returns Block' do
  91. expect do
  92. expect(account.block!(target_account)).to be_kind_of Block
  93. end.to change { account.block_relationships.count }.by 1
  94. end
  95. end
  96. describe '#mute!' do
  97. subject { account.mute!(target_account, notifications: arg_notifications) }
  98. context 'Mute does not exist yet' do
  99. context 'arg :notifications is nil' do
  100. let(:arg_notifications) { nil }
  101. it 'creates Mute, and returns Mute' do
  102. expect do
  103. expect(subject).to be_kind_of Mute
  104. end.to change { account.mute_relationships.count }.by 1
  105. end
  106. end
  107. context 'arg :notifications is false' do
  108. let(:arg_notifications) { false }
  109. it 'creates Mute, and returns Mute' do
  110. expect do
  111. expect(subject).to be_kind_of Mute
  112. end.to change { account.mute_relationships.count }.by 1
  113. end
  114. end
  115. context 'arg :notifications is true' do
  116. let(:arg_notifications) { true }
  117. it 'creates Mute, and returns Mute' do
  118. expect do
  119. expect(subject).to be_kind_of Mute
  120. end.to change { account.mute_relationships.count }.by 1
  121. end
  122. end
  123. end
  124. context 'Mute already exists' do
  125. before do
  126. account.mute_relationships << mute
  127. end
  128. let(:mute) do
  129. Fabricate(:mute,
  130. account: account,
  131. target_account: target_account,
  132. hide_notifications: hide_notifications)
  133. end
  134. context 'mute.hide_notifications is true' do
  135. let(:hide_notifications) { true }
  136. context 'arg :notifications is nil' do
  137. let(:arg_notifications) { nil }
  138. it 'returns Mute without updating mute.hide_notifications' do
  139. expect do
  140. expect(subject).to be_kind_of Mute
  141. end.not_to change { mute.reload.hide_notifications? }.from(true)
  142. end
  143. end
  144. context 'arg :notifications is false' do
  145. let(:arg_notifications) { false }
  146. it 'returns Mute, and updates mute.hide_notifications false' do
  147. expect do
  148. expect(subject).to be_kind_of Mute
  149. end.to change { mute.reload.hide_notifications? }.from(true).to(false)
  150. end
  151. end
  152. context 'arg :notifications is true' do
  153. let(:arg_notifications) { true }
  154. it 'returns Mute without updating mute.hide_notifications' do
  155. expect do
  156. expect(subject).to be_kind_of Mute
  157. end.not_to change { mute.reload.hide_notifications? }.from(true)
  158. end
  159. end
  160. end
  161. context 'mute.hide_notifications is false' do
  162. let(:hide_notifications) { false }
  163. context 'arg :notifications is nil' do
  164. let(:arg_notifications) { nil }
  165. it 'returns Mute, and updates mute.hide_notifications true' do
  166. expect do
  167. expect(subject).to be_kind_of Mute
  168. end.to change { mute.reload.hide_notifications? }.from(false).to(true)
  169. end
  170. end
  171. context 'arg :notifications is false' do
  172. let(:arg_notifications) { false }
  173. it 'returns Mute without updating mute.hide_notifications' do
  174. expect do
  175. expect(subject).to be_kind_of Mute
  176. end.not_to change { mute.reload.hide_notifications? }.from(false)
  177. end
  178. end
  179. context 'arg :notifications is true' do
  180. let(:arg_notifications) { true }
  181. it 'returns Mute, and updates mute.hide_notifications true' do
  182. expect do
  183. expect(subject).to be_kind_of Mute
  184. end.to change { mute.reload.hide_notifications? }.from(false).to(true)
  185. end
  186. end
  187. end
  188. end
  189. end
  190. describe '#mute_conversation!' do
  191. let(:conversation) { Fabricate(:conversation) }
  192. subject { account.mute_conversation!(conversation) }
  193. it 'creates and returns ConversationMute' do
  194. expect do
  195. is_expected.to be_kind_of ConversationMute
  196. end.to change { account.conversation_mutes.count }.by 1
  197. end
  198. end
  199. describe '#block_domain!' do
  200. let(:domain_block) { Fabricate(:domain_block) }
  201. subject { account.block_domain!(domain_block) }
  202. it 'creates and returns AccountDomainBlock' do
  203. expect do
  204. is_expected.to be_kind_of AccountDomainBlock
  205. end.to change { account.domain_blocks.count }.by 1
  206. end
  207. end
  208. describe '#unfollow!' do
  209. subject { account.unfollow!(target_account) }
  210. context 'following target_account' do
  211. it 'returns destroyed Follow' do
  212. account.active_relationships.create(target_account: target_account)
  213. is_expected.to be_kind_of Follow
  214. expect(subject).to be_destroyed
  215. end
  216. end
  217. context 'not following target_account' do
  218. it 'returns nil' do
  219. is_expected.to be_nil
  220. end
  221. end
  222. end
  223. describe '#unblock!' do
  224. subject { account.unblock!(target_account) }
  225. context 'blocking target_account' do
  226. it 'returns destroyed Block' do
  227. account.block_relationships.create(target_account: target_account)
  228. is_expected.to be_kind_of Block
  229. expect(subject).to be_destroyed
  230. end
  231. end
  232. context 'not blocking target_account' do
  233. it 'returns nil' do
  234. is_expected.to be_nil
  235. end
  236. end
  237. end
  238. describe '#unmute!' do
  239. subject { account.unmute!(target_account) }
  240. context 'muting target_account' do
  241. it 'returns destroyed Mute' do
  242. account.mute_relationships.create(target_account: target_account)
  243. is_expected.to be_kind_of Mute
  244. expect(subject).to be_destroyed
  245. end
  246. end
  247. context 'not muting target_account' do
  248. it 'returns nil' do
  249. is_expected.to be_nil
  250. end
  251. end
  252. end
  253. describe '#unmute_conversation!' do
  254. let(:conversation) { Fabricate(:conversation) }
  255. subject { account.unmute_conversation!(conversation) }
  256. context 'muting the conversation' do
  257. it 'returns destroyed ConversationMute' do
  258. account.conversation_mutes.create(conversation: conversation)
  259. is_expected.to be_kind_of ConversationMute
  260. expect(subject).to be_destroyed
  261. end
  262. end
  263. context 'not muting the conversation' do
  264. it 'returns nil' do
  265. is_expected.to be nil
  266. end
  267. end
  268. end
  269. describe '#unblock_domain!' do
  270. let(:domain) { 'example.com' }
  271. subject { account.unblock_domain!(domain) }
  272. context 'blocking the domain' do
  273. it 'returns destroyed AccountDomainBlock' do
  274. account_domain_block = Fabricate(:account_domain_block, domain: domain)
  275. account.domain_blocks << account_domain_block
  276. is_expected.to be_kind_of AccountDomainBlock
  277. expect(subject).to be_destroyed
  278. end
  279. end
  280. context 'unblocking the domain' do
  281. it 'returns nil' do
  282. is_expected.to be_nil
  283. end
  284. end
  285. end
  286. describe '#following?' do
  287. subject { account.following?(target_account) }
  288. context 'following target_account' do
  289. it 'returns true' do
  290. account.active_relationships.create(target_account: target_account)
  291. is_expected.to be true
  292. end
  293. end
  294. context 'not following target_account' do
  295. it 'returns false' do
  296. is_expected.to be false
  297. end
  298. end
  299. end
  300. describe '#blocking?' do
  301. subject { account.blocking?(target_account) }
  302. context 'blocking target_account' do
  303. it 'returns true' do
  304. account.block_relationships.create(target_account: target_account)
  305. is_expected.to be true
  306. end
  307. end
  308. context 'not blocking target_account' do
  309. it 'returns false' do
  310. is_expected.to be false
  311. end
  312. end
  313. end
  314. describe '#domain_blocking?' do
  315. let(:domain) { 'example.com' }
  316. subject { account.domain_blocking?(domain) }
  317. context 'blocking the domain' do
  318. it' returns true' do
  319. account_domain_block = Fabricate(:account_domain_block, domain: domain)
  320. account.domain_blocks << account_domain_block
  321. is_expected.to be true
  322. end
  323. end
  324. context 'not blocking the domain' do
  325. it 'returns false' do
  326. is_expected.to be false
  327. end
  328. end
  329. end
  330. describe '#muting?' do
  331. subject { account.muting?(target_account) }
  332. context 'muting target_account' do
  333. it 'returns true' do
  334. mute = Fabricate(:mute, account: account, target_account: target_account)
  335. account.mute_relationships << mute
  336. is_expected.to be true
  337. end
  338. end
  339. context 'not muting target_account' do
  340. it 'returns false' do
  341. is_expected.to be false
  342. end
  343. end
  344. end
  345. describe '#muting_conversation?' do
  346. let(:conversation) { Fabricate(:conversation) }
  347. subject { account.muting_conversation?(conversation) }
  348. context 'muting the conversation' do
  349. it 'returns true' do
  350. account.conversation_mutes.create(conversation: conversation)
  351. is_expected.to be true
  352. end
  353. end
  354. context 'not muting the conversation' do
  355. it 'returns false' do
  356. is_expected.to be false
  357. end
  358. end
  359. end
  360. describe '#muting_notifications?' do
  361. before do
  362. mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
  363. account.mute_relationships << mute
  364. end
  365. subject { account.muting_notifications?(target_account) }
  366. context 'muting notifications of target_account' do
  367. let(:hide) { true }
  368. it 'returns true' do
  369. is_expected.to be true
  370. end
  371. end
  372. context 'not muting notifications of target_account' do
  373. let(:hide) { false }
  374. it 'returns false' do
  375. is_expected.to be false
  376. end
  377. end
  378. end
  379. describe '#requested?' do
  380. subject { account.requested?(target_account) }
  381. context 'requested by target_account' do
  382. it 'returns true' do
  383. Fabricate(:follow_request, account: account, target_account: target_account)
  384. is_expected.to be true
  385. end
  386. end
  387. context 'not requested by target_account' do
  388. it 'returns false' do
  389. is_expected.to be false
  390. end
  391. end
  392. end
  393. describe '#favourited?' do
  394. let(:status) { Fabricate(:status, account: account, favourites: favourites) }
  395. subject { account.favourited?(status) }
  396. context 'favorited' do
  397. let(:favourites) { [Fabricate(:favourite, account: account)] }
  398. it 'returns true' do
  399. is_expected.to be true
  400. end
  401. end
  402. context 'not favorited' do
  403. let(:favourites) { [] }
  404. it 'returns false' do
  405. is_expected.to be false
  406. end
  407. end
  408. end
  409. describe '#reblogged?' do
  410. let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
  411. subject { account.reblogged?(status) }
  412. context 'reblogged' do
  413. let(:reblogs) { [Fabricate(:status, account: account)] }
  414. it 'returns true' do
  415. is_expected.to be true
  416. end
  417. end
  418. context 'not reblogged' do
  419. let(:reblogs) { [] }
  420. it 'returns false' do
  421. is_expected.to be false
  422. end
  423. end
  424. end
  425. describe '#pinned?' do
  426. let(:status) { Fabricate(:status, account: account) }
  427. subject { account.pinned?(status) }
  428. context 'pinned' do
  429. it 'returns true' do
  430. Fabricate(:status_pin, account: account, status: status)
  431. is_expected.to be true
  432. end
  433. end
  434. context 'not pinned' do
  435. it 'returns false' do
  436. is_expected.to be false
  437. end
  438. end
  439. end
  440. describe 'muting an account' do
  441. let(:me) { Fabricate(:account, username: 'Me') }
  442. let(:you) { Fabricate(:account, username: 'You') }
  443. context 'with the notifications option unspecified' do
  444. before do
  445. me.mute!(you)
  446. end
  447. it 'defaults to muting notifications' do
  448. expect(me.muting_notifications?(you)).to be true
  449. end
  450. end
  451. context 'with the notifications option set to false' do
  452. before do
  453. me.mute!(you, notifications: false)
  454. end
  455. it 'does not mute notifications' do
  456. expect(me.muting_notifications?(you)).to be false
  457. end
  458. end
  459. context 'with the notifications option set to true' do
  460. before do
  461. me.mute!(you, notifications: true)
  462. end
  463. it 'does mute notifications' do
  464. expect(me.muting_notifications?(you)).to be true
  465. end
  466. end
  467. end
  468. describe 'ignoring reblogs from an account' do
  469. before do
  470. @me = Fabricate(:account, username: 'Me')
  471. @you = Fabricate(:account, username: 'You')
  472. end
  473. context 'with the reblogs option unspecified' do
  474. before do
  475. @me.follow!(@you)
  476. end
  477. it 'defaults to showing reblogs' do
  478. expect(@me.muting_reblogs?(@you)).to be(false)
  479. end
  480. end
  481. context 'with the reblogs option set to false' do
  482. before do
  483. @me.follow!(@you, reblogs: false)
  484. end
  485. it 'does mute reblogs' do
  486. expect(@me.muting_reblogs?(@you)).to be(true)
  487. end
  488. end
  489. context 'with the reblogs option set to true' do
  490. before do
  491. @me.follow!(@you, reblogs: true)
  492. end
  493. it 'does not mute reblogs' do
  494. expect(@me.muting_reblogs?(@you)).to be(false)
  495. end
  496. end
  497. end
  498. describe 'ignoring reblogs from an account' do
  499. before do
  500. @me = Fabricate(:account, username: 'Me')
  501. @you = Fabricate(:account, username: 'You')
  502. end
  503. context 'with the reblogs option unspecified' do
  504. before do
  505. @me.follow!(@you)
  506. end
  507. it 'defaults to showing reblogs' do
  508. expect(@me.muting_reblogs?(@you)).to be(false)
  509. end
  510. end
  511. context 'with the reblogs option set to false' do
  512. before do
  513. @me.follow!(@you, reblogs: false)
  514. end
  515. it 'does mute reblogs' do
  516. expect(@me.muting_reblogs?(@you)).to be(true)
  517. end
  518. end
  519. context 'with the reblogs option set to true' do
  520. before do
  521. @me.follow!(@you, reblogs: true)
  522. end
  523. it 'does not mute reblogs' do
  524. expect(@me.muting_reblogs?(@you)).to be(false)
  525. end
  526. end
  527. end
  528. end