add streaming templates: part 2

adds template streaming to the following endpoints:

assignments#show
context_modules#index
courses#show
discussion_topics#show
quizzes/quizzes#show
quizzes/quizzes#edit
quizzes/quizzes#history

Change-Id: I2481f3f738077fb0eaef16e6b5f0db3ea6f60c16
Reviewed-on: https://gerrit.instructure.com/202708
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
James Williams 2019-07-25 14:01:44 -06:00
parent e962475942
commit f888621298
8 changed files with 23 additions and 5 deletions

View File

@ -2531,7 +2531,14 @@ class ApplicationController < ActionController::Base
end
def can_stream_template?
Setting.get("disable_template_streaming_all", "false") != "true" &&
Setting.get("disable_template_streaming_for_#{controller_name}/#{action_name}", "false") != "true"
if ::Rails.env.test?
# don't actually stream because it kills selenium
# but still set the instance variable so we catch errors that we'd encounter streaming frd
@streaming_template = true
false
else
Setting.get("disable_template_streaming_all", "false") != "true" &&
Setting.get("disable_template_streaming_for_#{controller_name}/#{action_name}", "false") != "true"
end
end
end

View File

@ -258,7 +258,7 @@ class AssignmentsController < ApplicationController
render locals: {
eula_url: tool_eula_url,
show_moderation_link: @assignment.moderated_grading? && @assignment.permits_moderation?(@current_user)
}
}, stream: can_stream_template?
end
end
end

View File

@ -114,6 +114,7 @@ class ContextModulesController < ApplicationController
add_body_class('padless-content')
js_bundle :context_modules
css_bundle :content_next, :context_modules2
render stream: can_stream_template?
end
end

View File

@ -1866,6 +1866,7 @@ class CoursesController < ApplicationController
add_crumb(t('#crumbs.modules', "Modules"))
load_modules
when 'syllabus'
set_active_tab "syllabus"
rce_js_env
add_crumb(t('#crumbs.syllabus', "Syllabus"))
@groups = @context.assignment_groups.active.order(
@ -1923,6 +1924,9 @@ class CoursesController < ApplicationController
elsif @context.available?
content_for_head helpers.auto_discovery_link_tag(:atom, feeds_course_format_path(@context.feed_code, :atom), {:title => t("Course Atom Feed")})
end
set_active_tab "home" unless get_active_tab
render stream: can_stream_template?
elsif @context.indexed && @context.available?
render :description
else

View File

@ -793,6 +793,7 @@ class DiscussionTopicsController < ApplicationController
end
end
render stream: can_stream_template?
end
end
end

View File

@ -273,6 +273,7 @@ class Quizzes::QuizzesController < ApplicationController
log_asset_access(@quiz, "quizzes", "quizzes")
js_bundle :quiz_show
css_bundle :quizzes, :learning_outcomes
render stream: can_stream_template? unless @declined_reason
end
end
@padless = true
@ -361,7 +362,7 @@ class Quizzes::QuizzesController < ApplicationController
js_bundle :quizzes_bundle
css_bundle :quizzes, :tinymce
render :new
render :new, stream: can_stream_template?
end
end
@ -741,6 +742,7 @@ class Quizzes::QuizzesController < ApplicationController
end
js_bundle :quiz_history
@google_analytics_page_title = @quiz.survey? ? "User's Survey History" : "User's Quiz History"
render stream: can_stream_template?
end
end
end

View File

@ -17,7 +17,7 @@
%>
<% provide :page_title, @context.name %>
<% set_active_tab "home" unless get_active_tab %>
<h1 class='screenreader-only'><%= @context.name %></h1>
<% provide :right_side do %>

View File

@ -86,6 +86,9 @@ end
ActionController::Base.set_callback(:process_action, :around,
->(_r, block) { SpecTransactionWrapper.wrap_block_in_transaction(block) })
ActionController::Base.set_callback(:process_action, :before,
->(_r) { @streaming_template = false })
module RSpec::Core::Hooks
class AfterContextHook < Hook
def run(example)