Skip to content

Commit

Permalink
Merge pull request #2882 from AlchemyCMS/fix-file-tab-select
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen authored May 22, 2024
2 parents e7e037c + b477c1a commit a1e0391
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/components/alchemy/admin/link_dialog/file_tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def attachment

def attachment_select
label = label_tag("file_link", Alchemy.t(:file), class: "control-label")
input = text_field_tag("file_link", url, id: "file_link")
input = text_field_tag("file_link", attachment && url, id: "file_link")
select = render Alchemy::Admin::AttachmentSelect.new(attachment).with_content(input)
content_tag("div", label + select, class: "input select")
end
Expand Down
27 changes: 12 additions & 15 deletions spec/components/alchemy/admin/link_dialog/file_tab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,21 @@
it_behaves_like "a link dialog tab", :file, "File"
it_behaves_like "a link dialog - target select", :file

context "file link" do
it "has a file select" do
expect(page).to have_selector("alchemy-attachment-select [name=file_link]")
end

context "tab selected" do
let(:is_selected) { true }
it "has a file select" do
expect(page).to have_selector("alchemy-attachment-select [name=file_link]")
end

it "has a selected value" do
expect(page).to have_selector("alchemy-attachment-select [value='#{url}']")
end
context "with attachment found by url" do
it "has value set" do
expect(page).to have_selector("alchemy-attachment-select [value='#{url}']")
end
end

context "with attachment not found by url" do
let(:url) { Alchemy::Engine.routes.url_helpers.show_page_path(urlname: "foo") }

context "tab not selected" do
it "has a selected value" do
expect(page).to have_selector("alchemy-attachment-select [value='#{url}']")
# expect(page).to_not have_selector("alchemy-attachment-select [name=file_link] option[selected='selected']")
end
it "has no value set" do
expect(page).to_not have_selector("alchemy-attachment-select [value='#{url}']")
end
end
end

0 comments on commit a1e0391

Please sign in to comment.