闭社主体 forked from https://github.com/tootsuite/mastodon
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.

31 lines
859 B

  1. require 'rails_helper'
  2. RSpec.describe ApplicationHelper, type: :helper do
  3. let(:local_domain) { 'local.tld' }
  4. before do
  5. Rails.configuration.x.local_domain = local_domain
  6. end
  7. describe '#unique_tag' do
  8. it 'returns a string' do
  9. expect(helper.unique_tag(Time.now, 12, 'Status')).to be_a String
  10. end
  11. end
  12. describe '#unique_tag_to_local_id' do
  13. it 'returns the ID part' do
  14. expect(helper.unique_tag_to_local_id("tag:#{local_domain};objectId=12:objectType=Status", 'Status')).to eql '12'
  15. end
  16. end
  17. describe '#local_id?' do
  18. it 'returns true for a local ID' do
  19. expect(helper.local_id?("tag:#{local_domain};objectId=12:objectType=Status")).to be true
  20. end
  21. it 'returns false for a foreign ID' do
  22. expect(helper.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
  23. end
  24. end
  25. end