diff --git a/app/models/organizations/mail_team.rb b/app/models/organizations/mail_team.rb index 3ec9ea7a905..6ac9991ee70 100644 --- a/app/models/organizations/mail_team.rb +++ b/app/models/organizations/mail_team.rb @@ -8,4 +8,8 @@ def self.singleton def users_can_create_mail_task? true end + + def can_bulk_assign_tasks? + true + end end diff --git a/app/models/organizations/privacy_team.rb b/app/models/organizations/privacy_team.rb index d910a53138b..6b48a5eb520 100644 --- a/app/models/organizations/privacy_team.rb +++ b/app/models/organizations/privacy_team.rb @@ -4,4 +4,8 @@ class PrivacyTeam < Organization def self.singleton PrivacyTeam.first || PrivacyTeam.create(name: "Privacy Team", url: "privacy") end + + def can_bulk_assign_tasks? + true + end end diff --git a/app/models/organizations/transcription_team.rb b/app/models/organizations/transcription_team.rb index 987adb7d91b..5e64594f819 100644 --- a/app/models/organizations/transcription_team.rb +++ b/app/models/organizations/transcription_team.rb @@ -4,4 +4,8 @@ class TranscriptionTeam < Organization def self.singleton TranscriptionTeam.first || TranscriptionTeam.create(name: "Transcription", url: "transcription") end + + def can_bulk_assign_tasks? + true + end end diff --git a/app/models/organizations/vso.rb b/app/models/organizations/vso.rb index 97089ea8ba2..0afcbed1567 100644 --- a/app/models/organizations/vso.rb +++ b/app/models/organizations/vso.rb @@ -1,3 +1,13 @@ # frozen_string_literal: true -class Vso < Representative; end +class Vso < Representative + def can_bulk_assign_tasks? + bulk_assign_vso_names = [ + "American Legion", + "Disabled American Veterans", + "Veterans of Foreign Wars" + ] + + Vso.where(name: bulk_assign_vso_names).include?(self) + end +end diff --git a/spec/workflows/bulk_task_assignment_spec.rb b/spec/workflows/bulk_task_assignment_spec.rb index edadbc9e021..35be51357c7 100644 --- a/spec/workflows/bulk_task_assignment_spec.rb +++ b/spec/workflows/bulk_task_assignment_spec.rb @@ -62,6 +62,22 @@ end end + shared_examples "valid bulk assign" do + it "bulk assigns tasks" do + count_before = Task.count + bulk_assignment = BulkTaskAssignment.new(params) + expect(bulk_assignment.valid?).to eq true + result = bulk_assignment.process + expect(Task.count).to eq count_before + 2 + expect(result.count).to eq 2 + expect(result.first.assigned_to).to eq assigned_to + expect(result.first.type).to eq "NoShowHearingTask" + expect(result.first.assigned_by).to eq assigned_by + expect(result.first.appeal).to eq no_show_hearing_task1.appeal + expect(result.first.parent_id).to eq no_show_hearing_task1.id + end + end + context "when assigned to user does not belong to organization" do let(:assigned_to_param) { create(:user) } let(:error) { "does not belong to organization with url #{organization.url}" } @@ -111,18 +127,28 @@ end context "when all attributes are present" do - it "bulk assigns tasks" do - count_before = Task.count - bulk_assignment = BulkTaskAssignment.new(params) - expect(bulk_assignment.valid?).to eq true - result = bulk_assignment.process - expect(Task.count).to eq count_before + 2 - expect(result.count).to eq 2 - expect(result.first.assigned_to).to eq assigned_to - expect(result.first.type).to eq "NoShowHearingTask" - expect(result.first.assigned_by).to eq assigned_by - expect(result.first.appeal).to eq no_show_hearing_task1.appeal - expect(result.first.parent_id).to eq no_show_hearing_task1.id + it_behaves_like "valid bulk assign" + + context "when the org is not hearings management" do + context "when the org is the mail team" do + let(:organization) { MailTeam.singleton } + + it_behaves_like "valid bulk assign" + end + + context "when the org is a vso" do + let(:organization) { create(:vso, name: "VSO that cannot bulk assign") } + let(:error) { "with url #{organization_url} cannot bulk assign tasks" } + let(:error_sym) { :organization } + + it_behaves_like "invalid bulk assign" + + context "when the vso is American Legion" do + let(:organization) { create(:vso, name: "American Legion") } + + it_behaves_like "valid bulk assign" + end + end end context "when there are legacy appeals and regional office is passed" do