Skip to content

Commit

Permalink
Merge pull request #1583 from iainbeeston/patch-1
Browse files Browse the repository at this point in the history
Added binary fields to the disabled column types for mongoid
  • Loading branch information
bbenezech committed Apr 2, 2013
2 parents ec547e8 + 084b07c commit 5653ba2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/rails_admin/adapters/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module RailsAdmin
module Adapters
module Mongoid
STRING_TYPE_COLUMN_NAMES = [:name, :title, :subject]
DISABLED_COLUMN_TYPES = ['Range']
DISABLED_COLUMN_TYPES = ['Range', 'Moped::BSON::Binary']
ObjectId = (::Mongoid::VERSION >= '3' ? ::Moped::BSON::ObjectId : ::BSON::ObjectId)

def new(params = {})
Expand Down
3 changes: 2 additions & 1 deletion spec/dummy_app/app/mongoid/field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FieldTest
field :big_decimal_field, :type => BigDecimal
field :boolean_field, :type => Boolean
field :bson_object_id_field, :type => RailsAdmin::Adapters::Mongoid::ObjectId
field :bson_binary_field, :type => Moped::BSON::Binary
field :date_field, :type => Date
field :datetime_field, :type => DateTime
field :time_with_zone_field, :type => ActiveSupport::TimeWithZone
Expand All @@ -30,7 +31,7 @@ class FieldTest
field :protected_field, :type => String
has_mongoid_attached_file :paperclip_asset, :styles => { :thumb => "100x100>" }

basic_accessible_fields = [:comment_attributes, :nested_field_tests_attributes, :embed_attributes, :embeds_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :name, :array_field, :big_decimal_field, :boolean_field, :bson_object_id_field, :date_field, :datetime_field, :time_with_zone_field, :default_field, :float_field, :hash_field, :integer_field, :object_field, :range_field, :string_field, :symbol_field, :text_field, :time_field, :created_at, :updated_at, :format]
basic_accessible_fields = [:comment_attributes, :nested_field_tests_attributes, :embed_attributes, :embeds_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :name, :array_field, :big_decimal_field, :boolean_field, :bson_object_id_field, :bson_binary_field, :date_field, :datetime_field, :time_with_zone_field, :default_field, :float_field, :hash_field, :integer_field, :object_field, :range_field, :string_field, :symbol_field, :text_field, :time_field, :created_at, :updated_at, :format]
attr_accessible *basic_accessible_fields
attr_accessible *(basic_accessible_fields + [:restricted_field, {:as => :custom_role}])
attr_accessible *(basic_accessible_fields + [:protected_field, {:as => :extra_safe_role}])
Expand Down
8 changes: 4 additions & 4 deletions spec/rails_admin/adapters/mongoid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ class MongoEmbedsChild < MongoEmbedsParent; end

it "maps Mongoid column types to RA types" do
expect(@abstract_model.properties.select{|p| %w(_id array_field big_decimal_field
boolean_field bson_object_id_field date_field datetime_field time_with_zone_field default_field float_field
hash_field integer_field name object_field range_field short_text string_field subject
symbol_field text_field time_field title).
include? p[:name].to_s}).to match_array [
boolean_field bson_object_id_field bson_binary_field date_field datetime_field
time_with_zone_field default_field float_field hash_field integer_field name
object_field range_field short_text string_field subject symbol_field text_field
time_field title).include? p[:name].to_s}).to match_array [
{ :name => :_id,
:pretty_name => "Id",
:nullable? => true,
Expand Down

0 comments on commit 5653ba2

Please sign in to comment.