rails_current 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rails_current.rb CHANGED
@@ -4,7 +4,7 @@ require 'map'
4
4
 
5
5
  module Current
6
6
  def Current.version
7
- '1.5.0'
7
+ '1.6.0'
8
8
  end
9
9
 
10
10
  def Current.data
@@ -140,6 +140,56 @@ module Current
140
140
  super
141
141
  end
142
142
  end
143
+
144
+ def Current.mock_controller(options = {})
145
+ require 'rails'
146
+ require 'action_controller'
147
+ require 'action_dispatch/testing/test_request.rb'
148
+ require 'action_dispatch/testing/test_response.rb'
149
+
150
+ default_url_options =
151
+ begin
152
+ require 'rails_default_url_options'
153
+ DefaultUrlOptions
154
+ rescue LoadError
155
+ options[:default_url_options] || {}
156
+ end
157
+
158
+ ensure_rails_application do
159
+ store = ActiveSupport::Cache::MemoryStore.new
160
+ controller =
161
+ begin
162
+ ApplicationController.new
163
+ rescue NameError
164
+ ActionController::Base.new
165
+ end
166
+ controller.perform_caching = true
167
+ controller.cache_store = store
168
+ request = ActionDispatch::TestRequest.new
169
+ response = ActionDispatch::TestResponse.new
170
+ controller.request = request
171
+ controller.response = response
172
+ #controller.send(:initialize_template_class, response)
173
+ #controller.send(:assign_shortcuts, request, response)
174
+ controller.send(:default_url_options).merge!(default_url_options)
175
+ controller
176
+ end
177
+ end
178
+
179
+ def Current.ensure_rails_application(&block)
180
+ require 'rails' unless defined?(Rails)
181
+ if Rails.application.nil?
182
+ mock = Class.new(Rails::Application)
183
+ Rails.application = mock.instance
184
+ begin
185
+ block.call()
186
+ ensure
187
+ Rails.application = nil
188
+ end
189
+ else
190
+ block.call()
191
+ end
192
+ end
143
193
  end
144
194
 
145
195
  def Current(*args, &block)
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rails_current"
6
- spec.version = "1.5.0"
6
+ spec.version = "1.6.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rails_current"
9
9
  spec.description = "description: rails_current kicks the ass"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_current
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-16 00:00:00.000000000 Z
12
+ date: 2012-02-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'description: rails_current kicks the ass'
15
15
  email: ara.t.howard@gmail.com