-2

In my Rails application, ruby 2.6.5, rails 6.1. I use Active admin and I created this page. How can I create some tests for this using rspec? I have already created tests for the model and the controller.

ActiveAdmin.register BxBlockTermsAndConditions::TermsAndCondition, as:  "TermsAndConditions" do

  permit_params :description, :account_id

  index do
    selectable_column
    id_column
    column :account_id
    column :description
    column :created_at
    column :updated_at
    actions
  end

  form do |f|
    f.inputs do
      f.input :account_id, label: "Conta"
      f.input :description
    end
    f.actions
  end

  show do
    attributes_table do
      row :id
      row :account_id
      row :description
      row :created_at
      row :updated_at
    end
  end
end

Someone can help me?

How to test the page

1 Answer 1

1

It's a normal request spec. For example, if you want to test the index action

RSpec.describe Admin::TermsAndConditionsController, type: :request do
  let(:admin_user) { create(:admin_user) }

  before { sign_in admin_user }

  describe "GET" do
    it 'index returns http success' do
      get main_app.admin_terms_and_conditions_path
      expect(response).to be_successful
    end
  end
end

Check your rails/routes to be sure about the path

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.