Sha256: 9eeff6a194d3ff22ff564620c0f3f9df88a5b82d8f82030218231e0bd527e12a
Contents?: true
Size: 1.23 KB
Versions: 19
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' if ENV['USE_MONGOID'] describe AdminIt::MongoidData::Resource do before do # class MongoTestEmbed include Mongoid::Document field :name, type: String embedded_in :mongo_test_parent end # class MongoTestParent include Mongoid::Document field :name, type: String embeds_many :mongo_test_embeds end end after do if Object.const_defined?(:MongoTestParent) Object.send(:remove_const, :MongoTestParent) end end let(:resource) { AdminIt::Resource.new(:mongo_test, MongoTestParent) } it 'provides default fields' do expect( resource.fields(scope: :all).map(&:field_name) ).to match_array %i(id name mongo_test_embeds) end it 'hides id field' do expect(resource.field(:id).visible?).to be_false end it 'gives right field types' do expect(resource.field(:id).type).to eq :integer expect(resource.field(:name).type).to eq :string expect(resource.field(:mongo_test_embeds).type).to eq :relation end it 'provides default filters' do expect( resource.filters.map(&:filter_name) ).to match_array %i(name_value) end end end
Version data entries
19 entries across 19 versions & 1 rubygems