gon 6.2.0 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gon might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c19eee4ca6c0cff3ee98d241cec763d760538dde
4
- data.tar.gz: e8a58a191ac62e622c5f172c879a693852fce131
2
+ SHA256:
3
+ metadata.gz: dd7174b8f5d1b62bee948c0f44209496833d931a77feb0e5d1c9b77ec32ea477
4
+ data.tar.gz: d704723d05a03958b993a20e6f71a71f06d5ddd66407fa7dc56b118ce5db3170
5
5
  SHA512:
6
- metadata.gz: bac0b2f0b276f6e22a0a4f5e1d7820d2789410f980b02f329a6e1a713ace8c18c85e9c1211eab634193b5e54cc0c54c3a2728b47ef7a3568866a5cfa92a5616e
7
- data.tar.gz: 1fdd5df1b97870e96dfc7b357aa5af95406b7e8b574b9c811b7a43d79a8637af1fc9716e8e0ff1e45718b261b718dec8c3a18253a3f59e309b7465490b90c55e
6
+ metadata.gz: b3f2e623bc54fe8058ca00e9cce8b3f15e9f9129833d5a99ae5aecf7b1365f63084ed9e8a307b759273c8fa561298cd246c0bf9fac87f97014ab93d4007989e5
7
+ data.tar.gz: 81aed53ece55c3dae69aea03741867b97c0389fcd1500401de2c6c2d4f25d63fa670056e3c73385a78d20bb5b57f0bdf9d846b769eaf1577e6668b52da7772da
@@ -1,5 +1,9 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ env:
4
+ - "RABL_GEM=rabl"
5
+ - "RABL_GEM=rabl-rails"
6
+
3
7
  rvm:
4
8
  - 2.3.3
5
9
  - 2.4.0
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in gon.gemspec
4
+ gem ENV['RABL_GEM'] || 'rabl'
5
+
4
6
  gemspec
data/README.md CHANGED
@@ -40,7 +40,7 @@ you might be doing something like this:
40
40
  that) - you just use data from this js - OK.
41
41
  4. You can use your data in your js
42
42
 
43
- And everytime when you need to send some data from action to js you do this.
43
+ And every time when you need to send some data from action to js you do this.
44
44
 
45
45
  With gon you configure it firstly - just put in layout one tag, and add
46
46
  gem line to your Gemfile and do the following:
@@ -124,7 +124,7 @@ class Gon
124
124
 
125
125
  def convert_key(key, camelize)
126
126
  cache = RequestStore.store[:gon_keys_cache] ||= {}
127
- cache[key] ||= camelize ? key.to_s.camelize(:lower) : key.to_s
127
+ cache["#{key}_#{camelize}"] ||= camelize ? key.to_s.camelize(:lower) : key.to_s
128
128
  end
129
129
 
130
130
  end
@@ -24,7 +24,7 @@ class Gon
24
24
  end
25
25
  end
26
26
 
27
- if defined?(ActionController::TestCase::Behavior)
27
+ if ENV['RAILS_ENV'] == 'test' && defined?(ActionController::TestCase::Behavior)
28
28
  ActionController::TestCase::Behavior.send :include, Gon::SpecHelper::Rails
29
29
  end
30
30
 
@@ -1,3 +1,3 @@
1
1
  class Gon
2
- VERSION = '6.2.0'
2
+ VERSION = '6.2.1'
3
3
  end
@@ -159,6 +159,16 @@ describe Gon do
159
159
  )
160
160
  end
161
161
 
162
+ it 'outputs correct key with camel_case option set alternately ' do
163
+ Gon.test_hash = 1
164
+ @base.include_gon(camel_case: true)
165
+
166
+ expect(@base.include_gon(camel_case: false)).to eq(
167
+ wrap_script('window.gon={};' +
168
+ 'gon.test_hash=1;')
169
+ )
170
+ end
171
+
162
172
  it 'outputs correct js with an integer and without tag' do
163
173
  Gon.int = 1
164
174
  expect(@base.include_gon(need_tag: false)).to eq( \
@@ -1,9 +1,4 @@
1
1
  describe Gon do
2
-
3
- before(:all) do
4
- ensure_rabl_is_loaded
5
- end
6
-
7
2
  describe '.rabl' do
8
3
 
9
4
  before :each do
@@ -14,50 +14,6 @@ end
14
14
  require 'gon'
15
15
 
16
16
  require 'jbuilder'
17
- require 'rabl'
18
- require 'rabl-rails'
19
-
20
- # rabl has a conflict with rabl-rails as rabl-rails causes Rails
21
- # to be defined. In order to run all specs at once, we'll need to
22
- # load/unload rabl and rabl-rails whenever we switch from testing
23
- # one to another.
24
- def ensure_rabl_is_loaded
25
- Object.send(:remove_const, :RablRails) if defined? RablRails
26
- Object.send(:remove_const, :Rails) if defined? Rails
27
- unless defined? Rabl
28
- load 'rabl.rb'
29
- load 'rabl/version.rb'
30
- load 'rabl/helpers.rb'
31
- load 'rabl/sources.rb'
32
- load 'rabl/partials.rb'
33
- load 'rabl/multi_builder.rb'
34
- load 'rabl/builder.rb'
35
- load 'rabl/engine.rb'
36
- load 'rabl/configuration.rb'
37
- load 'rabl/renderer.rb'
38
- load 'rabl/cache_engine.rb'
39
- end
40
- end
41
-
42
- # Unloads rabl and loads rabl-rails.
43
- def ensure_rabl_rails_is_loaded
44
- Object.send(:remove_const, :Rabl) if defined? Rabl
45
- unless defined? RablRails
46
- load 'rabl-rails/renderer.rb'
47
- load 'rabl-rails/helpers.rb'
48
- load 'rabl-rails/configuration.rb'
49
- load 'rabl-rails/nodes/node.rb'
50
- load 'rabl-rails/nodes/attribute.rb'
51
- load 'rabl-rails/compiler.rb'
52
- load 'rabl-rails/renderers/hash.rb'
53
- load 'rabl-rails/renderers/json.rb'
54
- load 'rabl-rails/renderers/xml.rb'
55
- load 'rabl-rails/renderers/plist.rb'
56
- load 'rabl-rails.rb'
57
- load 'rabl-rails/template.rb'
58
- load 'rabl-rails/library.rb'
59
- end
60
- end
61
17
 
62
18
  RSpec.configure do |config|
63
19
  config.before(:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gazay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -189,8 +189,7 @@ files:
189
189
  - spec/gon/basic_spec.rb
190
190
  - spec/gon/global_spec.rb
191
191
  - spec/gon/jbuilder_spec.rb
192
- - spec/gon/rabl_with_rabl_rails_spec.rb
193
- - spec/gon/rabl_with_rabl_spec.rb
192
+ - spec/gon/rabl_spec.rb
194
193
  - spec/gon/templates_spec.rb
195
194
  - spec/gon/thread_spec.rb
196
195
  - spec/gon/watch_spec.rb
@@ -226,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
225
  version: '0'
227
226
  requirements: []
228
227
  rubyforge_project:
229
- rubygems_version: 2.5.2.1
228
+ rubygems_version: 2.7.6
230
229
  signing_key:
231
230
  specification_version: 4
232
231
  summary: Get your Rails variables in your JS
@@ -1,63 +0,0 @@
1
- describe Gon do
2
-
3
- before(:all) do
4
- ensure_rabl_rails_is_loaded
5
- RablRails.configuration.cache_templates = false
6
- end
7
-
8
- describe '.rabl with rabl-rails gem' do
9
-
10
- before :each do
11
- Gon.clear
12
- controller.instance_variable_set('@objects', objects)
13
- controller.request = ActionDispatch::TestRequest.create
14
- end
15
-
16
- let(:controller) { ActionController::Base.new }
17
- let(:objects) { [1, 2] }
18
-
19
- context 'render template with deprecation' do
20
- it 'still works' do
21
- Gon.rabl 'spec/test_data/sample_rabl_rails.rabl', :controller => controller
22
- expect(Gon.objects.length).to eq(2)
23
- end
24
- end
25
-
26
- context 'option locals' do
27
- it 'works without locals object properly' do
28
- Gon.rabl(
29
- :template =>'spec/test_data/sample_rabl_rails.rabl',
30
- :controller => controller
31
- )
32
- expect(Gon.objects.map { |it| it['inspect'] }).to eq(%w(1 2))
33
- end
34
-
35
- it 'works with different locals object' do
36
- Gon.rabl(
37
- :template => 'spec/test_data/sample_rabl_rails.rabl',
38
- :controller => controller,
39
- :locals => { :objects => [3, 4] }
40
- )
41
- expect(Gon.objects.map { |it| it['inspect'] }).to eq(%w(3 4))
42
- end
43
- end
44
-
45
- it 'works if rabl-rails is included' do
46
- Gon.rabl :template => 'spec/test_data/sample_rabl_rails.rabl', :controller => controller
47
- expect(Gon.objects.length).to eq(2)
48
- end
49
-
50
- it 'works with ActionView::Helpers' do
51
- Gon.rabl :template =>'spec/test_data/sample_with_helpers_rabl_rails.rabl', :controller => controller
52
- expect(Gon.objects.first['time_ago']).to eq('about 6 hours')
53
- end
54
-
55
- it 'raise exception if rabl or rabl-rails is not included' do
56
- Object.send :remove_const, :RablRails # ensure_rabl_rails_is_loaded method already removed Rabl
57
- expect { Gon.rabl :template => 'spec/test_data/sample.rabl', :controller => controller}.to raise_error(RuntimeError)
58
- ensure_rabl_rails_is_loaded # load up rabl-rails again, we're not done testing
59
- end
60
-
61
- end
62
-
63
- end