rspec test which calls the fullpage_redirect_to charge.confirmation_url to simulate the redirect to Charge Confirmation URL.NoMethodError: undefined method `match' for nil:NilClass
NoMethodError:
undefined method `match' for nil:NilClass
# /Users/maris/.rvm/gems/ruby-2.4.4/gems/shopify_app-8.4.0/lib/shopify_app/controller_concerns/itp.rb:38:in `user_agent_can_partition_cookies'
# /Users/maris/.rvm/gems/ruby-2.4.4/gems/shopify_app-8.4.0/lib/shopify_app/controller_concerns/itp.rb:10:in `set_test_cookie'
# ./spec/controllers/charge_controller_spec.rb:22:in `block (3 levels) in <top (required)>'
File: shopify_app-8.4.0/lib/shopify_app/controller_concerns/itp.rb:38:in 'user_agent_can_partition_cookies'
def user_agent_can_partition_cookies
user_agent = BrowserSniffer.new(request.user_agent).browser_info
is_safari = user_agent[:name].match(/Safari/)
return false unless is_safari
user_agent[:version].match(/12.0/)
end
During the tests, the user_agent is an empty Hash.
So user_agent[:name] produces nil result.
def user_agent_can_partition_cookies
user_agent = BrowserSniffer.new(request.user_agent).browser_info
is_safari = user_agent[:name]&.match(/Safari/)
return false unless is_safari
user_agent[:version]&.match(/12.0/)
end
Guard against user_agent[:name] being nil.
Hi @marisveide, thanks for reporting. We would happily merge a PR for this, if not I can make the change later this week.
@tylerball - PR created: https://github.com/Shopify/shopify_app/pull/675
Made it a bit different than initially thought, this should be safer.
Looks like this bug must have been recently introduced. I pinned my version to 8.3.2 and my tests are passing now.
Hi
I'm getting this error too.
Any idea when we'll have a release with this fix?
This should be resolved as soon as we release version 8.4.1.
Most helpful comment
@tylerball - PR created: https://github.com/Shopify/shopify_app/pull/675
Made it a bit different than initially thought, this should be safer.