File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ def scenarios(experiment)
3737 config . scenarios experiment
3838 end
3939
40+ def properties
41+ @env [ :properties ]
42+ end
43+
4044 def env
4145 @env ||= {
4246 'conditions' => conditions
Original file line number Diff line number Diff line change 11module AbPanel
22 class Javascript
33 def self . environment
4- props = {
5- distinct_id : AbPanel . env [ "distinct_id" ]
6- } . merge ( AbPanel . env [ :properties ] )
4+ props = { distinct_id : AbPanel . env [ "distinct_id" ] }
5+ props . merge! ( AbPanel . properties ) if AbPanel . properties
76
87 AbPanel . funnels . each { |f | props [ "funnel_#{ f } " ] = true }
98
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe AbPanel ::Javascript do
4+ it 'returns json of all relevant properties, funnels and experiments' do
5+ AbPanel . set_env ( 'distinct_id' , 'distinct_id' )
6+ AbPanel . set_env ( :properties , { post_name : 'test' } )
7+ result = JSON . parse ( AbPanel ::Javascript . environment )
8+ result [ 'distinct_id' ] . should == 'distinct_id'
9+ end
10+
11+ it 'works without extra properties' do
12+ AbPanel . set_env ( :properties , nil )
13+ result = JSON . parse ( AbPanel ::Javascript . environment )
14+ result [ 'distinct_id' ] . should == 'distinct_id'
15+ end
16+ end
You can’t perform that action at this time.
0 commit comments