logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

status_pin_spec.rb (2247B)


  1. require 'rails_helper'
  2. RSpec.describe StatusPin, type: :model do
  3. describe 'validations' do
  4. it 'allows pins of own statuses' do
  5. account = Fabricate(:account)
  6. status = Fabricate(:status, account: account)
  7. expect(StatusPin.new(account: account, status: status).save).to be true
  8. end
  9. it 'does not allow pins of statuses by someone else' do
  10. account = Fabricate(:account)
  11. status = Fabricate(:status)
  12. expect(StatusPin.new(account: account, status: status).save).to be false
  13. end
  14. it 'does not allow pins of reblogs' do
  15. account = Fabricate(:account)
  16. status = Fabricate(:status, account: account)
  17. reblog = Fabricate(:status, reblog: status)
  18. expect(StatusPin.new(account: account, status: reblog).save).to be false
  19. end
  20. it 'does not allow pins of private statuses' do
  21. account = Fabricate(:account)
  22. status = Fabricate(:status, account: account, visibility: :private)
  23. expect(StatusPin.new(account: account, status: status).save).to be false
  24. end
  25. it 'does not allow pins of direct statuses' do
  26. account = Fabricate(:account)
  27. status = Fabricate(:status, account: account, visibility: :direct)
  28. expect(StatusPin.new(account: account, status: status).save).to be false
  29. end
  30. max_pins = 5
  31. it 'does not allow pins above the max' do
  32. account = Fabricate(:account)
  33. status = []
  34. (max_pins + 1).times do |i|
  35. status[i] = Fabricate(:status, account: account)
  36. end
  37. max_pins.times do |i|
  38. expect(StatusPin.new(account: account, status: status[i]).save).to be true
  39. end
  40. expect(StatusPin.new(account: account, status: status[max_pins]).save).to be false
  41. end
  42. it 'allows pins above the max for remote accounts' do
  43. account = Fabricate(:account, domain: 'remote', username: 'bob', url: 'https://remote/')
  44. status = []
  45. (max_pins + 1).times do |i|
  46. status[i] = Fabricate(:status, account: account)
  47. end
  48. max_pins.times do |i|
  49. expect(StatusPin.new(account: account, status: status[i]).save).to be true
  50. end
  51. expect(StatusPin.new(account: account, status: status[max_pins]).save).to be true
  52. end
  53. end
  54. end