Skip to content

Commit d8d5c92

Browse files
Remove reject button, all functionality, and update tests (#747)
## Status - [Closes](RaspberryPiFoundation/digital-editor-issues#1232) ## What's changed? - Removed the reject button from the admin console, along with the tests for it
1 parent 331f991 commit d8d5c92

9 files changed

Lines changed: 8 additions & 124 deletions

File tree

app/controllers/admin/schools_controller.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ def verify
1414
redirect_to admin_school_path(requested_resource)
1515
end
1616

17-
def reject
18-
service = SchoolVerificationService.new(requested_resource)
19-
20-
if service.reject
21-
flash[:notice] = t('administrate.controller.reject_school.success')
22-
else
23-
flash[:error] = t('administrate.controller.reject_school.error')
24-
end
25-
26-
redirect_to admin_school_path(requested_resource)
27-
end
28-
2917
def reopen
3018
service = SchoolVerificationService.new(requested_resource)
3119

app/models/school.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ def generate_code!
9696
end
9797
end
9898

99-
def reject
100-
update(rejected_at: Time.zone.now)
101-
end
102-
10399
def reopen
104100
return false unless rejected?
105101

app/services/school_verification_service.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ def verify
1717
true
1818
end
1919

20-
delegate :reject, to: :school
2120
delegate :reopen, to: :school
2221
end

app/views/admin/schools/show.html.erb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ as well as a link to its edit page.
4545
style: "background-color: darkorange; margin: 5px;",
4646
data: { confirm: t("administrate.actions.confirm_reopen_school") }
4747
) unless page.resource.verified? || !page.resource.rejected? %>
48-
49-
<%= link_to(
50-
t("administrate.actions.reject_school"),
51-
reject_admin_school_path(page.resource),
52-
class: "button button--danger",
53-
method: :patch,
54-
style: "background-color: hsla(0, 88%, 33%, 1); margin: 5px 5px 5px 0;",
55-
data: { confirm: t("administrate.actions.confirm_reject_school") }
56-
) unless page.resource.verified? || page.resource.rejected? %>
5748
</div>
5849
</header>
5950

config/locales/admin/en.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ en:
66
confirm_discard: Are you sure you want to discard this record?
77
verify_school: Verify School
88
confirm_verify_school: Are you sure you want to verify this school?
9-
reject_school: Reject School
10-
confirm_reject_school: Are you sure you want to reject this school?
119
reopen_school: Reopen School
1210
confirm_reopen_school: Are you sure you want to reopen this school?
1311
controller:
1412
verify_school:
1513
success: "Successfully verified."
1614
error: "There was an error verifying the school"
17-
reject_school:
18-
success: "Successfully rejected."
19-
error: "There was an error rejecting the school"
2015
reopen_school:
2116
success: "Successfully reopened."
2217
error: "There was an error reopening the school"

config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
resources :schools, only: %i[index show edit update] do
1616
member do
1717
post :verify
18-
patch :reject
1918
patch :reopen
2019
end
2120
end

spec/features/admin/schools_spec.rb

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
expect(response.body).to include(I18n.t('administrate.actions.verify_school'))
3737
end
3838

39-
it 'includes link to reject school' do
40-
expect(response.body).to include(I18n.t('administrate.actions.reject_school'))
41-
end
42-
4339
it 'does not include a link to search for this school by its ZIP code in the NCES public schools database' do
4440
expect(response.body).not_to include('Search for this school in the NCES database')
4541
end
@@ -52,10 +48,6 @@
5248
expect(response.body).not_to include(I18n.t('administrate.actions.verify_school'))
5349
end
5450

55-
it 'does not include a link to reject school' do
56-
expect(response.body).not_to include(I18n.t('administrate.actions.reject_school'))
57-
end
58-
5951
it 'does not include a link to reopen school' do
6052
expect(response.body).not_to include(I18n.t('administrate.actions.reopen_school'))
6153
end
@@ -68,10 +60,6 @@
6860
expect(response.body).not_to include(I18n.t('administrate.actions.verify_school'))
6961
end
7062

71-
it 'does not include a link to reject school' do
72-
expect(response.body).not_to include(I18n.t('administrate.actions.reject_school'))
73-
end
74-
7563
it 'includes link to reopen school' do
7664
expect(response.body).to include(I18n.t('administrate.actions.reopen_school'))
7765
end
@@ -132,48 +120,6 @@
132120
end
133121
end
134122

135-
describe 'PUT #reject' do
136-
let(:creator) { create(:user) }
137-
let(:school) { create(:school, creator_id: creator.id) }
138-
let(:rejection_result) { nil }
139-
let(:verification_service) { instance_double(SchoolVerificationService, reject: rejection_result) }
140-
141-
before do
142-
stub_user_info_api_for(creator)
143-
allow(SchoolVerificationService).to receive(:new).with(school).and_return(verification_service)
144-
145-
patch reject_admin_school_path(school)
146-
end
147-
148-
it 'redirects to school path' do
149-
expect(response).to redirect_to(admin_school_path(school))
150-
end
151-
152-
describe 'when rejection was successful' do
153-
let(:rejection_result) { true }
154-
155-
before do
156-
follow_redirect!
157-
end
158-
159-
it 'displays success message' do
160-
expect(response.body).to include(I18n.t('administrate.controller.reject_school.success'))
161-
end
162-
end
163-
164-
describe 'when rejection was unsuccessful' do
165-
let(:rejection_result) { false }
166-
167-
before do
168-
follow_redirect!
169-
end
170-
171-
it 'displays failure message' do
172-
expect(response.body).to include(I18n.t('administrate.controller.reject_school.error'))
173-
end
174-
end
175-
end
176-
177123
describe 'PUT #reopen' do
178124
let(:creator) { create(:user) }
179125
let(:school) { create(:verified_school, creator_id: creator.id) }

spec/models/school_spec.rb

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@
192192
end
193193

194194
it 'allows reference reuse when original school is rejected' do
195-
school.reference = '100000'
196-
school.save!
197-
school.reject
195+
school.update!(reference: '100000', rejected_at: Time.zone.now)
198196

199197
new_school = build(:school, reference: '100000')
200198
expect(new_school).to be_valid
@@ -259,8 +257,7 @@
259257
end
260258

261259
it 'allows district_nces_id reuse when original school is rejected' do
262-
us_school.district_nces_id = '0100000'
263-
us_school.reject
260+
us_school.update!(rejected_at: Time.zone.now)
264261

265262
new_school = build(:school, country_code: 'US', district_name: 'Some District', district_nces_id: '0100000')
266263
expect(new_school).to be_valid
@@ -331,7 +328,7 @@
331328
end
332329

333330
it 'allows school_roll_number reuse when original school is rejected' do
334-
ireland_school.reject
331+
ireland_school.update!(rejected_at: Time.zone.now)
335332

336333
new_school = build(:school, school_roll_number: '01572D', country_code: 'IE')
337334
expect(new_school).to be_valid
@@ -400,12 +397,12 @@
400397

401398
it 'cannot have #rejected_at set when #verified_at is present' do
402399
school.verify!
403-
school.reject
400+
school.update(rejected_at: Time.zone.now)
404401
expect(school.errors[:rejected_at]).to include('must be blank')
405402
end
406403

407404
it 'cannot have #verified_at set when #rejected_at is present' do
408-
school.reject
405+
school.rejected_at = Time.zone.now
409406
school.update(verified_at: Time.zone.now)
410407
expect(school.errors[:verified_at]).to include('must be blank')
411408
end
@@ -487,7 +484,7 @@
487484
it('raises ActiveRecord::RecordNotFound if the user is the creator of a rejected school') do
488485
creator = create(:user)
489486
school.update!(creator_id: creator.id)
490-
school.reject
487+
school.update!(rejected_at: Time.zone.now)
491488

492489
expect { described_class.find_for_user!(creator) }.to raise_error(ActiveRecord::RecordNotFound)
493490
end
@@ -617,17 +614,6 @@
617614
end
618615
end
619616

620-
describe '#reject' do
621-
it 'sets rejected_at to the current time' do
622-
school.reject
623-
expect(school.rejected_at).to be_within(1.second).of(Time.zone.now)
624-
end
625-
626-
it 'returns true on successful rejection' do
627-
expect(school.reject).to be(true)
628-
end
629-
end
630-
631617
describe 'salesforce sync' do
632618
around do |example|
633619
ClimateControl.modify(SALESFORCE_ENABLED: 'true') { example.run }
@@ -668,13 +654,13 @@
668654

669655
describe '#reopen' do
670656
it 'sets rejected_at to nil' do
671-
school.reject
657+
school.rejected_at = Time.zone.now
672658
school.reopen
673659
expect(school.rejected_at).to be_nil
674660
end
675661

676662
it 'returns true on successful reopening' do
677-
school.reject
663+
school.rejected_at = Time.zone.now
678664
expect(school.reopen).to be(true)
679665
end
680666

spec/services/school_verification_service_spec.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,9 @@
4343
end
4444
end
4545

46-
describe '#reject' do
47-
before do
48-
service.reject
49-
school.reload
50-
end
51-
52-
it 'sets verified_at to nil' do
53-
expect(school.verified_at).to be_nil
54-
end
55-
56-
it 'sets rejected_at to a date' do
57-
expect(school.rejected_at).to be_a(ActiveSupport::TimeWithZone)
58-
end
59-
end
60-
6146
describe 'when the school was previously verified' do
6247
before do
6348
service.verify
64-
service.reject
6549
school.reload
6650
end
6751

0 commit comments

Comments
 (0)