Skip to content

Commit

Permalink
Add a spec for use of :type and :as without column or method when usi…
Browse files Browse the repository at this point in the history
…ng Sequel plugin

There does not appear to be a spec for for this combination of
options.
  • Loading branch information
jeremyevans committed Mar 28, 2024
1 parent e108f4d commit 802975b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spec/sequel_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class << @ab
@b.input(:artist_name).must_equal '<label>Artist name: <input aria-describedby="album_artist_name_error_message" aria-invalid="true" class="error" id="album_artist_name" name="album[artist_name]" type="text" value="a"/></label><span class="error_message" id="album_artist_name_error_message">foo</span>'
end

it "should respect a :type option with a schema type as the input type for methods not backed by columns" do
it "should respect a :type option with a schema type and :as option for html type for methods not backed by columns" do
def @ab.foo; false end
@b.input(:foo, :type=>:boolean, :as=>:select).must_equal '<label>Foo: <select id="album_foo" name="album[foo]"><option value=""></option><option value="t">True</option><option selected="selected" value="f">False</option></select></label>'
end
Expand All @@ -421,6 +421,10 @@ def @ab.foo; "bar" end
@b.input(:foo, :type=>:phone).must_equal '<label>Foo: <input id="album_foo" name="album[foo]" type="phone" value="bar"/></label>'
end

it "should respect a :type option with a schema type and :as option for html type when no method exists" do
@b.input(:foo, :type=>:boolean, :as=>:select, :value=>false).must_equal '<label>Foo: <select id="album_foo" name="album[foo]"><option value=""></option><option value="t">True</option><option selected="selected" value="f">False</option></select></label>'
end

it "should not override an explicit :error setting" do
@ab.errors.add(:name, 'tis not valid')
@b.input(:name, :error=>nil).must_equal '<label>Name: <input id="album_name" maxlength="255" name="album[name]" type="text" value="b"/></label>'
Expand Down

0 comments on commit 802975b

Please sign in to comment.