Skip to content

Commit cb84c41

Browse files
committed
Add data-default-select attribute to existing body element
1 parent 60ddc29 commit cb84c41

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/activeadmin_addons/active_admin_config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class ActiveAdmin::Views::Pages::Base
33

44
def build(*args)
55
original_build(args)
6+
body = get_elements_by_tag_name("body").first
67
body.set_attribute "data-default-select", ActiveadminAddons.default_select
78
end
89
end

spec/features/inputs/select2_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,21 @@
7676
expect(page).to have_selector("select.select2")
7777
end
7878
end
79+
80+
context "when building ActiveAdmin html" do
81+
describe "the <body> element" do
82+
it "is present in the document only once" do
83+
visit admin_invoices_path
84+
85+
expect(page.all('body').size).to eq 1
86+
end
87+
88+
it "contains the data-default-select attribute" do
89+
visit admin_invoices_path
90+
91+
body = find("body")
92+
expect(body['data-default-select']).to eq ActiveadminAddons.default_select
93+
end
94+
end
95+
end
7996
end

0 commit comments

Comments
 (0)