breezy_template 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,11 @@
1
1
  require 'rails'
2
+ require 'sqlite3'
2
3
  require 'abstract_controller'
3
4
  require 'abstract_controller/railties/routes_helpers'
4
5
  require 'action_controller'
5
6
  require "active_support"
6
7
  require 'active_record'
7
- require 'active_support/testing/autorun' if Rails.version >= '4'
8
+ require 'active_support/testing/autorun'
8
9
  require 'active_support/test_case'
9
10
 
10
11
  require "mocha"
@@ -96,72 +97,65 @@ blog_authors = [ "David Heinemeier Hansson", "Pavel Pravosud" ].cycle
96
97
  BLOG_POST_COLLECTION = Array.new(10){ |i| BlogPost.new(i+1, "post body #{i+1}", blog_authors.next) }
97
98
  COLLECTION_COLLECTION = Array.new(5){ |i| Collection.new(i+1, "collection #{i+1}") }
98
99
 
99
- class BreezyTemplateTestCase < ActionView::TestCase
100
- setup do
101
- self.request_forgery = false
102
- BreezyTemplate.configuration.track_sprockets_assets = []
103
- BreezyTemplate.configuration.track_pack_assets = []
104
-
105
- # this is a stub. Normally this would be set by the
106
- # controller locals
107
- self.breezy = {}
108
-
109
- @context = self
110
- Rails.cache.clear
111
- end
100
+ class FakeView < ActionView::Base
101
+ undef_method :fragment_name_with_digest if method_defined? :fragment_name_with_digest
102
+ undef_method :cache_fragment_name if method_defined? :cache_fragment_name
112
103
 
113
- teardown do
114
- # Mocha didn't auto teardown??
115
- Mocha::Mockery.teardown
104
+ # For Rails 6
105
+ if ActionView::Base.respond_to?(:with_empty_template_cache)
106
+ with_empty_template_cache
116
107
  end
117
108
 
109
+ # this is a stub. Normally this would be set by the
110
+ # controller locals
118
111
  cattr_accessor :request_forgery, :breezy
112
+ self.breezy = {}
119
113
  self.request_forgery = false
120
114
 
121
- def breezy_filter
122
- @breezy_filter
115
+ def view_cache_dependencies; []; end
116
+ def protect_against_forgery?; false; end
117
+
118
+ def form_authenticity_token
119
+ "secret"
123
120
  end
124
121
 
125
122
  def asset_pack_path(asset)
126
- return asset
123
+ asset
127
124
  end
125
+ end
128
126
 
129
- def strip_format(str)
130
- str.strip_heredoc.gsub(/\n\s*/, "")
131
- end
127
+ class BreezyTemplateTestCase < ActiveSupport::TestCase
128
+ setup do
129
+ BreezyTemplate.configuration.track_sprockets_assets = []
130
+ BreezyTemplate.configuration.track_pack_assets = []
132
131
 
133
- def request
134
- @request
132
+ @controller =ActionView::TestCase::TestController.new
133
+ partials = PARTIALS.clone
134
+ resolver = ActionView::FixtureResolver.new(partials)
135
+ @lookup_context = ActionView::LookupContext.new([ resolver ], {}, [""])
136
+ @lookup_context.formats = [:js]
137
+ @view = FakeView.new(@lookup_context, {}, @controller)
138
+
139
+ Rails.cache.clear
135
140
  end
136
141
 
137
- # Stub out a couple of methods that'll get called from cache_fragment_name
138
- def view_cache_dependencies
139
- []
142
+ teardown do
143
+ @controller = nil
144
+ @lookup_context = nil
145
+ @view = nil
146
+
147
+ # Mocha didn't auto teardown??
148
+ Mocha::Mockery.teardown
140
149
  end
141
150
 
142
- def jbuild(source, opts={})
143
- @breezy_filter = opts[:breezy_filter]
144
- @request = opts[:request] || action_controller_test_request
145
- @rendered = []
146
- partials = PARTIALS.clone
147
- partials["test.js.breezy"] = source
148
- resolver = ActionView::FixtureResolver.new(partials)
149
- lookup_context.view_paths = [resolver]
150
- lookup_context.formats = [:js]
151
- template = ActionView::Template.new(source, "test", BreezyTemplate::Handler, virtual_path: "test")
152
- template.render(self, {}).strip
151
+ def strip_format(str)
152
+ str.gsub(/\n\s*/, "")
153
153
  end
154
154
 
155
- def action_controller_test_request
156
- if ::Rails.version.start_with?('5.2')
157
- ::ActionController::TestRequest.create({})
158
- elsif ::Rails.version.start_with?('5.1')
159
- ::ActionController::TestRequest.create({})
160
- elsif ::Rails.version.start_with?('5')
161
- ::ActionController::TestRequest.create
162
- else
163
- ::ActionController::TestRequest.new
164
- end
155
+ def jbuild(source, options={})
156
+ @view.assign(options.fetch(:assigns, {}))
157
+ template = ActionView::Template.new(source, "test", BreezyTemplate::Handler, virtual_path: "test", locals: [])
158
+ template.render(@view, {}).strip
165
159
  end
166
160
 
167
161
  def cache_keys
@@ -172,17 +166,5 @@ class BreezyTemplateTestCase < ActionView::TestCase
172
166
  keys = YAML.load_file(path)
173
167
  keys[method_name][rails_v]
174
168
  end
175
-
176
- def undef_context_methods(*names)
177
- self.class_eval do
178
- names.each do |name|
179
- undef_method name.to_sym if method_defined?(name.to_sym)
180
- end
181
- end
182
- end
183
-
184
- def form_authenticity_token
185
- "secret"
186
- end
187
169
  end
188
170
 
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breezy_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johny Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2019-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: actionpack
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: activesupport
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '5.0'
19
+ version: 5.0.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '5.0'
26
+ version: 5.0.0
41
27
  - !ruby/object:Gem::Dependency
42
- name: multi_json
28
+ name: actionpack
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '1.2'
48
- type: :runtime
33
+ version: 5.0.0
34
+ type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '1.2'
40
+ version: 5.0.0
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: mocha
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +106,7 @@ require_paths:
120
106
  - lib
121
107
  required_ruby_version: !ruby/object:Gem::Requirement
122
108
  requirements:
123
- - - "~>"
109
+ - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '2.3'
126
112
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -130,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
116
  version: '0'
131
117
  requirements: []
132
118
  rubyforge_project:
133
- rubygems_version: 2.5.2
119
+ rubygems_version: 2.6.11
134
120
  signing_key:
135
121
  specification_version: 4
136
122
  summary: Breezy Templates for React props