phony_rails 0.6.1 → 0.6.2

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.
@@ -67,8 +67,8 @@ module PhonyRails
67
67
  options.assert_valid_keys :country_code, :default_country_code, :as
68
68
  if options[:as].present?
69
69
  raise ArgumentError, ':as option can not be used on phony_normalize with multiple attribute names! (PhonyRails)' if attributes.size > 1
70
- raise ArgumentError, "'#{options[:as]}' is not an attribute on #{self.name}. You might want to use 'phony_normalized_method :#{attributes.first}' (PhonyRails)" if not self.attribute_method?(options[:as])
71
70
  end
71
+
72
72
  # Add before validation that saves a normalized version of the phone number
73
73
  self.before_validation do
74
74
  set_phony_normalized_numbers(attributes, options)
@@ -0,0 +1,4 @@
1
+ de:
2
+ errors:
3
+ messages:
4
+ improbable_phone: "ist keine gültige Nummer"
@@ -0,0 +1,4 @@
1
+ tr:
2
+ errors:
3
+ messages:
4
+ improbable_phone: "geçersiz numara"
@@ -1,3 +1,3 @@
1
1
  module PhonyRails
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -187,16 +187,16 @@ describe PhonyRails do
187
187
  }.should raise_error(ArgumentError)
188
188
  end
189
189
 
190
- it "should not accept :as option with unexisting attribute name" do
190
+ it "should accept :as option with non existing attribute name" do
191
191
  lambda {
192
- model_klass.phony_normalize(:non_existing_attribute, :as => 'non_existing_attribute')
193
- }.should raise_error(ArgumentError)
192
+ dummy_klass.phony_normalize(:non_existing_attribute, :as => 'non_existing_attribute')
193
+ }.should_not raise_error
194
194
  end
195
195
 
196
- it "should not accept :as option with single non existing attribute name" do
196
+ it "should accept :as option with single non existing attribute name" do
197
197
  lambda {
198
- model_klass.phony_normalize(:phone_number, :as => 'something_else')
199
- }.should raise_error(ArgumentError)
198
+ dummy_klass.phony_normalize(:phone_number, :as => 'something_else')
199
+ }.should_not raise_error
200
200
  end
201
201
 
202
202
  it "should accept :as option with single existing attribute name" do
@@ -294,6 +294,14 @@ describe PhonyRails do
294
294
  dummy.valid?
295
295
  }.should raise_error(RuntimeError)
296
296
  end
297
+
298
+ it "should raise a RuntimeError at validation if the :as option attribute doesn't exist" do
299
+ dummy_klass.phony_normalize :phone_number, :as => :non_existing_attribute
300
+ dummy = dummy_klass.new
301
+ lambda {
302
+ dummy.valid?
303
+ }.should raise_error(RuntimeError)
304
+ end
297
305
  end
298
306
  end
299
307
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
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: 2014-02-24 00:00:00.000000000 Z
12
+ date: 2014-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: phony
@@ -108,9 +108,11 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - lib/phony_rails.rb
111
+ - lib/phony_rails/locales/de.yml
111
112
  - lib/phony_rails/locales/en.yml
112
113
  - lib/phony_rails/locales/fr.yml
113
114
  - lib/phony_rails/locales/ja.yml
115
+ - lib/phony_rails/locales/tr.yml
114
116
  - lib/phony_rails/string_extensions.rb
115
117
  - lib/phony_rails/version.rb
116
118
  - lib/validators/phony_validator.rb