0
0
Fork 0

Misc spec coverage for Admin:: area controllers (#25282)

This commit is contained in:
Matt Jankowski 2023-06-06 07:57:00 -04:00 committed by GitHub
parent eb6f8181e1
commit 1e243e2df7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 277 additions and 0 deletions

View file

@ -73,4 +73,30 @@ describe Admin::AnnouncementsController do
expect(flash.notice).to match(I18n.t('admin.announcements.destroyed_msg'))
end
end
describe 'POST #publish' do
subject { post :publish, params: { id: announcement.id } }
let(:announcement) { Fabricate(:announcement, published_at: nil) }
it 'marks announcement published' do
subject
expect(announcement.reload).to be_published
expect(response).to redirect_to admin_announcements_path
end
end
describe 'POST #unpublish' do
subject { post :unpublish, params: { id: announcement.id } }
let(:announcement) { Fabricate(:announcement, published_at: 4.days.ago) }
it 'marks announcement as not published' do
subject
expect(announcement.reload).to_not be_published
expect(response).to redirect_to admin_announcements_path
end
end
end