heavenstudio / pag_seguro

A Ruby Client to deal with PagSeguro's API
http://heavenstudio.com.br
71 stars 38 forks source link

Add Rails 4 compatibility #15

Closed abitdodgy closed 11 years ago

abitdodgy commented 11 years ago

Upgrading to Rails 4 causes this error:

Mohamads-MacBook-Pro:printagram Mohamad$ rspec .
/Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/format.rb:46:in `check_options_validity': The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option? (ArgumentError)
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/format.rb:20:in `check_validity!'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validator.rb:143:in `initialize'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/with.rb:87:in `new'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/with.rb:87:in `block in validates_with'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/with.rb:86:in `each'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/with.rb:86:in `validates_with'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-4.0.0.rc1/lib/active_model/validations/format.rb:111:in `validates_format_of'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/pag_seguro-0.5.3/lib/pag_seguro/pre_approval.rb:19:in `<class:PreApproval>'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/pag_seguro-0.5.3/lib/pag_seguro/pre_approval.rb:2:in `<module:PagSeguro>'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/pag_seguro-0.5.3/lib/pag_seguro/pre_approval.rb:1:in `<top (required)>'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/pag_seguro-0.5.3/lib/pag_seguro.rb:24:in `require'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/pag_seguro-0.5.3/lib/pag_seguro.rb:24:in `<top (required)>'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
    from /Users/Mohamad/.rvm/gems/ruby-1.9.3-p327/gems/bundler-
...

I believe this is related to this issue: https://github.com/rails/rails/pull/6569

Line 22 of lib/pag_seguro/pre_aproval.rb

validates_format_of :day_of_year, with: /^\d{2}-\d{2}$/, if: :yearly?

teonimesic commented 11 years ago

i fixed the regex with correct anchor tags. I did not test it further on a rails 4 app, so other problems could still arise. Try version 0.5.4 and see what happens!

abitdodgy commented 11 years ago

I'll let you know how this goes. Thanks.

abitdodgy commented 11 years ago

I think this issue can be closed. So far so good.