Sha256: a68a73fe2c84eef13be242449ba53640ab4a0c072495289cf4c4341a0bd8becc

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

class ActionView::TestCase::TestController
  def default_url_options(options={})
    { :locale => I18n.locale }.merge options
  end
end

# The following snippet breaks url_for
# as described by franca
# https://github.com/screenconcept/shoestrap/issues/23
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#class ActionDispatch::Routing::RouteSet
  #def default_url_options(options={})
    #{ :locale => I18n.locale }
  #end
#end
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

# Fixes the missing default locale problem in controller specs
# See http://www.ruby-forum.com/topic/3448797#1041659
class ActionController::TestCase
  module Behavior
    def process_with_default_locale(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
      parameters = { :locale => I18n.locale }.merge( parameters || {} )
      process_without_default_locale(action, parameters, session, flash, http_method)
    end
    alias_method_chain :process, :default_locale
  end
end

module ActionDispatch::Assertions::RoutingAssertions
  def assert_recognizes_with_default_locale(expected_options, path, extras = {}, message=nil)
    expected_options = { :locale => I18n.locale.to_s }.merge(expected_options || {} )
    assert_recognizes_without_default_locale(expected_options, path, extras, message)
  end
  alias_method_chain :assert_recognizes, :default_locale
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kuhsaft-1.8.6 spec/support/default_url_options.rb
kuhsaft-1.8.5 spec/support/default_url_options.rb
kuhsaft-1.8.4 spec/support/default_url_options.rb
kuhsaft-1.8.1 spec/support/default_url_options.rb
kuhsaft-1.8.0 spec/support/default_url_options.rb
kuhsaft-1.7.1 spec/support/default_url_options.rb
kuhsaft-1.7.0 spec/support/default_url_options.rb