The code powering m.abunchtell.com https://m.abunchtell.com
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

61 wiersze
2.0 KiB

  1. require 'rails_helper'
  2. describe HashtagQueryService, type: :service do
  3. describe '.call' do
  4. let(:account) { Fabricate(:account) }
  5. let(:tag1) { Fabricate(:tag) }
  6. let(:tag2) { Fabricate(:tag) }
  7. let!(:status1) { Fabricate(:status, tags: [tag1]) }
  8. let!(:status2) { Fabricate(:status, tags: [tag2]) }
  9. let!(:both) { Fabricate(:status, tags: [tag1, tag2]) }
  10. it 'can add tags in "any" mode' do
  11. results = subject.call(tag1, { any: [tag2.name] })
  12. expect(results).to include status1
  13. expect(results).to include status2
  14. expect(results).to include both
  15. end
  16. it 'can remove tags in "all" mode' do
  17. results = subject.call(tag1, { all: [tag2.name] })
  18. expect(results).to_not include status1
  19. expect(results).to_not include status2
  20. expect(results).to include both
  21. end
  22. it 'can remove tags in "none" mode' do
  23. results = subject.call(tag1, { none: [tag2.name] })
  24. expect(results).to include status1
  25. expect(results).to_not include status2
  26. expect(results).to_not include both
  27. end
  28. it 'ignores an invalid mode' do
  29. results = subject.call(tag1, { wark: [tag2.name] })
  30. expect(results).to include status1
  31. expect(results).to_not include status2
  32. expect(results).to include both
  33. end
  34. it 'handles being passed non existant tag names' do
  35. results = subject.call(tag1, { any: ['wark'] })
  36. expect(results).to include status1
  37. expect(results).to_not include status2
  38. expect(results).to include both
  39. end
  40. it 'can restrict to an account' do
  41. BlockService.new.call(account, status1.account)
  42. results = subject.call(tag1, { none: [tag2.name] }, account)
  43. expect(results).to_not include status1
  44. end
  45. it 'can restrict to local' do
  46. status1.account.update(domain: 'example.com')
  47. status1.update(local: false, uri: 'example.com/toot')
  48. results = subject.call(tag1, { any: [tag2.name] }, nil, true)
  49. expect(results).to_not include status1
  50. end
  51. end
  52. end