Skip to content

Commit

Permalink
Tag option for sets the attribute when value is a string or symbol [#…
Browse files Browse the repository at this point in the history
…18]

We didn't change the option to avoid a breaking change.

fixes #18
  • Loading branch information
Janice Concepcion and Ramon Tayag authored and ramontayag committed Jan 6, 2016
1 parent 239e811 commit 261dece
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## unreleased [](https://github.com/activeadmin/arbre/compare/v1.0.3...master)

* Tag option `for` sets the attribute when value is a string or symbol [#18]

## 1.0.3 [](https://github.com/activeadmin/arbre/compare/v1.0.2...v1.0.3)

* Performance improvements [#40][] by [@alexesDev][]
Expand Down
5 changes: 4 additions & 1 deletion lib/arbre/html/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def build(*args)
attributes = extract_arguments(args)
self.content = args.first if args.first

set_for_attribute(attributes.delete(:for))
for_value = attributes[:for]
unless for_value.kind_of?(String) || for_value.kind_of?(Symbol)
set_for_attribute(attributes.delete(:for))
end

attributes.each do |key, value|
set_attribute(key, value)
Expand Down
12 changes: 12 additions & 0 deletions spec/arbre/unit/html/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ def default_id_for_prefix
end
end

describe "creating a tag with a for attribute" do
it "sets the `for` attribute when a string is given" do
tag.build for: "email"
expect(tag.attributes[:for]).to eq "email"
end

it "sets the `for` attribute when a symbol is given" do
tag.build for: :email
expect(tag.attributes[:for]).to eq :email
end
end

describe "css class names" do

it "should add a class" do
Expand Down

0 comments on commit 261dece

Please sign in to comment.