Sha256: bf98a25fb2c148be0e3ded6f5832c3f29f29f3e0fb0401ce48aa38f8b6172327

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'rails_helper'

module ActiveAdmin
  RSpec.describe Resource, "Attributes" do
    let(:application) { ActiveAdmin::Application.new }
    let(:namespace) { ActiveAdmin::Namespace.new application, :admin }
    let(:resource_config) { ActiveAdmin::Resource.new namespace, Post }

    describe "#resource_attributes" do
      subject do
        resource_config.resource_attributes
      end

      it 'should return attributes hash' do
        expect(subject).to eq( author_id: :author,
                               body: :body,
                               created_at: :created_at,
                               custom_category_id: :category,
                               foo_id: :foo_id,
                               position: :position,
                               published_date: :published_date,
                               starred: :starred,
                               title: :title,
                               updated_at: :updated_at)
      end
    end

    describe "#association_columns" do
      subject do
        resource_config.association_columns
      end

      it 'should return associations' do
        expect(subject).to eq([:author, :category])
      end
    end

    describe "#content_columns" do
      subject do
        resource_config.content_columns
      end

      it 'should return columns without associations' do
        expect(subject).to eq([:title, :body, :published_date, :position, :starred, :foo_id, :created_at, :updated_at])
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activeadmin-1.0.0 spec/unit/resource/attributes_spec.rb