Files
codeocean/spec/policies/submission_policy_spec.rb
kiragrammel 175c8933f3 Automatically submit LTI grade on each score run
With this commit, we refactor the overall score handling of CodeOcean. Previously, "Score" and "Submit" were two distinct actions, requiring users to confirm the LTI transmission of their score (after assessing their submission). This yielded many questions and was unnecessary, since LTI parameters are no longer expiring after each use. Therefore, we can now transmit the current grade on each score run with the very same LTI parameters. As a consequence, the LTI consumer gets a more detailed history of the scores, enabling further analytical insights.

For users, the previous "Submit" button got replaced with a notification that is shown as soon as the full score got reached. Then, learners can decide to "finalize" their work on the given exercise, which will initiate a redirect to a follow-up action (as defined in the RedirectBehavior). This RedirectBehavior has also been unified and simplified for better readability.

As part of this refactoring, we rephrased the notifications and UX workflow of a) the LTI transmission, b) the finalization of an exercise (measured by reaching the full score) and c) the deadline handling (on time, within grace period, too late). Those information are now separately shown, potentially resulting in multiple notifications. As a side effect, they are much better maintainable, and the LTI transmission is more decoupled from this notification handling.
2023-11-23 14:42:10 +01:00

48 lines
1.6 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SubmissionPolicy do
subject(:policy) { described_class }
permissions :create? do
it 'grants access to anyone' do
%i[admin external_user teacher].each do |factory_name|
expect(policy).to permit(create(factory_name), Submission.new)
end
end
end
%i[download? download_file? download_submission_file? render_file? run? score? show? statistics? stop? test? insights? finalize?].each do |action|
permissions(action) do
let(:exercise) { build(:math) }
let(:group_author) { build(:external_user) }
let(:other_group_author) { build(:external_user) }
it 'grants access to admins' do
expect(policy).to permit(build(:admin), Submission.new)
end
it 'grants access to authors' do
contributor = create(:external_user)
expect(policy).to permit(contributor, build(:submission, exercise:, contributor:))
end
it 'grants access to other authors of the programming group' do
contributor = build(:programming_group, exercise:, users: [group_author, other_group_author])
expect(policy).to permit(group_author, build(:submission, exercise:, contributor:))
expect(policy).to permit(other_group_author, build(:submission, exercise:, contributor:))
end
end
end
permissions :index? do
it 'grants access to admins only' do
expect(policy).to permit(build(:admin), Submission.new)
%i[external_user teacher].each do |factory_name|
expect(policy).not_to permit(create(factory_name), Submission.new)
end
end
end
end