Modify codepen_tag to parse public and private Pen urls (#13481)
* Modify codepen_tag to parse public and private Pen urls * Fixed broken test for codepen_tag private test * Replace codepen_tag tests with links to real Pens
This commit is contained in:
parent
2447bc3a40
commit
a0c3ef0329
2 changed files with 19 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
class CodepenTag < LiquidTagBase
|
||||
PARTIAL = "liquids/codepen".freeze
|
||||
URL_REGEXP =
|
||||
%r{\A(http|https)://(codepen\.io|codepen\.io/team)/[a-zA-Z0-9_\-]{1,30}/pen/([a-zA-Z]{5,7})/{0,1}\z}
|
||||
%r{\A(http|https)://(codepen\.io|codepen\.io/team)/[a-zA-Z0-9_\-]{1,30}/pen/([a-zA-Z0-9]{5,32})/{0,1}\z}
|
||||
.freeze
|
||||
|
||||
def initialize(_tag_name, link, _parse_context)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe CodepenTag, type: :liquid_tag do
|
||||
describe "#link" do
|
||||
let(:codepen_private_link) { "https://codepen.io/quezo/pen/e10ca45c611b9cf3c98a1011dedc1471" }
|
||||
let(:codepen_link) { "https://codepen.io/twhite96/pen/XKqrJX" }
|
||||
let(:codepen_team_private_link) { "https://codepen.io/team/codepen/pen/fb02c34281cb08966ec44b4e1ae22bc3" }
|
||||
let(:codepen_team_link) { "https://codepen.io/team/keyframers/pen/ZMRMEw" }
|
||||
let(:codepen_link_with_default_tab) { "https://codepen.io/twhite96/pen/XKqrJX default-tab=js,result" }
|
||||
|
||||
|
|
@ -26,6 +28,15 @@ RSpec.describe CodepenTag, type: :liquid_tag do
|
|||
)
|
||||
end
|
||||
|
||||
it "accepts codepen private link" do
|
||||
liquid = generate_new_liquid(codepen_private_link)
|
||||
|
||||
expect(liquid.render).to include("<iframe")
|
||||
.and include(
|
||||
'src="https://codepen.io/quezo/embed/e10ca45c611b9cf3c98a1011dedc1471?height=600&default-tab=result&embed-version=2"',
|
||||
)
|
||||
end
|
||||
|
||||
it "accepts codepen link with a / at the end" do
|
||||
codepen_link = "https://codepen.io/twhite96/pen/XKqrJX/"
|
||||
expect do
|
||||
|
|
@ -40,6 +51,13 @@ RSpec.describe CodepenTag, type: :liquid_tag do
|
|||
end.not_to raise_error
|
||||
end
|
||||
|
||||
it "accepts codepen team private link" do
|
||||
codepen_link = codepen_team_private_link
|
||||
expect do
|
||||
generate_new_liquid(codepen_link)
|
||||
end.not_to raise_error
|
||||
end
|
||||
|
||||
it "accepts codepen link with an underscore in the username" do
|
||||
codepen_link = "https://codepen.io/t_white96/pen/XKqrJX/"
|
||||
expect do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue