Skip to content

Commit b922bf5

Browse files
committed
Added spec for partial rendering in jbuilder
1 parent 82c6053 commit b922bf5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

spec/gon/gon_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@
5858
Gon.objects.length.should == 2
5959
end
6060

61+
it 'render json from jbuilder template with a partial' do
62+
Gon.clear
63+
controller = ActionController::Base.new
64+
controller.view_paths << 'spec/test_data'
65+
objects = [1,2]
66+
controller.instance_variable_set('@objects', objects)
67+
Gon.jbuilder 'spec/test_data/sample_with_partial.json.jbuilder', :controller => controller
68+
Gon.objects.length.should == 2
69+
end
70+
6171
def request
6272
@request ||= double 'request', :env => {}
6373
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
json.objects objects
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
json.partial! 'sample_partial', :objects => @objects

0 commit comments

Comments
 (0)