Skip to content

Commit

Permalink
Fix passing attributes to govukSelect (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
stdstaff committed Sep 15, 2022
1 parent edc63c0 commit 9f34e5e
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 62 deletions.
121 changes: 61 additions & 60 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
PATH
remote: .
specs:
govuk-design-system-rails (0.9.3)
govuk-design-system-rails (0.9.4)

GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.6.1)
actionpack (= 6.1.6.1)
activesupport (= 6.1.6.1)
actioncable (6.1.7)
actionpack (= 6.1.7)
activesupport (= 6.1.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.6.1)
actionpack (= 6.1.6.1)
activejob (= 6.1.6.1)
activerecord (= 6.1.6.1)
activestorage (= 6.1.6.1)
activesupport (= 6.1.6.1)
actionmailbox (6.1.7)
actionpack (= 6.1.7)
activejob (= 6.1.7)
activerecord (= 6.1.7)
activestorage (= 6.1.7)
activesupport (= 6.1.7)
mail (>= 2.7.1)
actionmailer (6.1.6.1)
actionpack (= 6.1.6.1)
actionview (= 6.1.6.1)
activejob (= 6.1.6.1)
activesupport (= 6.1.6.1)
actionmailer (6.1.7)
actionpack (= 6.1.7)
actionview (= 6.1.7)
activejob (= 6.1.7)
activesupport (= 6.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.6.1)
actionview (= 6.1.6.1)
activesupport (= 6.1.6.1)
actionpack (6.1.7)
actionview (= 6.1.7)
activesupport (= 6.1.7)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.6.1)
actionpack (= 6.1.6.1)
activerecord (= 6.1.6.1)
activestorage (= 6.1.6.1)
activesupport (= 6.1.6.1)
actiontext (6.1.7)
actionpack (= 6.1.7)
activerecord (= 6.1.7)
activestorage (= 6.1.7)
activesupport (= 6.1.7)
nokogiri (>= 1.8.5)
actionview (6.1.6.1)
activesupport (= 6.1.6.1)
actionview (6.1.7)
activesupport (= 6.1.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.6.1)
activesupport (= 6.1.6.1)
activejob (6.1.7)
activesupport (= 6.1.7)
globalid (>= 0.3.6)
activemodel (6.1.6.1)
activesupport (= 6.1.6.1)
activerecord (6.1.6.1)
activemodel (= 6.1.6.1)
activesupport (= 6.1.6.1)
activestorage (6.1.6.1)
actionpack (= 6.1.6.1)
activejob (= 6.1.6.1)
activerecord (= 6.1.6.1)
activesupport (= 6.1.6.1)
activemodel (6.1.7)
activesupport (= 6.1.7)
activerecord (6.1.7)
activemodel (= 6.1.7)
activesupport (= 6.1.7)
activestorage (6.1.7)
actionpack (= 6.1.7)
activejob (= 6.1.7)
activerecord (= 6.1.7)
activesupport (= 6.1.7)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.6.1)
activesupport (6.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -79,7 +79,7 @@ GEM
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
loofah (2.18.0)
loofah (2.19.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -103,29 +103,29 @@ GEM
rack (2.2.4)
rack-test (2.0.2)
rack (>= 1.3)
rails (6.1.6.1)
actioncable (= 6.1.6.1)
actionmailbox (= 6.1.6.1)
actionmailer (= 6.1.6.1)
actionpack (= 6.1.6.1)
actiontext (= 6.1.6.1)
actionview (= 6.1.6.1)
activejob (= 6.1.6.1)
activemodel (= 6.1.6.1)
activerecord (= 6.1.6.1)
activestorage (= 6.1.6.1)
activesupport (= 6.1.6.1)
rails (6.1.7)
actioncable (= 6.1.7)
actionmailbox (= 6.1.7)
actionmailer (= 6.1.7)
actionpack (= 6.1.7)
actiontext (= 6.1.7)
actionview (= 6.1.7)
activejob (= 6.1.7)
activemodel (= 6.1.7)
activerecord (= 6.1.7)
activestorage (= 6.1.7)
activesupport (= 6.1.7)
bundler (>= 1.15.0)
railties (= 6.1.6.1)
railties (= 6.1.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (6.1.6.1)
actionpack (= 6.1.6.1)
activesupport (= 6.1.6.1)
railties (6.1.7)
actionpack (= 6.1.7)
activesupport (= 6.1.7)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand All @@ -135,7 +135,7 @@ GEM
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec-expectations (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
Expand All @@ -149,7 +149,7 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rspec-support (3.11.1)
rubocop (1.35.0)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -168,7 +168,7 @@ GEM
rubocop-rails (= 2.15.2)
rubocop-rake (= 0.6.0)
rubocop-rspec (= 2.12.1)
rubocop-performance (1.14.3)
rubocop-performance (1.15.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.15.2)
Expand All @@ -187,15 +187,16 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.4.4)
sqlite3 (1.5.0)
mini_portile2 (~> 2.8.0)
super_diff (0.9.0)
attr_extras (>= 6.2.4)
diff-lcs
patience_diff
thor (1.2.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.2.0)
unicode-display_width (2.3.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
2 changes: 1 addition & 1 deletion app/views/components/_govuk_select.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"aria-describedby": described_by.presence
}

select_attributes.merge!({ attributes: local_assigns[:attributes] }) if local_assigns[:attributes]
select_attributes.merge!(local_assigns[:attributes]) if local_assigns[:attributes]
%>
<%= tag.div(class: form_group_classes) do %>
Expand Down
2 changes: 1 addition & 1 deletion govuk_design_system-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $LOAD_PATH.push File.expand_path("lib", __dir__)

Gem::Specification.new do |s|
s.name = "govuk-design-system-rails"
s.version = "0.9.3"
s.version = "0.9.4"
s.authors = %w[OfficeForProductSafetyAndStandards]
s.summary = "An implementation of the govuk-frontend macros in Ruby on Rails"
s.test_files = Dir["spec/**/*"]
Expand Down
37 changes: 37 additions & 0 deletions spec/helpers/govuk_design_system/select_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,42 @@
</div>
HTML
end

it "allows attributes to be passed" do
html = helper.govukSelect({
id: "sort",
name: "sort",
label: {
text: "Sort by"
},
items: [
{
value: "published",
text: "Recently published"
},
{
value: "updated",
text: "Recently updated",
selected: true
}
],
attributes: {
disabled: true,
data: { test: "testing" }
}
})

expect(html).to match_html(<<~HTML)
<div class="govuk-form-group">
<label class="govuk-label" for="sort">
Sort by
</label>
<select class="govuk-select" id="sort" name="sort" disabled="disabled" data-test="testing">
<option value="published">Recently published</option>
<option value="updated" selected="selected">Recently updated</option>
</select>
</div>
HTML
end
end
end

0 comments on commit 9f34e5e

Please sign in to comment.