From f444ab2e2707aaab5c21e82ec4995ee4a9ab76c0 Mon Sep 17 00:00:00 2001 From: James Williams Date: Mon, 24 Jul 2017 06:38:12 -0600 Subject: [PATCH] spec: rails 5.1: rewrite controller spec format - part F-G Change-Id: Ie5bce0ade92b053b9ac3d4254f0d8074746e232b Reviewed-on: https://gerrit.instructure.com/120222 Tested-by: Jenkins Reviewed-by: Cody Cutrer Product-Review: James Williams QA-Review: James Williams --- .../file_previews_controller_spec.rb | 28 +-- spec/controllers/files_controller_spec.rb | 222 ++++++++--------- spec/controllers/folders_controller_spec.rb | 20 +- .../gradebook_csvs_controller_spec.rb | 6 +- .../gradebook_history_api_controller_spec.rb | 10 +- .../gradebook_settings_controller_spec.rb | 12 +- .../gradebook_uploads_controller_spec.rb | 10 +- .../controllers/gradebooks_controller_spec.rb | 230 +++++++++--------- .../grading_period_sets_controller_spec.rb | 34 +-- .../grading_periods_controller_spec.rb | 92 +++---- .../grading_standards_controller_spec.rb | 12 +- spec/controllers/graphql_controller_spec.rb | 2 +- .../group_categories_controller_spec.rb | 48 ++-- spec/controllers/groups_controller_spec.rb | 100 ++++---- 14 files changed, 414 insertions(+), 412 deletions(-) diff --git a/spec/controllers/file_previews_controller_spec.rb b/spec/controllers/file_previews_controller_spec.rb index 9692152c479..cdacc1a43ba 100644 --- a/spec/controllers/file_previews_controller_spec.rb +++ b/spec/controllers/file_previews_controller_spec.rb @@ -32,13 +32,13 @@ describe FilePreviewsController do it "should require authorization to view the file" do course_model attachment_model - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response.status).to eq 401 end it "should render lock information for the file" do attachment_model locked: true - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response).to render_template 'lock_explanation' end @@ -46,7 +46,7 @@ describe FilePreviewsController do attachment_model file_id = @attachment.id @attachment.destroy_permanently! - get :show, course_id: @course.id, file_id: file_id + get :show, params: {course_id: @course.id, file_id: file_id} expect(response.status).to eq 404 expect(assigns['headers']).to eq false expect(assigns['show_left_side']).to eq false @@ -56,7 +56,7 @@ describe FilePreviewsController do Attachment.any_instance.stubs(:crocodoc_url).returns('http://example.com/fake_crocodoc_url') Attachment.any_instance.stubs(:canvadoc_url).returns('http://example.com/fake_canvadoc_url') attachment_model content_type: 'application/msword' - get :show, course_id: @course.id, file_id: @attachment.id, annotate: 1 + get :show, params: {course_id: @course.id, file_id: @attachment.id, annotate: 1} expect(response).to redirect_to @attachment.crocodoc_url end @@ -64,7 +64,7 @@ describe FilePreviewsController do Attachment.any_instance.stubs(:crocodoc_url).returns('http://example.com/fake_crocodoc_url') Attachment.any_instance.stubs(:canvadoc_url).returns('http://example.com/fake_canvadoc_url') attachment_model content_type: 'application/msword' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response).to redirect_to @attachment.canvadoc_url end @@ -72,7 +72,7 @@ describe FilePreviewsController do Attachment.any_instance.stubs(:crocodoc_url).returns(nil) Attachment.any_instance.stubs(:canvadoc_url).returns(nil) attachment_model content_type: 'application/msword' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response).to be_redirect expect(response.location).to match %r{\A//docs.google.com/viewer} end @@ -81,7 +81,7 @@ describe FilePreviewsController do Attachment.any_instance.stubs(:crocodoc_url).returns(nil) Attachment.any_instance.stubs(:canvadoc_url).returns(nil) attachment_model content_type: 'text/html' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response).to be_redirect expect(response.location).to match %r{/courses/#{@course.id}/files/#{@attachment.id}/preview} end @@ -92,21 +92,21 @@ describe FilePreviewsController do @account.disable_service(:google_docs_previews) @account.save! attachment_model content_type: 'application/msword' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response.status).to eq 200 expect(response).to render_template 'no_preview' end it "should render an img element for image types" do attachment_model content_type: 'image/png' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response.status).to eq 200 expect(response).to render_template 'img_preview' end it "should render a media tag for media types" do attachment_model content_type: 'video/mp4' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response.status).to eq 200 expect(response).to render_template 'media_preview' end @@ -118,14 +118,14 @@ describe FilePreviewsController do mod.completion_requirements = { tag.id => {:type => 'must_view'} } mod.save! expect(mod.evaluate_for(@user).workflow_state).to eq "unlocked" - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(mod.evaluate_for(@user).workflow_state).to eq "completed" end it "should log asset accesses when previewable" do Setting.set('enable_page_views', 'db') attachment_model content_type: 'image/png' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} access = AssetUserAccess.for_user(@user).first expect(access.asset).to eq @attachment end @@ -133,7 +133,7 @@ describe FilePreviewsController do it "should not log asset accesses when not previewable" do Setting.set('enable_page_views', 'db') attachment_model content_type: 'unknown/unknown' - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} access = AssetUserAccess.for_user(@user) expect(access).to be_empty end @@ -141,7 +141,7 @@ describe FilePreviewsController do it "should work with hidden files" do attachment_model content_type: 'image/png' @attachment.update_attribute(:file_state, 'hidden') - get :show, course_id: @course.id, file_id: @attachment.id + get :show, params: {course_id: @course.id, file_id: @attachment.id} expect(response).to be_success end end diff --git a/spec/controllers/files_controller_spec.rb b/spec/controllers/files_controller_spec.rb index c1942da6515..a3783e20bdf 100644 --- a/spec/controllers/files_controller_spec.rb +++ b/spec/controllers/files_controller_spec.rb @@ -93,20 +93,20 @@ describe FilesController do describe "GET 'quota'" do it "should require authorization" do - get 'quota', :course_id => @course.id + get 'quota', params: {:course_id => @course.id} assert_unauthorized end it "should assign variables for course quota" do user_session(@teacher) - get 'quota', :course_id => @course.id + get 'quota', params: {:course_id => @course.id} expect(assigns[:quota]).not_to be_nil expect(response).to be_success end it "should assign variables for user quota" do user_session(@student) - get 'quota', :user_id => @student.id + get 'quota', params: {:user_id => @student.id} expect(assigns[:quota]).not_to be_nil expect(response).to be_success end @@ -114,7 +114,7 @@ describe FilesController do it "should assign variables for group quota" do user_session(@teacher) group_model(:context => @course) - get 'quota', :group_id => @group.id + get 'quota', params: {:group_id => @group.id} expect(assigns[:quota]).not_to be_nil expect(response).to be_success end @@ -122,7 +122,7 @@ describe FilesController do it "should allow changing group quota" do user_session(@teacher) group_model(:context => @course, :storage_quota => 500.megabytes) - get 'quota', :group_id => @group.id + get 'quota', params: {:group_id => @group.id} expect(assigns[:quota]).to eq 500.megabytes expect(response).to be_success end @@ -130,21 +130,21 @@ describe FilesController do describe "GET 'index'" do it "should require authorization" do - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} assert_unauthorized end it "should redirect 'disabled', if disabled by the teacher" do user_session(@student) @course.update_attribute(:tab_configuration, [{'id'=>11,'hidden'=>true}]) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(response).to be_redirect expect(flash[:notice]).to match(/That page has been disabled/) end it "should assign variables" do user_session(@teacher) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(response).to be_success expect(assigns[:contexts]).not_to be_nil expect(assigns[:contexts][0]).to eql(@course) @@ -155,7 +155,7 @@ describe FilesController do r1 = Folder.root_folders(@course).first f1 = course_folder a1 = folder_file - get 'index', :course_id => @course.id, :format => 'json' + get 'index', params: {:course_id => @course.id}, :format => 'json' expect(response).to be_success data = json_parse expect(data).not_to be_nil @@ -165,13 +165,13 @@ describe FilesController do it "should work for a user context, too" do user_session(@student) - get 'index', :user_id => @student.id + get 'index', params: {:user_id => @student.id} expect(response).to be_success end it "should work for a group context, too" do group_with_user_logged_in(:group_context => Account.default) - get 'index', :group_id => @group.id + get 'index', params: {:group_id => @group.id} expect(response).to be_success end @@ -180,7 +180,7 @@ describe FilesController do new_valid_tool(@course) user_file @file.context = @group - get 'index', :group_id => @group.id + get 'index', params: {:group_id => @group.id} expect(assigns[:js_env][:FILES_CONTEXTS][0][:file_menu_tools]).to eq [] end @@ -203,14 +203,14 @@ describe FilesController do it "should show restricted external tools to teachers" do @course.enroll_teacher(@user).accept! - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(assigns[:js_env][:FILES_CONTEXTS][0][:file_menu_tools].count).to eq 1 end it "should not show restricted external tools to students" do @course.enroll_student(@user).accept! - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(assigns[:js_env][:FILES_CONTEXTS][0][:file_menu_tools]).to eq [] end end @@ -229,12 +229,12 @@ describe FilesController do end it "authorizes users on a remote shard" do - get 'index', :user_id => @user.global_id + get 'index', params: {:user_id => @user.global_id} expect(response).to be_success end it "authorizes users on a remote shard for JSON data" do - get 'index', :user_id => @user.global_id, :format => :json + get 'index', params: {:user_id => @user.global_id}, :format => :json expect(response).to be_success end end @@ -246,14 +246,14 @@ describe FilesController do end it "should require authorization" do - get 'show', :course_id => @course.id, :id => @file.id + get 'show', params: {:course_id => @course.id, :id => @file.id} assert_unauthorized end describe "with verifiers" do it "should allow public access with legacy verifier" do Attachment.any_instance.stubs(:canvadoc_url).returns "stubby" - get 'show', :course_id => @course.id, :id => @file.id, :verifier => @file.uuid, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @file.id, :verifier => @file.uuid}, :format => 'json' expect(response).to be_success expect(json_parse['attachment']).to_not be_nil expect(json_parse['attachment']['canvadoc_session_url']).to eq "stubby" @@ -262,7 +262,7 @@ describe FilesController do it "should allow public access with new verifier" do verifier = Attachments::Verification.new(@file).verifier_for_user(nil) - get 'show', :course_id => @course.id, :id => @file.id, :verifier => verifier, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @file.id, :verifier => verifier}, :format => 'json' expect(response).to be_success expect(json_parse['attachment']).to_not be_nil expect(json_parse['attachment']['md5']).to be_nil @@ -272,14 +272,14 @@ describe FilesController do user_session(@teacher) session[:require_terms] = true verifier = Attachments::Verification.new(@file).verifier_for_user(@teacher) - get 'show', :course_id => @course.id, :id => @file.id, :verifier => verifier, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @file.id, :verifier => verifier}, :format => 'json' expect(response).to be_success end end it "should assign variables" do user_session(@teacher) - get 'show', :course_id => @course.id, :id => @file.id + get 'show', params: {:course_id => @course.id, :id => @file.id} expect(response).to be_success expect(assigns[:attachment]).not_to be_nil expect(assigns[:attachment]).to eql(@file) @@ -287,7 +287,7 @@ describe FilesController do it "should redirect for download" do user_session(@teacher) - get 'show', :course_id => @course.id, :id => @file.id, :download => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1} expect(response).to be_redirect end @@ -295,7 +295,7 @@ describe FilesController do user_session(@teacher) # this call should happen inside of FilesController#send_attachment FilesController.any_instance.expects(:send_stored_file).with(@file, false) - get 'show', :course_id => @course.id, :id => @file.id, :download => 1, :verifier => @file.uuid, :download_frd => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1, :verifier => @file.uuid, :download_frd => 1} end it "should remember most recent sf_verifier in session" do @@ -309,7 +309,7 @@ describe FilesController do # first verifier user_session(user1) - get 'show', :user_id => user1.id, :id => file1.id, :ts => ts1, :sf_verifier => sf_verifier1 + get 'show', params: {:user_id => user1.id, :id => file1.id, :ts => ts1, :sf_verifier => sf_verifier1} expect(response).to be_success expect(session[:file_access_user_id]).to eq user1.id @@ -318,7 +318,7 @@ describe FilesController do permissions_key = session[:permissions_key] # second verifier, should update session - get 'show', :user_id => user2.id, :id => @file.id, :ts => ts2, :sf_verifier => sf_verifier2 + get 'show', params: {:user_id => user2.id, :id => @file.id, :ts => ts2, :sf_verifier => sf_verifier2} expect(response).to be_success expect(session[:file_access_user_id]).to eq user2.id @@ -329,14 +329,14 @@ describe FilesController do # repeat access, even without verifier, should extend expiration (though # we can't assert that, because milliseconds) and thus change # permissions_key - get 'show', :user_id => user2.id, :id => @file.id + get 'show', params: {:user_id => user2.id, :id => @file.id} expect(response).to be_success expect(session[:permissions_key]).not_to eq permissions_key end it "should set cache headers for non text files" do - get 'show', :course_id => @course.id, :id => @file.id, :download => 1, :verifier => @file.uuid, :download_frd => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1, :verifier => @file.uuid, :download_frd => 1} expect(response.header["Cache-Control"]).to include "private, max-age" expect(response.header["Cache-Control"]).not_to include "no-cache" expect(response.header["Cache-Control"]).not_to include "no-store" @@ -349,7 +349,7 @@ describe FilesController do it "should not set cache headers for text files" do @file.content_type = "text/html" @file.save - get 'show', :course_id => @course.id, :id => @file.id, :download => 1, :verifier => @file.uuid, :download_frd => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1, :verifier => @file.uuid, :download_frd => 1} expect(response.header["Cache-Control"]).not_to include "private, max-age" expect(response.header["Cache-Control"]).to include "no-cache" expect(response.header["Cache-Control"]).to include "no-store" @@ -362,9 +362,9 @@ describe FilesController do it "should allow concluded teachers to read and download files" do user_session(@teacher) @enrollment.conclude - get 'show', :course_id => @course.id, :id => @file.id + get 'show', params: {:course_id => @course.id, :id => @file.id} expect(response).to be_success - get 'show', :course_id => @course.id, :id => @file.id, :download => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1} expect(response).to be_redirect end @@ -375,7 +375,7 @@ describe FilesController do @old_file.save! user_session(@teacher) - get 'show', course_id: @course.id, id: @old_file.id, preview: 1 + get 'show', params: {course_id: @course.id, id: @old_file.id, preview: 1} expect(response).to be_redirect expect(response.location).to match /\/courses\/#{@course.id}\/files\/#{@file.id}/ end @@ -387,15 +387,15 @@ describe FilesController do it "should allow concluded students to read and download files" do @enrollment.conclude - get 'show', :course_id => @course.id, :id => @file.id + get 'show', params: {:course_id => @course.id, :id => @file.id} expect(response).to be_success - get 'show', :course_id => @course.id, :id => @file.id, :download => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1} expect(response).to be_redirect end it "should mark files as viewed for module progressions if the file is previewed inline" do file_in_a_module - get 'show', :course_id => @course.id, :id => @file.id, :inline => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :inline => 1} expect(json_parse).to eq({'ok' => true}) @module.reload expect(@module.evaluate_for(@student).state).to eql(:completed) @@ -403,7 +403,7 @@ describe FilesController do it "should mark files as viewed for module progressions if the file is downloaded" do file_in_a_module - get 'show', :course_id => @course.id, :id => @file.id, :download => 1 + get 'show', params: {:course_id => @course.id, :id => @file.id, :download => 1} @module.reload expect(@module.evaluate_for(@student).state).to eql(:completed) end @@ -411,7 +411,7 @@ describe FilesController do it "should mark files as viewed for module progressions if the file data is requested and is canvadocable" do file_in_a_module Attachment.any_instance.stubs(:canvadocable?).returns true - get 'show', :course_id => @course.id, :id => @file.id, :format => :json + get 'show', params: {:course_id => @course.id, :id => @file.id}, :format => :json @module.reload expect(@module.evaluate_for(@student).state).to eql(:completed) end @@ -419,7 +419,7 @@ describe FilesController do it "should mark media files viewed when rendering html with file_preview" do @file = attachment_model(:context => @course, :uploaded_data => stub_file_data('test.m4v', 'asdf', 'video/mp4')) file_in_a_module - get 'show', :course_id => @course.id, :id => @file.id, :format => :html + get 'show', params: {:course_id => @course.id, :id => @file.id}, :format => :html @module.reload expect(@module.evaluate_for(@student).state).to eql(:completed) end @@ -430,7 +430,7 @@ describe FilesController do owned_file.user_id = @student.id owned_file.save owned_file.destroy - get 'show', :course_id => @course.id, :id => owned_file.id + get 'show', params: {:course_id => @course.id, :id => owned_file.id} expect(response).to be_redirect expect(flash[:notice]).to match(/has been deleted/) expect(URI.parse(response['Location']).path).to eq "/courses/#{@course.id}/files" @@ -441,7 +441,7 @@ describe FilesController do new_file.display_name = 'holla' new_file.save - get 'show', :course_id => @course.id, :id => new_file.id + get 'show', params: {:course_id => @course.id, :id => new_file.id} expect(response).to be_success expect(assigns(:attachment)).to eq new_file end @@ -452,7 +452,7 @@ describe FilesController do unowned_file.save unowned_file.destroy - get 'show', :course_id => @course.id, :id => unowned_file.id + get 'show', params: {:course_id => @course.id, :id => unowned_file.id} expect(response.status).to eq(404) expect(assigns(:not_found_message)).to eq("This file has been deleted") end @@ -464,7 +464,7 @@ describe FilesController do unowned_file.destroy remove_user_session - get 'show', :course_id => @course.id, :id => unowned_file.id + get 'show', params: {:course_id => @course.id, :id => unowned_file.id} expect(response.status).to eq(404) expect(assigns(:not_found_message)).to eq("This file has been deleted") end @@ -475,7 +475,7 @@ describe FilesController do @assignment.submit_homework @student, attachments: [@attachment] # create an orphaned attachment_association @assignment.all_submissions.delete_all - get 'show', user_id: @student.id, id: @attachment.id, download_frd: 1 + get 'show', params: {user_id: @student.id, id: @attachment.id, download_frd: 1} expect(response).to be_success end end @@ -488,8 +488,8 @@ describe FilesController do it "should work for quiz_statistics" do quiz_model file = @quiz.statistics_csv('student_analysis').csv_attachment - get 'show', :quiz_statistics_id => file.reload.context.id, - :file_id => file.id, :download => '1', :verifier => file.uuid + get 'show', params: {:quiz_statistics_id => file.reload.context.id, + :file_id => file.id, :download => '1', :verifier => file.uuid} expect(response).to be_redirect end @@ -497,7 +497,7 @@ describe FilesController do @assignment = @course.assignments.create!(:title => 'upload_assignment', :submission_types => 'online_upload') attachment_model :context => @student @assignment.submit_homework @student, :attachments => [@attachment] - get 'show', :user_id => @student.id, :id => @attachment.id, :inline => 1 + get 'show', params: {:user_id => @student.id, :id => @attachment.id, :inline => 1} expect(response).to be_success end end @@ -510,20 +510,20 @@ describe FilesController do end it "is included if :download is allowed" do - get 'show', :course_id => @course.id, :id => @file.id, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @file.id}, :format => 'json' expect(json_parse['attachment']['canvadoc_session_url']).to be_present end it "is not included if locked" do @file.lock_at = 1.month.ago @file.save! - get 'show', :course_id => @course.id, :id => @file.id, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @file.id}, :format => 'json' expect(json_parse['attachment']['canvadoc_session_url']).to be_nil end it "is included in newly uploaded files" do user_session(@teacher) - post 'create', :format => 'json', :course_id => @course.id, :attachment => {:display_name => "bob", :uploaded_data => io} + post 'create', params: {:course_id => @course.id, :attachment => {:display_name => "bob", :uploaded_data => io}}, :format => 'json' expect(json_parse['attachment']['canvadoc_session_url']).to be_present end end @@ -541,16 +541,16 @@ describe FilesController do end it "should find files by relative path" do - get "show_relative", :course_id => @course.id, :file_path => @file.full_display_path + get "show_relative", params: {:course_id => @course.id, :file_path => @file.full_display_path} expect(response).to be_redirect - get "show_relative", :course_id => @course.id, :file_path => @file.full_path + get "show_relative", params: {:course_id => @course.id, :file_path => @file.full_path} expect(response).to be_redirect def test_path(path) file_with_path(path) - get "show_relative", :course_id => @course.id, :file_path => @file.full_display_path + get "show_relative", params: {:course_id => @course.id, :file_path => @file.full_display_path} expect(response).to be_redirect - get "show_relative", :course_id => @course.id, :file_path => @file.full_path + get "show_relative", params: {:course_id => @course.id, :file_path => @file.full_path} expect(response).to be_redirect end @@ -560,21 +560,21 @@ describe FilesController do end it "should render unauthorized access page if the file path doesn't match" do - get "show_relative", :course_id => @course.id, :file_path => @file.full_display_path+"blah" + get "show_relative", params: {:course_id => @course.id, :file_path => @file.full_display_path+"blah"} expect(response).to render_template("shared/errors/file_not_found") - get "show_relative", :file_id => @file.id, :course_id => @course.id, :file_path => @file.full_display_path+"blah" + get "show_relative", params: {:file_id => @file.id, :course_id => @course.id, :file_path => @file.full_display_path+"blah"} expect(response).to render_template("shared/errors/file_not_found") end it "should render file_not_found even if the format is non-html" do - get "show_relative", :file_id => @file.id, :course_id => @course.id, :file_path => @file.full_display_path+".css", :format => 'css' + get "show_relative", params: {:file_id => @file.id, :course_id => @course.id, :file_path => @file.full_display_path+".css"}, :format => 'css' expect(response).to render_template("shared/errors/file_not_found") end it "should ignore bad file_ids" do - get "show_relative", :file_id => @file.id + 1, :course_id => @course.id, :file_path => @file.full_display_path + get "show_relative", params: {:file_id => @file.id + 1, :course_id => @course.id, :file_path => @file.full_display_path} expect(response).to be_redirect - get "show_relative", :file_id => "blah", :course_id => @course.id, :file_path => @file.full_display_path + get "show_relative", params: {:file_id => "blah", :course_id => @course.id, :file_path => @file.full_display_path} expect(response).to be_redirect end @@ -589,7 +589,7 @@ describe FilesController do allow(s3object).to receive(:body).and_return(s3object) allow(s3object).to receive(:read).and_return('hello') @file.any_instantiation.stubs(:s3object).returns(s3object) - get "show_relative", file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1 + get "show_relative", params: {file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1} expect(response).to be_success expect(response.body).to eq 'hello' expect(response.content_type).to eq 'text/html' @@ -602,7 +602,7 @@ describe FilesController do @file.update_attribute(:content_type, 'text/html') @file.update_attribute(:size, 1024 * 1024) @file.any_instantiation.stubs(:inline_url).returns("https://s3/myfile") - get "show_relative", file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1 + get "show_relative", params: {file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1} expect(response).to redirect_to("https://s3/myfile") end @@ -612,7 +612,7 @@ describe FilesController do request.host = 'files.test' @file.update_attribute(:content_type, 'image/jpeg') @file.any_instantiation.stubs(:inline_url).returns("https://s3/myfile") - get "show_relative", file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1 + get "show_relative", params: {file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1} expect(response).to redirect_to("https://s3/myfile") end @@ -622,7 +622,7 @@ describe FilesController do request.host = 'files.test' # it's a .doc file @file.any_instantiation.stubs(:download_url).returns("https://s3/myfile") - get "show_relative", file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1 + get "show_relative", params: {file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1} expect(response).to redirect_to("https://s3/myfile") end @@ -630,12 +630,12 @@ describe FilesController do context "unauthenticated user" do it "renders unauthorized if the file exists" do - get "show_relative", :course_id => @course.id, :file_path => @file.full_display_path + get "show_relative", params: {:course_id => @course.id, :file_path => @file.full_display_path} assert_unauthorized end it "renders unauthorized if the file doesn't exist" do - get "show_relative", :course_id => @course.id, :file_path => "course files/nope" + get "show_relative", params: {:course_id => @course.id, :file_path => "course files/nope"} assert_unauthorized end end @@ -643,13 +643,13 @@ describe FilesController do describe "POST 'create'" do it "should require authorization" do - post 'create', :course_id => @course.id, :attachment => {:display_name => "bob"} + post 'create', params: {:course_id => @course.id, :attachment => {:display_name => "bob"}} assert_unauthorized end it "should create file" do user_session(@teacher) - post 'create', :course_id => @course.id, :attachment => {:display_name => "bob", :uploaded_data => io} + post 'create', params: {:course_id => @course.id, :attachment => {:display_name => "bob", :uploaded_data => io}} expect(response).to be_redirect expect(assigns[:attachment]).not_to be_nil expect(assigns[:attachment].display_name).to eql("bob") @@ -659,14 +659,14 @@ describe FilesController do @course.account.allow_feature! :usage_rights_required @course.enable_feature! :usage_rights_required user_session(@teacher) - post 'create', :course_id => @course.id, :attachment => {:display_name => "wat", :uploaded_data => io} + post 'create', params: {:course_id => @course.id, :attachment => {:display_name => "wat", :uploaded_data => io}} expect(assigns[:attachment]).to be_locked end it "should reject an upload that would exceed quota" do user_session(@teacher) Setting.set('user_default_quota', 7) # seven... seven bytes. - post 'create', :user_id => @teacher.id, :format => :json, :attachment => {:display_name => "bob", :uploaded_data => io} + post 'create', params: {:user_id => @teacher.id, :attachment => {:display_name => "bob", :uploaded_data => io}}, :format => :json expect(response.status).to eq 400 expect(response.body).to include 'quota exceeded' end @@ -679,21 +679,21 @@ describe FilesController do file.file_state = 'deleted' file.workflow_state = 'unattached' file.save! - post 'create', :user_id => @student.id, - :format => 'json', + post 'create', params: {:user_id => @student.id, :check_quota_after => '0', :filename => 'submission.doc', :attachment => { :unattached_attachment_id => file.id, :uploaded_data => io - } + }}, + :format => 'json' expect(response).to be_success expect(file.reload).to be_available end it "refuses to create a file in a submissions folder" do user_session(@student) - post 'create', :user_id => @student.id, :format => :json, :attachment => {:display_name => 'blah', :uploaded_data => io, :folder_id => @student.submissions_folder.id} + post 'create', params: {:user_id => @student.id, :attachment => {:display_name => 'blah', :uploaded_data => io, :folder_id => @student.submissions_folder.id}}, :format => :json expect(response.status).to eq 401 end @@ -714,7 +714,7 @@ describe FilesController do @assignment = @course.assignments.create!(:title => 'upload_assignment', :submission_types => 'online_upload') user_session(@student) - post 'create', :attachment => {:display_name => "bob", :uploaded_data => io, :unattached_attachment_id => @attachment.id} + post 'create', params: {:attachment => {:display_name => "bob", :uploaded_data => io, :unattached_attachment_id => @attachment.id}} expect(response).to be_redirect expect(assigns[:attachment]).not_to be_nil expect(assigns[:attachment].display_name).to eql("bob") @@ -729,13 +729,13 @@ describe FilesController do end it "should require authorization" do - put 'update', :course_id => @course.id, :id => @file.id + put 'update', params: {:course_id => @course.id, :id => @file.id} assert_unauthorized end it "should update file" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:display_name => "new name", :uploaded_data => nil} + put 'update', params: {:course_id => @course.id, :id => @file.id, :attachment => {:display_name => "new name", :uploaded_data => nil}} expect(response).to be_redirect expect(assigns[:attachment]).to eql(@file) expect(assigns[:attachment].display_name).to eql("new name") @@ -746,7 +746,7 @@ describe FilesController do user_session(@teacher) course_folder - put 'update', :course_id => @course.id, :id => @file.id, :attachment => { :folder_id => @folder.id }, :format => 'json' + put 'update', params: {:course_id => @course.id, :id => @file.id, :attachment => { :folder_id => @folder.id }}, :format => 'json' expect(response).to be_success @file.reload @@ -764,13 +764,13 @@ describe FilesController do it "should not move a file into a submissions folder" do user_session(@student) - put 'update', :user_id => @student.id, :id => @file.id, :attachment => { :folder_id => @sub_folder.id }, :format => 'json' + put 'update', params: {:user_id => @student.id, :id => @file.id, :attachment => { :folder_id => @sub_folder.id }}, :format => 'json' expect(response.status).to eq 401 end it "should not move a file out of a submissions folder" do user_session(@student) - put 'update', :user_id => @student.id, :id => @sub_file.id, :attachment => { :folder_id => @root_folder.id }, :format => 'json' + put 'update', params: {:user_id => @student.id, :id => @sub_file.id, :attachment => { :folder_id => @root_folder.id }}, :format => 'json' expect(response.status).to eq 401 end end @@ -779,7 +779,7 @@ describe FilesController do course_with_teacher_logged_in(:active_all => true) course_file new_content = default_uploaded_data - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:uploaded_data => new_content} + put 'update', params: {:course_id => @course.id, :id => @file.id, :attachment => {:uploaded_data => new_content}} expect(response).to be_redirect expect(assigns[:attachment]).to eql(@file) @file.reload @@ -795,14 +795,14 @@ describe FilesController do end it "should not publish if usage_rights unset" do - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} + put 'update', params: {:course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"}} expect(@file.reload).to be_locked end it "should publish if usage_rights set" do @file.usage_rights = @course.usage_rights.create! use_justification: 'public_domain' @file.save! - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} + put 'update', params: {:course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"}} expect(@file.reload).not_to be_locked end end @@ -815,14 +815,14 @@ describe FilesController do end it "should require authorization" do - delete 'destroy', :course_id => @course.id, :id => @file.id + delete 'destroy', params: {:course_id => @course.id, :id => @file.id} expect(response.body).to eql("{\"message\":\"Unauthorized to delete this file\"}") expect(assigns[:attachment].file_state).to eq 'available' end it "should delete file" do user_session(@teacher) - delete 'destroy', :course_id => @course.id, :id => @file.id + delete 'destroy', params: {:course_id => @course.id, :id => @file.id} expect(response).to be_redirect expect(assigns[:attachment]).to eql(@file) expect(assigns[:attachment].file_state).to eq 'deleted' @@ -831,7 +831,7 @@ describe FilesController do it "refuses to delete a file in a submissions folder" do file = @student.attachments.create! :display_name => 'blah', :uploaded_data => default_uploaded_data, :folder => @student.submissions_folder - delete 'destroy', :user_id => @student.id, :id => file.id + delete 'destroy', params: {:user_id => @student.id, :id => file.id} expect(response.status).to eq 401 end @@ -851,7 +851,7 @@ describe FilesController do end it "should not delete" do - delete 'destroy', :id => @file.id + delete 'destroy', params: {:id => @file.id} expect(response.body).to eql("{\"message\":\"Cannot delete a file that has been submitted as part of an assignment\"}") expect(assigns[:attachment].file_state).to eq 'available' end @@ -861,19 +861,19 @@ describe FilesController do describe "POST 'create_pending'" do it "should require authorization" do user_session(@other_user) - post 'create_pending', {:attachment => {:context_code => @course.asset_string}} + post 'create_pending', params: {:attachment => {:context_code => @course.asset_string}} assert_unauthorized end it "should require a pseudonym" do - post 'create_pending', {:attachment => {:context_code => @course.asset_string}} + post 'create_pending', params: {:attachment => {:context_code => @course.asset_string}} expect(response).to redirect_to login_url end it "should create file placeholder (in local mode)" do local_storage! user_session(@teacher) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :filename => "bob.txt" }} @@ -892,7 +892,7 @@ describe FilesController do it "should create file placeholder (in s3 mode)" do s3_storage! user_session(@teacher) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :filename => "bob.txt" }} @@ -912,7 +912,7 @@ describe FilesController do # the API does, and the files page sends it based on the browser's detection s3_storage! user_session(@teacher) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :filename => "something.rb", :content_type => "text/magical-incantation" @@ -925,7 +925,7 @@ describe FilesController do s3_storage! user_session(@student) Setting.set('user_default_quota', -1) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @student.asset_string, :filename => "bob.txt" }} @@ -938,7 +938,7 @@ describe FilesController do user_session(@student) @assignment = @course.assignments.create!(:title => 'upload_assignment', :submission_types => 'online_upload') Setting.set('user_default_quota', -1) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @assignment.context_code, :asset_string => @assignment.asset_string, :intent => 'submit', @@ -967,7 +967,7 @@ describe FilesController do #assignment.grants_right?(@student, :nothing).should be_true s3_storage! - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :asset_string => assignment.asset_string, :intent => 'submit', @@ -982,7 +982,7 @@ describe FilesController do it "should create the file in unlocked state if :usage_rights_required is disabled" do @course.disable_feature! :usage_rights_required user_session(@teacher) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :filename => "bob.txt" }} @@ -993,7 +993,7 @@ describe FilesController do it "should create the file in locked state if :usage_rights_required is enabled" do @course.enable_feature! :usage_rights_required user_session(@teacher) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :filename => "bob.txt" }} @@ -1003,7 +1003,7 @@ describe FilesController do it "refuses to create a file in a submissions folder" do user_session(@student) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @student.asset_string, :filename => 'test.txt', :folder_id => @student.submissions_folder.id @@ -1015,7 +1015,7 @@ describe FilesController do @course.root_account.enable_feature! :submissions_folder user_session(@student) assignment = @course.assignments.create!(:submission_types => 'online_upload') - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => assignment.context_code, :asset_string => assignment.asset_string, :filename => 'test.txt', @@ -1033,7 +1033,7 @@ describe FilesController do group = category.groups.create(:context => @course) group.add_user(@student) user_session(@student) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :asset_string => assignment.asset_string, :intent => 'submit', @@ -1054,7 +1054,7 @@ describe FilesController do group = category.groups.create(:context => @course) group.add_user(@student) user_session(@student) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :asset_string => assignment.asset_string, :intent => 'submit', @@ -1074,7 +1074,7 @@ describe FilesController do account = Account.create! course_with_teacher_logged_in(:active_all => true, :account => account) end - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :filename => "bob.txt" }} @@ -1101,7 +1101,7 @@ describe FilesController do @assignment = @course.assignments.create!(:title => 'upload_assignment', :submission_types => 'online_upload') user_session(@student) - post 'create_pending', {:attachment => { + post 'create_pending', params: {:attachment => { :context_code => @course.asset_string, :asset_string => @assignment.asset_string, :intent => 'submit', @@ -1137,7 +1137,7 @@ describe FilesController do it "should accept the upload data if the policy and attachment are acceptable" do params = @attachment.ajax_upload_params(@teacher.pseudonym, "", "") - post "api_create", params[:upload_params].merge(:file => @content) + post "api_create", params: params[:upload_params].merge(:file => @content) expect(response).to be_redirect @attachment.reload # the file is not available until the third api call is completed @@ -1147,7 +1147,7 @@ describe FilesController do it "opens up cors headers" do params = @attachment.ajax_upload_params(@teacher.pseudonym, "", "") - post "api_create", params[:upload_params].merge(:file => @content) + post "api_create", params: params[:upload_params].merge(:file => @content) expect(response.header["Access-Control-Allow-Origin"]).to eq "*" end @@ -1157,20 +1157,20 @@ describe FilesController do end it "should reject a blank policy" do - post "api_create", { :file => @content } + post "api_create", params: { :file => @content } assert_status(400) end it "should reject an expired policy" do params = @attachment.ajax_upload_params(@teacher.pseudonym, "", "", :expiration => -60.seconds) - post "api_create", params[:upload_params].merge({ :file => @content }) + post "api_create", params: params[:upload_params].merge({ :file => @content }) assert_status(400) end it "should reject a modified policy" do params = @attachment.ajax_upload_params(@teacher.pseudonym, "", "") params[:upload_params]['Policy'] << 'a' - post "api_create", params[:upload_params].merge({ :file => @content }) + post "api_create", params: params[:upload_params].merge({ :file => @content }) assert_status(400) end @@ -1178,7 +1178,7 @@ describe FilesController do params = @attachment.ajax_upload_params(@teacher.pseudonym, "", "") @attachment.uploaded_data = @content @attachment.save! - post "api_create", params[:upload_params].merge(:file => @content) + post "api_create", params: params[:upload_params].merge(:file => @content) assert_status(400) end end @@ -1196,7 +1196,7 @@ describe FilesController do end it "should give a download url" do - get "public_url", :id => @attachment.id + get "public_url", params: {:id => @attachment.id} expect(response).to be_success data = json_parse expect(data).to eq({ "public_url" => @attachment.authenticated_s3_url }) @@ -1209,12 +1209,12 @@ describe FilesController do end it "should fail if no submission_id is given" do - get "public_url", :id => @attachment.id + get "public_url", params: {:id => @attachment.id} assert_unauthorized end it "should allow a teacher to download a student's submission" do - get "public_url", :id => @attachment.id, :submission_id => @submission.id + get "public_url", params: {:id => @attachment.id, :submission_id => @submission.id} expect(response).to be_success data = json_parse expect(data).to eq({ "public_url" => @attachment.authenticated_s3_url }) @@ -1222,7 +1222,7 @@ describe FilesController do it "should verify that the requested file belongs to the submission" do otherfile = attachment_model - get "public_url", :id => otherfile, :submission_id => @submission.id + get "public_url", params: {:id => otherfile, :submission_id => @submission.id} assert_unauthorized end @@ -1230,7 +1230,7 @@ describe FilesController do old_file = @attachment new_file = attachment_model(:context => @student) @assignment.submit_homework @student, :attachments => [new_file] - get "public_url", :id => old_file.id, :submission_id => @submission.id + get "public_url", params: {:id => old_file.id, :submission_id => @submission.id} expect(response).to be_success data = json_parse expect(data).to eq({ "public_url" => old_file.authenticated_s3_url }) diff --git a/spec/controllers/folders_controller_spec.rb b/spec/controllers/folders_controller_spec.rb index f42a29d7c89..4e13eac6cd6 100644 --- a/spec/controllers/folders_controller_spec.rb +++ b/spec/controllers/folders_controller_spec.rb @@ -45,13 +45,13 @@ describe FoldersController do file.context = @course file.save! - get 'show', :course_id => @course.id, :id => @folder.id, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @folder.id}, :format => 'json' json = json_parse expect(json['files'].count).to eql(1) file.hidden = true file.save! - get 'show', :course_id => @course.id, :id => @folder.id, :format => 'json' + get 'show', params: {:course_id => @course.id, :id => @folder.id}, :format => 'json' json = json_parse expect(json['files'].count).to eql(0) end @@ -60,13 +60,13 @@ describe FoldersController do describe "PUT 'update'" do before(:once) { course_folder } it "should require authorization" do - put 'update', :course_id => @course.id, :id => @folder.id, :folder => {:name => "hi"} + put 'update', params: {:course_id => @course.id, :id => @folder.id, :folder => {:name => "hi"}} assert_unauthorized end it "should update folder" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @folder.id, :folder => {:name => "new name"} + put 'update', params: {:course_id => @course.id, :id => @folder.id, :folder => {:name => "new name"}} expect(response).to be_redirect expect(assigns[:folder]).not_to be_nil expect(assigns[:folder]).to eql(@folder) @@ -76,13 +76,13 @@ describe FoldersController do describe "POST 'create'" do it "should require authorization" do - post 'create', :course_id => @course.id, :folder => {:name => "folder"} + post 'create', params: {:course_id => @course.id, :folder => {:name => "folder"}} assert_unauthorized end it "should create folder" do user_session(@teacher) - post 'create', :course_id => @course.id, :folder => {:name => "new name"} + post 'create', params: {:course_id => @course.id, :folder => {:name => "new name"}} expect(response).to be_redirect expect(assigns[:folder]).not_to be_nil expect(assigns[:folder].name).to eql("new name") @@ -90,7 +90,7 @@ describe FoldersController do it "should force new folders to be sub_folders" do user_session(@teacher) - post 'create', :course_id => @course.id, :folder => {:name => "new name"} + post 'create', params: {:course_id => @course.id, :folder => {:name => "new name"}} expect(response).to be_redirect expect(assigns[:folder]).not_to be_nil expect(assigns[:folder].name).to eql("new name") @@ -101,7 +101,7 @@ describe FoldersController do it "should create sub_folder" do user_session(@teacher) course_folder - post 'create', :course_id => @course.id, :folder => {:name => "new folder", :parent_folder_id => @folder.id} + post 'create', params: {:course_id => @course.id, :folder => {:name => "new folder", :parent_folder_id => @folder.id}} expect(response).to be_redirect end end @@ -109,14 +109,14 @@ describe FoldersController do describe "DELETE 'destroy'" do before(:once) { course_folder } it "should require authorization" do - delete 'destroy', :course_id => @course.id, :id => @folder.id + delete 'destroy', params: {:course_id => @course.id, :id => @folder.id} assert_unauthorized end def delete_folder user_session(@teacher) yield if block_given? - delete 'destroy', :course_id => @course.id, :id => @folder.id + delete 'destroy', params: {:course_id => @course.id, :id => @folder.id} expect(response).to be_redirect expect(assigns[:folder]).not_to be_frozen expect(assigns[:folder]).to be_deleted diff --git a/spec/controllers/gradebook_csvs_controller_spec.rb b/spec/controllers/gradebook_csvs_controller_spec.rb index f545900265e..b19586d10be 100644 --- a/spec/controllers/gradebook_csvs_controller_spec.rb +++ b/spec/controllers/gradebook_csvs_controller_spec.rb @@ -34,7 +34,7 @@ describe GradebookCsvsController do it "returns the attachment and progress" do user_session @teacher - get 'show', course_id: @course.id, format: :json + get 'show', params: {course_id: @course.id}, format: :json json = json_parse(response.body) expect(response).to be_success expect(json).to have_key 'attachment_id' @@ -44,7 +44,7 @@ describe GradebookCsvsController do it "creates the attachment and progress" do user_session @teacher - get 'show', course_id: @course.id, format: :json + get 'show', params: {course_id: @course.id}, format: :json json = json_parse(response.body) expect(Attachment.find json['attachment_id']).not_to be_nil expect(Progress.find json['progress_id']).not_to be_nil @@ -53,7 +53,7 @@ describe GradebookCsvsController do it "names the CSV file after course#short_name" do user_session @teacher - get 'show', course_id: @course.id, format: :json + get 'show', params: {course_id: @course.id}, format: :json json = json_parse(response.body) attachment = Attachment.find(json['attachment_id']) expect(@course.short_name).to eq(File.basename(attachment.filename.split("-").last, ".csv")) diff --git a/spec/controllers/gradebook_history_api_controller_spec.rb b/spec/controllers/gradebook_history_api_controller_spec.rb index 75d3f2472bf..f5a818ee00b 100644 --- a/spec/controllers/gradebook_history_api_controller_spec.rb +++ b/spec/controllers/gradebook_history_api_controller_spec.rb @@ -67,7 +67,7 @@ describe GradebookHistoryApiController do describe 'default params' do - before { get 'days', :course_id => @course.id, :format => 'json' } + before { get 'days', params: {:course_id => @course.id}, :format => 'json' } it 'provides an array of the dates where there are submissions' do expect(json_body.map{ |d| d['date'] }.sort).to eq [date_key(@submission1), date_key(@submission3)].sort @@ -85,13 +85,13 @@ describe GradebookHistoryApiController do end it 'paginates' do - get 'days', :course_id => @course.id, :format => 'json', :page => 2, :per_page => 2 + get 'days', params: {:course_id => @course.id, :page => 2, :per_page => 2}, :format => 'json' expect(json_body.map{|d| d['date'] }).to eq [@submission3.graded_at.to_date.as_json] end end describe 'GET day_details' do - before { get 'day_details', :course_id => @course.id, :format => 'json', :date => @submission1.graded_at.strftime('%Y-%m-%d') } + before { get 'day_details', params: {:course_id => @course.id, :date => @submission1.graded_at.strftime('%Y-%m-%d')}, format: 'json' } it 'has the graders as the top level piece of data' do expect(json_body.map{|g| g['id'] }.sort).to eq [@grader.id, @super_grader.id].sort @@ -106,7 +106,7 @@ describe GradebookHistoryApiController do let(:date) { @submission1.graded_at.strftime('%Y-%m-%d') } let(:params) { { :course_id => @course.id, :date => date, :grader_id => @grader.id, :assignment_id => @assignment1.id } } - before { get( 'submissions', { :format => 'json' }.merge(params) ) } + before { get( 'submissions', params: params, format: 'json' ) } it 'lists submissions' do expect(json_body.first['submission_id']).to eq @submission1.id @@ -118,7 +118,7 @@ describe GradebookHistoryApiController do context 'deleted submissions' do before :each do @submission1.destroy - get 'feed', course_id: @course.id, format: 'json' + get 'feed', params: {course_id: @course.id}, format: 'json' end it 'does not return an error' do diff --git a/spec/controllers/gradebook_settings_controller_spec.rb b/spec/controllers/gradebook_settings_controller_spec.rb index b5601bb4035..8174371a2b6 100644 --- a/spec/controllers/gradebook_settings_controller_spec.rb +++ b/spec/controllers/gradebook_settings_controller_spec.rb @@ -73,7 +73,7 @@ RSpec.describe GradebookSettingsController, type: :controller do end it "saves new gradebook_settings in preferences" do - put :update, valid_params + put :update, params: valid_params expect(response).to be_ok expected_settings = { @@ -85,7 +85,7 @@ RSpec.describe GradebookSettingsController, type: :controller do end it "transforms 'null' string values to nil" do - put :update, valid_params + put :update, params: valid_params expect(teacher.preferences[:gradebook_settings][@course.id]['filter_rows_by']['section_id']).to be_nil end @@ -98,7 +98,7 @@ RSpec.describe GradebookSettingsController, type: :controller do } teacher.save! - put :update, valid_params + put :update, params: valid_params expected_user_settings = { @course.id => show_settings_massaged.except("colors"), @@ -119,7 +119,7 @@ RSpec.describe GradebookSettingsController, type: :controller do @course.enrollment_term = term # `update_attribute` with a term has unwanted side effects @course.save! - put :update, valid_params + put :update, params: valid_params expect(response).to be_ok expected_settings = { @@ -134,7 +134,7 @@ RSpec.describe GradebookSettingsController, type: :controller do @course.workflow_state = "concluded" @course.save! - put :update, valid_params + put :update, params: valid_params expect(response).to be_ok expected_settings = { @@ -149,7 +149,7 @@ RSpec.describe GradebookSettingsController, type: :controller do context "given invalid params" do it "give an error response" do invalid_params = { "course_id" => @course.id } - put :update, invalid_params + put :update, params: invalid_params expect(response).not_to be_ok expect(json_response).to include( diff --git a/spec/controllers/gradebook_uploads_controller_spec.rb b/spec/controllers/gradebook_uploads_controller_spec.rb index ec8d0061c27..66c848af10a 100644 --- a/spec/controllers/gradebook_uploads_controller_spec.rb +++ b/spec/controllers/gradebook_uploads_controller_spec.rb @@ -41,7 +41,7 @@ describe GradebookUploadsController do def upload_gradebook_import(course, file) data = Rack::Test::UploadedFile.new(file.path, 'text/csv', true) - post 'create', course_id: course.id, gradebook_upload: {uploaded_data: data} + post 'create', params: {course_id: course.id, gradebook_upload: {uploaded_data: data}} end def check_create_response(include_sis_id=false) @@ -77,7 +77,7 @@ describe GradebookUploadsController do describe "POST 'create'" do it "should require authorization" do - post 'create', :course_id => @course.id + post 'create', params: {:course_id => @course.id} assert_unauthorized end @@ -114,7 +114,7 @@ describe GradebookUploadsController do describe "GET 'data'" do it "requires authorization" do - get 'data', course_id: @course.id + get 'data', params: {course_id: @course.id} assert_unauthorized end @@ -125,7 +125,7 @@ describe GradebookUploadsController do @gb_upload = GradebookUpload.new course: @course, user: @teacher, progress: progress, gradebook: {foo: 'bar'} @gb_upload.save - get 'data', course_id: @course.id + get 'data', params: {course_id: @course.id} expect(response).to be_success expect(response.body).to eq("while(1);{\"foo\":\"bar\"}") end @@ -135,7 +135,7 @@ describe GradebookUploadsController do progress = Progress.create!(tag: "test", context: @teacher) @gb_upload = GradebookUpload.new course: @course, user: @teacher, progress: progress, gradebook: {foo: 'bar'} @gb_upload.save - get 'data', course_id: @course.id + get 'data', params: {course_id: @course.id} expect { GradebookUpload.find(@gb_upload.id) }.to raise_error(ActiveRecord::RecordNotFound) expect(response).to be_success end diff --git a/spec/controllers/gradebooks_controller_spec.rb b/spec/controllers/gradebooks_controller_spec.rb index 9e173e05bbd..ea3797aaf08 100644 --- a/spec/controllers/gradebooks_controller_spec.rb +++ b/spec/controllers/gradebooks_controller_spec.rb @@ -39,33 +39,33 @@ describe GradebooksController do describe "GET 'grade_summary'" do it "redirects to the login page if the user is logged out" do - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to redirect_to(login_url) expect(flash[:warning]).to be_present end it "redirects teacher to gradebook" do user_session(@teacher) - get 'grade_summary', :course_id => @course.id, :id => nil + get 'grade_summary', params: {:course_id => @course.id, :id => nil} expect(response).to redirect_to(:action => 'show') end it "renders for current user" do user_session(@student) - get 'grade_summary', :course_id => @course.id, :id => nil + get 'grade_summary', params: {:course_id => @course.id, :id => nil} expect(response).to render_template('grade_summary') end it "does not allow access for inactive enrollment" do user_session(@student) @student_enrollment.deactivate - get 'grade_summary', :course_id => @course.id, :id => nil + get 'grade_summary', params: {:course_id => @course.id, :id => nil} assert_unauthorized end it "renders with specified user_id" do user_session(@student) - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to render_template('grade_summary') expect(assigns[:presenter].courses_with_grades).not_to be_nil end @@ -73,15 +73,15 @@ describe GradebooksController do it "does not allow access for wrong user" do user_factory(active_all: true) user_session(@user) - get 'grade_summary', :course_id => @course.id, :id => nil + get 'grade_summary', params: {:course_id => @course.id, :id => nil} assert_unauthorized - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} assert_unauthorized end it "allows access for a linked observer" do user_session(@observer) - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to render_template('grade_summary') expect(assigns[:courses_with_grades]).to be_nil end @@ -93,7 +93,7 @@ describe GradebooksController do @se.accept @se.update_attribute(:associated_user_id, @student.id) @user.reload - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} assert_unauthorized end @@ -104,14 +104,14 @@ describe GradebooksController do user_session(@observer) - get 'grade_summary', :course_id => @course2.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course2.id, :id => @student.id} assert_unauthorized end it "allows concluded teachers to see a student grades pages" do user_session(@teacher) @teacher_enrollment.conclude - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to be_success expect(response).to render_template('grade_summary') expect(assigns[:courses_with_grades]).to be_nil @@ -120,7 +120,7 @@ describe GradebooksController do it "allows concluded students to see their grades pages" do user_session(@student) @student_enrollment.conclude - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to render_template('grade_summary') end @@ -130,7 +130,7 @@ describe GradebooksController do course_with_teacher(:user => @teacher, :active_all => 1) student_in_course :user => @student, :active_all => 1 user_session(@student) - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to be_success expect(assigns[:presenter].courses_with_grades).not_to be_nil expect(assigns[:presenter].courses_with_grades.length).to eq 2 @@ -142,7 +142,7 @@ describe GradebooksController do course_with_teacher(:user => @teacher, :active_all => 1) student_in_course :user => @student, :active_all => 1 user_session(@teacher) - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(response).to be_success expect(assigns[:courses_with_grades]).to be_nil end @@ -161,14 +161,14 @@ describe GradebooksController do oe.accept user_session(@observer) - get 'grade_summary', :course_id => course1.id, :id => @student.id + get 'grade_summary', params: {:course_id => course1.id, :id => @student.id} expect(response).to be_success expect(assigns[:courses_with_grades]).to be_nil end it "assigns assignment group values for grade calculator to ENV" do user_session(@teacher) - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(assigns[:js_env][:submissions]).not_to be_nil expect(assigns[:js_env][:assignment_groups]).not_to be_nil end @@ -179,7 +179,7 @@ describe GradebooksController do assignment1.submission_types = "discussion_topic" assignment1.save! - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} expect(assigns[:js_env][:assignment_groups].first[:assignments].first["discussion_topic"]).to be_nil end @@ -187,7 +187,7 @@ describe GradebooksController do user_session(@student) assignment = @course.assignments.create!(title: "Example Assignment") assignment.mute! - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assigns[:js_env][:assignment_groups].first[:assignments].size).to eq 1 expect(assigns[:js_env][:assignment_groups].first[:assignments].first[:muted]).to eq true end @@ -200,7 +200,7 @@ describe GradebooksController do a1.mute! a1.grade_student(@student, grade: 10, grader: @teacher) a2.grade_student(@student, grade: 5, grader: @teacher) - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expected = expect(assigns[:js_env][:submissions].sort_by { |s| s['assignment_id'] @@ -213,7 +213,7 @@ describe GradebooksController do user_session(@student) assignment = @course.assignments.create!(points_possible: 10) assignment.grade_student(@student, grade: 10, grader: @teacher) - get('grade_summary', course_id: @course.id, id: @student.id) + get('grade_summary', params: {course_id: @course.id, id: @student.id}) submission = assigns[:js_env][:submissions].first expect(submission).to include :excused expect(submission).to include :workflow_state @@ -232,14 +232,14 @@ describe GradebooksController do let(:assignment_ids) { assigns[:presenter].assignments.select{ |a| a.class == Assignment }.map(&:id) } it "sorts assignments by due date (null last), then title if there is no saved order preference" do - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment3, assignment2, assignment1].map(&:id) end it "sort order of 'due_at' sorts by due date (null last), then title" do @teacher.preferences[:course_grades_assignment_order] = { @course.id => :due_at } @teacher.save! - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment3, assignment2, assignment1].map(&:id) end @@ -250,14 +250,14 @@ describe GradebooksController do end it "sorts assignments by title" do - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment2, assignment1, assignment3].map(&:id) end it "ingores case" do assignment1.title = 'banana' assignment1.save! - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment2, assignment1, assignment3].map(&:id) end end @@ -265,7 +265,7 @@ describe GradebooksController do it "sort order of 'assignment_group' sorts by assignment group position, then assignment position" do @teacher.preferences[:course_grades_assignment_order] = { @course.id => :assignment_group } @teacher.save! - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment1, assignment2, assignment3].map(&:id) end @@ -296,14 +296,14 @@ describe GradebooksController do end it "sorts by module position, then context module tag position" do - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment3, assignment2, assignment1].map(&:id) end it "sorts by module position, then context module tag position, " \ "with those not belonging to a module sorted last" do assignment3.context_module_tags.first.destroy! - get 'grade_summary', course_id: @course.id, id: @student.id + get 'grade_summary', params: {course_id: @course.id, id: @student.id} expect(assignment_ids).to eq [assignment2, assignment1, assignment3].map(&:id) end end @@ -324,34 +324,34 @@ describe GradebooksController do it "does not display totals if 'All Grading Periods' is selected" do user_session(@student) all_grading_periods_id = 0 - get 'grade_summary', :course_id => @course.id, :id => @student.id, grading_period_id: all_grading_periods_id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id, grading_period_id: all_grading_periods_id} expect(assigns[:exclude_total]).to eq true end it "assigns grading period values for grade calculator to ENV" do user_session(@teacher) all_grading_periods_id = 0 - get 'grade_summary', :course_id => @course.id, :id => @student.id, grading_period_id: all_grading_periods_id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id, grading_period_id: all_grading_periods_id} expect(assigns[:js_env][:submissions]).not_to be_nil expect(assigns[:js_env][:grading_periods]).not_to be_nil end it "displays totals if any grading period other than 'All Grading Periods' is selected" do user_session(@student) - get 'grade_summary', :course_id => @course.id, :id => @student.id, grading_period_id: 1 + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id, grading_period_id: 1} expect(assigns[:exclude_total]).to eq false end it "includes the grading period group (as 'set') in the ENV" do user_session(@teacher) - get :grade_summary, { course_id: @course.id, id: @student.id } + get :grade_summary, params: { course_id: @course.id, id: @student.id } grading_period_set = assigns[:js_env][:grading_period_set] expect(grading_period_set[:id]).to eq @grading_period_group.id end it "includes grading periods within the group" do user_session(@teacher) - get :grade_summary, { course_id: @course.id, id: @student.id } + get :grade_summary, params: { course_id: @course.id, id: @student.id } grading_period_set = assigns[:js_env][:grading_period_set] expect(grading_period_set[:grading_periods].count).to eq 3 period = grading_period_set[:grading_periods][0] @@ -361,7 +361,7 @@ describe GradebooksController do it "includes necessary keys with each grading period" do user_session(@teacher) - get :grade_summary, { course_id: @course.id, id: @student.id } + get :grade_summary, params: { course_id: @course.id, id: @student.id } periods = assigns[:js_env][:grading_period_set][:grading_periods] expect(periods).to all include(:id, :start_date, :end_date, :close_date, :is_closed, :is_last) end @@ -391,7 +391,7 @@ describe GradebooksController do [@student, @teacher, @observer].each do |u| controller.js_env.clear user_session(u) - get 'grade_summary', :course_id => @course.id, :id => @student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @student.id} assignment_due_at = assigns[:presenter].assignments.find{|a| a.class == Assignment}.due_at expect(assignment_due_at.to_i).to eq due_at.to_i end @@ -423,7 +423,7 @@ describe GradebooksController do @fake_student = @course.student_view_student session[:become_user_id] = @fake_student.id - get 'grade_summary', :course_id => @course.id, :id => @fake_student.id + get 'grade_summary', params: {:course_id => @course.id, :id => @fake_student.id} assignment_due_at = assigns[:presenter].assignments.find{|a| a.class == Assignment}.due_at expect(assignment_due_at.to_i).to eq @due_at.to_i end @@ -484,7 +484,7 @@ describe GradebooksController do it "raises an exception on a non-integer :id" do user_session(@teacher) assert_page_not_found do - get 'grade_summary', :course_id => @course.id, :id => "lqw" + get 'grade_summary', params: {:course_id => @course.id, :id => "lqw"} end end end @@ -494,7 +494,7 @@ describe GradebooksController do it "renders successfully" do account_admin_user(account: @course.root_account) user_session(@admin) - get "show", :course_id => @course.id + get "show", params: {:course_id => @course.id} expect(response).to render_template("gradebook") end end @@ -507,20 +507,20 @@ describe GradebooksController do it "renders new gradebook when enabled" do @course.enable_feature!(:new_gradebook) - get "show", course_id: @course.id + get "show", params: {course_id: @course.id} expect(response).to render_template("gradebooks/gradezilla/gradebook") end it "renders new indidivual view when enabled" do @course.enable_feature!(:new_gradebook) allow(@admin).to receive(:preferred_gradebook_version).and_return('individual') - get "show", course_id: @course.id + get "show", params: {course_id: @course.id} expect(response).to render_template("gradebooks/gradezilla/individual") end it "ignores the version parameter outside development environments" do allow(Rails.env).to receive(:development?).and_return(false) - get "show", course_id: @course.id, version: 'gradezilla-gradebook' + get "show", params: {course_id: @course.id, version: 'gradezilla-gradebook'} expect(response).to render_template(:gradebook) end end @@ -534,12 +534,12 @@ describe GradebooksController do it "includes colors if New Gradebook is enabled" do @course.enable_feature!(:new_gradebook) - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(gradebook_options).to have_key :colors end it "does not include colors if New Gradebook is disabled" do - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(gradebook_options).not_to have_key :colors end @@ -556,14 +556,14 @@ describe GradebooksController do it 'includes api_max_per_page' do Setting.set('api_max_per_page', 50) - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} api_max_per_page = assigns[:js_env][:GRADEBOOK_OPTIONS][:api_max_per_page] expect(api_max_per_page).to eq(50) end describe "graded_late_or_missing_submissions_exist" do it "is not included if New Gradebook is disabled" do - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(gradebook_options).not_to have_key :graded_late_or_missing_submissions_exist end @@ -585,7 +585,7 @@ describe GradebooksController do end it "is included if New Gradebook is enabled" do - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} gradebook_options = controller.js_env.fetch(:GRADEBOOK_OPTIONS) expect(gradebook_options).to have_key :graded_late_or_missing_submissions_exist end @@ -593,30 +593,30 @@ describe GradebooksController do it "is true if graded late submissions exist" do assignment.submit_homework(@student, body: "a body") assignment.grade_student(@student, grader: @teacher, grade: 8) - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(graded_late_or_missing_submissions_exist).to eq(true) end it "is false if late submissions exist, but they are not graded" do assignment.submit_homework(@student, body: "a body") - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(graded_late_or_missing_submissions_exist).to eq(false) end it "is true if graded missing submissions exist" do assignment.grade_student(@student, grader: @teacher, grade: 8) - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(graded_late_or_missing_submissions_exist).to eq(true) end it "is false if missing submissions exist, but they are not graded" do assignment # create the assignment so that missing submissions exist - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(graded_late_or_missing_submissions_exist).to eq(false) end it "is false if there are no graded late or missing submissions" do - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(graded_late_or_missing_submissions_exist).to eq(false) end end @@ -636,7 +636,7 @@ describe GradebooksController do shared_examples_for "working download" do it "does not recompute enrollment grades" do Enrollment.expects(:recompute_final_score).never - get 'show', :course_id => @course.id, :init => 1, :assignments => 1, :format => 'csv' + get 'show', params: {:course_id => @course.id, :init => 1, :assignments => 1}, :format => 'csv' end it "should get all the expected datas even with multibytes characters", :focus => true do @course.assignments.create(:title => "Déjà vu") @@ -672,25 +672,25 @@ describe GradebooksController do it "redirects to Grid View with a friendly URL" do @teacher.preferences[:gradebook_version] = "2" - get "show", :course_id => @course.id + get "show", params: {:course_id => @course.id} expect(response).to render_template("gradebook") end it "redirects to Individual View with a friendly URL" do @teacher.preferences[:gradebook_version] = "srgb" - get "show", :course_id => @course.id + get "show", params: {:course_id => @course.id} expect(response).to render_template("screenreader") end it "requests groups without wiki_page assignments" do - get "show", :course_id => @course.id + get "show", params: {:course_id => @course.id} url = controller.js_env[:GRADEBOOK_OPTIONS][:assignment_groups_url] expect(URI.unescape(url)).to include 'exclude_assignment_submission_types[]=wiki_page' end end it "renders the unauthorized page without gradebook authorization" do - get "show", :course_id => @course.id + get "show", params: {:course_id => @course.id} assert_unauthorized end @@ -698,7 +698,7 @@ describe GradebooksController do before do user_session(@teacher) - get 'show', course_id: @course.id + get 'show', params: {course_id: @course.id} @gradebook_env = assigns[:js_env][:GRADEBOOK_OPTIONS] end @@ -726,19 +726,19 @@ describe GradebooksController do before { user_session(@teacher) } it "includes context_id" do - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} context_id = assigns[:js_env][:GRADEBOOK_OPTIONS][:context_id] expect(context_id).to eq @course.id.to_param end it "doesn't enable context cards when feature is off" do - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED]).to eq false end it "enables context cards when feature is on" do @course.root_account.enable_feature! :student_context_cards - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} expect(assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED]).to eq true end end @@ -749,7 +749,7 @@ describe GradebooksController do it 'includes login_handle_name' do @course.account.update!(login_handle_name: custom_login_id) - get :show, course_id: @course.id + get :show, params: {course_id: @course.id} login_handle_name = assigns[:js_env][:GRADEBOOK_OPTIONS][:login_handle_name] @@ -772,13 +772,13 @@ describe GradebooksController do before { user_session(@teacher) } it "includes the grading period group (as 'set') in the ENV" do - get :show, { course_id: @course.id } + get :show, params: { course_id: @course.id } grading_period_set = assigns[:js_env][:GRADEBOOK_OPTIONS][:grading_period_set] expect(grading_period_set[:id]).to eq @grading_period_group.id end it "includes grading periods within the group" do - get :show, { course_id: @course.id } + get :show, params: { course_id: @course.id } grading_period_set = assigns[:js_env][:GRADEBOOK_OPTIONS][:grading_period_set] expect(grading_period_set[:grading_periods].count).to eq 3 period = grading_period_set[:grading_periods][0] @@ -787,7 +787,7 @@ describe GradebooksController do end it "includes necessary keys with each grading period" do - get :show, { course_id: @course.id } + get :show, params: { course_id: @course.id } periods = assigns[:js_env][:GRADEBOOK_OPTIONS][:grading_period_set][:grading_periods] expect(periods).to all include(:id, :start_date, :end_date, :close_date, :is_closed, :is_last) end @@ -796,26 +796,26 @@ describe GradebooksController do describe "GET 'user_ids'" do it "returns unauthorized if there is no current user" do - get :user_ids, course_id: @course.id, format: :json + get :user_ids, params: {course_id: @course.id}, format: :json assert_status(401) end it "returns unauthorized if the user is not authorized to manage grades" do user_session(@student) - get :user_ids, course_id: @course.id, format: :json + get :user_ids, params: {course_id: @course.id}, format: :json assert_status(401) end it "grants authorization to teachers in active courses" do user_session(@teacher) - get :user_ids, course_id: @course.id, format: :json + get :user_ids, params: {course_id: @course.id}, format: :json expect(response).to be_ok end it "grants authorization to teachers in concluded courses" do @course.complete! user_session(@teacher) - get :user_ids, course_id: @course.id, format: :json + get :user_ids, params: {course_id: @course.id}, format: :json expect(response).to be_ok end @@ -832,7 +832,7 @@ describe GradebooksController do } user_session(@teacher) - get :user_ids, course_id: @course.id, format: :json + get :user_ids, params: {course_id: @course.id}, format: :json user_ids = json_parse(response.body)["user_ids"] expect(user_ids).to eq([student2.id, student1.id, student3.id]) end @@ -885,12 +885,12 @@ describe GradebooksController do describe "GET 'change_gradebook_version'" do it 'switches to gradebook if clicked' do user_session(@teacher) - get 'grade_summary', :course_id => @course.id, :id => nil + get 'grade_summary', params: {:course_id => @course.id, :id => nil} expect(response).to redirect_to(:action => 'show') # tell it to use gradebook 2 - get 'change_gradebook_version', :course_id => @course.id, :version => 2 + get 'change_gradebook_version', params: {:course_id => @course.id, :version => 2} expect(response).to redirect_to(:action => 'show') end end @@ -899,7 +899,7 @@ describe GradebooksController do it "requires authentication" do course_factory assignment_model - post 'submissions_zip_upload', :course_id => @course.id, :assignment_id => @assignment.id, :submissions_zip => 'dummy' + post 'submissions_zip_upload', params: {:course_id => @course.id, :assignment_id => @assignment.id, :submissions_zip => 'dummy'} assert_unauthorized end end @@ -911,13 +911,15 @@ describe GradebooksController do @student = @course.enroll_user(User.create!(:name => "some user")) post( 'update_submission', - format: :json, - course_id: @course.id, - submission: { - assignment_id: @assignment.id, - user_id: @student.user_id, - grade: 10 - } + params: { + course_id: @course.id, + submission: { + assignment_id: @assignment.id, + user_id: @student.user_id, + grade: 10 + } + }, + format: :json ) submissions = JSON.parse(response.body).map{ |sub| sub['submission']} @@ -928,8 +930,8 @@ describe GradebooksController do user_session(@teacher) @assignment = @course.assignments.create!(:title => "some assignment") @student = @course.enroll_user(User.create!(:name => "some user")) - post 'update_submission', :course_id => @course.id, :submission => - {:comment => "some comment",:assignment_id => @assignment.id, :user_id => @student.user_id} + post 'update_submission', params: {:course_id => @course.id, :submission => + {:comment => "some comment",:assignment_id => @assignment.id, :user_id => @student.user_id}} expect(response).to be_redirect expect(assigns[:assignment]).to eql(@assignment) expect(assigns[:submissions]).not_to be_nil @@ -944,11 +946,11 @@ describe GradebooksController do @student = @course.enroll_user(User.create!(:name => "some user")) data = fixture_file_upload("scribd_docs/doc.doc", "application/msword", true) post 'update_submission', - :course_id => @course.id, + params: {:course_id => @course.id, :attachments => { "0" => { :uploaded_data => data } }, :submission => { :comment => "some comment", :assignment_id => @assignment.id, - :user_id => @student.user_id } + :user_id => @student.user_id }} expect(response).to be_redirect expect(assigns[:assignment]).to eql(@assignment) expect(assigns[:submissions]).not_to be_nil @@ -965,10 +967,10 @@ describe GradebooksController do @assignment = @course.assignments.create!(:title => "some assignment") @student = @course.enroll_user(User.create!(:name => "some user")) post 'update_submission', - :course_id => @course.id, + params: {:course_id => @course.id, :submission => { :comment => "some comment", :assignment_id => @assignment.id, - :user_id => @student.user_id } + :user_id => @student.user_id }} assert_unauthorized end @@ -982,18 +984,18 @@ describe GradebooksController do :assignment => @assignment) post 'update_submission', - :course_id => @course.id, + params: {:course_id => @course.id, :submission => { :comment => "some comment", :assignment_id => @assignment.id, - :user_id => s1.user_id } + :user_id => s1.user_id }} expect(response).to be_redirect # attempt to grade another section throws not found post 'update_submission', - :course_id => @course.id, + params: {:course_id => @course.id, :submission => { :comment => "some comment", :assignment_id => @assignment.id, - :user_id => s2.user_id } + :user_id => s2.user_id }} expect(flash[:error]).to eql 'Submission was unsuccessful: Submission Failed' end @@ -1010,13 +1012,13 @@ describe GradebooksController do it "creates a provisional grade" do submission = @assignment.submit_homework(@student, :body => "hello") post 'update_submission', - :format => :json, - :course_id => @course.id, + params: {:course_id => @course.id, :submission => { :score => 100, :comment => "provisional!", :assignment_id => @assignment.id, :user_id => @student.id, - :provisional => true } + :provisional => true }}, + :format => :json # confirm "real" grades/comments were not written submission.reload @@ -1040,14 +1042,14 @@ describe GradebooksController do it "includes the graded anonymously flag in the provisional grade object" do submission = @assignment.submit_homework(@student, body: "hello") post 'update_submission', - format: :json, - course_id: @course.id, + params: {course_id: @course.id, submission: { score: 100, comment: "provisional!", assignment_id: @assignment.id, user_id: @student.id, provisional: true, - graded_anonymously: true } + graded_anonymously: true }}, + format: :json submission.reload pg = submission.provisional_grade(@teacher) @@ -1055,14 +1057,14 @@ describe GradebooksController do submission = @assignment.submit_homework(@student, body: "hello") post 'update_submission', - format: :json, - course_id: @course.id, + params: {course_id: @course.id, submission: { score: 100, comment: "provisional!", assignment_id: @assignment.id, user_id: @student.id, provisional: true, - graded_anonymously: false } + graded_anonymously: false }}, + format: :json submission.reload pg = submission.provisional_grade(@teacher) @@ -1074,9 +1076,9 @@ describe GradebooksController do other_teacher = teacher_in_course(:course => @course, :active_all => true).user submission.find_or_create_provisional_grade!(other_teacher) - post 'update_submission', :format => :json, :course_id => @course.id, + post 'update_submission', params: {:course_id => @course.id, :submission => { :score => 100, :comment => "provisional!", :assignment_id => @assignment.id, - :user_id => @student.id, :provisional => true } + :user_id => @student.id, :provisional => true }}, :format => :json expect(response).to_not be_success expect(response.body).to include("Student already has the maximum number of provisional grades") end @@ -1088,9 +1090,9 @@ describe GradebooksController do @assignment.moderated_grading_selections.create!(:student => @student) - post 'update_submission', :format => :json, :course_id => @course.id, + post 'update_submission', params: {:course_id => @course.id, :submission => { :score => 100, :comment => "provisional!", :assignment_id => @assignment.id, - :user_id => @student.id, :provisional => true } + :user_id => @student.id, :provisional => true }}, :format => :json expect(response).to be_success end @@ -1100,15 +1102,15 @@ describe GradebooksController do submission.find_or_create_provisional_grade!(other_teacher) # create one so we can make a final post 'update_submission', - :format => :json, - :course_id => @course.id, + params: {:course_id => @course.id, :submission => { :score => 100, :comment => "provisional!", :assignment_id => @assignment.id, :user_id => @student.id, :provisional => true, :final => true - } + }}, + :format => :json expect(response).to be_success # confirm "real" grades/comments were not written @@ -1141,7 +1143,7 @@ describe GradebooksController do Course.any_instance.stubs(:large_roster?).returns(true) - get 'speed_grader', :course_id => @course.id, :assignment_id => assignment.id + get 'speed_grader', params: {:course_id => @course.id, :assignment_id => assignment.id} expect(response).to be_redirect expect(flash[:notice]).to eq 'SpeedGrader is disabled for this course' end @@ -1157,7 +1159,7 @@ describe GradebooksController do end it "redirects if the assignment is unpublished" do - get 'speed_grader', course_id: @course, assignment_id: @assign.id + get 'speed_grader', params: {course_id: @course, assignment_id: @assign.id} expect(response).to be_redirect expect(flash[:notice]).to eq I18n.t( :speedgrader_enabled_only_for_published_content, @@ -1166,7 +1168,7 @@ describe GradebooksController do it "does not redirect if the assignment is published" do @assign.publish - get 'speed_grader', course_id: @course, assignment_id: @assign.id + get 'speed_grader', params: {course_id: @course, assignment_id: @assign.id} expect(response).not_to be_redirect end end @@ -1175,7 +1177,7 @@ describe GradebooksController do user_session(@teacher) @assignment = @course.assignments.create!(title: "A Title", submission_types: 'online_url,online_file') - get 'speed_grader', course_id: @course, assignment_id: @assignment.id + get 'speed_grader', params: {course_id: @course, assignment_id: @assignment.id} expect(assigns[:js_env][:lti_retrieve_url]).not_to be_nil end @@ -1187,7 +1189,7 @@ describe GradebooksController do grading_type: 'percent' ) - get 'speed_grader', course_id: @course, assignment_id: @assignment.id + get 'speed_grader', params: {course_id: @course, assignment_id: @assignment.id} expect(assigns[:js_env][:grading_type]).to eq('percent') end end @@ -1197,12 +1199,12 @@ describe GradebooksController do user_session(@teacher) expect(@teacher.preferences[:enable_speedgrader_grade_by_question]).not_to be_truthy - post 'speed_grader_settings', course_id: @course.id, - enable_speedgrader_grade_by_question: "1" + post 'speed_grader_settings', params: {course_id: @course.id, + enable_speedgrader_grade_by_question: "1"} expect(@teacher.reload.preferences[:enable_speedgrader_grade_by_question]).to be_truthy - post 'speed_grader_settings', course_id: @course.id, - enable_speedgrader_grade_by_question: "0" + post 'speed_grader_settings', params: {course_id: @course.id, + enable_speedgrader_grade_by_question: "0"} expect(@teacher.reload.preferences[:enable_speedgrader_grade_by_question]).not_to be_truthy end end @@ -1210,7 +1212,7 @@ describe GradebooksController do describe "POST 'save_assignment_order'" do it "saves the sort order in the user's preferences" do user_session(@teacher) - post 'save_assignment_order', course_id: @course.id, assignment_order: 'due_at' + post 'save_assignment_order', params: {course_id: @course.id, assignment_order: 'due_at'} saved_order = @teacher.preferences[:course_grades_assignment_order][@course.id] expect(saved_order).to eq(:due_at) end diff --git a/spec/controllers/grading_period_sets_controller_spec.rb b/spec/controllers/grading_period_sets_controller_spec.rb index 69def6b3cd7..2ed2a398698 100644 --- a/spec/controllers/grading_period_sets_controller_spec.rb +++ b/spec/controllers/grading_period_sets_controller_spec.rb @@ -38,7 +38,7 @@ RSpec.describe GradingPeriodSetsController, type: :controller do it "fetches grading period sets" do group_helper.create_for_account(root_account) - get :index, {account_id: root_account.to_param}, valid_session + get :index, params: {account_id: root_account.to_param}, session: valid_session expect(json_parse.fetch('grading_period_sets').count).to eql 1 end @@ -46,7 +46,7 @@ RSpec.describe GradingPeriodSetsController, type: :controller do it "includes grading periods" do group = group_helper.create_for_account(root_account) period = Factories::GradingPeriodHelper.new.create_for_group(group) - get :index, {account_id: root_account.to_param}, valid_session + get :index, params: {account_id: root_account.to_param}, session: valid_session sets = json_parse.fetch('grading_period_sets') periods = sets.first.fetch('grading_periods') expect(periods.count).to eql 1 @@ -56,11 +56,11 @@ RSpec.describe GradingPeriodSetsController, type: :controller do describe "POST #create" do let(:post_create) do - post :create, { + post :create, params: { account_id: root_account.to_param, enrollment_term_ids: [enrollment_term.to_param], grading_period_set: group_helper.valid_attributes(weighted: true) - }, valid_session + }, session: valid_session end context "with valid params" do @@ -82,7 +82,7 @@ RSpec.describe GradingPeriodSetsController, type: :controller do account_id: root_account.to_param, grading_period_set: group_helper.valid_attributes } - expect { post :create, params, valid_session }.to change(GradingPeriodGroup, :count).by(1) + expect { post :create, params: params, session: valid_session }.to change(GradingPeriodGroup, :count).by(1) end context "given a sub account enrollment term" do @@ -92,11 +92,11 @@ RSpec.describe GradingPeriodSetsController, type: :controller do end it "returns a Not Found status code" do - post :create, { + post :create, params: { account_id: root_account.to_param, enrollment_term_ids: [sub_account_enrollment_term.id], grading_period_set: group_helper.valid_attributes - }, valid_session + }, session: valid_session expect(response.status).to eql Rack::Utils.status_code(:not_found) end end @@ -108,12 +108,12 @@ RSpec.describe GradingPeriodSetsController, type: :controller do context "with valid params" do let(:patch_update) do - patch :update, { + patch :update, params: { account_id: root_account.to_param, id: grading_period_set.to_param, enrollment_term_ids: [enrollment_term.to_param], grading_period_set: new_attributes - }, valid_session + }, session: valid_session end it "updates the requested grading_period_set" do @@ -135,18 +135,18 @@ RSpec.describe GradingPeriodSetsController, type: :controller do expect(GradeCalculator).to receive(:recompute_final_score) do |_, course_id, _| course_id == course.id end - patch :update, { + patch :update, params: { account_id: root_account.to_param, id: grading_period_set.to_param, enrollment_term_ids: [], grading_period_set: new_attributes - }, valid_session + }, session: valid_session end end it "defaults enrollment_term_ids to empty array" do grading_period_set.enrollment_terms << enrollment_term - patch :update, { + patch :update, params: { account_id: root_account.to_param, id: grading_period_set.to_param, grading_period_set: group_helper.valid_attributes @@ -162,12 +162,12 @@ RSpec.describe GradingPeriodSetsController, type: :controller do end it "returns a Not Found status code" do - patch :update, { + patch :update, params: { id: grading_period_set.to_param, account_id: root_account.to_param, enrollment_term_ids: [sub_account_enrollment_term.id], grading_period_set: group_helper.valid_attributes - }, valid_session + }, session: valid_session expect(response.status).to eql Rack::Utils.status_code(:not_found) end end @@ -177,10 +177,10 @@ RSpec.describe GradingPeriodSetsController, type: :controller do it "destroys the requested grading period set" do grading_period_set = group_helper.create_for_account(root_account) expect(grading_period_set.reload.workflow_state).to eq 'active' - delete :destroy, { + delete :destroy, params: { account_id: Account.default, id: grading_period_set.to_param - }, valid_session + }, session: valid_session expect(grading_period_set.reload.workflow_state).to eq 'deleted' end end @@ -192,7 +192,7 @@ RSpec.describe GradingPeriodSetsController, type: :controller do it "it fetches sets through the root account" do grading_period_set = group_helper.create_for_account(root_account) - get :index, {account_id: sub_account.to_param}, valid_session + get :index, params: {account_id: sub_account.to_param}, session: valid_session expect(json_parse.fetch('grading_period_sets').count).to eql 1 end diff --git a/spec/controllers/grading_periods_controller_spec.rb b/spec/controllers/grading_periods_controller_spec.rb index a945a71acf6..bf4cf36c63d 100644 --- a/spec/controllers/grading_periods_controller_spec.rb +++ b/spec/controllers/grading_periods_controller_spec.rb @@ -67,7 +67,7 @@ describe GradingPeriodsController do describe 'GET index' do it "paginates" do create_course_grading_period(course) - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect(json_parse).to have_key('meta') expect(json_parse['meta']).to have_key('pagination') expect(json_parse['meta']['primaryCollection']).to eql('grading_periods') @@ -75,7 +75,7 @@ describe GradingPeriodsController do describe 'with root account admins' do it 'disallows creating grading periods' do - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect(json_parse['can_create_grading_periods']).to be false end end @@ -83,7 +83,7 @@ describe GradingPeriodsController do describe 'with sub account admins' do it 'disallows creating grading periods' do login_sub_account - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect(json_parse['can_create_grading_periods']).to be false end end @@ -91,7 +91,7 @@ describe GradingPeriodsController do describe 'with course context' do it "can get any course associated grading periods with read_only set to false" do period = create_course_grading_period(course) - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect_grading_period_id_match(json_parse, period) expect(json_parse['grading_periods_read_only']).to eql(false) end @@ -100,13 +100,13 @@ describe GradingPeriodsController do create_course_grading_period(course, start_date: 2.days.from_now) create_course_grading_period(course, start_date: 5.days.from_now) create_course_grading_period(course, start_date: 3.days.from_now) - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect(json_parse['grading_periods']).to be_sorted_by('start_date') end it "can get any account associated grading periods with read_only set to true" do period = create_account_grading_period(root_account) - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect_grading_period_id_match(json_parse, period) expect(json_parse['grading_periods_read_only']).to eql(true) end @@ -114,12 +114,12 @@ describe GradingPeriodsController do it "gets course associated grading periods if both are available" do course_period = create_course_grading_period(course) account_period = create_account_grading_period(root_account) - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect_grading_period_id_match(json_parse, course_period) end it "sets read_only to false if no grading periods are given" do - get :index, { course_id: course.id } + get :index, params: { course_id: course.id } expect(json_parse['grading_periods_read_only']).to eql(false) end end @@ -127,7 +127,7 @@ describe GradingPeriodsController do describe 'with account context' do it "can get any account associated grading periods with read_only set to false" do period = create_account_grading_period(root_account) - get :index, { account_id: root_account.id } + get :index, params: { account_id: root_account.id } expect_grading_period_id_match(json_parse, period) expect(json_parse['grading_periods_read_only']).to eql(false) end @@ -136,18 +136,18 @@ describe GradingPeriodsController do create_account_grading_period(root_account, start_date: 2.days.from_now) create_account_grading_period(root_account, start_date: 5.days.from_now) create_account_grading_period(root_account, start_date: 3.days.from_now) - get :index, { account_id: root_account.id } + get :index, params: { account_id: root_account.id } expect(json_parse['grading_periods']).to be_sorted_by('start_date') end it "cannot get any course associated grading periods" do period = create_course_grading_period(course) - get :index, { account_id: root_account.id } + get :index, params: { account_id: root_account.id } expect(json_parse['grading_periods'].count).to eql(0) end it "sets read_only to false if no grading periods are given" do - get :index, { account_id: root_account.id } + get :index, params: { account_id: root_account.id } expect(json_parse['grading_periods_read_only']).to eql(false) end end @@ -156,19 +156,19 @@ describe GradingPeriodsController do describe 'GET show' do it 'can show course associated grading periods' do period = create_course_grading_period(course) - get :show, { course_id: course.id, id: period.to_param } + get :show, params: { course_id: course.id, id: period.to_param } expect_grading_period_id_match(json_parse, period) end it 'can show account associated grading periods' do period = create_account_grading_period(root_account) - get :show, { course_id: course.id, id: period.to_param } + get :show, params: { course_id: course.id, id: period.to_param } expect_grading_period_id_match(json_parse, period) end it 'returns the expected attributes' do period = create_course_grading_period(course) - get :show, { course_id: course.id, id: period.to_param } + get :show, params: { course_id: course.id, id: period.to_param } expected_attributes = [ "id", "grading_period_group_id", @@ -191,7 +191,7 @@ describe GradingPeriodsController do it "can update any course associated grading periods" do period = create_course_grading_period(course, { title: 'Grading Period' }) - put :update, { + put :update, params: { course_id: course.id, id: period.to_param, grading_periods: [{ @@ -203,7 +203,7 @@ describe GradingPeriodsController do it "cannot update any account associated grading periods" do period = create_account_grading_period(root_account, { title: 'Grading Period' }) - put :update, { + put :update, params: { course_id: course.id, id: period.to_param, grading_periods: [{ @@ -223,13 +223,13 @@ describe GradingPeriodsController do describe "with course context" do it "can destroy any course associated grading periods" do period = create_course_grading_period(course) - delete :destroy, { course_id: course.id, id: period.to_param } + delete :destroy, params: { course_id: course.id, id: period.to_param } expect(period.reload).to be_deleted end it "cannot destroy any account associated grading periods" do period = create_account_grading_period(root_account) - delete :destroy, { course_id: course.id, id: period.to_param } + delete :destroy, params: { course_id: course.id, id: period.to_param } expect(period.reload).not_to be_deleted expect(response).to be_not_found end @@ -238,13 +238,13 @@ describe GradingPeriodsController do describe "with account context" do it "can destroy any account associated grading periods" do period = create_account_grading_period(root_account) - delete :destroy, { account_id: root_account.id, id: period.to_param } + delete :destroy, params: { account_id: root_account.id, id: period.to_param } expect(period.reload).to be_deleted end it "cannot destroy any course associated grading periods" do period = create_course_grading_period(course) - delete :destroy, { account_id: root_account.id, id: period.to_param } + delete :destroy, params: { account_id: root_account.id, id: period.to_param } expect(period.reload).not_to be_deleted expect(response).to be_not_found end @@ -274,7 +274,7 @@ describe GradingPeriodsController do it "ignores unrelated grading period sets" do unrelated_group = group_helper.create_for_account(root_account) - patch :batch_update, { + patch :batch_update, params: { set_id: group.id, grading_periods: [period_1_params] } @@ -283,7 +283,7 @@ describe GradingPeriodsController do end it "compares the in memory periods' dates for overlapping" do - patch :batch_update, { + patch :batch_update, params: { set_id: group.id, grading_periods: [ period_1_params.merge(id: period_1.id, end_date: 3.days.from_now(now), close_date: 3.days.from_now(now)), @@ -302,7 +302,7 @@ describe GradingPeriodsController do end_date: (i+1).days.from_now(now) } end - patch :batch_update, { + patch :batch_update, params: { set_id: group.id, grading_periods: period_params } @@ -318,13 +318,13 @@ describe GradingPeriodsController do it "can create a single grading period" do expect do - patch :batch_update, { set_id: group.id, grading_periods: [period_1_params] } + patch :batch_update, params: { set_id: group.id, grading_periods: [period_1_params] } end.to change { group.grading_periods.count }.by 1 end it "can create multiple grading periods" do expect do - patch :batch_update, { + patch :batch_update, params: { set_id: group.id, grading_periods: [period_1_params, period_2_params] } @@ -332,14 +332,14 @@ describe GradingPeriodsController do end it "can update a single grading period" do - patch :batch_update, { set_id: group.id, grading_periods: [ + patch :batch_update, params: { set_id: group.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Updated Title') ] } expect(group.reload.grading_periods.find(period_1.id).title).to eq 'Updated Title' end it "can update multiple grading periods" do - patch :batch_update, { set_id: group.id, grading_periods: [ + patch :batch_update, params: { set_id: group.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title'), period_2_params.merge(id: period_2.id, title: 'Updated Title') ] } @@ -350,7 +350,7 @@ describe GradingPeriodsController do it "can create and update multiple grading periods" do period_1 = group.grading_periods.create!(period_1_params) expect do - patch :batch_update, { set_id: group.id, grading_periods: [ + patch :batch_update, params: { set_id: group.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'A Different Title'), period_2_params ] } @@ -376,7 +376,7 @@ describe GradingPeriodsController do end it "cannot update any grading periods" do - patch :batch_update, { set_id: group.id, grading_periods: [ + patch :batch_update, params: { set_id: group.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Updated Title') ] } expect(period_1.reload.title).to eql('Original Title') @@ -384,7 +384,7 @@ describe GradingPeriodsController do end it "responds with 404 not found upon failure" do - patch :batch_update, { set_id: group.id, grading_periods: [ + patch :batch_update, params: { set_id: group.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Updated Title') ] } expect(response).to be_not_found @@ -413,7 +413,7 @@ describe GradingPeriodsController do let(:period_2) { group.grading_periods.create!(period_2_params) } it "compares the in memory periods' dates for overlapping" do - patch :batch_update, { + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, end_date: 3.days.from_now(now), close_date: 3.days.from_now(now)), @@ -426,7 +426,7 @@ describe GradingPeriodsController do it "responds with json upon success" do request.content_type = 'application/json' - patch :batch_update, { course_id: course.id, grading_periods: [] } + patch :batch_update, params: { course_id: course.id, grading_periods: [] } expect(response).to be_ok json = JSON.parse(response.body) expect(json['grading_periods']).to be_empty @@ -435,7 +435,7 @@ describe GradingPeriodsController do it "responds with json upon failure" do period = period_helper.create_with_group_for_course(course) - patch :batch_update, { course_id: course.id, grading_periods: [{id: period.id, title: ''}] } + patch :batch_update, params: { course_id: course.id, grading_periods: [{id: period.id, title: ''}] } expect(response).not_to be_ok json = JSON.parse(response.body) expect(json['errors']).to be_present @@ -449,14 +449,14 @@ describe GradingPeriodsController do it "cannot create a single grading period" do expect do - patch :batch_update, { course_id: course.id, grading_periods: [period_1_params] } + patch :batch_update, params: { course_id: course.id, grading_periods: [period_1_params] } end.not_to change { course.grading_periods.count } expect(response.status).to eql(Rack::Utils.status_code(:unauthorized)) end it "cannot create multiple grading periods" do expect do - patch :batch_update, { + patch :batch_update, params: { course_id: course.id, grading_periods: [period_1_params, period_2_params] } @@ -464,14 +464,14 @@ describe GradingPeriodsController do end it "can update a single grading period" do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title') ] } expect(course.grading_periods.find(period_1.id).title).to eql('Original Title') end it "can update multiple grading periods" do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title'), period_2_params.merge(id: period_2.id, title: 'Updated Title') ] } @@ -482,7 +482,7 @@ describe GradingPeriodsController do it "cannot create and update multiple grading periods" do period_1 = group.grading_periods.create!(period_1_params) expect do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title'), period_2_params ] } @@ -498,14 +498,14 @@ describe GradingPeriodsController do it "cannot create a single grading period" do expect do - patch :batch_update, { course_id: course.id, grading_periods: [period_1_params] } + patch :batch_update, params: { course_id: course.id, grading_periods: [period_1_params] } end.not_to change { course.grading_periods.count } expect(response.status).to eql(Rack::Utils.status_code(:unauthorized)) end it "cannot create multiple grading periods" do expect do - patch :batch_update, { + patch :batch_update, params: { course_id: course.id, grading_periods: [period_1_params, period_2_params] } @@ -513,14 +513,14 @@ describe GradingPeriodsController do end it "can update a single grading period" do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title') ] } expect(course.grading_periods.find(period_1.id).title).to eql('Original Title') end it "can update multiple grading periods" do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title'), period_2_params.merge(id: period_2.id, title: 'Updated Title') ] } @@ -531,7 +531,7 @@ describe GradingPeriodsController do it "cannot create and update multiple grading periods" do period_1 = group.grading_periods.create!(period_1_params) expect do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Original Title'), period_2_params ] } @@ -558,7 +558,7 @@ describe GradingPeriodsController do end it "cannot update any grading periods" do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Updated Title') ] } expect(period_1.reload.title).to eql('Original Title') @@ -566,7 +566,7 @@ describe GradingPeriodsController do end it "responds with json upon failure" do - patch :batch_update, { course_id: course.id, grading_periods: [ + patch :batch_update, params: { course_id: course.id, grading_periods: [ period_1_params.merge(id: period_1.id, title: 'Updated Title') ] } expect(response.status).to eql(Rack::Utils.status_code(:not_found)) diff --git a/spec/controllers/grading_standards_controller_spec.rb b/spec/controllers/grading_standards_controller_spec.rb index e052e9af59d..76148a6ebb6 100644 --- a/spec/controllers/grading_standards_controller_spec.rb +++ b/spec/controllers/grading_standards_controller_spec.rb @@ -34,12 +34,12 @@ describe GradingStandardsController do let(:json_response) { json_parse['grading_standard']['data'] } it "responds with a 200 with a valid user, course id, and json format" do - post 'create', course_id: @course.id, format: 'json' + post 'create', params: {course_id: @course.id}, format: 'json' expect(response).to be_ok end it "uses the default grading standard if no standard data is provided" do - post 'create', course_id: @course.id, format: 'json' + post 'create', params: {course_id: @course.id}, format: 'json' expect(json_response).to eq(default_grading_standard) end @@ -50,7 +50,7 @@ describe GradingStandardsController do } # send the request as JSON, so that the nested arrays are preserved request.content_type = 'application/json' - post 'create', course_id: @course.id, grading_standard: standard, format: 'json' + post 'create', params: {course_id: @course.id, grading_standard: standard}, format: 'json' expect(json_response).to eq(standard[:data]) end @@ -62,7 +62,7 @@ describe GradingStandardsController do scheme_2: {name: 'F',value: 0} } } - post 'create', course_id: @course.id, grading_standard: standard, format: 'json' + post 'create', params: {course_id: @course.id, grading_standard: standard}, format: 'json' expected_response_data = [['A', 0.61], ['F', 0.00]] expect(json_response).to eq(expected_response_data) end @@ -75,7 +75,7 @@ describe GradingStandardsController do @admin = account_admin_user(account: @account) end - subject { get :index, account_id: @account.id } + subject { get :index, params: {account_id: @account.id} } it "returns a 200 for a valid request" do user_session(@admin) @@ -93,7 +93,7 @@ describe GradingStandardsController do course_with_teacher(active_all: true) end - subject { get :index, course_id: @course.id } + subject { get :index, params: {course_id: @course.id} } it "returns a 200 for a valid request" do user_session(@teacher) diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 9dd3bcf6419..0d60a8acdaa 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -62,7 +62,7 @@ describe GraphQLController do before { Account.default.enable_feature!("graphql") } it "works" do - post :execute, query: "{}" + post :execute, params: {query: "{}"} expect(JSON.parse(response.body)["errors"]).not_to be_blank end end diff --git a/spec/controllers/group_categories_controller_spec.rb b/spec/controllers/group_categories_controller_spec.rb index f8742a9def1..139f01dbe0c 100644 --- a/spec/controllers/group_categories_controller_spec.rb +++ b/spec/controllers/group_categories_controller_spec.rb @@ -27,7 +27,7 @@ describe GroupCategoriesController do describe "POST create" do it "should require authorization" do @group = @course.groups.create(:name => "some groups") - post 'create', :course_id => @course.id, :category => {} + post 'create', params: {:course_id => @course.id, :category => {}} assert_unauthorized end @@ -35,7 +35,7 @@ describe GroupCategoriesController do user_session(@teacher) @group = @course.groups.create(:name => "some groups") create_users_in_course(@course, 5) # plus one student in before block - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :split_group_count => 2, :split_groups => '1'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :split_group_count => 2, :split_groups => '1'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil groups = assigns[:group_category].groups @@ -46,7 +46,7 @@ describe GroupCategoriesController do it "should give the new groups the right group_category" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :split_group_count => 1, :split_groups => '1'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :split_group_count => 1, :split_groups => '1'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil expect(assigns[:group_category].groups[0].group_category.name).to eq "Study Groups" @@ -54,26 +54,26 @@ describe GroupCategoriesController do it "should error if the group name is protected" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {:name => "Student Groups"} + post 'create', params: {:course_id => @course.id, :category => {:name => "Student Groups"}} expect(response).not_to be_success end it "should error if the group name is already in use" do user_session(@teacher) @course.group_categories.create(:name => "My Category") - post 'create', :course_id => @course.id, :category => {:name => "My Category"} + post 'create', params: {:course_id => @course.id, :category => {:name => "My Category"}} expect(response).not_to be_success end it "should require the group name" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {} + post 'create', params: {:course_id => @course.id, :category => {}} expect(response).not_to be_success end it "should respect enable_self_signup" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil expect(assigns[:group_category]).to be_self_signup @@ -82,7 +82,7 @@ describe GroupCategoriesController do it "should use create_group_count when self-signup" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :create_group_count => '3'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :create_group_count => '3'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil expect(assigns[:group_category].groups.size).to eq 3 @@ -90,7 +90,7 @@ describe GroupCategoriesController do it "respects auto_leader params" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :enable_auto_leader => '1', :auto_leader_type => 'RANDOM'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :enable_auto_leader => '1', :auto_leader_type => 'RANDOM'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil expect(assigns[:group_category].auto_leader).to eq 'random' @@ -99,7 +99,7 @@ describe GroupCategoriesController do it "should respect the max new-category group count" do user_session(@teacher) Setting.set('max_groups_in_new_category', '5') - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :create_group_count => '7'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :create_group_count => '7'}} expect(response).to be_success expect(assigns[:group_category].groups.size).to eq 5 end @@ -107,7 +107,7 @@ describe GroupCategoriesController do it "should not distribute students when self-signup" do user_session(@teacher) create_users_in_course(@course, 3) - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :create_category_count => '2'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :create_category_count => '2'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil assigns[:group_category].groups.all?{ |g| expect(g.users).to be_empty } @@ -115,7 +115,7 @@ describe GroupCategoriesController do it "should respect restrict_self_signup" do user_session(@teacher) - post 'create', :course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :restrict_self_signup => '1'} + post 'create', params: {:course_id => @course.id, :category => {:name => "Study Groups", :enable_self_signup => '1', :restrict_self_signup => '1'}} expect(response).to be_success expect(assigns[:group_category]).not_to be_nil expect(assigns[:group_category]).to be_restricted_self_signup @@ -128,13 +128,13 @@ describe GroupCategoriesController do end it "should require authorization" do - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {}} assert_unauthorized end it "should update category" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {:name => "Different Category", :enable_self_signup => "1"} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {:name => "Different Category", :enable_self_signup => "1"}} expect(response).to be_success expect(assigns[:group_category]).to eql(@group_category) expect(assigns[:group_category].name).to eql("Different Category") @@ -143,33 +143,33 @@ describe GroupCategoriesController do it "should leave the name alone if not given" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {}} expect(response).to be_success expect(assigns[:group_category].name).to eq "My Category" end it "should not accept a sent but empty name" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {:name => ''} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {:name => ''}} expect(response).not_to be_success end it "should error if the name is protected" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {:name => "Student Groups"} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {:name => "Student Groups"}} expect(response).not_to be_success end it "should error if the name is already in use" do user_session(@teacher) @course.group_categories.create(:name => "Other Category") - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {:name => "Other Category"} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {:name => "Other Category"}} expect(response).not_to be_success end it "should not error if the name is the current name" do user_session(@teacher) - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {:name => "My Category"} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {:name => "My Category"}} expect(response).to be_success expect(assigns[:group_category].name).to eql("My Category") end @@ -184,7 +184,7 @@ describe GroupCategoriesController do group.add_user(user2) user_session(@teacher) - put 'update', :course_id => @course.id, :id => @group_category.id, :category => {:enable_self_signup => '1', :restrict_self_signup => '1'} + put 'update', params: {:course_id => @course.id, :id => @group_category.id, :category => {:enable_self_signup => '1', :restrict_self_signup => '1'}} expect(response).not_to be_success end end @@ -192,7 +192,7 @@ describe GroupCategoriesController do describe "DELETE delete" do it "should require authorization" do group_category = @course.group_categories.create(:name => "Study Groups") - delete 'destroy', :course_id => @course.id, :id => group_category.id + delete 'destroy', params: {:course_id => @course.id, :id => group_category.id} assert_unauthorized end @@ -202,7 +202,7 @@ describe GroupCategoriesController do category2 = @course.group_categories.create(:name => "Other Groups") @course.groups.create(:name => "some group", :group_category => category1) @course.groups.create(:name => "another group", :group_category => category2) - delete 'destroy', :course_id => @course.id, :id => category1.id + delete 'destroy', params: {:course_id => @course.id, :id => category1.id} expect(response).to be_success @course.reload expect(@course.all_group_categories.length).to eql(2) @@ -213,13 +213,13 @@ describe GroupCategoriesController do it "should fail if category doesn't exist" do user_session(@teacher) - delete 'destroy', :course_id => @course.id, :id => 11235 + delete 'destroy', params: {:course_id => @course.id, :id => 11235} expect(response).not_to be_success end it "should fail if category is protected" do user_session(@teacher) - delete 'destroy', :course_id => @course.id, :id => GroupCategory.student_organized_for(@course).id + delete 'destroy', params: {:course_id => @course.id, :id => GroupCategory.student_organized_for(@course).id} expect(response).not_to be_success end end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index d58a5b4f67e..6a084f145e8 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -35,7 +35,7 @@ describe GroupsController do it "is disabled when feature_flag is off" do @course.root_account.disable_feature! :student_context_cards user_session(@teacher) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED]).to be_falsey end @@ -44,13 +44,13 @@ describe GroupsController do RoleOverride.manage_role_override(Account.default, teacher_role, perm, override: false) end user_session(@teacher) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED]).to be true end it "is always disabled for students" do user_session(@student) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} cards_enabled = assigns[:js_env] && assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED] expect(cards_enabled).to be_falsey end @@ -63,7 +63,7 @@ describe GroupsController do g1 = @course.groups.create(:name => "some group", :group_category => category1) g2 = @course.groups.create(:name => "some other group", :group_category => category1) g3 = @course.groups.create(:name => "some third group", :group_category => category2) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} assert_unauthorized end @@ -74,7 +74,7 @@ describe GroupsController do g1 = @course.groups.create(:name => "some group", :group_category => category1) g2 = @course.groups.create(:name => "some other group", :group_category => category1) g3 = @course.groups.create(:name => "some third group", :group_category => category2) - get 'index', :course_id => @course.id + get 'index', params: {:course_id => @course.id} expect(response).to be_success expect(assigns[:groups]).not_to be_empty expect(assigns[:groups].length).to eql(3) @@ -99,7 +99,7 @@ describe GroupsController do groups << @course.groups.create(:name => "44", :group_category => category3) groups << @course.groups.create(:name => "4.5", :group_category => category3) groups.each {|g| g.add_user @student, 'accepted' } - get 'index', :course_id => @course.id, :per_page => 50, :format => 'json' + get 'index', params: {:course_id => @course.id, :per_page => 50}, format: 'json' expect(response).to be_success expect(assigns[:paginated_groups]).not_to be_empty expect(assigns[:paginated_groups].length).to eql(9) @@ -183,13 +183,13 @@ describe GroupsController do end it "should not paginate non-json" do - get 'index', :per_page => 1 + get 'index', params: {:per_page => 1} expect(assigns[:current_groups]).to eq @student.current_groups.by_name expect(response.headers['Link']).to be_nil end it "should paginate json" do - get 'index', :format => 'json', :per_page => 1 + get 'index', params: {:per_page => 1}, format: 'json' expect(assigns[:groups]).to eq [@student.current_groups.by_name.first] expect(response.headers['Link']).not_to be_nil end @@ -199,7 +199,7 @@ describe GroupsController do describe "GET show" do it "should require authorization" do @group = Account.default.groups.create!(:name => "some group") - get 'show', :id => @group.id + get 'show', params: {:id => @group.id} expect(assigns[:group]).to eql(@group) assert_unauthorized end @@ -209,7 +209,7 @@ describe GroupsController do @user = user_model user_session(@user) @group.add_user(@user) - get 'show', :id => @group.id + get 'show', params: {:id => @group.id} expect(response).to be_success expect(assigns[:group]).to eql(@group) expect(assigns[:context]).to eql(@group) @@ -223,7 +223,7 @@ describe GroupsController do category1.save! g1 = @course.groups.create!(:name => "some group", :group_category => category1) - get 'show', :course_id => @course.id, :id => g1.id, :join => 1 + get 'show', params: {:course_id => @course.id, :id => g1.id, :join => 1} g1.reload expect(g1.users.map(&:id)).to include @student.id end @@ -236,7 +236,7 @@ describe GroupsController do g1 = @course.groups.create!(:name => "some group", :group_category => category1) g1.add_user(@student) - get 'show', :course_id => @course.id, :id => g1.id, :leave => 1 + get 'show', params: {:course_id => @course.id, :id => g1.id, :leave => 1} g1.reload expect(g1.users.map(&:id)).not_to include @student.id end @@ -246,7 +246,7 @@ describe GroupsController do category1 = GroupCategory.student_organized_for(@course) g1 = @course.groups.create!(:name => "some group", :group_category => category1, :join_level => "parent_context_auto_join") - get 'show', :course_id => @course.id, :id => g1.id, :join => 1 + get 'show', params: {:course_id => @course.id, :id => g1.id, :join => 1} g1.reload expect(g1.users.map(&:id)).to include @student.id end @@ -257,7 +257,7 @@ describe GroupsController do g1 = @course.groups.create!(:name => "some group", :group_category => category1) g1.add_user(@student) - get 'show', :course_id => @course.id, :id => g1.id, :leave => 1 + get 'show', params: {:course_id => @course.id, :id => g1.id, :leave => 1} g1.reload expect(g1.users.map(&:id)).not_to include @student.id end @@ -268,7 +268,7 @@ describe GroupsController do category = @course.group_categories.create(:name => "category") group = @course.groups.create(:name => "some group", :group_category => category) - get 'show', :id => group.id + get 'show', params: {:id => group.id} expect(response).to be_success expect(assigns[:group]).to eql(group) @@ -278,7 +278,7 @@ describe GroupsController do describe "GET new" do it "should require authorization" do @group = @course.groups.create!(:name => "some group") - get 'new', :course_id => @course.id + get 'new', params: {:course_id => @course.id} assert_unauthorized end end @@ -286,7 +286,7 @@ describe GroupsController do describe "POST add_user" do it "should require authorization" do @group = Account.default.groups.create!(:name => "some group") - post 'add_user', :group_id => @group.id + post 'add_user', params: {:group_id => @group.id} assert_unauthorized end @@ -294,7 +294,7 @@ describe GroupsController do user_session(@teacher) @group = @course.groups.create!(:name => "PG 1", :group_category => @category) @user = user_factory(active_all: true) - post 'add_user', :group_id => @group.id, :user_id => @user.id + post 'add_user', params: {:group_id => @group.id, :user_id => @user.id} expect(response).to be_success expect(assigns[:membership]).not_to be_nil expect(assigns[:membership].user).to eql(@user) @@ -312,7 +312,7 @@ describe GroupsController do group = group_category.groups.create(:context => @course) group.add_user(user1) - post 'add_user', :group_id => group.id, :user_id => user2.id + post 'add_user', params: {:group_id => group.id, :user_id => user2.id} expect(response).not_to be_success expect(assigns[:membership]).not_to be_nil expect(assigns[:membership].user).to eql(user2) @@ -325,7 +325,7 @@ describe GroupsController do @group = Account.default.groups.create!(:name => "some group") @user = user_factory(active_all: true) @group.add_user(@user) - delete 'remove_user', :group_id => @group.id, :user_id => @user.id, :id => @user.id + delete 'remove_user', params: {:group_id => @group.id, :user_id => @user.id, :id => @user.id} assert_unauthorized end @@ -333,7 +333,7 @@ describe GroupsController do user_session(@teacher) @group = @course.groups.create!(:name => "PG 1", :group_category => @category) @group.add_user(@user) - delete 'remove_user', :group_id => @group.id, :user_id => @user.id, :id => @user.id + delete 'remove_user', params: {:group_id => @group.id, :user_id => @user.id, :id => @user.id} expect(response).to be_success @group.reload expect(@group.users).to be_empty @@ -342,13 +342,13 @@ describe GroupsController do describe "POST create" do it "should require authorization" do - post 'create', :course_id => @course.id, :group => {:name => "some group"} + post 'create', params: {:course_id => @course.id, :group => {:name => "some group"}} assert_unauthorized end it "should create new group" do user_session(@teacher) - post 'create', :course_id => @course.id, :group => {:name => "some group"} + post 'create', params: {:course_id => @course.id, :group => {:name => "some group"}} expect(response).to be_redirect expect(assigns[:group]).not_to be_nil expect(assigns[:group].name).to eql("some group") @@ -357,7 +357,7 @@ describe GroupsController do it "should honor group[group_category_id] when permitted" do user_session(@teacher) group_category = @course.group_categories.create(:name => 'some category') - post 'create', :course_id => @course.id, :group => {:name => "some group", :group_category_id => group_category.id} + post 'create', params: {:course_id => @course.id, :group => {:name => "some group", :group_category_id => group_category.id}} expect(response).to be_redirect expect(assigns[:group]).not_to be_nil expect(assigns[:group].group_category).to eq group_category @@ -366,7 +366,7 @@ describe GroupsController do it "should not honor group[group_category_id] when not permitted" do user_session(@student) group_category = @course.group_categories.create(:name => 'some category') - post 'create', :course_id => @course.id, :group => {:name => "some group", :group_category_id => group_category.id} + post 'create', params: {:course_id => @course.id, :group => {:name => "some group", :group_category_id => group_category.id}} expect(response).to be_redirect expect(assigns[:group]).not_to be_nil expect(assigns[:group].group_category).to eq GroupCategory.student_organized_for(@course) @@ -375,7 +375,7 @@ describe GroupsController do it "should fail when group[group_category_id] would be honored but doesn't exist" do user_session(@student) group_category = @course.group_categories.create(:name => 'some category') - post 'create', :course_id => @course.id, :group => {:name => "some group", :group_category_id => 11235} + post 'create', params: {:course_id => @course.id, :group => {:name => "some group", :group_category_id => 11235}} expect(response).not_to be_success end @@ -390,7 +390,7 @@ describe GroupsController do end it "should ignore the storage_quota_mb parameter" do - post 'create', :course_id => @course.id, :group => {:name => "a group", :storage_quota_mb => 22} + post 'create', params: {:course_id => @course.id, :group => {:name => "a group", :storage_quota_mb => 22}} expect(assigns[:group].storage_quota_mb).to eq 11 end end @@ -402,7 +402,7 @@ describe GroupsController do end it "should set the storage_quota_mb parameter" do - post 'create', :course_id => @course.id, :group => {:name => "a group", :storage_quota_mb => 22} + post 'create', params: {:course_id => @course.id, :group => {:name => "a group", :storage_quota_mb => 22}} expect(assigns[:group].storage_quota_mb).to eq 22 end end @@ -412,14 +412,14 @@ describe GroupsController do describe "PUT update" do it "should require authorization" do @group = @course.groups.create!(:name => "some group") - put 'update', :course_id => @course.id, :id => @group.id, :group => {:name => "new name"} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:name => "new name"}} assert_unauthorized end it "should update group" do user_session(@teacher) @group = @course.groups.create!(:name => "some group") - put 'update', :course_id => @course.id, :id => @group.id, :group => {:name => "new name"} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:name => "new name"}} expect(response).to be_redirect expect(assigns[:group]).to eql(@group) expect(assigns[:group].name).to eql("new name") @@ -429,7 +429,7 @@ describe GroupsController do user_session(@teacher) group_category = @course.group_categories.create(:name => 'some category') @group = @course.groups.create!(:name => "some group") - put 'update', :course_id => @course.id, :id => @group.id, :group => {:group_category_id => group_category.id} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:group_category_id => group_category.id}} expect(response).to be_redirect expect(assigns[:group]).to eql(@group) expect(assigns[:group].group_category).to eq group_category @@ -439,7 +439,7 @@ describe GroupsController do user_session(@teacher) group_category = @course.group_categories.create(:name => 'some category') @group = @course.groups.create!(:name => "some group", :group_category => group_category) - put 'update', :course_id => @course.id, :id => @group.id, :group => {:group_category_id => 11235} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:group_category_id => 11235}} expect(response).not_to be_success end @@ -448,7 +448,7 @@ describe GroupsController do @group = @course.groups.create!(:name => "some group") @group.add_user(@student1) @group.update_attribute(:leader, @student1) - put 'update', :course_id => @course.id, :id => @group.id, :group => {:leader => nil} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:leader => nil}} expect(@group.reload.leader).to be_nil end @@ -465,7 +465,7 @@ describe GroupsController do end it "should ignore the quota parameter" do - put 'update', :course_id => @course.id, :id => @group.id, :group => {:name => 'the group', :storage_quota_mb => 22} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:name => 'the group', :storage_quota_mb => 22}} @group.reload expect(@group.name).to eq 'the group' expect(@group.storage_quota_mb).to eq 11 @@ -479,7 +479,7 @@ describe GroupsController do end it "should update group quota" do - put 'update', :course_id => @course.id, :id => @group.id, :group => {:name => 'the group', :storage_quota_mb => 22} + put 'update', params: {:course_id => @course.id, :id => @group.id, :group => {:name => 'the group', :storage_quota_mb => 22}} @group.reload expect(@group.name).to eq 'the group' expect(@group.storage_quota_mb).to eq 22 @@ -491,14 +491,14 @@ describe GroupsController do describe "DELETE destroy" do it "should require authorization" do @group = @course.groups.create!(:name => "some group") - delete 'destroy', :course_id => @course.id, :id => @group.id + delete 'destroy', params: {:course_id => @course.id, :id => @group.id} assert_unauthorized end it "should delete group" do user_session(@teacher) @group = @course.groups.create!(:name => "some group") - delete 'destroy', :course_id => @course.id, :id => @group.id + delete 'destroy', params: {:course_id => @course.id, :id => @group.id} expect(assigns[:group]).to eql(@group) expect(assigns[:group]).not_to be_frozen expect(assigns[:group]).to be_deleted @@ -518,7 +518,7 @@ describe GroupsController do group.add_user(u1) group.add_user(u2) - get 'unassigned_members', :course_id => @course.id, :category_id => group.group_category.id + get 'unassigned_members', params: {:course_id => @course.id, :category_id => group.group_category.id} expect(response).to be_success data = json_parse expect(data).not_to be_nil @@ -545,21 +545,21 @@ describe GroupsController do group3.add_user(u2) group3.add_user(u3) - get 'unassigned_members', :course_id => @course.id, :category_id => group1.group_category.id + get 'unassigned_members', params: {:course_id => @course.id, :category_id => group1.group_category.id} expect(response).to be_success data = json_parse expect(data).not_to be_nil expect(data['users'].map{ |u| u['user_id'] }.sort). to eq [u2, u3].map{ |u| u.id }.sort - get 'unassigned_members', :course_id => @course.id, :category_id => group2.group_category.id + get 'unassigned_members', params: {:course_id => @course.id, :category_id => group2.group_category.id} expect(response).to be_success data = json_parse expect(data).not_to be_nil expect(data['users'].map{ |u| u['user_id'] }.sort). to eq [u1, u3].map{ |u| u.id }.sort - get 'unassigned_members', :course_id => @course.id, :category_id => group3.group_category.id + get 'unassigned_members', params: {:course_id => @course.id, :category_id => group3.group_category.id} expect(response).to be_success data = json_parse expect(data).not_to be_nil @@ -574,7 +574,7 @@ describe GroupsController do group = @course.groups.create(:name => "Group 1", :group_category => GroupCategory.student_organized_for(@course)) group.add_user(u1) - get 'unassigned_members', :course_id => @course.id, :category_id => group.group_category.id + get 'unassigned_members', params: {:course_id => @course.id, :category_id => group.group_category.id} data = json_parse expect(data['users'].first['sections'].first['section_id']).to eq @course.default_section.id expect(data['users'].first['sections'].first['section_code']).to eq @course.default_section.section_code @@ -588,7 +588,7 @@ describe GroupsController do group = @course.groups.create(:name => "Group 1", :group_category => GroupCategory.student_organized_for(@course)) group.add_user(u1) - get 'context_group_members', :group_id => group.id + get 'context_group_members', params: {:group_id => group.id} data = json_parse expect(data.first['sections'].first['section_id']).to eq @course.default_section.id expect(data.first['sections'].first['section_code']).to eq @course.default_section.section_code @@ -602,7 +602,7 @@ describe GroupsController do # u1 in the group has :read_roster permission user_session(u1) - get 'context_group_members', :group_id => group.id + get 'context_group_members', params: {:group_id => group.id} expect(response).to be_success # u2 outside the group doesn't have :read_roster permission, since the @@ -610,7 +610,7 @@ describe GroupsController do # context permission cache, though) controller.instance_variable_set(:@context_all_permissions, nil) user_session(u2) - get 'context_group_members', :group_id => group.id + get 'context_group_members', params: {:group_id => group.id} expect(response).not_to be_success end end @@ -622,12 +622,12 @@ describe GroupsController do end it "should require authorization" do - get 'public_feed', :format => 'atom', :feed_code => @group.feed_code + 'x' + get 'public_feed', params: {:feed_code => @group.feed_code + 'x'}, format: 'atom' expect(assigns[:problem]).to match /The verification code is invalid/ end it "should include absolute path for rel='self' link" do - get 'public_feed', :format => 'atom', :feed_code => @group.feed_code + get 'public_feed', params: {:feed_code => @group.feed_code}, format: 'atom' feed = Atom::Feed.load_feed(response.body) rescue nil expect(feed).not_to be_nil expect(feed.links.first.rel).to match(/self/) @@ -635,7 +635,7 @@ describe GroupsController do end it "should include an author for each entry" do - get 'public_feed', :format => 'atom', :feed_code => @group.feed_code + get 'public_feed', params: {:feed_code => @group.feed_code}, format: 'atom' feed = Atom::Feed.load_feed(response.body) rescue nil expect(feed).not_to be_nil expect(feed.entries).not_to be_empty @@ -656,14 +656,14 @@ describe GroupsController do end it "should successfully create invitations" do - get 'accept_invitation', :group_id => @group.id, :uuid => @membership.uuid + get 'accept_invitation', params: {:group_id => @group.id, :uuid => @membership.uuid} @group.reload expect(@group.has_member?(@user)).to be_truthy expect(@group.group_memberships.where(:workflow_state => "invited").count).to eq 0 end it "should reject an invalid invitation uuid" do - get 'accept_invitation', :group_id => @group.id, :uuid => @membership.uuid + "x" + get 'accept_invitation', params: {:group_id => @group.id, :uuid => @membership.uuid + "x"} @group.reload expect(@group.has_member?(@user)).to be_falsey expect(@group.group_memberships.where(:workflow_state => "invited").count).to eq 1