show sync grades to SIS only when SIS is used

fixes GRADE-200

test plan:
 1. Select or create a Course
 2. Visit Course Settings
 3. Set the SIS ID to any value
 4. Visit New Gradebook as an admin
 5. Verify the Actions Menu includes:
    Sync grades to SIS
 6. Visit Course Settings
 7. Clear the SIS ID
 8. Visit New Gradebook as an admin
 9. Verify the Actions Menu does not include:
    Sync grades to SIS

Change-Id: Id8bcff2a46745c3cded09607a4257fffb708d1a3
Reviewed-on: https://gerrit.instructure.com/131999
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
This commit is contained in:
Jeremy Neander 2017-11-06 17:19:36 -06:00
parent 7fa26638f6
commit f5fa49ef4c
5 changed files with 76 additions and 22 deletions

View File

@ -1320,7 +1320,7 @@ define [
label: @options.sis_name
store: @postGradesStore
publishGradesToSis:
isEnabled: @options.publish_to_sis_enabled?
isEnabled: @options.publish_to_sis_enabled
publishToSisUrl: @options.publish_to_sis_url
progressData = @options.gradebook_csv_progress

View File

@ -350,7 +350,9 @@ class GradebooksController < ApplicationController
gradebook_import_url: new_course_gradebook_upload_path(@context),
setting_update_url: api_v1_course_settings_url(@context),
show_total_grade_as_points: @context.show_total_grade_as_points?,
publish_to_sis_enabled: @context.allows_grade_publishing_by(@current_user) && @gradebook_is_editable,
publish_to_sis_enabled: (
!!@context.sis_source_id && @context.allows_grade_publishing_by(@current_user) && @gradebook_is_editable
),
publish_to_sis_url: context_url(@context, :context_details_url, anchor: 'tab-grade-publishing'),
speed_grader_enabled: @context.allows_speed_grader?,
active_grading_periods: active_grading_periods_json,

View File

@ -726,6 +726,45 @@ describe GradebooksController do
expect(api_max_per_page).to eq(50)
end
context "publish_to_sis_enabled" do
before(:once) do
@course.sis_source_id = 'xyz'
@course.save
end
it "is true when the user is able to sync grades to the course SIS" do
expect_any_instantiation_of(@course).to receive(:allows_grade_publishing_by).with(@teacher).and_return(true)
get :show, params: { course_id: @course.id }
expect(gradebook_options[:publish_to_sis_enabled]).to be true
end
it "is false when the user is not allowed to publish grades" do
expect_any_instantiation_of(@course).to receive(:allows_grade_publishing_by).with(@teacher).and_return(false)
get :show, params: { course_id: @course.id }
expect(gradebook_options[:publish_to_sis_enabled]).to be false
end
it "is false when the user is not allowed to manage grades" do
allow_any_instantiation_of(@course).to receive(:allows_grade_publishing_by).with(@teacher).and_return(true)
@course.root_account.role_overrides.create!(
permission: :manage_grades,
role: Role.find_by(name: 'TeacherEnrollment'),
enabled: false
)
get :show, params: { course_id: @course.id }
expect(gradebook_options[:publish_to_sis_enabled]).to be false
end
it "is false when the course is not using a SIS" do
allow_any_instantiation_of(@course).to receive(:allows_grade_publishing_by).with(@teacher).and_return(true)
@course.sis_source_id = nil
@course.save
get :show, params: { course_id: @course.id }
expect(gradebook_options[:publish_to_sis_enabled]).to be false
end
end
it "includes sis_section_id on the sections even if the teacher doesn't have 'Read SIS Data' permissions" do
@course.root_account.role_overrides.create!(permission: :read_sis, enabled: false, role: teacher_role)
get :show, params: { course_id: @course.id }

View File

@ -6088,28 +6088,40 @@ test('sets postGradesLtis to conform to ActionMenu.propTypes.postGradesLtis', fu
ok(console.error.notCalled); // eslint-disable-line no-console
});
QUnit.module('Gradebook#getActionMenuProps', {
teardown () {
$fixtures.innerHTML = '';
}
});
QUnit.module('Gradebook', () => {
QUnit.module('#getActionMenuProps', (hooks) => {
let options;
test('generates props that conform to ActionMenu.propTypes', function () {
$fixtures.innerHTML = '<span data-component="ActionMenu"><button /></span>';
const gradebook = createGradebook({
context_allows_gradebook_uploads: true,
gradebook_import_url: 'http://example.com/import',
currentUserId: '123',
export_gradebook_csv_url: 'http://example.com/export',
post_grades_feature: false,
publish_to_sis_enabled: false
hooks.beforeEach(() => {
$fixtures.innerHTML = '<span data-component="ActionMenu"><button /></span>';
options = {
context_allows_gradebook_uploads: true,
currentUserId: '123',
export_gradebook_csv_url: 'http://example.com/export',
gradebook_import_url: 'http://example.com/import',
post_grades_feature: false,
publish_to_sis_enabled: false
};
});
hooks.afterEach(() => {
$fixtures.innerHTML = '';
});
test('sets publishGradesToSis.isEnabled to true when "publish to SIS" is enabled', () => {
options.publish_to_sis_enabled = true;
const gradebook = createGradebook(options);
const props = gradebook.getActionMenuProps();
strictEqual(props.publishGradesToSis.isEnabled, true);
});
test('sets publishGradesToSis.isEnabled to false when "publish to SIS" is not enabled', () => {
options.publish_to_sis_enabled = false;
const gradebook = createGradebook(options);
const props = gradebook.getActionMenuProps();
strictEqual(props.publishGradesToSis.isEnabled, false);
});
});
const props = gradebook.getActionMenuProps();
this.spy(console, 'error');
PropTypes.checkPropTypes(ActionMenu.propTypes, props, 'props', 'ActionMenu')
ok(console.error.notCalled); // eslint-disable-line no-console
});
QUnit.module('Gradebook#getInitialGridDisplaySettings');

View File

@ -40,6 +40,7 @@ export function createGradebook (options = {}) {
new_gradebook_development_enabled: true,
outcome_gradebook_enabled: false,
post_grades_ltis: [],
publish_to_sis_enabled: false,
sections: [],
settings: {
show_concluded_enrollments: 'false',