property_sets 1.0.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/gemfiles/rails2.3.gemfile.lock +3 -2
- data/gemfiles/rails3.0.gemfile.lock +3 -2
- data/gemfiles/rails3.2.gemfile.lock +3 -2
- data/lib/property_sets/action_view_extension.rb +3 -2
- data/lib/property_sets/property_set_model.rb +3 -1
- data/property_sets.gemspec +1 -1
- data/test/test_property_sets.rb +5 -0
- data/test/test_view_extensions.rb +34 -5
- metadata +2 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/primdahl/Git/property_sets
|
3
3
|
specs:
|
4
|
-
property_sets (
|
4
|
+
property_sets (2.0.0)
|
5
5
|
activerecord (>= 2.3.14, < 3.3)
|
6
6
|
activesupport (>= 2.3.14, < 3.3)
|
7
7
|
json
|
@@ -23,7 +23,8 @@ GEM
|
|
23
23
|
bundler
|
24
24
|
rake
|
25
25
|
jdbc-mysql (5.1.13)
|
26
|
-
json (1.
|
26
|
+
json (1.8.0)
|
27
|
+
json (1.8.0-java)
|
27
28
|
metaclass (0.0.1)
|
28
29
|
mocha (0.10.5)
|
29
30
|
metaclass (~> 0.0.1)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/primdahl/Git/property_sets
|
3
3
|
specs:
|
4
|
-
property_sets (
|
4
|
+
property_sets (2.0.0)
|
5
5
|
activerecord (>= 2.3.14, < 3.3)
|
6
6
|
activesupport (>= 2.3.14, < 3.3)
|
7
7
|
json
|
@@ -45,7 +45,8 @@ GEM
|
|
45
45
|
abstract (>= 1.0.0)
|
46
46
|
i18n (0.5.0)
|
47
47
|
jdbc-mysql (5.1.13)
|
48
|
-
json (1.
|
48
|
+
json (1.8.0)
|
49
|
+
json (1.8.0-java)
|
49
50
|
metaclass (0.0.1)
|
50
51
|
mocha (0.10.5)
|
51
52
|
metaclass (~> 0.0.1)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/primdahl/Git/property_sets
|
3
3
|
specs:
|
4
|
-
property_sets (
|
4
|
+
property_sets (2.0.0)
|
5
5
|
activerecord (>= 2.3.14, < 3.3)
|
6
6
|
activesupport (>= 2.3.14, < 3.3)
|
7
7
|
json
|
@@ -46,7 +46,8 @@ GEM
|
|
46
46
|
i18n (0.6.1)
|
47
47
|
jdbc-mysql (5.1.13)
|
48
48
|
journey (1.0.4)
|
49
|
-
json (1.
|
49
|
+
json (1.8.0)
|
50
|
+
json (1.8.0-java)
|
50
51
|
metaclass (0.0.1)
|
51
52
|
mocha (0.10.5)
|
52
53
|
metaclass (~> 0.0.1)
|
@@ -21,8 +21,9 @@ module ActionView
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def radio_button(property, checked_value = "1", options = {})
|
24
|
+
options[:id] ||= "#{object_name}_#{property_set}_#{property}_#{checked_value}"
|
24
25
|
options = prepare_options(property, options) do |properties|
|
25
|
-
properties.send("#{property}") == checked_value
|
26
|
+
properties.send("#{property}") == checked_value
|
26
27
|
end
|
27
28
|
template.radio_button(object_name, property, checked_value, options)
|
28
29
|
end
|
@@ -34,7 +35,7 @@ module ActionView
|
|
34
35
|
def hidden_field(property, options = {})
|
35
36
|
options = prepare_id_name(property, options)
|
36
37
|
unless options.keys.include?(:value)
|
37
|
-
options[:value] = cast_boolean(options[:object].send(property_set).send(property))
|
38
|
+
options[:value] = cast_boolean(options[:object].send(property_set).send(property))
|
38
39
|
end
|
39
40
|
template.hidden_field(object_name, property, options)
|
40
41
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
1
3
|
module PropertySets
|
2
4
|
module PropertySetModel
|
3
5
|
module InstanceMethods
|
@@ -89,7 +91,7 @@ module PropertySets
|
|
89
91
|
end
|
90
92
|
|
91
93
|
def property(key, options = nil)
|
92
|
-
@properties ||=
|
94
|
+
@properties ||= HashWithIndifferentAccess.new
|
93
95
|
@properties[key] = options
|
94
96
|
end
|
95
97
|
|
data/property_sets.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Gem::Specification.new "property_sets", "
|
1
|
+
Gem::Specification.new "property_sets", "2.0.0" do |s|
|
2
2
|
s.summary = "Property sets for ActiveRecord."
|
3
3
|
s.description = "This gem is an ActiveRecord extension which provides a convenient interface for managing per row properties."
|
4
4
|
s.authors = ["Morten Primdahl"]
|
data/test/test_property_sets.rb
CHANGED
@@ -62,6 +62,11 @@ class TestPropertySets < ActiveSupport::TestCase
|
|
62
62
|
assert_equal 'skep', @account.settings.hep
|
63
63
|
end
|
64
64
|
|
65
|
+
should "be flexible when fetching property data" do
|
66
|
+
assert_equal 'skep', @account.settings.default(:hep)
|
67
|
+
assert_equal 'skep', @account.settings.default('hep')
|
68
|
+
end
|
69
|
+
|
65
70
|
context 'querying for a setting that does not exist' do
|
66
71
|
setup do
|
67
72
|
assert_equal([], @account.settings)
|
@@ -116,16 +116,45 @@ class TestViewExtensions < ActiveSupport::TestCase
|
|
116
116
|
end
|
117
117
|
|
118
118
|
context "#radio_button" do
|
119
|
+
setup do
|
120
|
+
settings = stub(@property => 'hello')
|
121
|
+
@object.stubs(@property_set).returns(settings)
|
122
|
+
|
123
|
+
@expected_options = base_options.merge(
|
124
|
+
:id => "#{@object_name}_#{@property_set}_#{@property}_hello",
|
125
|
+
:checked => false
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
should "generate a unique id when one is not provided" do
|
130
|
+
@expected_options.merge!(
|
131
|
+
:id => "#{@object_name}_#{@property_set}_#{@property}_pancake"
|
132
|
+
)
|
133
|
+
@template.expects(:radio_button).with(@object_name, @property, 'pancake', @expected_options)
|
134
|
+
@proxy.radio_button(@property, 'pancake')
|
135
|
+
end
|
136
|
+
|
119
137
|
context "when called with checked true for a truth value" do
|
138
|
+
|
139
|
+
should "call with checked true for a truth value" do
|
140
|
+
@expected_options.merge!(:checked => true)
|
141
|
+
@template.expects(:radio_button).with(@object_name, @property, 'hello', @expected_options)
|
142
|
+
@proxy.radio_button(@property, 'hello')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when called with a value of a different type" do
|
120
147
|
setup do
|
121
|
-
settings = stub(@property => '
|
148
|
+
settings = stub(@property => '1')
|
122
149
|
@object.stubs(@property_set).returns(settings)
|
123
150
|
end
|
124
151
|
|
125
|
-
should "call with checked
|
126
|
-
expected_options
|
127
|
-
|
128
|
-
|
152
|
+
should "call with checked false" do
|
153
|
+
@expected_options.merge!(
|
154
|
+
:id => "#{@object_name}_#{@property_set}_#{@property}_1"
|
155
|
+
)
|
156
|
+
@template.expects(:radio_button).with(@object_name, @property, 1, @expected_options)
|
157
|
+
@proxy.radio_button(@property, 1)
|
129
158
|
end
|
130
159
|
end
|
131
160
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: property_sets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|