From 99c5a210225c04a1297ae87c0ac58dc53552bb9e Mon Sep 17 00:00:00 2001 From: Simon Williams Date: Tue, 21 Aug 2012 10:08:06 -0600 Subject: [PATCH] api: allow only offer as a param to course update fixes #10063 the coures update api required passing at least one course[*something*] parameter, which meant if all you wanted to do was offer the course, you had to pass a dummy parameter. test plan: - call the course update api an only pass {:offer => 1} - it should work Change-Id: I5b89f1f3f474c3b097083f17403e1da20be4ca56 Reviewed-on: https://gerrit.instructure.com/13057 Tested-by: Jenkins Reviewed-by: Brian Palmer --- app/controllers/courses_controller.rb | 1 + spec/apis/v1/courses_api_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bada0cdc4af..5ba8664b796 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1107,6 +1107,7 @@ class CoursesController < ApplicationController def update @course = api_find(Course, params[:id]) if authorized_action(@course, @current_user, :update) + params[:course] ||= {} root_account_id = params[:course].delete :root_account_id if root_account_id && Account.site_admin.grants_right?(@current_user, session, :manage_courses) @course.root_account = Account.root_accounts.find(root_account_id) diff --git a/spec/apis/v1/courses_api_spec.rb b/spec/apis/v1/courses_api_spec.rb index 6c07a51039e..c7d7c13f3ec 100644 --- a/spec/apis/v1/courses_api_spec.rb +++ b/spec/apis/v1/courses_api_spec.rb @@ -269,6 +269,14 @@ describe CoursesController, :type => :integration do @course.reload @course.end_at.should be_nil end + + it "should allow updating only the offer parameter" do + @course.workflow_state = "claimed" + @course.save! + api_call(:put, @path, @params, {:offer => 1}) + @course.reload + @course.workflow_state.should == "available" + end end context "a teacher" do