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,48 @@ RSpec.describe Admin::TermsOfService::GeneratesController do
|
|||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
subject { post :create, params: params }
|
||||
|
||||
context 'with valid params' do
|
||||
let(:params) do
|
||||
{
|
||||
terms_of_service_generator: {
|
||||
admin_email: 'test@host.example',
|
||||
arbitration_address: '123 Main Street',
|
||||
arbitration_website: 'https://host.example',
|
||||
dmca_address: '123 DMCA Ave',
|
||||
dmca_email: 'dmca@host.example',
|
||||
domain: 'host.example',
|
||||
jurisdiction: 'Europe',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'saves new record' do
|
||||
expect { subject }
|
||||
.to change(TermsOfService, :count).by(1)
|
||||
expect(response)
|
||||
.to redirect_to(admin_terms_of_service_draft_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
let(:params) do
|
||||
{
|
||||
terms_of_service_generator: {
|
||||
admin_email: 'what the',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'does not save new record' do
|
||||
expect { subject }
|
||||
.to_not change(TermsOfService, :count)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue