Add coverage for admin/terms/drafts#update and admin/terms/generates#create actions (#33251)
This commit is contained in:
parent
094e2172ec
commit
39364346bb
2 changed files with 89 additions and 0 deletions
|
@ -18,4 +18,49 @@ RSpec.describe Admin::TermsOfService::DraftsController do
|
|||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
subject { put :update, params: params }
|
||||
|
||||
let!(:terms) { Fabricate :terms_of_service, published_at: nil }
|
||||
|
||||
context 'with publishing params' do
|
||||
let(:params) { { terms_of_service: { text: 'new' }, action_type: 'publish' } }
|
||||
|
||||
it 'publishes the record' do
|
||||
expect { subject }
|
||||
.to change(Admin::ActionLog, :count).by(1)
|
||||
|
||||
expect(response)
|
||||
.to redirect_to(admin_terms_of_service_index_path)
|
||||
expect(terms.reload.published_at)
|
||||
.to_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with non publishing params' do
|
||||
let(:params) { { terms_of_service: { text: 'new' }, action_type: 'save_draft' } }
|
||||
|
||||
it 'updates but does not publish the record' do
|
||||
expect { subject }
|
||||
.to_not change(Admin::ActionLog, :count)
|
||||
|
||||
expect(response)
|
||||
.to redirect_to(admin_terms_of_service_draft_path)
|
||||
expect(terms.reload.published_at)
|
||||
.to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
let(:params) { { terms_of_service: { text: '' }, action_type: 'save_draft' } }
|
||||
|
||||
it 'does not update the record' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue