spicycode-micronaut-rails 0.2.3 → 0.2.4
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/VERSION.yml +2 -2
- data/lib/micronaut/rails/controllers.rb +37 -46
- data/lib/micronaut/rails/extensions/active_record.rb +1 -1
- data/lib/micronaut/rails/matchers/controllers/render_template.rb +2 -0
- data/lib/micronaut/rails/transactional_database_support.rb +7 -7
- data/lib/micronaut-rails.rb +0 -2
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
require 'action_controller/test_process'
|
3
|
+
|
1
4
|
module Micronaut
|
2
5
|
module Rails
|
3
6
|
module Controllers
|
@@ -14,11 +17,11 @@ module Micronaut
|
|
14
17
|
ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
|
15
18
|
ActionController::Routing::Routes.recognize_path(path, :method => method)
|
16
19
|
end
|
17
|
-
|
20
|
+
|
18
21
|
end
|
19
22
|
|
20
23
|
module RenderOverrides
|
21
|
-
|
24
|
+
|
22
25
|
def render_views!
|
23
26
|
@render_views = true
|
24
27
|
end
|
@@ -27,42 +30,36 @@ module Micronaut
|
|
27
30
|
@render_views
|
28
31
|
end
|
29
32
|
|
30
|
-
def render(options=nil,
|
31
|
-
if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
|
32
|
-
deprecated_status_or_extra_options = {}
|
33
|
-
end
|
34
|
-
Micronaut.configuration.trace { "In RenderOverrides#render with options => #{options.inspect}, deprecated_status_or_extra_options => #{deprecated_status_or_extra_options.inspect}, render_views? => #{render_views?.inspect}"}
|
33
|
+
def render(options=nil, &block)
|
35
34
|
response.headers['Status'] = interpret_status((options.is_a?(Hash) && options[:status]) || ::ActionController::Base::DEFAULT_RENDER_STATUS_CODE)
|
36
|
-
|
37
|
-
unless block_given?
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
define_method :file_exists? do; true; end
|
42
|
-
end
|
43
|
-
else
|
44
|
-
(class << @template; self; end).class_eval do
|
45
|
-
define_method :file_exists? do; true; end
|
46
|
-
end
|
35
|
+
|
36
|
+
unless block_given? || render_views?
|
37
|
+
if @template.respond_to?(:finder)
|
38
|
+
(class << @template.finder; self; end).class_eval do
|
39
|
+
define_method :file_exists? do; true; end
|
47
40
|
end
|
41
|
+
else
|
48
42
|
(class << @template; self; end).class_eval do
|
43
|
+
define_method :file_exists? do; true; end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
(class << @template; self; end).class_eval do
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
define_method :_pick_template do |*args|
|
56
|
-
@_first_render ||= args[0] unless args[0] =~ /^layouts/
|
57
|
-
PickedTemplate.new
|
58
|
-
end
|
48
|
+
define_method :render_file do |*args|
|
49
|
+
@first_render ||= args[0] unless args[0] =~ /^layouts/
|
50
|
+
@_first_render ||= args[0] unless args[0] =~ /^layouts/
|
51
|
+
end
|
59
52
|
|
53
|
+
define_method :_pick_template do |*args|
|
54
|
+
@_first_render ||= args[0] unless args[0] =~ /^layouts/
|
55
|
+
PickedTemplate.new
|
60
56
|
end
|
61
|
-
|
57
|
+
|
62
58
|
end
|
59
|
+
|
63
60
|
end
|
64
|
-
|
65
|
-
super(options,
|
61
|
+
|
62
|
+
super(options, &block)
|
66
63
|
end
|
67
64
|
|
68
65
|
end
|
@@ -75,28 +72,22 @@ module Micronaut
|
|
75
72
|
def render_partial(*ignore_args); end
|
76
73
|
end
|
77
74
|
|
78
|
-
def self.extended(
|
79
|
-
|
80
|
-
|
81
|
-
kls.send(:include, ActionController::TestProcess)
|
82
|
-
kls.send(:include, InstanceMethods)
|
83
|
-
kls.send(:include, Micronaut::Rails::Matchers::Controllers)
|
75
|
+
def self.extended(extended_behaviour)
|
76
|
+
extended_behaviour.send :include, ::ActionController::TestProcess, InstanceMethods, ::Micronaut::Rails::Matchers::Controllers
|
77
|
+
extended_behaviour.describes.send :include, RenderOverrides, ::ActionController::TestCase::RaiseActionExceptions
|
84
78
|
|
85
|
-
|
79
|
+
extended_behaviour.before do
|
86
80
|
@controller = self.class.describes.new
|
87
|
-
|
88
|
-
@
|
89
|
-
@controller.class.send :include, ActionController::TestCase::RaiseActionExceptions
|
90
|
-
@request = ActionController::TestRequest.new
|
91
|
-
@controller.request = @request
|
92
|
-
@response = ActionController::TestResponse.new
|
93
|
-
@controller.params = {}
|
94
|
-
@controller.send(:initialize_current_url)
|
81
|
+
@controller.request = @request = ::ActionController::TestRequest.new
|
82
|
+
@response = ::ActionController::TestResponse.new
|
95
83
|
@response.session = @request.session
|
84
|
+
|
85
|
+
@controller.params = {}
|
86
|
+
@controller.send(:initialize_current_url)
|
96
87
|
end
|
97
88
|
|
98
89
|
end
|
99
90
|
|
100
91
|
end
|
101
92
|
end
|
102
|
-
end
|
93
|
+
end
|
@@ -13,6 +13,8 @@ module Micronaut
|
|
13
13
|
def matches?(response)
|
14
14
|
if response.respond_to?(:rendered_file)
|
15
15
|
@actual = response.rendered_file
|
16
|
+
elsif response.respond_to?(:captured_render)
|
17
|
+
@actual = @controller.captured_render
|
16
18
|
else
|
17
19
|
@actual = response.rendered_template.to_s
|
18
20
|
end
|
@@ -5,25 +5,25 @@ module Micronaut
|
|
5
5
|
module InstanceMethods
|
6
6
|
|
7
7
|
def active_record_configured?
|
8
|
-
defined?(ActiveRecord) &&
|
8
|
+
defined?(::ActiveRecord) && !::ActiveRecord::Base.configurations.blank?
|
9
9
|
end
|
10
10
|
|
11
11
|
def transactional_protection_start
|
12
12
|
return unless active_record_configured?
|
13
13
|
|
14
|
-
ActiveRecord::Base.connection.increment_open_transactions
|
15
|
-
ActiveRecord::Base.connection.begin_db_transaction
|
14
|
+
::ActiveRecord::Base.connection.increment_open_transactions
|
15
|
+
::ActiveRecord::Base.connection.begin_db_transaction
|
16
16
|
end
|
17
17
|
|
18
18
|
def transactional_protection_cleanup
|
19
19
|
return unless active_record_configured?
|
20
20
|
|
21
|
-
if ActiveRecord::Base.connection.open_transactions != 0
|
22
|
-
ActiveRecord::Base.connection.rollback_db_transaction
|
23
|
-
ActiveRecord::Base.connection.decrement_open_transactions
|
21
|
+
if ::ActiveRecord::Base.connection.open_transactions != 0
|
22
|
+
::ActiveRecord::Base.connection.rollback_db_transaction
|
23
|
+
::ActiveRecord::Base.connection.decrement_open_transactions
|
24
24
|
end
|
25
25
|
|
26
|
-
ActiveRecord::Base.clear_active_connections!
|
26
|
+
::ActiveRecord::Base.clear_active_connections!
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/micronaut-rails.rb
CHANGED