property_sets 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -86,6 +86,7 @@ We support a couple of convenience mechanisms for building forms and putting the
86
86
  <h3><%= f.property_set(:settings).check_box :activated %> Activated?</h3>
87
87
  <h3><%= f.property_set(:settings).radio_button :hot, "yes" %> Hot</h3>
88
88
  <h3><%= f.property_set(:settings).radio_button :not, "no" %> Not</h3>
89
+ <h3><%= f.property_set(:settings).select :level, [["One", 1], ["Two", 2]] %></h3>
89
90
  <% end %>
90
91
 
91
92
  == Installation
@@ -135,4 +136,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
135
136
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
136
137
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
137
138
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
138
- OTHER DEALINGS IN THE SOFTWARE.
139
+ OTHER DEALINGS IN THE SOFTWARE.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -32,6 +32,12 @@ module ActionView
32
32
  template.hidden_field(object_name, property, prepare_id_name(property, options))
33
33
  end
34
34
 
35
+ def select(property, choices, options = {})
36
+ options = prepare_id_name(property, options)
37
+ current_value = options[:object].send(property_set).send(property)
38
+ template.select("#{object_name}[#{property_set}]", property, choices, :selected => current_value)
39
+ end
40
+
35
41
  def prepare_id_name(property, options)
36
42
  throw "Invalid options type #{options.inspect}" unless options.is_a?(Hash)
37
43
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{property_sets}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Morten Primdahl"]
12
- s.date = %q{2011-04-15}
12
+ s.date = %q{2011-04-26}
13
13
  s.description = %q{This gem is an ActiveRecord extension which provides a convenient interface for managing per row properties}
14
14
  s.email = %q{morten@zendesk.com}
15
15
  s.extra_rdoc_files = [
@@ -89,6 +89,25 @@ class TestViewExtensions < ActiveSupport::TestCase
89
89
  @proxy.radio_button(@property, "hello")
90
90
  end
91
91
  end
92
+
93
+ context "select" do
94
+ should "render a <select> with <option>s" do
95
+ settings = stub(:count => "2")
96
+ object = stub()
97
+ object.expects(@association).returns(settings)
98
+
99
+ template = stub()
100
+ template.expects(:instance_variable_get).with("@object_name").returns(object)
101
+
102
+ select_options = { :selected => "2" }
103
+ select_choices = [["One", 1], ["Two", 2], ["Three", 3]]
104
+ html_options = { :id => "foo", :name => "bar" }
105
+ template.expects(:select).with("object_name[settings]", :count, select_choices, select_options)
106
+
107
+ @proxy.stubs(:template).returns(template)
108
+ @proxy.select(:count, select_choices)
109
+ end
110
+ end
92
111
  end
93
112
  end
94
113
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: property_sets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-15 00:00:00 -07:00
18
+ date: 2011-04-26 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency