Skip to content

Commit

Permalink
Only import specail member names if they are #present? rather than no…
Browse files Browse the repository at this point in the history
…t #nil?. CSV returns empty strings. Also use #update! on committee_member update so error is raised rather than returning nil (#801)
  • Loading branch information
ajkiessl authored Jun 28, 2024
1 parent 7245196 commit 5254874
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/lionpath/lionpath_committee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.external_ids
private

def committee_member_update(committee_member, row, committee_role)
committee_member.update committee_member_attrs(row, committee_role) unless
committee_member.update! committee_member_attrs(row, committee_role) unless
committee_member.submission.status_behavior.beyond_waiting_for_final_submission_response_rejected?
end

Expand All @@ -58,7 +58,7 @@ def committee_member_attrs(row, committee_role)
end

def special_member?(row)
!row['Special Member First Name'].nil? && !row['Special Member Last Name'].nil?
row['Special Member First Name'].present? && row['Special Member Last Name'].present?
end

def submission(row)
Expand Down
7 changes: 5 additions & 2 deletions spec/models/lionpath/lionpath_committee_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
let(:row) do
{ 'Access ID' => 'abc123', 'Last Name' => 'Tester', 'First Name' => 'Test', 'Role' => 'C',
'Committee' => 'DOCCM', 'Committee Long Descr' => 'Chair of Committee', 'Student ID' => '999999999',
'Student Campus ID' => 'def123', 'Suprvsr Nbr' => '932352541' }
'Student Campus ID' => 'def123', 'Suprvsr Nbr' => '932352541', 'Special Member First Name' => '',
'Special Member Last Name' => '' }
end

context "when author's submission's year is before 2021" do
Expand Down Expand Up @@ -110,14 +111,16 @@
let(:row2) do
{ 'Access ID' => 'mgc25', 'Last Name' => 'Committee', 'First Name' => 'Member', 'Role' => 'S',
'Committee' => 'DOCCM', 'Committee Long Descr' => 'Special Member', 'Student ID' => '999999999',
'Student Campus ID' => 'def123', 'Suprvsr Nbr' => '932352541' }
'Student Campus ID' => 'def123', 'Suprvsr Nbr' => '932352541', 'Special Member First Name' => 'Special',
'Special Member Last Name' => 'Person' }
end

context 'when the committee member does not yet exist in the db' do
it 'imports the record' do
expect { lionpath_committee.import(row2) }.to change { submission.committee_members.count }.by 1
expect(submission.committee_members.last.access_id).to eq 'mgc25'
expect(submission.committee_members.last.external_to_psu_id).to eq 'mgc25'
expect(submission.committee_members.last.name).to eq 'Special Person'
end
end

Expand Down

0 comments on commit 5254874

Please sign in to comment.