From d2d88835985a09217af9f895512fa378cd9a8a28 Mon Sep 17 00:00:00 2001 From: Jan Schwenzien Date: Fri, 3 Aug 2012 09:51:08 +0200 Subject: [PATCH] updated gems, added 'unless _changed?' trap --- Gemfile | 8 +- Gemfile.lock | 162 ++++++++++-------- VERSION | 2 +- .../orm/active_record_extension.rb | 2 + .../validators/bank_account_validator.rb | 1 + 5 files changed, 98 insertions(+), 77 deletions(-) diff --git a/Gemfile b/Gemfile index 4488a96..e47e01b 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,8 @@ gem "rails", ">= 3.0.0" gem 'kontoapi-ruby', ">= 0.2.0" group :development do - gem "rspec", "~> 2.3.0" - gem "bundler", "~> 1.0.0" - gem "jeweler", "~> 1.5.2" - gem "rcov", ">= 0" + gem "rspec", ">= 2.3.0" + gem "bundler", ">= 1.1.0" + gem "jeweler", ">= 1.5.2" + gem "simplecov", ">= 0" end diff --git a/Gemfile.lock b/Gemfile.lock index e9da158..f536c3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,96 +1,114 @@ GEM remote: http://rubygems.org/ specs: - abstract (1.0.0) - actionmailer (3.0.7) - actionpack (= 3.0.7) - mail (~> 2.2.15) - actionpack (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.7) - activesupport (= 3.0.7) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - arel (~> 2.0.2) - tzinfo (~> 0.3.23) - activeresource (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - activesupport (3.0.7) - addressable (2.2.7) - arel (2.0.9) - builder (2.1.2) - diff-lcs (1.1.2) - erubis (2.6.6) - abstract (>= 1.0.0) + actionmailer (3.2.7) + actionpack (= 3.2.7) + mail (~> 2.4.4) + actionpack (3.2.7) + activemodel (= 3.2.7) + activesupport (= 3.2.7) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.0) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.1.3) + activemodel (3.2.7) + activesupport (= 3.2.7) + builder (~> 3.0.0) + activerecord (3.2.7) + activemodel (= 3.2.7) + activesupport (= 3.2.7) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.7) + activemodel (= 3.2.7) + activesupport (= 3.2.7) + activesupport (3.2.7) + i18n (~> 0.6) + multi_json (~> 1.0) + addressable (2.3.2) + arel (3.0.2) + builder (3.0.0) + diff-lcs (1.1.3) + erubis (2.7.0) git (1.2.5) - i18n (0.5.0) - jeweler (1.5.2) - bundler (~> 1.0.0) + hike (1.2.1) + i18n (0.6.0) + jeweler (1.8.4) + bundler (~> 1.0) git (>= 1.2.5) rake + rdoc + journey (1.0.4) + json (1.7.4) kontoapi-ruby (0.2.0) addressable yajl-ruby - mail (2.2.17) - activesupport (>= 2.3.6) + mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.16) - polyglot (0.3.1) - rack (1.2.2) - rack-mount (0.6.14) - rack (>= 1.0.0) - rack-test (0.5.7) + mime-types (1.19) + multi_json (1.3.6) + polyglot (0.3.3) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) rack (>= 1.0) - rails (3.0.7) - actionmailer (= 3.0.7) - actionpack (= 3.0.7) - activerecord (= 3.0.7) - activeresource (= 3.0.7) - activesupport (= 3.0.7) + rails (3.2.7) + actionmailer (= 3.2.7) + actionpack (= 3.2.7) + activerecord (= 3.2.7) + activeresource (= 3.2.7) + activesupport (= 3.2.7) bundler (~> 1.0) - railties (= 3.0.7) - railties (3.0.7) - actionpack (= 3.0.7) - activesupport (= 3.0.7) + railties (= 3.2.7) + railties (3.2.7) + actionpack (= 3.2.7) + activesupport (= 3.2.7) + rack-ssl (~> 1.3.2) rake (>= 0.8.7) - thor (~> 0.14.4) - rake (0.8.7) - rcov (0.9.9) - rspec (2.3.0) - rspec-core (~> 2.3.0) - rspec-expectations (~> 2.3.0) - rspec-mocks (~> 2.3.0) - rspec-core (2.3.1) - rspec-expectations (2.3.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.3.0) - thor (0.14.6) - treetop (1.4.9) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.2) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.1) + simplecov (0.6.4) + multi_json (~> 1.0) + simplecov-html (~> 0.5.3) + simplecov-html (0.5.3) + sprockets (2.1.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + thor (0.15.4) + tilt (1.3.3) + treetop (1.4.10) + polyglot polyglot (>= 0.3.1) - tzinfo (0.3.26) + tzinfo (0.3.33) yajl-ruby (1.1.0) PLATFORMS ruby DEPENDENCIES - bundler (~> 1.0.0) - jeweler (~> 1.5.2) + bundler (>= 1.1.0) + jeweler (>= 1.5.2) kontoapi-ruby (>= 0.2.0) rails (>= 3.0.0) - rcov - rspec (~> 2.3.0) + rspec (>= 2.3.0) + simplecov diff --git a/VERSION b/VERSION index f477849..373f8c6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.2 \ No newline at end of file +0.2.3 \ No newline at end of file diff --git a/lib/kontoapi-rails/orm/active_record_extension.rb b/lib/kontoapi-rails/orm/active_record_extension.rb index 243ba8d..82b9454 100644 --- a/lib/kontoapi-rails/orm/active_record_extension.rb +++ b/lib/kontoapi-rails/orm/active_record_extension.rb @@ -50,6 +50,7 @@ def validates_iban(field, options={}) options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore ) define_method :iban_validation do value = send(field) + return true unless send(:"#{field}_changed?") return true if options[:allow_nil] && value.nil? begin errors.add(field, :invalid) unless KontoAPI::valid?( :iban => value ) @@ -70,6 +71,7 @@ def validates_bic(field, options={}) options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore ) define_method :bic_validation do value = send(field) + return true unless send(:"#{field}_changed?") return true if options[:allow_nil] && value.nil? begin errors.add(field, :invalid) unless KontoAPI::valid?( :bic => send(field) ) diff --git a/lib/kontoapi-rails/validators/bank_account_validator.rb b/lib/kontoapi-rails/validators/bank_account_validator.rb index 38070c7..b70b7fc 100644 --- a/lib/kontoapi-rails/validators/bank_account_validator.rb +++ b/lib/kontoapi-rails/validators/bank_account_validator.rb @@ -6,6 +6,7 @@ class BankAccountValidator < ActiveModel::Validator def validate(record) account_number = record.send(:"#{options[:account_number_field]}") bank_code = record.send(:"#{options[:bank_code_field]}") + return true unless send(:"#{options[:account_number_field]}_changed?") || send(:"#{options[:bank_code_field]}_changed?") return true if options[:allow_nil] && (account_number.nil? || bank_code.nil?) record.errors.add(:"#{options[:account_number_field]}", :invalid) unless KontoAPI::valid?( :ktn => account_number, :blz => bank_code ) rescue Timeout::Error => ex