rails_current 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDFiMGFhZTZmYTMzYWJlMzI3MDgwNGU0NTAyZGI3ZDU4N2U3YWE5NA==
4
+ OTEyNzAzZTc0MGYzOWZhMzc0MjY5ZTY1N2MyOWQ1ZGRkOGFhZDE2NQ==
5
5
  data.tar.gz: !binary |-
6
- NDUyNDJiYWExM2QwMjE5M2JjN2RhNzNlZWQ1N2FlZGFiYjA0Y2Q1OA==
6
+ MmE2NzM3YjYxMjIzMTcxM2QzYWZlMTRjYmEyOGM0M2MwNjczMTM5ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzlhZTY2OTg3YWYzNjQzYTA3ZmFkZGUwODE1YjcxOWQwMTQ4ZjgzNjliM2Ey
10
- ZTc3YzhlZTNiNWNkN2VkMmJmNWExYWMyYjU1ZDZmOWM2NWE0MzE5YWYyYmI2
11
- ZTE3YmU2MzNlMDI3ZDkyMzhlMWU0ZTA5MGIxNTJlZGMzYTdkNDI=
9
+ ZDZlZjA1ZmY4MzIzZTJjMWIxMTg1YmNkZjllYWY0ZGQ4YjdkMjk3NjE3YmFl
10
+ NDAyMWJmMDA4ZjhhNjExZDFlNDYwNDFmZTcxMTk5MjZjOThhZDk0NzVlZGIy
11
+ OTkyNGNlOGYwMmRhYWRkNDE0YjQzMDJjMWY5NGUwNDYwNWM5OGM=
12
12
  data.tar.gz: !binary |-
13
- YzljNDQ4NDhkZmM2ZjE1Y2E2Mjg1OTJhMmFhNzIzMTI0YjFkNjk3ZGI3YmY0
14
- ZGM0OWM1OTg0ZWIxNzNhMGQ5MzhhYWFlNzVhYWY2ZDc2YmYyODlkYTk0MGY4
15
- Yzg0MTYyNmQwZjMxOTQ1Zjk2MGM0YWM3OTkyYjY2YjJmNjU5MzA=
13
+ NWM4ODVlMTIzNWU0OTgzMzUzNGQ4NjI0YjkyZDlhZGZjODEzZmIxYzVhNGY5
14
+ NjE2ZjNiMzMyMTdiY2NkZDA5YWQ1ZGJiYTZlNjRiZjdkN2U3Mzc0NjUyNDdl
15
+ NWQwYzcyNmM5ZjU3YThiYzY3MWU2NzNhYmNkNjRhNzI5YmQyZTU=
data/lib/rails_current.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Current
4
4
  def Current.version
5
- '1.8.2'
5
+ '1.9.0'
6
6
  end
7
7
 
8
8
  def Current.dependencies
@@ -161,40 +161,53 @@ module Current
161
161
  end
162
162
 
163
163
  def Current.mock_controller(options = {})
164
- require 'rails'
165
- require 'action_controller'
166
- require 'action_dispatch/testing/test_request.rb'
167
- require 'action_dispatch/testing/test_response.rb'
164
+ ensure_rails_application do
165
+ require 'action_controller'
166
+ require 'action_dispatch/testing/test_request.rb'
167
+ require 'action_dispatch/testing/test_response.rb'
168
168
 
169
- default_url_options =
170
- begin
171
- require 'rails_default_url_options'
172
- DefaultUrlOptions
173
- rescue LoadError
174
- options[:default_url_options] || {}
169
+ store = ActiveSupport::Cache::MemoryStore.new
170
+
171
+ controller = mock_controller_class.new
172
+ controller.perform_caching = true
173
+ controller.cache_store = store
174
+
175
+ request = ActionDispatch::TestRequest.new
176
+ response = ActionDispatch::TestResponse.new
177
+
178
+ controller.request = request
179
+ controller.response = response
180
+
181
+ singleton_class =
182
+ class << controller
183
+ self
184
+ end
185
+
186
+ singleton_class.module_eval do
187
+ define_method(:default_url_options) do
188
+ @default_url_options ||= (
189
+ defined?(DefaultUrlOptions) ? DefaultUrlOptions.dup : {}
190
+ )
191
+ end
175
192
  end
176
193
 
177
- ensure_rails_application do
178
- store = ActiveSupport::Cache::MemoryStore.new
179
- controller =
180
- begin
181
- ApplicationController.new
182
- rescue NameError
183
- ActionController::Base.new
184
- end
185
- controller.perform_caching = true
186
- controller.cache_store = store
187
- request = ActionDispatch::TestRequest.new
188
- response = ActionDispatch::TestResponse.new
189
- controller.request = request
190
- controller.response = response
191
- #controller.send(:initialize_template_class, response)
192
- #controller.send(:assign_shortcuts, request, response)
193
- controller.send(:default_url_options).merge!(default_url_options)
194
194
  Current.proxy_for(controller)
195
195
  end
196
196
  end
197
197
 
198
+ def Current.mock_controller_class
199
+ unless const_defined?(:Controller)
200
+ controller_class =
201
+ if defined?(::ApplicationController)
202
+ Class.new(::ApplicationController)
203
+ else
204
+ Class.new(::ActionController::Base)
205
+ end
206
+ const_set(:Controller, controller_class)
207
+ end
208
+ return const_get(:Controller)
209
+ end
210
+
198
211
  def Current.ensure_rails_application(&block)
199
212
  require 'rails' unless defined?(Rails)
200
213
  if Rails.application.nil?
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rails_current"
6
- spec.version = "1.8.2"
6
+ spec.version = "1.9.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rails_current"
9
9
  spec.description = "track 'current_user' et all in a tidy, global, and thread-safe fashion for your rails apps"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_current
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2014-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: map