Skip to content

Commit 147b3b5

Browse files
committed
Fix bug with gon clear with global variables, bump version
1 parent 8af0ac1 commit 147b3b5

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ Thats it!
349349
Puts this line into `Gemfile` then run `$ bundle`:
350350

351351
``` ruby
352-
gem 'gon', '3.0.3'
352+
gem 'gon', '3.0.4'
353353
```
354354

355355
Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
356356

357357
``` ruby
358-
config.gem 'gon', :version => '3.0.3'
358+
config.gem 'gon', :version => '3.0.4'
359359
```
360360

361361
Or manually install gon gem: `$ gem install gon`

lib/gon/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module Base
33
class << self
44

55
def render_data(options)
6+
data = Gon.all_variables || {}
67
if Gon.global.all_variables.present?
7-
Gon::Request.gon['global'] = Gon.global.all_variables
8+
data[:global] = Gon.global.all_variables
89
end
9-
data = Gon.all_variables
1010
namespace = options[:namespace] || 'gon'
1111
need_tag = options[:need_tag].nil? || options[:need_tag]
1212
start = "#{need_tag ? '<script>' : ''}window.#{namespace} = {};"

lib/gon/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def gon
2424
end
2525

2626
def clear
27-
@request_env['gon'] = {}
27+
env && (env[:gon] = {})
2828
end
2929

3030
end

lib/gon/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Gon
2-
VERSION = '3.0.3'
2+
VERSION = '3.0.4'
33
end

spec/gon/global_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
before(:each) do
66
Gon::Global.clear
7+
Gon::Request.instance_variable_set(:@request_env, nil)
78
end
89

910
describe '#all_variables' do
@@ -52,6 +53,7 @@
5253
it 'outputs correct js with an integer and integer in Gon' do
5354
Gon::Request.
5455
instance_variable_set(:@request_id, request.object_id)
56+
Gon::Request.env = {}
5557
Gon.int = 1
5658
Gon.global.int = 1
5759
@base.include_gon.should == "<script>window.gon = {};" +

0 commit comments

Comments
 (0)