UX: Strip class when link is not oneboxed due to site setting limits.

This commit is contained in:
Guo Xiang Tan 2018-11-29 14:33:01 +08:00
parent ceaf234f89
commit 56034c733a
2 changed files with 19 additions and 4 deletions

View File

@ -447,7 +447,12 @@ class CookedPostProcessor
skip_onebox = limit <= 0 && !map[url]
if skip_onebox
remove_inline_onebox_loading_class(element) unless is_onebox
if is_onebox
element.remove_class('onebox')
else
remove_inline_onebox_loading_class(element)
end
next
end

View File

@ -35,6 +35,10 @@ describe CookedPostProcessor do
"https://#{url_hostname}/t/mini-inline-onebox-support-rfc/66400"
end
let(:not_oneboxed_url) do
"https://#{url_hostname}/t/random-url"
end
let(:title) { 'some title' }
let(:post) do
@ -42,7 +46,7 @@ describe CookedPostProcessor do
#{url}
This is a #{url} with path
https://#{url_hostname}/t/random-url
#{not_oneboxed_url}
This is a https://#{url_hostname}/t/another-random-url test
This is a #{url} with path
@ -101,11 +105,17 @@ describe CookedPostProcessor do
without: {
class: described_class::INLINE_ONEBOX_LOADING_CSS_CLASS
},
text: "https://#{url_hostname}/t/another-random-url",
text: not_oneboxed_url,
count: 1
)
expect(cpp.html).to have_tag('a.onebox', count: 1)
expect(cpp.html).to have_tag('a',
without: {
class: 'onebox'
},
text: not_oneboxed_url,
count: 1
)
end
end