Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable bulk assign for test orgs #14523

Merged
merged 5 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/organizations/mail_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ def self.singleton
def users_can_create_mail_task?
true
end

def can_bulk_assign_tasks?
true
end
end
4 changes: 4 additions & 0 deletions app/models/organizations/privacy_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions app/models/organizations/transcription_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion app/models/organizations/vso.rb
Original file line number Diff line number Diff line change
@@ -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
50 changes: 38 additions & 12 deletions spec/workflows/bulk_task_assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
Expand Down Expand Up @@ -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
Expand Down