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.

770 lines
24 KiB

8 years ago
Account domain blocks (#2381) * Add <ostatus:conversation /> tag to Atom input/output Only uses ref attribute (not href) because href would be the alternate link that's always included also. Creates new conversation for every non-reply status. Carries over conversation for every reply. Keeps remote URIs verbatim, generates local URIs on the fly like the rest of them. * Conversation muting - prevents notifications that reference a conversation (including replies, favourites, reblogs) from being created. API endpoints /api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute Currently no way to tell when a status/conversation is muted, so the web UI only has a "disable notifications" button, doesn't work as a toggle * Display "Dismiss notifications" on all statuses in notifications column, not just own * Add "muted" as a boolean attribute on statuses JSON For now always false on contained reblogs, since it's only relevant for statuses returned from the notifications endpoint, which are not nested Remove "Disable notifications" from detailed status view, since it's only relevant in the notifications column * Up max class length * Remove pending test for conversation mute * Add tests, clean up * Rename to "mute conversation" and "unmute conversation" * Raise validation error when trying to mute/unmute status without conversation * Adding account domain blocks that filter notifications and public timelines * Add tests for domain blocks in notifications, public timelines Filter reblogs of blocked domains from home * Add API for listing and creating account domain blocks * API for creating/deleting domain blocks, tests for Status#ancestors and Status#descendants, filter domain blocks from them * Filter domains in streaming API * Update account_domain_block_spec.rb
7 years ago
8 years ago
  1. require 'rails_helper'
  2. RSpec.describe Status, type: :model do
  3. let(:alice) { Fabricate(:account, username: 'alice') }
  4. let(:bob) { Fabricate(:account, username: 'bob') }
  5. let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!') }
  6. subject { Fabricate(:status, account: alice) }
  7. describe '#local?' do
  8. it 'returns true when no remote URI is set' do
  9. expect(subject.local?).to be true
  10. end
  11. it 'returns false if a remote URI is set' do
  12. alice.update(domain: 'example.com')
  13. subject.save
  14. expect(subject.local?).to be false
  15. end
  16. it 'returns true if a URI is set and `local` is true' do
  17. subject.update(uri: 'example.com', local: true)
  18. expect(subject.local?).to be true
  19. end
  20. end
  21. describe '#reblog?' do
  22. it 'returns true when the status reblogs another status' do
  23. subject.reblog = other
  24. expect(subject.reblog?).to be true
  25. end
  26. it 'returns false if the status is self-contained' do
  27. expect(subject.reblog?).to be false
  28. end
  29. end
  30. describe '#reply?' do
  31. it 'returns true if the status references another' do
  32. subject.thread = other
  33. expect(subject.reply?).to be true
  34. end
  35. it 'returns false if the status is self-contained' do
  36. expect(subject.reply?).to be false
  37. end
  38. end
  39. describe '#verb' do
  40. context 'if destroyed?' do
  41. it 'returns :delete' do
  42. subject.destroy!
  43. expect(subject.verb).to be :delete
  44. end
  45. end
  46. context 'unless destroyed?' do
  47. context 'if reblog?' do
  48. it 'returns :share' do
  49. subject.reblog = other
  50. expect(subject.verb).to be :share
  51. end
  52. end
  53. context 'unless reblog?' do
  54. it 'returns :post' do
  55. subject.reblog = nil
  56. expect(subject.verb).to be :post
  57. end
  58. end
  59. end
  60. end
  61. describe '#object_type' do
  62. it 'is note when the status is self-contained' do
  63. expect(subject.object_type).to be :note
  64. end
  65. it 'is comment when the status replies to another' do
  66. subject.thread = other
  67. expect(subject.object_type).to be :comment
  68. end
  69. end
  70. describe '#title' do
  71. # rubocop:disable Style/InterpolationCheck
  72. let(:account) { subject.account }
  73. context 'if destroyed?' do
  74. it 'returns "#{account.acct} deleted status"' do
  75. subject.destroy!
  76. expect(subject.title).to eq "#{account.acct} deleted status"
  77. end
  78. end
  79. context 'unless destroyed?' do
  80. context 'if reblog?' do
  81. it 'returns "#{account.acct} shared a status by #{reblog.account.acct}"' do
  82. reblog = subject.reblog = other
  83. expect(subject.title).to eq "#{account.acct} shared a status by #{reblog.account.acct}"
  84. end
  85. end
  86. context 'unless reblog?' do
  87. it 'returns "New status by #{account.acct}"' do
  88. subject.reblog = nil
  89. expect(subject.title).to eq "New status by #{account.acct}"
  90. end
  91. end
  92. end
  93. end
  94. describe '#hidden?' do
  95. context 'if private_visibility?' do
  96. it 'returns true' do
  97. subject.visibility = :private
  98. expect(subject.hidden?).to be true
  99. end
  100. end
  101. context 'if direct_visibility?' do
  102. it 'returns true' do
  103. subject.visibility = :direct
  104. expect(subject.hidden?).to be true
  105. end
  106. end
  107. context 'if public_visibility?' do
  108. it 'returns false' do
  109. subject.visibility = :public
  110. expect(subject.hidden?).to be false
  111. end
  112. end
  113. context 'if unlisted_visibility?' do
  114. it 'returns false' do
  115. subject.visibility = :unlisted
  116. expect(subject.hidden?).to be false
  117. end
  118. end
  119. end
  120. describe '#content' do
  121. it 'returns the text of the status if it is not a reblog' do
  122. expect(subject.content).to eql subject.text
  123. end
  124. it 'returns the text of the reblogged status' do
  125. subject.reblog = other
  126. expect(subject.content).to eql other.text
  127. end
  128. end
  129. describe '#target' do
  130. it 'returns nil if the status is self-contained' do
  131. expect(subject.target).to be_nil
  132. end
  133. it 'returns nil if the status is a reply' do
  134. subject.thread = other
  135. expect(subject.target).to be_nil
  136. end
  137. it 'returns the reblogged status' do
  138. subject.reblog = other
  139. expect(subject.target).to eq other
  140. end
  141. end
  142. describe '#reblogs_count' do
  143. it 'is the number of reblogs' do
  144. Fabricate(:status, account: bob, reblog: subject)
  145. Fabricate(:status, account: alice, reblog: subject)
  146. expect(subject.reblogs_count).to eq 2
  147. end
  148. it 'is decremented when reblog is removed' do
  149. reblog = Fabricate(:status, account: bob, reblog: subject)
  150. expect(subject.reblogs_count).to eq 1
  151. reblog.destroy
  152. expect(subject.reblogs_count).to eq 0
  153. end
  154. end
  155. describe '#favourites_count' do
  156. it 'is the number of favorites' do
  157. Fabricate(:favourite, account: bob, status: subject)
  158. Fabricate(:favourite, account: alice, status: subject)
  159. expect(subject.favourites_count).to eq 2
  160. end
  161. it 'is decremented when favourite is removed' do
  162. favourite = Fabricate(:favourite, account: bob, status: subject)
  163. expect(subject.favourites_count).to eq 1
  164. favourite.destroy
  165. expect(subject.favourites_count).to eq 0
  166. end
  167. end
  168. describe '#proper' do
  169. it 'is itself for original statuses' do
  170. expect(subject.proper).to eq subject
  171. end
  172. it 'is the source status for reblogs' do
  173. subject.reblog = other
  174. expect(subject.proper).to eq other
  175. end
  176. end
  177. describe 'on create' do
  178. let(:local_account) { Fabricate(:account, username: 'local', domain: nil) }
  179. let(:remote_account) { Fabricate(:account, username: 'remote', domain: 'example.com') }
  180. subject { Status.new }
  181. describe 'on a status that ends with the local-only emoji' do
  182. before do
  183. subject.text = 'A toot ' + subject.local_only_emoji
  184. end
  185. context 'if the status originates from this instance' do
  186. before do
  187. subject.account = local_account
  188. end
  189. it 'is marked local-only' do
  190. subject.save!
  191. expect(subject).to be_local_only
  192. end
  193. end
  194. context 'if the status is remote' do
  195. before do
  196. subject.account = remote_account
  197. end
  198. it 'is not marked local-only' do
  199. subject.save!
  200. expect(subject).to_not be_local_only
  201. end
  202. end
  203. end
  204. end
  205. describe '.mutes_map' do
  206. let(:status) { Fabricate(:status) }
  207. let(:account) { Fabricate(:account) }
  208. subject { Status.mutes_map([status.conversation.id], account) }
  209. it 'returns a hash' do
  210. expect(subject).to be_a Hash
  211. end
  212. it 'contains true value' do
  213. account.mute_conversation!(status.conversation)
  214. expect(subject[status.conversation.id]).to be true
  215. end
  216. end
  217. describe '.favourites_map' do
  218. let(:status) { Fabricate(:status) }
  219. let(:account) { Fabricate(:account) }
  220. subject { Status.favourites_map([status], account) }
  221. it 'returns a hash' do
  222. expect(subject).to be_a Hash
  223. end
  224. it 'contains true value' do
  225. Fabricate(:favourite, status: status, account: account)
  226. expect(subject[status.id]).to be true
  227. end
  228. end
  229. describe '.reblogs_map' do
  230. let(:status) { Fabricate(:status) }
  231. let(:account) { Fabricate(:account) }
  232. subject { Status.reblogs_map([status], account) }
  233. it 'returns a hash' do
  234. expect(subject).to be_a Hash
  235. end
  236. it 'contains true value' do
  237. Fabricate(:status, account: account, reblog: status)
  238. expect(subject[status.id]).to be true
  239. end
  240. end
  241. describe '.in_chosen_languages' do
  242. context 'for accounts with language filters' do
  243. let(:user) { Fabricate(:user, chosen_languages: ['en']) }
  244. it 'does not include statuses in not in chosen languages' do
  245. status = Fabricate(:status, language: 'de')
  246. expect(Status.in_chosen_languages(user.account)).not_to include status
  247. end
  248. it 'includes status with unknown language' do
  249. status = Fabricate(:status, language: nil)
  250. expect(Status.in_chosen_languages(user.account)).to include status
  251. end
  252. end
  253. end
  254. describe '.as_home_timeline' do
  255. let(:account) { Fabricate(:account) }
  256. let(:followed) { Fabricate(:account) }
  257. let(:not_followed) { Fabricate(:account) }
  258. before do
  259. Fabricate(:follow, account: account, target_account: followed)
  260. @self_status = Fabricate(:status, account: account, visibility: :public)
  261. @self_direct_status = Fabricate(:status, account: account, visibility: :direct)
  262. @followed_status = Fabricate(:status, account: followed, visibility: :public)
  263. @followed_direct_status = Fabricate(:status, account: followed, visibility: :direct)
  264. @not_followed_status = Fabricate(:status, account: not_followed, visibility: :public)
  265. @results = Status.as_home_timeline(account)
  266. end
  267. it 'includes statuses from self' do
  268. expect(@results).to include(@self_status)
  269. end
  270. it 'does not include direct statuses from self' do
  271. expect(@results).to_not include(@self_direct_status)
  272. end
  273. it 'includes statuses from followed' do
  274. expect(@results).to include(@followed_status)
  275. end
  276. it 'does not include direct statuses mentioning recipient from followed' do
  277. Fabricate(:mention, account: account, status: @followed_direct_status)
  278. expect(@results).to_not include(@followed_direct_status)
  279. end
  280. it 'does not include direct statuses not mentioning recipient from followed' do
  281. expect(@results).not_to include(@followed_direct_status)
  282. end
  283. it 'does not include statuses from non-followed' do
  284. expect(@results).not_to include(@not_followed_status)
  285. end
  286. end
  287. describe '.as_direct_timeline' do
  288. let(:account) { Fabricate(:account) }
  289. let(:followed) { Fabricate(:account) }
  290. let(:not_followed) { Fabricate(:account) }
  291. before do
  292. Fabricate(:follow, account: account, target_account: followed)
  293. @self_public_status = Fabricate(:status, account: account, visibility: :public)
  294. @self_direct_status = Fabricate(:status, account: account, visibility: :direct)
  295. @followed_public_status = Fabricate(:status, account: followed, visibility: :public)
  296. @followed_direct_status = Fabricate(:status, account: followed, visibility: :direct)
  297. @not_followed_direct_status = Fabricate(:status, account: not_followed, visibility: :direct)
  298. @results = Status.as_direct_timeline(account)
  299. end
  300. it 'does not include public statuses from self' do
  301. expect(@results).to_not include(@self_public_status)
  302. end
  303. it 'includes direct statuses from self' do
  304. expect(@results).to include(@self_direct_status)
  305. end
  306. it 'does not include public statuses from followed' do
  307. expect(@results).to_not include(@followed_public_status)
  308. end
  309. it 'does not include direct statuses not mentioning recipient from followed' do
  310. expect(@results).to_not include(@followed_direct_status)
  311. end
  312. it 'does not include direct statuses not mentioning recipient from non-followed' do
  313. expect(@results).to_not include(@not_followed_direct_status)
  314. end
  315. it 'includes direct statuses mentioning recipient from followed' do
  316. Fabricate(:mention, account: account, status: @followed_direct_status)
  317. results2 = Status.as_direct_timeline(account)
  318. expect(results2).to include(@followed_direct_status)
  319. end
  320. it 'includes direct statuses mentioning recipient from non-followed' do
  321. Fabricate(:mention, account: account, status: @not_followed_direct_status)
  322. results2 = Status.as_direct_timeline(account)
  323. expect(results2).to include(@not_followed_direct_status)
  324. end
  325. end
  326. describe '.as_public_timeline' do
  327. it 'only includes statuses with public visibility' do
  328. public_status = Fabricate(:status, visibility: :public)
  329. private_status = Fabricate(:status, visibility: :private)
  330. results = Status.as_public_timeline
  331. expect(results).to include(public_status)
  332. expect(results).not_to include(private_status)
  333. end
  334. it 'does not include replies' do
  335. status = Fabricate(:status)
  336. reply = Fabricate(:status, in_reply_to_id: status.id)
  337. results = Status.as_public_timeline
  338. expect(results).to include(status)
  339. expect(results).not_to include(reply)
  340. end
  341. it 'does not include boosts' do
  342. status = Fabricate(:status)
  343. boost = Fabricate(:status, reblog_of_id: status.id)
  344. results = Status.as_public_timeline
  345. expect(results).to include(status)
  346. expect(results).not_to include(boost)
  347. end
  348. it 'filters out silenced accounts' do
  349. account = Fabricate(:account)
  350. silenced_account = Fabricate(:account, silenced: true)
  351. status = Fabricate(:status, account: account)
  352. silenced_status = Fabricate(:status, account: silenced_account)
  353. results = Status.as_public_timeline
  354. expect(results).to include(status)
  355. expect(results).not_to include(silenced_status)
  356. end
  357. context 'without local_only option' do
  358. let(:viewer) { nil }
  359. let!(:local_account) { Fabricate(:account, domain: nil) }
  360. let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
  361. let!(:local_status) { Fabricate(:status, account: local_account) }
  362. let!(:remote_status) { Fabricate(:status, account: remote_account) }
  363. subject { Status.as_public_timeline(viewer, false) }
  364. context 'without a viewer' do
  365. let(:viewer) { nil }
  366. it 'includes remote instances statuses' do
  367. expect(subject).to include(remote_status)
  368. end
  369. it 'includes local statuses' do
  370. expect(subject).to include(local_status)
  371. end
  372. end
  373. context 'with a viewer' do
  374. let(:viewer) { Fabricate(:account, username: 'viewer') }
  375. it 'includes remote instances statuses' do
  376. expect(subject).to include(remote_status)
  377. end
  378. it 'includes local statuses' do
  379. expect(subject).to include(local_status)
  380. end
  381. end
  382. end
  383. context 'with a local_only option set' do
  384. let!(:local_account) { Fabricate(:account, domain: nil) }
  385. let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
  386. let!(:local_status) { Fabricate(:status, account: local_account) }
  387. let!(:remote_status) { Fabricate(:status, account: remote_account) }
  388. subject { Status.as_public_timeline(viewer, true) }
  389. context 'without a viewer' do
  390. let(:viewer) { nil }
  391. it 'does not include remote instances statuses' do
  392. expect(subject).to include(local_status)
  393. expect(subject).not_to include(remote_status)
  394. end
  395. end
  396. context 'with a viewer' do
  397. let(:viewer) { Fabricate(:account, username: 'viewer') }
  398. it 'does not include remote instances statuses' do
  399. expect(subject).to include(local_status)
  400. expect(subject).not_to include(remote_status)
  401. end
  402. it 'is not affected by personal domain blocks' do
  403. viewer.block_domain!('test.com')
  404. expect(subject).to include(local_status)
  405. expect(subject).not_to include(remote_status)
  406. end
  407. end
  408. end
  409. describe 'with an account passed in' do
  410. before do
  411. @account = Fabricate(:account)
  412. end
  413. it 'excludes statuses from accounts blocked by the account' do
  414. blocked = Fabricate(:account)
  415. Fabricate(:block, account: @account, target_account: blocked)
  416. blocked_status = Fabricate(:status, account: blocked)
  417. results = Status.as_public_timeline(@account)
  418. expect(results).not_to include(blocked_status)
  419. end
  420. it 'excludes statuses from accounts who have blocked the account' do
  421. blocked = Fabricate(:account)
  422. Fabricate(:block, account: blocked, target_account: @account)
  423. blocked_status = Fabricate(:status, account: blocked)
  424. results = Status.as_public_timeline(@account)
  425. expect(results).not_to include(blocked_status)
  426. end
  427. it 'excludes statuses from accounts muted by the account' do
  428. muted = Fabricate(:account)
  429. Fabricate(:mute, account: @account, target_account: muted)
  430. muted_status = Fabricate(:status, account: muted)
  431. results = Status.as_public_timeline(@account)
  432. expect(results).not_to include(muted_status)
  433. end
  434. it 'excludes statuses from accounts from personally blocked domains' do
  435. blocked = Fabricate(:account, domain: 'example.com')
  436. @account.block_domain!(blocked.domain)
  437. blocked_status = Fabricate(:status, account: blocked)
  438. results = Status.as_public_timeline(@account)
  439. expect(results).not_to include(blocked_status)
  440. end
  441. context 'with language preferences' do
  442. it 'excludes statuses in languages not allowed by the account user' do
  443. user = Fabricate(:user, chosen_languages: [:en, :es])
  444. @account.update(user: user)
  445. en_status = Fabricate(:status, language: 'en')
  446. es_status = Fabricate(:status, language: 'es')
  447. fr_status = Fabricate(:status, language: 'fr')
  448. results = Status.as_public_timeline(@account)
  449. expect(results).to include(en_status)
  450. expect(results).to include(es_status)
  451. expect(results).not_to include(fr_status)
  452. end
  453. it 'includes all languages when user does not have a setting' do
  454. user = Fabricate(:user, chosen_languages: nil)
  455. @account.update(user: user)
  456. en_status = Fabricate(:status, language: 'en')
  457. es_status = Fabricate(:status, language: 'es')
  458. results = Status.as_public_timeline(@account)
  459. expect(results).to include(en_status)
  460. expect(results).to include(es_status)
  461. end
  462. it 'includes all languages when account does not have a user' do
  463. expect(@account.user).to be_nil
  464. en_status = Fabricate(:status, language: 'en')
  465. es_status = Fabricate(:status, language: 'es')
  466. results = Status.as_public_timeline(@account)
  467. expect(results).to include(en_status)
  468. expect(results).to include(es_status)
  469. end
  470. end
  471. context 'where that account is silenced' do
  472. it 'includes statuses from other accounts that are silenced' do
  473. @account.update(silenced: true)
  474. other_silenced_account = Fabricate(:account, silenced: true)
  475. other_status = Fabricate(:status, account: other_silenced_account)
  476. results = Status.as_public_timeline(@account)
  477. expect(results).to include(other_status)
  478. end
  479. end
  480. end
  481. context 'with local-only statuses' do
  482. let(:status) { Fabricate(:status, local_only: true) }
  483. subject { Status.as_public_timeline(viewer) }
  484. context 'without a viewer' do
  485. let(:viewer) { nil }
  486. it 'excludes local-only statuses' do
  487. expect(subject).to_not include(status)
  488. end
  489. end
  490. context 'with a viewer' do
  491. let(:viewer) { Fabricate(:account, username: 'viewer') }
  492. it 'includes local-only statuses' do
  493. expect(subject).to include(status)
  494. end
  495. end
  496. # TODO: What happens if the viewer is remote?
  497. # Can the viewer be remote?
  498. # What prevents the viewer from being remote?
  499. end
  500. end
  501. describe '.as_tag_timeline' do
  502. it 'includes statuses with a tag' do
  503. tag = Fabricate(:tag)
  504. status = Fabricate(:status, tags: [tag])
  505. other = Fabricate(:status)
  506. results = Status.as_tag_timeline(tag)
  507. expect(results).to include(status)
  508. expect(results).not_to include(other)
  509. end
  510. it 'allows replies to be included' do
  511. original = Fabricate(:status)
  512. tag = Fabricate(:tag)
  513. status = Fabricate(:status, tags: [tag], in_reply_to_id: original.id)
  514. results = Status.as_tag_timeline(tag)
  515. expect(results).to include(status)
  516. end
  517. context 'on a local-only status' do
  518. let(:tag) { Fabricate(:tag) }
  519. let(:status) { Fabricate(:status, local_only: true, tags: [tag]) }
  520. context 'without a viewer' do
  521. let(:viewer) { nil }
  522. it 'filters the local-only status out of the result set' do
  523. expect(Status.as_tag_timeline(tag, viewer)).not_to include(status)
  524. end
  525. end
  526. context 'with a viewer' do
  527. let(:viewer) { Fabricate(:account, username: 'viewer', domain: nil) }
  528. it 'keeps the local-only status in the result set' do
  529. expect(Status.as_tag_timeline(tag, viewer)).to include(status)
  530. end
  531. end
  532. end
  533. end
  534. describe '.permitted_for' do
  535. subject { described_class.permitted_for(target_account, account).pluck(:visibility) }
  536. let(:target_account) { alice }
  537. let(:account) { bob }
  538. let!(:public_status) { Fabricate(:status, account: target_account, visibility: 'public') }
  539. let!(:unlisted_status) { Fabricate(:status, account: target_account, visibility: 'unlisted') }
  540. let!(:private_status) { Fabricate(:status, account: target_account, visibility: 'private') }
  541. let!(:direct_status) do
  542. Fabricate(:status, account: target_account, visibility: 'direct').tap do |status|
  543. Fabricate(:mention, status: status, account: account)
  544. end
  545. end
  546. let!(:other_direct_status) do
  547. Fabricate(:status, account: target_account, visibility: 'direct').tap do |status|
  548. Fabricate(:mention, status: status)
  549. end
  550. end
  551. context 'given nil' do
  552. let(:account) { nil }
  553. let(:direct_status) { nil }
  554. it { is_expected.to eq(%w(unlisted public)) }
  555. end
  556. context 'given blocked account' do
  557. before do
  558. target_account.block!(account)
  559. end
  560. it { is_expected.to be_empty }
  561. end
  562. context 'given same account' do
  563. let(:account) { target_account }
  564. it { is_expected.to eq(%w(direct direct private unlisted public)) }
  565. end
  566. context 'given followed account' do
  567. before do
  568. account.follow!(target_account)
  569. end
  570. it { is_expected.to eq(%w(direct private unlisted public)) }
  571. end
  572. context 'given unfollowed account' do
  573. it { is_expected.to eq(%w(direct unlisted public)) }
  574. end
  575. end
  576. describe 'before_validation' do
  577. it 'sets account being replied to correctly over intermediary nodes' do
  578. first_status = Fabricate(:status, account: bob)
  579. intermediary = Fabricate(:status, thread: first_status, account: alice)
  580. final = Fabricate(:status, thread: intermediary, account: alice)
  581. expect(final.in_reply_to_account_id).to eq bob.id
  582. end
  583. it 'creates new conversation for stand-alone status' do
  584. expect(Status.create(account: alice, text: 'First').conversation_id).to_not be_nil
  585. end
  586. it 'keeps conversation of parent node' do
  587. parent = Fabricate(:status, text: 'First')
  588. expect(Status.create(account: alice, thread: parent, text: 'Response').conversation_id).to eq parent.conversation_id
  589. end
  590. it 'sets `local` to true for status by local account' do
  591. expect(Status.create(account: alice, text: 'foo').local).to be true
  592. end
  593. it 'sets `local` to false for status by remote account' do
  594. alice.update(domain: 'example.com')
  595. expect(Status.create(account: alice, text: 'foo').local).to be false
  596. end
  597. end
  598. describe 'validation' do
  599. it 'disallow empty uri for remote status' do
  600. alice.update(domain: 'example.com')
  601. status = Fabricate.build(:status, uri: '', account: alice)
  602. expect(status).to model_have_error_on_field(:uri)
  603. end
  604. end
  605. describe 'after_create' do
  606. it 'saves ActivityPub uri as uri for local status' do
  607. status = Status.create(account: alice, text: 'foo')
  608. status.reload
  609. expect(status.uri).to start_with('https://')
  610. end
  611. end
  612. end