amount_field_rails3 3.0.0 → 3.0.1
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/.gitignore +1 -0
- data/History.txt +5 -0
- data/lib/amount_field/validations.rb +6 -3
- data/lib/amount_field/version.rb +1 -1
- data/test/test_helper.rb +5 -0
- data/test/validations_test.rb +13 -2
- metadata +34 -51
data/.gitignore
CHANGED
data/History.txt
CHANGED
@@ -2,8 +2,11 @@ module AmountField #:nodoc:
|
|
2
2
|
module ActiveRecord #:nodoc:
|
3
3
|
module Validations
|
4
4
|
|
5
|
+
# Note: Don't use mattr_accessor here because it will define 'def configuration=' too which leads to error
|
6
|
+
# "ActiveRecord::DangerousAttributeError:configuration=" in case the AR model has an attribute 'configuration'.
|
5
7
|
@@configuration = {}
|
6
|
-
|
8
|
+
def self.configuration=(c); @@configuration = c; end
|
9
|
+
def self.configuration; @@configuration; end
|
7
10
|
|
8
11
|
def self.included(base) # :nodoc:
|
9
12
|
base.extend ClassMethods
|
@@ -15,7 +18,7 @@ module AmountField #:nodoc:
|
|
15
18
|
# code before validates_each is called only once!
|
16
19
|
configuration = attr_names.extract_options!
|
17
20
|
|
18
|
-
define_special_setter(attr_names
|
21
|
+
define_special_setter(attr_names)
|
19
22
|
|
20
23
|
# the following code defines the callbacks methods that are called on every validation
|
21
24
|
validates_each(attr_names, configuration) do |record, attr_name, value|
|
@@ -55,7 +58,7 @@ module AmountField #:nodoc:
|
|
55
58
|
|
56
59
|
private
|
57
60
|
|
58
|
-
def define_special_setter(attr_names
|
61
|
+
def define_special_setter(attr_names)
|
59
62
|
attr_names.each do |attr_name|
|
60
63
|
class_eval <<-EOV
|
61
64
|
def #{special_method_name(attr_name)}=(value)
|
data/lib/amount_field/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -21,6 +21,11 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
21
21
|
t.column "stock_price", :decimal, :precision => 12, :scale => 2
|
22
22
|
t.column "float_price", :float
|
23
23
|
end
|
24
|
+
|
25
|
+
create_table "test_products_with_configuration", :force => true do |t|
|
26
|
+
t.column "configuration", :string
|
27
|
+
t.column "price", :decimal, :precision => 12, :scale => 2
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
class ActiveSupport::TestCase
|
data/test/validations_test.rb
CHANGED
@@ -50,8 +50,7 @@ class ValidationsTest < ActiveSupport::TestCase
|
|
50
50
|
'1.234.567,89' => 1234567.89
|
51
51
|
}
|
52
52
|
end
|
53
|
-
|
54
|
-
|
53
|
+
|
55
54
|
test "orignal setter accept ruby value if set via new" do
|
56
55
|
product = TestProduct.new(:price => 12.34)
|
57
56
|
assert_in_delta 12.34, product.price, 0.001
|
@@ -385,5 +384,17 @@ class ValidationsTest < ActiveSupport::TestCase
|
|
385
384
|
assert p.errors.full_messages.include?("Price is not a number")
|
386
385
|
end
|
387
386
|
|
387
|
+
test "configuration must not interfere with an active record model attribute" do
|
388
|
+
class TestProductWithAttributeConfiguration < ActiveRecord::Base
|
389
|
+
set_table_name 'test_products_with_configuration'
|
390
|
+
validates_amount_format_of :price
|
391
|
+
end
|
392
|
+
with_locale('de') do
|
393
|
+
p = TestProductWithAttributeConfiguration.new(:amount_field_price => "1,23", :configuration => "TEXT")
|
394
|
+
assert p.valid?
|
395
|
+
assert_equal "TEXT", p.configuration
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
388
399
|
end
|
389
400
|
|
metadata
CHANGED
@@ -1,45 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: amount_field_rails3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 3
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
version: 3.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.1
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Thomas Baustert
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: mysql2
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2161516960 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :development
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2161516960
|
25
|
+
description: Rails gem/plugin that accepts (amount) values in german or us format
|
26
|
+
like 1.234,56 or 1,234.56
|
27
|
+
email:
|
35
28
|
- business@thomasbaustert.de
|
36
29
|
executables: []
|
37
|
-
|
38
30
|
extensions: []
|
39
|
-
|
40
31
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
32
|
+
files:
|
43
33
|
- .gitignore
|
44
34
|
- Gemfile
|
45
35
|
- History.txt
|
@@ -64,39 +54,32 @@ files:
|
|
64
54
|
- test/test_helper.rb
|
65
55
|
- test/validations_test.rb
|
66
56
|
- uninstall.rb
|
67
|
-
has_rdoc: true
|
68
57
|
homepage: http://github.com/thomasbaustert/amount_field
|
69
58
|
licenses: []
|
70
|
-
|
71
59
|
post_install_message:
|
72
60
|
rdoc_options: []
|
73
|
-
|
74
|
-
require_paths:
|
61
|
+
require_paths:
|
75
62
|
- lib
|
76
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
64
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
|
83
|
-
version: "0"
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
70
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
- 0
|
91
|
-
version: "0"
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
92
75
|
requirements: []
|
93
|
-
|
94
76
|
rubyforge_project: amount_field_rails3
|
95
|
-
rubygems_version: 1.
|
77
|
+
rubygems_version: 1.8.6
|
96
78
|
signing_key:
|
97
79
|
specification_version: 3
|
98
|
-
summary: Rails gem/plugin that accepts (amount) values in german or us format like
|
99
|
-
|
80
|
+
summary: Rails gem/plugin that accepts (amount) values in german or us format like
|
81
|
+
1.234,56 or 1,234.56
|
82
|
+
test_files:
|
100
83
|
- test/form_helper_test.rb
|
101
84
|
- test/form_tag_helper_test.rb
|
102
85
|
- test/models/test_product.rb
|