From 3cc47beb6e1f646baca64fdf56168e2f2e2bc726 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 9 Sep 2016 20:04:34 +0200 Subject: Refactored generation of unique tags, URIs and object URLs into own classes, as well as formatting of content --- spec/helpers/application_helper_spec.rb | 54 -------------------------------- spec/helpers/atom_builder_helper_spec.rb | 12 ++----- 2 files changed, 2 insertions(+), 64 deletions(-) (limited to 'spec/helpers') diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 9f68a504a..c2063c995 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,59 +1,5 @@ require 'rails_helper' RSpec.describe ApplicationHelper, type: :helper do - let(:local_domain) { Rails.configuration.x.local_domain } - describe '#unique_tag' do - it 'returns a string' do - expect(helper.unique_tag(Time.now, 12, 'Status')).to be_a String - end - end - - describe '#unique_tag_to_local_id' do - it 'returns the ID part' do - expect(helper.unique_tag_to_local_id("tag:#{local_domain};objectId=12:objectType=Status", 'Status')).to eql '12' - end - end - - describe '#local_id?' do - it 'returns true for a local ID' do - expect(helper.local_id?("tag:#{local_domain};objectId=12:objectType=Status")).to be true - end - - it 'returns false for a foreign ID' do - expect(helper.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false - end - end - - describe '#linkify' do - let(:alice) { Fabricate(:account, username: 'alice') } - let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', url: 'http://example.com/bob') } - - it 'turns mention of remote user into link' do - status = Fabricate(:status, text: 'Hello @bob@example.com', account: bob) - status.mentions.create(account: bob) - expect(helper.linkify(status)).to match('@bob@example.com') - end - - it 'turns mention of local user into link' do - status = Fabricate(:status, text: 'Hello @alice', account: bob) - status.mentions.create(account: alice) - expect(helper.linkify(status)).to match('@alice') - end - - it 'leaves mention of unresolvable user alone' do - status = Fabricate(:status, text: 'Hello @foo', account: bob) - expect(helper.linkify(status)).to match('Hello @foo') - end - end - - describe '#account_from_mentions' do - let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') } - let(:status) { Fabricate(:status, text: 'Hello @bob@example.com', account: bob) } - let(:mentions) { [Mention.create(status: status, account: bob)] } - - it 'returns account' do - expect(helper.account_from_mentions('bob@example.com', mentions)).to eq bob - end - end end diff --git a/spec/helpers/atom_builder_helper_spec.rb b/spec/helpers/atom_builder_helper_spec.rb index 7366b5b79..7e11a8a77 100644 --- a/spec/helpers/atom_builder_helper_spec.rb +++ b/spec/helpers/atom_builder_helper_spec.rb @@ -20,7 +20,7 @@ RSpec.describe AtomBuilderHelper, type: :helper do describe '#unique_id' do it 'creates an id' do time = Time.now - expect(used_in_builder { |xml| helper.unique_id(xml, time, 1, 'Status') }).to match "#{helper.unique_tag(time, 1, 'Status')}" + expect(used_in_builder { |xml| helper.unique_id(xml, time, 1, 'Status') }).to match "#{TagManager.instance.unique_tag(time, 1, 'Status')}" end end @@ -146,18 +146,10 @@ RSpec.describe AtomBuilderHelper, type: :helper do let(:account) { Fabricate(:account, username: 'alice') } it 'creates a link' do - expect(used_in_builder { |xml| helper.link_mention(xml, account) }).to match '' + expect(used_in_builder { |xml| helper.link_mention(xml, account) }).to match '' end end - describe '#disambiguate_uri' do - pending - end - - describe '#disambiguate_url' do - pending - end - describe '#include_author' do pending end -- cgit