Skip to content

Commit e2a19ce

Browse files
committed
add overrides_spec
1 parent 61fbbe2 commit e2a19ce

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

lib/decidim/extra_user_fields/form_builder_methods.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ module FormBuilderMethods
77
def custom_country_select(name, options = {})
88
label_text = options[:label].to_s
99
label_text = label_for(name) if label_text.blank?
10+
select_html = sanitize_country_select(country_select(name))
11+
(label_text + select_html).html_safe
12+
end
1013

11-
template = ""
12-
template += (label_text + required_for_attribute(name)) if options.fetch(:label, true)
13-
template += @template.country_select(@object_name, name)
14+
private
1415

15-
template.html_safe
16+
# Remove non-standard attrs added by country_select that fail HTML/accessibility validation
17+
def sanitize_country_select(html)
18+
html.gsub(/\s(skip_default_ids|allow_method_names_outside_object)="[^"]*"/, "")
1619
end
1720
end
1821
end

spec/lib/overrides_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
require "spec_helper"
4+
5+
# We make sure that the checksum of the file overriden is the same
6+
# as the expected. If this test fails, it means that the overriden
7+
# file should be updated to match any change/bug fix introduced in the core
8+
checksums = [
9+
{
10+
package: "decidim-core",
11+
files: {
12+
"/app/commands/decidim/create_registration.rb" => "c2fafd313dbe16624e3ef07584e946cd",
13+
"/app/commands/decidim/create_omniauth_registration.rb" => "5bca48c990c3b82d47119902c0a56ca1",
14+
"/app/commands/decidim/update_account.rb" => "d24090fdd9358c38e6e15c4607a78e18",
15+
"/app/models/decidim/organization.rb" => "a72b9d9ef10aa06dbe5aef27c68d5c7a",
16+
"/app/views/decidim/account/show.html.erb" => "f13218e2358a2d611996c2a197c0de25",
17+
"/app/views/decidim/devise/registrations/new.html.erb" => "b30423406afd43bb9af2c98d59d43632",
18+
"/app/views/decidim/devise/omniauth_registrations/new.html.erb" => "49f44efcd7ae6f87c04b309733ff28f6"
19+
}
20+
},
21+
{
22+
package: "decidim-admin",
23+
files: {
24+
"/app/views/decidim/admin/officializations/index.html.erb" => "e849c5dbaf04379bf233c15e860e1a18"
25+
}
26+
}
27+
]
28+
29+
describe "Overriden files", type: :view do
30+
checksums.each do |item|
31+
spec = Gem::Specification.find_by_name(item[:package])
32+
item[:files].each do |file, signature|
33+
it "#{spec.gem_dir}#{file} matches checksum" do
34+
expect(md5("#{spec.gem_dir}#{file}")).to eq(signature)
35+
end
36+
end
37+
end
38+
39+
private
40+
41+
def md5(file)
42+
Digest::MD5.hexdigest(File.read(file))
43+
end
44+
end

spec/system/account_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
it_behaves_like "accessible page"
9393
end
9494

95-
9695
describe "updating personal data" do
9796
let!(:encrypted_password) { user.encrypted_password }
9897

0 commit comments

Comments
 (0)