|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | RSpec.describe EtdaUtilities::Partner, type: :model do |
4 | | - describe 'current_partner.id' do |
5 | | - context "when ENV['PARTNER'] is graduate" do |
6 | | - before do |
7 | | - partner_set_env('graduate') |
8 | | - end |
9 | | - |
10 | | - it 'sets current.id to graduate' do |
11 | | - expect(described_class.current.id).to eql('graduate') |
12 | | - end |
13 | | - it 'responds to graduate?' do |
14 | | - expect(described_class.current).to be_graduate |
15 | | - end |
16 | | - end |
17 | | - |
18 | | - context "when ENV['PARTNER'] is honors" do |
19 | | - before do |
20 | | - partner_set_env('honors') |
21 | | - end |
22 | | - |
23 | | - it 'sets current.id to honors' do |
24 | | - expect(described_class.current.id).to eql('honors') |
25 | | - end |
26 | | - it 'responds to honors?' do |
27 | | - expect(described_class.current).to be_honors |
28 | | - end |
29 | | - end |
30 | | - |
31 | | - context "when ENV['PARTNER'] is milsch" do |
32 | | - before do |
33 | | - partner_set_env('milsch') |
34 | | - end |
35 | | - |
36 | | - it 'sets current.id to milsch' do |
37 | | - expect(described_class.current.id).to eql('milsch') |
38 | | - end |
39 | | - it 'responds to milsch?' do |
40 | | - expect(described_class.current).to be_milsch |
41 | | - end |
42 | | - end |
43 | | - |
44 | | - context "when ENV['PARTNER'] is sset" do |
45 | | - before do |
46 | | - partner_set_env('sset') |
47 | | - end |
48 | | - |
49 | | - it 'sets current.id to sset' do |
50 | | - expect(described_class.current.id).to eql('sset') |
51 | | - end |
52 | | - it 'responds to sset?' do |
53 | | - expect(described_class.current).to be_sset |
54 | | - end |
55 | | - end |
56 | | - |
57 | | - context "when ENV['PARTNER'] is not a valid partner" do |
58 | | - before do |
59 | | - partner_set_env('boguspartner') |
60 | | - end |
61 | | - |
62 | | - it 'reports an error' do |
63 | | - expect { described_class.current.id }.to raise_error(ArgumentError) |
64 | | - end |
65 | | - end |
66 | | - |
67 | | - context "when ENV['PARTNER'] is not set" do |
68 | | - before do |
69 | | - ENV.delete('PARTNER') |
70 | | - end |
71 | | - |
72 | | - it 'reports an error' do |
73 | | - expect { described_class.current.id }.to raise_error(KeyError) |
74 | | - end |
| 4 | + context "when ENV['PARTNER'] is graduate" do |
| 5 | + let(:current_partner) { described_class.current } |
| 6 | + |
| 7 | + before do |
| 8 | + partner_set_env('graduate') |
| 9 | + end |
| 10 | + |
| 11 | + it 'sets current.id to graduate' do |
| 12 | + expect(current_partner.id).to eql('graduate') |
| 13 | + end |
| 14 | + it 'responds to graduate?' do |
| 15 | + expect(current_partner).to be_graduate |
| 16 | + end |
| 17 | + it 'returns partner name' do |
| 18 | + expect(current_partner.name).to eq("Graduate School") |
| 19 | + end |
| 20 | + it 'returns partner email' do |
| 21 | + expect(current_partner.email_address).to eq("gradthesis@psu.edu") |
| 22 | + end |
| 23 | + it 'returns partner email list' do |
| 24 | + expect(current_partner.email_list).to eq('ul-etda-graduate-admin@pennstateoffice365.onmicrosoft.com') |
| 25 | + end |
| 26 | + it 'returns partner slug' do |
| 27 | + expect(current_partner.slug).to eq("eTD") |
| 28 | + end |
| 29 | + it 'returns partner label' do |
| 30 | + expect(current_partner.program_label).to eq("Graduate Program") |
| 31 | + end |
| 32 | + it 'returns partner committee label' do |
| 33 | + expect(current_partner.committee_label).to eq("Committee Member") |
| 34 | + end |
| 35 | + it 'returns partner committee list label' do |
| 36 | + expect(current_partner.committee_list_label).to eq("Committee Members") |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + context "when ENV['PARTNER'] is honors" do |
| 41 | + let(:current_partner) { described_class.current } |
| 42 | + |
| 43 | + before do |
| 44 | + partner_set_env('honors') |
| 45 | + end |
| 46 | + |
| 47 | + it 'sets current.id to honors' do |
| 48 | + expect(current_partner.id).to eql('honors') |
| 49 | + end |
| 50 | + it 'responds to honors?' do |
| 51 | + expect(current_partner).to be_honors |
| 52 | + end |
| 53 | + it 'returns partner name' do |
| 54 | + expect(current_partner.name).to eq("Schreyer Honors College") |
| 55 | + end |
| 56 | + it 'returns partner email' do |
| 57 | + expect(current_partner.email_address).to eq("SHCAcademics@psu.edu") |
| 58 | + end |
| 59 | + it 'returns partner email list' do |
| 60 | + expect(current_partner.email_list).to eq('ul-etda-honors-admin@pennstateoffice365.onmicrosoft.com') |
| 61 | + end |
| 62 | + it 'returns partner slug' do |
| 63 | + expect(current_partner.slug).to eq("eHT") |
| 64 | + end |
| 65 | + it 'returns partner label' do |
| 66 | + expect(current_partner.program_label).to eq("Area of Honors") |
| 67 | + end |
| 68 | + it 'returns partner committee label' do |
| 69 | + expect(current_partner.committee_label).to eq("Thesis Supervisor") |
| 70 | + end |
| 71 | + it 'returns partner committee list label' do |
| 72 | + expect(current_partner.committee_list_label).to eq("Thesis Supervisors") |
| 73 | + end |
| 74 | + end |
| 75 | + |
| 76 | + context "when ENV['PARTNER'] is milsch" do |
| 77 | + let(:current_partner) { described_class.current } |
| 78 | + |
| 79 | + before do |
| 80 | + partner_set_env('milsch') |
| 81 | + end |
| 82 | + |
| 83 | + it 'sets current.id to milsch' do |
| 84 | + expect(current_partner.id).to eql('milsch') |
| 85 | + end |
| 86 | + it 'responds to milsch?' do |
| 87 | + expect(current_partner).to be_milsch |
| 88 | + end |
| 89 | + it 'returns partner name' do |
| 90 | + expect(current_partner.name).to eq("Millennium Scholars Program") |
| 91 | + end |
| 92 | + it 'returns partner email' do |
| 93 | + expect(current_partner.email_address).to eq("millennium@psu.edu") |
| 94 | + end |
| 95 | + it 'returns partner email list' do |
| 96 | + expect(current_partner.email_list).to eq('ul-etda-milsch-admin@pennstateoffice365.onmicrosoft.com') |
| 97 | + end |
| 98 | + it 'returns partner slug' do |
| 99 | + expect(current_partner.slug).to eq("MSPT") |
| 100 | + end |
| 101 | + it 'returns partner label' do |
| 102 | + expect(current_partner.program_label).to eq("Millennium Scholars Program Name") |
| 103 | + end |
| 104 | + it 'returns partner committee label' do |
| 105 | + expect(current_partner.committee_label).to eq("Thesis Supervisor") |
| 106 | + end |
| 107 | + it 'returns partner committee list label' do |
| 108 | + expect(current_partner.committee_list_label).to eq("Thesis Supervisor") |
| 109 | + end |
| 110 | + end |
| 111 | + |
| 112 | + context "when ENV['PARTNER'] is sset" do |
| 113 | + let(:current_partner) { described_class.current } |
| 114 | + |
| 115 | + before do |
| 116 | + partner_set_env('sset') |
| 117 | + end |
| 118 | + |
| 119 | + it 'sets current.id to sset' do |
| 120 | + expect(current_partner.id).to eql('sset') |
| 121 | + end |
| 122 | + it 'responds to sset?' do |
| 123 | + expect(current_partner).to be_sset |
| 124 | + end |
| 125 | + it 'returns partner name' do |
| 126 | + expect(current_partner.name).to eq("School of Science, Engineering, and Technology") |
| 127 | + end |
| 128 | + it 'returns partner email' do |
| 129 | + expect(current_partner.email_address).to eq("sset@psu.edu") |
| 130 | + end |
| 131 | + it 'returns partner email list' do |
| 132 | + expect(current_partner.email_list).to eq('ul-etda-sset-admin@pennstateoffice365.onmicrosoft.com') |
| 133 | + end |
| 134 | + it 'returns partner slug' do |
| 135 | + expect(current_partner.slug).to eq("SSETT") |
| 136 | + end |
| 137 | + end |
| 138 | + |
| 139 | + context "when ENV['PARTNER'] is not a valid partner" do |
| 140 | + before do |
| 141 | + partner_set_env('boguspartner') |
| 142 | + end |
| 143 | + |
| 144 | + it 'reports an error' do |
| 145 | + expect { described_class.current.id }.to raise_error(ArgumentError) |
| 146 | + end |
| 147 | + end |
| 148 | + |
| 149 | + context "when ENV['PARTNER'] is not set" do |
| 150 | + before do |
| 151 | + ENV.delete('PARTNER') |
| 152 | + end |
| 153 | + |
| 154 | + it 'reports an error' do |
| 155 | + expect { described_class.current.id }.to raise_error(KeyError) |
75 | 156 | end |
76 | 157 | end |
77 | 158 | end |
0 commit comments