futurism 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 313e2de708762f264a6b0b647e9ae7e1eff5f2463e4ba852e95696ffd8706fb3
4
- data.tar.gz: 73f61a471267578dba1e2460cb0c388d96bdf46a52bcae5a047e9c729fe76095
3
+ metadata.gz: 4e79c03c8d157585784ab3e4f48d2660100acad4e317aa378cdfa94a0c5a3fb9
4
+ data.tar.gz: 5036367ba790b660ef6230e6155192cfedd65973fa65e00fd7b53f071f8a6ae8
5
5
  SHA512:
6
- metadata.gz: f205ad83640359aaaf72414069bd8a287faf5177b8ec320298c39b82db75eedab9799c45cbff003478804f432d033fc6fe65522ca1de7a5932601fe387c7e8a2
7
- data.tar.gz: 56b67210ed5b229298e07216d5b920b358c43758d825ce6dc906faf4a2289dc20feafb2aa8e25ff846802c8ca6bc8fce6061c20f210b1a37690d5798349cac7d
6
+ metadata.gz: cf2acd22c20fd40897b6caed2ad897eec3cc98f7ea1fbd9ab31ea19cf276cfa2f94f04ef87a16fe8c68ec03dab1e4e5832a1f4026fe269c58b8114dd1aecb54a
7
+ data.tar.gz: bda0591fb9174ebd6499839be5bfdb8512d8c7c110b9af837f6d8425eb6e9180384234fd493df1945fe51c021c2a0ab0e8ee5537238babd00617ca9bf4a16d8b
data/README.md CHANGED
@@ -25,6 +25,7 @@ Lazy-load Rails partials via CableReady
25
25
  - [Installation](#installation)
26
26
  - [Manual Installation](#manual-installation)
27
27
  - [Authentication](#authentication)
28
+ - [Testing](#testing)
28
29
  - [Gotchas](#gotchas)
29
30
  - [Contributing](#contributing)
30
31
  - [License](#license)
@@ -213,6 +214,15 @@ end
213
214
 
214
215
  The [Stimulus Reflex Docs](https://docs.stimulusreflex.com/authentication) have an excellent section about all sorts of authentication.
215
216
 
217
+ ## Testing
218
+ In Rails system tests there is a chance that flaky errors will occur due to Capybara not waiting for the placeholder elements to be replaced. To overcome this, add the flag
219
+
220
+ ```ruby
221
+ Futurism.skip_in_test = true
222
+ ```
223
+
224
+ to an initializer, for example `config/initializers/futurism.rb`.
225
+
216
226
  ## Gotchas
217
227
 
218
228
  ### ActiveStorage URLs aren't correct in development
@@ -10,6 +10,8 @@ module Futurism
10
10
 
11
11
  autoload :Helpers, "futurism/helpers"
12
12
 
13
+ mattr_accessor :skip_in_test
14
+
13
15
  ActiveSupport.on_load(:action_view) {
14
16
  include Futurism::Helpers
15
17
  }
@@ -1,5 +1,16 @@
1
+ require "rails"
2
+ require "action_cable"
3
+ require "cable_ready"
1
4
  require "futurism/engine"
5
+ require "futurism/channel"
6
+ require "futurism/helpers"
2
7
 
3
8
  module Futurism
4
- # Your code goes here...
9
+ extend ActiveSupport::Autoload
10
+
11
+ autoload :Helpers, "futurism/helpers"
12
+
13
+ ActiveSupport.on_load(:action_view) {
14
+ include Futurism::Helpers
15
+ }
5
16
  end
@@ -1,6 +1,14 @@
1
1
  module Futurism
2
2
  module Helpers
3
3
  def futurize(records_or_string = nil, extends:, **options, &block)
4
+ if Rails.env.test? && Futurism.skip_in_test
5
+ if records_or_string.nil?
6
+ return render **options
7
+ else
8
+ return render records_or_string, **options
9
+ end
10
+ end
11
+
4
12
  placeholder = capture(&block)
5
13
 
6
14
  if records_or_string.is_a?(ActiveRecord::Base) || records_or_string.is_a?(ActiveRecord::Relation)
@@ -1,6 +1,15 @@
1
1
  module Futurism
2
2
  module Helpers
3
3
  def futurize(records_or_string = nil, extends:, **options, &block)
4
+ if Rails.env.test? && Futurism.skip_in_test
5
+ if records_or_string.nil?
6
+ render options
7
+ else
8
+ render records_or_string, options
9
+ end
10
+ return
11
+ end
12
+
4
13
  placeholder = capture(&block)
5
14
 
6
15
  if records_or_string.is_a?(ActiveRecord::Base) || records_or_string.is_a?(ActiveRecord::Relation)
@@ -36,11 +45,12 @@ module Futurism
36
45
  class Element
37
46
  include ActionView::Helpers
38
47
 
39
- attr_reader :extends, :placeholder, :html_options, :data_attributes, :model, :options
48
+ attr_reader :extends, :placeholder, :html_options, :data_attributes, :model, :options, :eager
40
49
 
41
50
  def initialize(extends:, placeholder:, options:)
42
51
  @extends = extends
43
52
  @placeholder = placeholder
53
+ @eager = options.delete(:eager)
44
54
  @html_options = options.delete(:html_options) || {}
45
55
  @data_attributes = html_options.fetch(:data, {}).except(:sgid, :signed_params)
46
56
  @model = options.delete(:model)
@@ -50,7 +60,8 @@ module Futurism
50
60
  def dataset
51
61
  data_attributes.merge({
52
62
  signed_params: signed_params,
53
- sgid: model && model.to_sgid.to_s
63
+ sgid: model && model.to_sgid.to_s,
64
+ eager: eager.presence
54
65
  })
55
66
  end
56
67
 
@@ -1,3 +1,3 @@
1
1
  module Futurism
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: futurism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal