From 69a84608799839146dfe3a823969a02074082a60 Mon Sep 17 00:00:00 2001 From: Jason Madsen Date: Mon, 11 Nov 2013 12:28:30 -0700 Subject: [PATCH] create fabulous quiz entry point closes CNVS-9394 test plan: - visit quiz index - verify current quiz system displayed - enable fabulous quizzes - visit quiz index - verify ember / fabulous quizzes skeleton displays Change-Id: Ie0737328b9aaa7bb2f97dc78647107b4ff9a7be2 Reviewed-on: https://gerrit.instructure.com/26204 Tested-by: Jenkins Reviewed-by: Stanley Stuart QA-Review: Myller de Araujo Product-Review: Jason Madsen --- app/controllers/quizzes_controller.rb | 9 ++++ app/views/quizzes/fabulous_quizzes.html.erb | 1 + config/routes.rb | 3 ++ spec/controllers/quizzes_controller_spec.rb | 60 +++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 app/views/quizzes/fabulous_quizzes.html.erb diff --git a/app/controllers/quizzes_controller.rb b/app/controllers/quizzes_controller.rb index 7d34e0d77f2..b3ed382e5ad 100644 --- a/app/controllers/quizzes_controller.rb +++ b/app/controllers/quizzes_controller.rb @@ -33,6 +33,9 @@ class QuizzesController < ApplicationController def index if authorized_action(@context, @current_user, :read) + if @context.root_account.enable_fabulous_quizzes? + redirect_to fabulous_quizzes_course_quizzes_path + end return unless tab_enabled?(@context.class::TAB_QUIZZES) @quizzes = @context.quizzes.active.include_assignment.sort_by{|q| [(q.assignment ? q.assignment.due_at : q.lock_at) || SortLast, Canvas::ICU.collation_key(q.title || SortFirst)]} @@ -82,6 +85,12 @@ class QuizzesController < ApplicationController end end + def fabulous_quizzes + if !@context.root_account.enable_fabulous_quizzes? || !authorized_action(@context, @current_user, :read) + redirect_to course_quizzes_path + end + end + def show if @quiz.deleted? flash[:error] = t('errors.quiz_deleted', "That quiz has been deleted") diff --git a/app/views/quizzes/fabulous_quizzes.html.erb b/app/views/quizzes/fabulous_quizzes.html.erb new file mode 100644 index 00000000000..714bd9cab48 --- /dev/null +++ b/app/views/quizzes/fabulous_quizzes.html.erb @@ -0,0 +1 @@ +

Fabulous Ember Quizzes

diff --git a/config/routes.rb b/config/routes.rb index 4aa40b81c85..1e3f7c9f069 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -317,6 +317,9 @@ FakeRails3Routes.draw do match 'statistics' => 'quizzes#statistics', :as => :statistics match 'read_only' => 'quizzes#read_only', :as => :read_only match 'filters' => 'quizzes#filters', :as => :filters + collection do + get :fabulous_quizzes + end resources :quiz_submissions, :path => :submissions do collection do put :backup diff --git a/spec/controllers/quizzes_controller_spec.rb b/spec/controllers/quizzes_controller_spec.rb index abab048cf05..73216913868 100644 --- a/spec/controllers/quizzes_controller_spec.rb +++ b/spec/controllers/quizzes_controller_spec.rb @@ -129,6 +129,66 @@ describe QuizzesController do end end + describe "GET 'index' without fabulous quizzes enabled" do + before :each do + a = Account.default + a.disable_fabulous_quizzes! + a.save! + end + + after :each do + a = Account.default + a.enable_fabulous_quizzes! + a.save! + end + + it "should not redirect" do + course_with_teacher_logged_in(:active_all => true) + course_quiz(active = true) + a = Account.default + a.enable_fabulous_quizzes?.should eql false + get 'index', :course_id => @course.id + assert_response(:success) + end + end + + describe "GET 'index' with fabulous quizzes enabled" do + before :each do + a = Account.default + a.enable_fabulous_quizzes! + a.save! + end + + after :each do + a = Account.default + a.disable_fabulous_quizzes! + a.save! + end + + it "should redirect to fabulous quizzes app" do + course_with_teacher_logged_in(:active_all => true) + course_quiz(active = true) + a = Account.default + a.enable_fabulous_quizzes?.should eql true + get 'index', :course_id => @course.id + assert_redirected_to(:controller => "quizzes", :action => "fabulous_quizzes") + end + end + + describe "GET 'fabulous_quizzes' without fabulous quizzes enabled" do + it "should redirect to index" do + a = Account.default + a.disable_fabulous_quizzes! + a.save! + course_with_teacher_logged_in(:active_all => true) + course_quiz(active = true) + a = Account.default + a.enable_fabulous_quizzes?.should eql false + get 'fabulous_quizzes', :course_id => @course.id + assert_redirected_to(:controller => "quizzes", :action => "index") + end + end + describe "GET 'new'" do it "should require authorization" do course_with_teacher(:active_all => true)