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.

667 lines
18 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. context 'Mute does not exist yet' do
  98. context 'arg :notifications is nil' do
  99. let(:arg_notifications) { nil }
  100. it 'creates Mute, and returns nil' do
  101. expect do
  102. expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
  103. end.to change { account.mute_relationships.count }.by 1
  104. end
  105. end
  106. context 'arg :notifications is false' do
  107. let(:arg_notifications) { false }
  108. it 'creates Mute, and returns nil' do
  109. expect do
  110. expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
  111. end.to change { account.mute_relationships.count }.by 1
  112. end
  113. end
  114. context 'arg :notifications is true' do
  115. let(:arg_notifications) { true }
  116. it 'creates Mute, and returns nil' do
  117. expect do
  118. expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
  119. end.to change { account.mute_relationships.count }.by 1
  120. end
  121. end
  122. end
  123. context 'Mute already exists' do
  124. before do
  125. account.mute_relationships << mute
  126. end
  127. let(:mute) do
  128. Fabricate(:mute,
  129. account: account,
  130. target_account: target_account,
  131. hide_notifications: hide_notifications)
  132. end
  133. context 'mute.hide_notifications is true' do
  134. let(:hide_notifications) { true }
  135. context 'arg :notifications is nil' do
  136. let(:arg_notifications) { nil }
  137. it 'returns nil without updating mute.hide_notifications' do
  138. expect do
  139. expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
  140. mute = account.mute_relationships.find_by(target_account: target_account)
  141. expect(mute.hide_notifications?).to be true
  142. end
  143. end
  144. end
  145. context 'arg :notifications is false' do
  146. let(:arg_notifications) { false }
  147. it 'returns true, and updates mute.hide_notifications false' do
  148. expect do
  149. expect(account.mute!(target_account, notifications: arg_notifications)).to be true
  150. mute = account.mute_relationships.find_by(target_account: target_account)
  151. expect(mute.hide_notifications?).to be false
  152. end
  153. end
  154. end
  155. context 'arg :notifications is true' do
  156. let(:arg_notifications) { true }
  157. it 'returns nil without updating mute.hide_notifications' do
  158. expect do
  159. expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
  160. mute = account.mute_relationships.find_by(target_account: target_account)
  161. expect(mute.hide_notifications?).to be true
  162. end
  163. end
  164. end
  165. end
  166. context 'mute.hide_notifications is false' do
  167. let(:hide_notifications) { false }
  168. context 'arg :notifications is nil' do
  169. let(:arg_notifications) { nil }
  170. it 'returns true, and updates mute.hide_notifications true' do
  171. expect do
  172. expect(account.mute!(target_account, notifications: arg_notifications)).to be true
  173. mute = account.mute_relationships.find_by(target_account: target_account)
  174. expect(mute.hide_notifications?).to be true
  175. end
  176. end
  177. end
  178. context 'arg :notifications is false' do
  179. let(:arg_notifications) { false }
  180. it 'returns nil without updating mute.hide_notifications' do
  181. expect do
  182. expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
  183. mute = account.mute_relationships.find_by(target_account: target_account)
  184. expect(mute.hide_notifications?).to be false
  185. end
  186. end
  187. end
  188. context 'arg :notifications is true' do
  189. let(:arg_notifications) { true }
  190. it 'returns true, and updates mute.hide_notifications true' do
  191. expect do
  192. expect(account.mute!(target_account, notifications: arg_notifications)).to be true
  193. mute = account.mute_relationships.find_by(target_account: target_account)
  194. expect(mute.hide_notifications?).to be true
  195. end
  196. end
  197. end
  198. end
  199. end
  200. end
  201. describe '#mute_conversation!' do
  202. let(:conversation) { Fabricate(:conversation) }
  203. subject { account.mute_conversation!(conversation) }
  204. it 'creates and returns ConversationMute' do
  205. expect do
  206. is_expected.to be_kind_of ConversationMute
  207. end.to change { account.conversation_mutes.count }.by 1
  208. end
  209. end
  210. describe '#block_domain!' do
  211. let(:domain_block) { Fabricate(:domain_block) }
  212. subject { account.block_domain!(domain_block) }
  213. it 'creates and returns AccountDomainBlock' do
  214. expect do
  215. is_expected.to be_kind_of AccountDomainBlock
  216. end.to change { account.domain_blocks.count }.by 1
  217. end
  218. end
  219. describe '#unfollow!' do
  220. subject { account.unfollow!(target_account) }
  221. context 'following target_account' do
  222. it 'returns destroyed Follow' do
  223. account.active_relationships.create(target_account: target_account)
  224. is_expected.to be_kind_of Follow
  225. expect(subject).to be_destroyed
  226. end
  227. end
  228. context 'not following target_account' do
  229. it 'returns nil' do
  230. is_expected.to be_nil
  231. end
  232. end
  233. end
  234. describe '#unblock!' do
  235. subject { account.unblock!(target_account) }
  236. context 'blocking target_account' do
  237. it 'returns destroyed Block' do
  238. account.block_relationships.create(target_account: target_account)
  239. is_expected.to be_kind_of Block
  240. expect(subject).to be_destroyed
  241. end
  242. end
  243. context 'not blocking target_account' do
  244. it 'returns nil' do
  245. is_expected.to be_nil
  246. end
  247. end
  248. end
  249. describe '#unmute!' do
  250. subject { account.unmute!(target_account) }
  251. context 'muting target_account' do
  252. it 'returns destroyed Mute' do
  253. account.mute_relationships.create(target_account: target_account)
  254. is_expected.to be_kind_of Mute
  255. expect(subject).to be_destroyed
  256. end
  257. end
  258. context 'not muting target_account' do
  259. it 'returns nil' do
  260. is_expected.to be_nil
  261. end
  262. end
  263. end
  264. describe '#unmute_conversation!' do
  265. let(:conversation) { Fabricate(:conversation) }
  266. subject { account.unmute_conversation!(conversation) }
  267. context 'muting the conversation' do
  268. it 'returns destroyed ConversationMute' do
  269. account.conversation_mutes.create(conversation: conversation)
  270. is_expected.to be_kind_of ConversationMute
  271. expect(subject).to be_destroyed
  272. end
  273. end
  274. context 'not muting the conversation' do
  275. it 'returns nil' do
  276. is_expected.to be nil
  277. end
  278. end
  279. end
  280. describe '#unblock_domain!' do
  281. let(:domain) { 'example.com' }
  282. subject { account.unblock_domain!(domain) }
  283. context 'blocking the domain' do
  284. it 'returns destroyed AccountDomainBlock' do
  285. account_domain_block = Fabricate(:account_domain_block, domain: domain)
  286. account.domain_blocks << account_domain_block
  287. is_expected.to be_kind_of AccountDomainBlock
  288. expect(subject).to be_destroyed
  289. end
  290. end
  291. context 'unblocking the domain' do
  292. it 'returns nil' do
  293. is_expected.to be_nil
  294. end
  295. end
  296. end
  297. describe '#following?' do
  298. subject { account.following?(target_account) }
  299. context 'following target_account' do
  300. it 'returns true' do
  301. account.active_relationships.create(target_account: target_account)
  302. is_expected.to be true
  303. end
  304. end
  305. context 'not following target_account' do
  306. it 'returns false' do
  307. is_expected.to be false
  308. end
  309. end
  310. end
  311. describe '#blocking?' do
  312. subject { account.blocking?(target_account) }
  313. context 'blocking target_account' do
  314. it 'returns true' do
  315. account.block_relationships.create(target_account: target_account)
  316. is_expected.to be true
  317. end
  318. end
  319. context 'not blocking target_account' do
  320. it 'returns false' do
  321. is_expected.to be false
  322. end
  323. end
  324. end
  325. describe '#domain_blocking?' do
  326. let(:domain) { 'example.com' }
  327. subject { account.domain_blocking?(domain) }
  328. context 'blocking the domain' do
  329. it' returns true' do
  330. account_domain_block = Fabricate(:account_domain_block, domain: domain)
  331. account.domain_blocks << account_domain_block
  332. is_expected.to be true
  333. end
  334. end
  335. context 'not blocking the domain' do
  336. it 'returns false' do
  337. is_expected.to be false
  338. end
  339. end
  340. end
  341. describe '#muting?' do
  342. subject { account.muting?(target_account) }
  343. context 'muting target_account' do
  344. it 'returns true' do
  345. mute = Fabricate(:mute, account: account, target_account: target_account)
  346. account.mute_relationships << mute
  347. is_expected.to be true
  348. end
  349. end
  350. context 'not muting target_account' do
  351. it 'returns false' do
  352. is_expected.to be false
  353. end
  354. end
  355. end
  356. describe '#muting_conversation?' do
  357. let(:conversation) { Fabricate(:conversation) }
  358. subject { account.muting_conversation?(conversation) }
  359. context 'muting the conversation' do
  360. it 'returns true' do
  361. account.conversation_mutes.create(conversation: conversation)
  362. is_expected.to be true
  363. end
  364. end
  365. context 'not muting the conversation' do
  366. it 'returns false' do
  367. is_expected.to be false
  368. end
  369. end
  370. end
  371. describe '#muting_notifications?' do
  372. before do
  373. mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
  374. account.mute_relationships << mute
  375. end
  376. subject { account.muting_notifications?(target_account) }
  377. context 'muting notifications of target_account' do
  378. let(:hide) { true }
  379. it 'returns true' do
  380. is_expected.to be true
  381. end
  382. end
  383. context 'not muting notifications of target_account' do
  384. let(:hide) { false }
  385. it 'returns false' do
  386. is_expected.to be false
  387. end
  388. end
  389. end
  390. describe '#requested?' do
  391. subject { account.requested?(target_account) }
  392. context 'requested by target_account' do
  393. it 'returns true' do
  394. Fabricate(:follow_request, account: account, target_account: target_account)
  395. is_expected.to be true
  396. end
  397. end
  398. context 'not requested by target_account' do
  399. it 'returns false' do
  400. is_expected.to be false
  401. end
  402. end
  403. end
  404. describe '#favourited?' do
  405. let(:status) { Fabricate(:status, account: account, favourites: favourites) }
  406. subject { account.favourited?(status) }
  407. context 'favorited' do
  408. let(:favourites) { [Fabricate(:favourite, account: account)] }
  409. it 'returns true' do
  410. is_expected.to be true
  411. end
  412. end
  413. context 'not favorited' do
  414. let(:favourites) { [] }
  415. it 'returns false' do
  416. is_expected.to be false
  417. end
  418. end
  419. end
  420. describe '#reblogged?' do
  421. let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
  422. subject { account.reblogged?(status) }
  423. context 'reblogged' do
  424. let(:reblogs) { [Fabricate(:status, account: account)] }
  425. it 'returns true' do
  426. is_expected.to be true
  427. end
  428. end
  429. context 'not reblogged' do
  430. let(:reblogs) { [] }
  431. it 'returns false' do
  432. is_expected.to be false
  433. end
  434. end
  435. end
  436. describe '#pinned?' do
  437. let(:status) { Fabricate(:status, account: account) }
  438. subject { account.pinned?(status) }
  439. context 'pinned' do
  440. it 'returns true' do
  441. Fabricate(:status_pin, account: account, status: status)
  442. is_expected.to be true
  443. end
  444. end
  445. context 'not pinned' do
  446. it 'returns false' do
  447. is_expected.to be false
  448. end
  449. end
  450. end
  451. describe 'muting an account' do
  452. let(:me) { Fabricate(:account, username: 'Me') }
  453. let(:you) { Fabricate(:account, username: 'You') }
  454. context 'with the notifications option unspecified' do
  455. before do
  456. me.mute!(you)
  457. end
  458. it 'defaults to muting notifications' do
  459. expect(me.muting_notifications?(you)).to be true
  460. end
  461. end
  462. context 'with the notifications option set to false' do
  463. before do
  464. me.mute!(you, notifications: false)
  465. end
  466. it 'does not mute notifications' do
  467. expect(me.muting_notifications?(you)).to be false
  468. end
  469. end
  470. context 'with the notifications option set to true' do
  471. before do
  472. me.mute!(you, notifications: true)
  473. end
  474. it 'does mute notifications' do
  475. expect(me.muting_notifications?(you)).to be true
  476. end
  477. end
  478. end
  479. describe 'ignoring reblogs from an account' do
  480. before do
  481. @me = Fabricate(:account, username: 'Me')
  482. @you = Fabricate(:account, username: 'You')
  483. end
  484. context 'with the reblogs option unspecified' do
  485. before do
  486. @me.follow!(@you)
  487. end
  488. it 'defaults to showing reblogs' do
  489. expect(@me.muting_reblogs?(@you)).to be(false)
  490. end
  491. end
  492. context 'with the reblogs option set to false' do
  493. before do
  494. @me.follow!(@you, reblogs: false)
  495. end
  496. it 'does mute reblogs' do
  497. expect(@me.muting_reblogs?(@you)).to be(true)
  498. end
  499. end
  500. context 'with the reblogs option set to true' do
  501. before do
  502. @me.follow!(@you, reblogs: true)
  503. end
  504. it 'does not mute reblogs' do
  505. expect(@me.muting_reblogs?(@you)).to be(false)
  506. end
  507. end
  508. end
  509. describe 'ignoring reblogs from an account' do
  510. before do
  511. @me = Fabricate(:account, username: 'Me')
  512. @you = Fabricate(:account, username: 'You')
  513. end
  514. context 'with the reblogs option unspecified' do
  515. before do
  516. @me.follow!(@you)
  517. end
  518. it 'defaults to showing reblogs' do
  519. expect(@me.muting_reblogs?(@you)).to be(false)
  520. end
  521. end
  522. context 'with the reblogs option set to false' do
  523. before do
  524. @me.follow!(@you, reblogs: false)
  525. end
  526. it 'does mute reblogs' do
  527. expect(@me.muting_reblogs?(@you)).to be(true)
  528. end
  529. end
  530. context 'with the reblogs option set to true' do
  531. before do
  532. @me.follow!(@you, reblogs: true)
  533. end
  534. it 'does not mute reblogs' do
  535. expect(@me.muting_reblogs?(@you)).to be(false)
  536. end
  537. end
  538. end
  539. end