spicycode-micronaut-rails 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 2
3
- :patch: 3
2
+ :patch: 4
4
3
  :major: 0
4
+ :minor: 2
@@ -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, deprecated_status_or_extra_options=nil, &block)
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
- unless render_views?
39
- if @template.respond_to?(:finder)
40
- (class << @template.finder; self; end).class_eval do
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
- define_method :render_file do |*args|
51
- @first_render ||= args[0] unless args[0] =~ /^layouts/
52
- @_first_render ||= args[0] unless args[0] =~ /^layouts/
53
- end
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, deprecated_status_or_extra_options, &block)
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(kls)
79
- Micronaut.configuration.trace { "In #{self} extended callback for #{kls}"}
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
- kls.before do
79
+ extended_behaviour.before do
86
80
  @controller = self.class.describes.new
87
- Micronaut.configuration.trace { "Enhancing #{@controller.inspect} with Rails controller extensions" }
88
- @controller.class.send :include, RenderOverrides
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
@@ -15,5 +15,5 @@ module Micronaut
15
15
  end
16
16
 
17
17
  if defined?(::ActiveRecord::Base)
18
- ::ActiveRecord::Base.send(:include, Micronaut::Rails::Extensions::ActiveRecord)
18
+ ::ActiveRecord::Base.send(:include, ::Micronaut::Rails::Extensions::ActiveRecord)
19
19
  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) && !ActiveRecord::Base.configurations.blank?
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
@@ -1,5 +1,3 @@
1
- require 'action_controller'
2
- require 'action_controller/test_process'
3
1
  require 'micronaut/rails/configuration'
4
2
  require 'micronaut/rails/matchers/controllers/redirect_to'
5
3
  require 'micronaut/rails/matchers/controllers/render_template'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spicycode-micronaut-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries