From 34e96e40beedfbd2d531ad973d2c66052b59b1c6 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Thu, 26 Oct 2017 15:43:14 +0200 Subject: [PATCH] Fix submissions controller test json response --- spec/controllers/submissions_controller_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index d1e489ff..d9ee5316 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -184,13 +184,17 @@ describe SubmissionsController do end describe 'GET #show.json' do + # Render views requested in controller tests in order to get json responses + # https://github.com/rails/jbuilder/issues/32 + render_views + before(:each) { get :show, id: submission.id, format: :json } expect_assigns(submission: :submission) expect_status(200) [:render, :run, :test].each do |action| describe "##{action}_url" do - let(:url) { response.body.send(:"#{action}_url") } + let(:url) { JSON.parse(response.body).with_indifferent_access.fetch("#{action}_url") } it "starts like the #{action} path" do filename = File.basename(__FILE__)