Reputation: 723
I've checked my coverage file, built by simplecov and I've seen uncovered area like this:
form do |f|
inputs 'Details' do
input :email, required: true
input :password, input_html: { value: t('empty_string') }, required: true
input :is_active, label: t('active')
input :slug
input :name
input :logo, as: :file
end
actions
end
How can I deal with this ?
UPDATE: The render_views can help to avoid uncovered area.
Upvotes: 3
Views: 1835
Reputation: 7995
For SimpleCov to detect coverage of ActiveAdmin's form DSL, you need to create a controller test for the edit action. It would be a good idea to add coverage for the create and update actions to make sure permitted_params
is not filtering specific attributes. I've included specs for the edit and update actions for the AdminUser model.
# spec/controllers/admin/users_controller_spec.rb
require 'rails_helper'
include Devise::TestHelpers
RSpec.describe Admin::AdminUsersController, type: :controller do
render_views
let(:admin_user) { AdminUser.create!(email: '[email protected]', password: 'password')}
before(:each) do
sign_in admin_user
end
describe 'edit' do
it 'renders user form' do
get :edit, id: admin_user.to_param
expect(assigns(:admin_user)).to eq admin_user
end
end
describe 'update' do
it 'updates user' do
patch :update, { id: admin_user.to_param, admin_user: { email: '[email protected]' }}
admin_user.reload
expect(admin_user.email).to eq '[email protected]'
end
end
end
Upvotes: 3