rails_current 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rails_current.rb +51 -1
- data/rails_current.gemspec +1 -1
- metadata +2 -2
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.
|
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)
|
data/rails_current.gemspec
CHANGED
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.
|
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-
|
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
|