Add extraction of file extension in TopicLink and related rspec tests.

This commit is contained in:
Jakub Macina
2017-06-19 17:09:54 +02:00
parent 4c22f3a0e2
commit eaf46431d4
2 changed files with 9 additions and 3 deletions

View File

@ -193,7 +193,7 @@ http://b.com/#{'a'*500}
end
context "link to a local attachments" do
let(:post) { topic.posts.create(user: user, raw: '<a class="attachment" href="/uploads/default/208/87bb3d8428eb4783.rb">ruby.rb</a>') }
let(:post) { topic.posts.create(user: user, raw: '<a class="attachment" href="/uploads/default/208/87bb3d8428eb4783.rb?foo=bar">ruby.rb</a>') }
it "extracts the link" do
TopicLink.extract_from(post)
@ -203,9 +203,11 @@ http://b.com/#{'a'*500}
# is set to internal
expect(link).to be_internal
# has the correct url
expect(link.url).to eq("/uploads/default/208/87bb3d8428eb4783.rb")
expect(link.url).to eq("/uploads/default/208/87bb3d8428eb4783.rb?foo=bar")
# should not be the reflection
expect(link).not_to be_reflection
# should have file extension
expect(link.extension).to eq('rb')
end
end
@ -224,6 +226,8 @@ http://b.com/#{'a'*500}
expect(link.url).to eq("//s3.amazonaws.com/bucket/2104a0211c9ce41ed67989a1ed62e9a394c1fbd1446.rb")
# should not be the reflection
expect(link).not_to be_reflection
# should have file extension
expect(link.extension).to eq('rb')
end
end